diff options
Diffstat (limited to 'include')
-rw-r--r-- | include/blender/blender.h | 26 | ||||
-rw-r--r-- | include/blender/canvas.h | 79 | ||||
-rw-r--r-- | include/common/geom.h | 93 | ||||
-rw-r--r-- | include/common/time.h | 7 | ||||
-rw-r--r-- | include/painter/canvas.h | 92 | ||||
-rw-r--r-- | include/painter/color.h (renamed from include/blender/color.h) | 17 | ||||
-rw-r--r-- | include/painter/rasterizer.h | 41 |
7 files changed, 241 insertions, 114 deletions
diff --git a/include/blender/blender.h b/include/blender/blender.h deleted file mode 100644 index 26ff802..0000000 --- a/include/blender/blender.h +++ /dev/null | |||
@@ -1,26 +0,0 @@ | |||
1 | #ifndef UPEM_MORPHING_BLENDER | ||
2 | #define UPEM_MORPHING_BLENDER | ||
3 | |||
4 | /** | ||
5 | * File: blender.h | ||
6 | * Will it blend? That is the question. | ||
7 | */ | ||
8 | |||
9 | #include "common/time.h" | ||
10 | #include "blender/canvas.h" | ||
11 | #include "morpher/morphing.h" | ||
12 | |||
13 | /** | ||
14 | * Function: blender_blend_canvas | ||
15 | * Blends two canvas by applying the given morphing at the requested time frame. | ||
16 | * | ||
17 | * Parameters: | ||
18 | * *canvas - pointer to the canvas to paint | ||
19 | * *source - source image | ||
20 | * *target - target image | ||
21 | * *morphing - morphing transform to apply | ||
22 | * frame - the interpolation distance from the origin canvas [0;1] | ||
23 | */ | ||
24 | void blender_blend_canvas(Canvas *canvas, Canvas *source, Canvas *target, Morphing *morphing, TimeVector frame); | ||
25 | |||
26 | #endif | ||
diff --git a/include/blender/canvas.h b/include/blender/canvas.h deleted file mode 100644 index aae217d..0000000 --- a/include/blender/canvas.h +++ /dev/null | |||
@@ -1,79 +0,0 @@ | |||
1 | #ifndef UPEM_MORPHING_CANVAS | ||
2 | #define UPEM_MORPHING_CANVAS | ||
3 | |||
4 | /** | ||
5 | * File: canvas.h | ||
6 | * | ||
7 | * See also: | ||
8 | * Freedom, according to Bob Ross | ||
9 | */ | ||
10 | |||
11 | #include <MLV/MLV_image.h> | ||
12 | #include "common/geom.h" | ||
13 | #include "color.h" | ||
14 | |||
15 | /** | ||
16 | * Type: Canvas | ||
17 | * Represents a fixed size RGBa pixel matrix. | ||
18 | */ | ||
19 | typedef struct { | ||
20 | MLV_Image *mlv; | ||
21 | } Canvas; | ||
22 | |||
23 | /** | ||
24 | * Function: canvas_init | ||
25 | * Initialises a canvas of the given size | ||
26 | * | ||
27 | * Parameters: | ||
28 | * *canvas - the canvas to initialise | ||
29 | * width - the width in pixels | ||
30 | * height - the height in pixels | ||
31 | */ | ||
32 | void canvas_init(Canvas *canvas, IntVector width, IntVector height); | ||
33 | |||
34 | /** | ||
35 | * Function: canvas_free | ||
36 | * Frees all memory allocated to a canvas. | ||
37 | * | ||
38 | * Parameters: | ||
39 | * *canvas - the canvas to destroy | ||
40 | */ | ||
41 | void canvas_free(Canvas *canvas); | ||
42 | |||
43 | /** | ||
44 | * Function: canvas_set_pixel | ||
45 | * Sets the pixel colour at the given coordinates. | ||
46 | * | ||
47 | * Parameters: | ||
48 | * *canvas - the canvas to alter | ||
49 | * position - the cartesian coordinates of the pixel to set | ||
50 | * color - the new colour to set | ||
51 | */ | ||
52 | void canvas_set_pixel(Canvas *canvas, CartesianVector position, Color color); | ||
53 | |||
54 | /** | ||
55 | * Function: canvas_get_pixel | ||
56 | * Returns the colour of the pixel at the given position. | ||
57 | * | ||
58 | * Parameters: | ||
59 | * *canvas - the base canvas | ||
60 | * position - the position in cartesian coordinates | ||
61 | * | ||
62 | * Returns: | ||
63 | * The colour of the requested pixel | ||
64 | */ | ||
65 | Color canvas_get_pixel(Canvas *canvas, CartesianVector position); | ||
66 | |||
67 | /** | ||
68 | * Function: canvas_get_dim | ||
69 | * Returns the size (in pixels) of the given canvas. | ||
70 | * | ||
71 | * Parameters: | ||
72 | * *canvas - the canvas | ||
73 | * | ||
74 | * Returns: | ||
75 | * The size of the canvas | ||
76 | */ | ||
77 | CartesianVector canvas_get_dim(Canvas *canvas); | ||
78 | |||
79 | #endif | ||
diff --git a/include/common/geom.h b/include/common/geom.h index b3564a5..334e95c 100644 --- a/include/common/geom.h +++ b/include/common/geom.h | |||
@@ -15,6 +15,12 @@ | |||
15 | typedef int32_t IntVector; | 15 | typedef int32_t IntVector; |
16 | 16 | ||
17 | /** | 17 | /** |
18 | * Type: RealVector | ||
19 | * An abstract 1-D real vector. | ||
20 | */ | ||
21 | typedef double RealVector; | ||
22 | |||
23 | /** | ||
18 | * Struct: CartesianVector | 24 | * Struct: CartesianVector |
19 | * An abstract 2-D vector in cartesian coordinates. | 25 | * An abstract 2-D vector in cartesian coordinates. |
20 | * | 26 | * |
@@ -27,6 +33,19 @@ typedef struct { | |||
27 | } CartesianVector; | 33 | } CartesianVector; |
28 | 34 | ||
29 | /** | 35 | /** |
36 | * Struct: BarycentricVector | ||
37 | * An abstract barycentric coordinate tuple relative to a triangle. | ||
38 | * The third barycentric coordinate is deduced from the first two ones. | ||
39 | * | ||
40 | * Fields: | ||
41 | * a - the first barycentric coordinate | ||
42 | * b - the second barycentric coordinate | ||
43 | */ | ||
44 | typedef struct { | ||
45 | RealVector a, b; | ||
46 | } BarycentricVector; | ||
47 | |||
48 | /** | ||
30 | * Struct: CartesianMapping | 49 | * Struct: CartesianMapping |
31 | * A tuple of cartesian vectors representing a mapping. | 50 | * A tuple of cartesian vectors representing a mapping. |
32 | * | 51 | * |
@@ -38,6 +57,16 @@ typedef struct { | |||
38 | CartesianVector origin, target; | 57 | CartesianVector origin, target; |
39 | } CartesianMapping; | 58 | } CartesianMapping; |
40 | 59 | ||
60 | /** | ||
61 | * Struct: Triangle | ||
62 | * Represents a simple triangle with three vertices. | ||
63 | * | ||
64 | * Fields: | ||
65 | * v[] - array of vertices | ||
66 | */ | ||
67 | typedef struct { | ||
68 | CartesianVector v[3]; | ||
69 | } Triangle; | ||
41 | 70 | ||
42 | /** | 71 | /** |
43 | * Function: m | 72 | * Function: m |
@@ -66,6 +95,19 @@ CartesianMapping m(int x, int y); | |||
66 | CartesianVector v(int x, int y); | 95 | CartesianVector v(int x, int y); |
67 | 96 | ||
68 | /** | 97 | /** |
98 | * Function: b | ||
99 | * Shorthand for a barycentric vector. | ||
100 | * | ||
101 | * Parameters: | ||
102 | * a - the a-coordinate | ||
103 | * b - the b-coordinate | ||
104 | * | ||
105 | * Returns: | ||
106 | * A barycentric vector | ||
107 | */ | ||
108 | BarycentricVector b(double a, double b); | ||
109 | |||
110 | /** | ||
69 | * Function: mappings_equals | 111 | * Function: mappings_equals |
70 | * Compares two cartesian mappings. | 112 | * Compares two cartesian mappings. |
71 | * | 113 | * |
@@ -92,17 +134,54 @@ bool mappings_equals(CartesianMapping m1, CartesianMapping m2); | |||
92 | bool vector_equals(CartesianVector v1, CartesianVector v2); | 134 | bool vector_equals(CartesianVector v1, CartesianVector v2); |
93 | 135 | ||
94 | /** | 136 | /** |
95 | * Function: triangle_area | 137 | * Function: barycentric_vector_equals |
96 | * Computes the area of a triangle. | 138 | * Compares two barycentric vectors. |
139 | * | ||
140 | * Parameters: | ||
141 | * v1 - the first vector | ||
142 | * v2 - the second vector | ||
143 | * | ||
144 | * Returns: | ||
145 | * T(v1 is equal to v2) | ||
146 | */ | ||
147 | bool barycentric_vector_equals(BarycentricVector b1, BarycentricVector b2); | ||
148 | |||
149 | /** | ||
150 | * Function: square_area | ||
151 | * Computes the area of a square spawned by three positively oriented vertices. | ||
152 | * | ||
153 | * Parameters: | ||
154 | * vi - vertices | ||
155 | * | ||
156 | * Returns: | ||
157 | * The area of the square | ||
158 | */ | ||
159 | IntVector square_area(CartesianVector v1, CartesianVector v2, CartesianVector v3); | ||
160 | |||
161 | /** | ||
162 | * Function: cartesian_to_barycentric | ||
163 | * Computes and returns the barycentric coordinates of a given point in the given reference triangle. | ||
164 | * | ||
165 | * Parameters: | ||
166 | * t - reference triangle | ||
167 | * p - the vector to convert | ||
168 | * | ||
169 | * Returns: | ||
170 | * The barycentric coordinates vector | ||
171 | */ | ||
172 | BarycentricVector cartesian_to_barycentric(Triangle t, CartesianVector p); | ||
173 | |||
174 | /** | ||
175 | * Function: barycentric_to_cartesian | ||
176 | * Computes and returns the cartesian coordinates of a given point in the given reference triangle. | ||
97 | * | 177 | * |
98 | * Parameters: | 178 | * Parameters: |
99 | * v1 - first vertex | 179 | * t - reference triangle |
100 | * v2 - second vertex | 180 | * p - the vector to convert |
101 | * v3 - third vertex | ||
102 | * | 181 | * |
103 | * Returns: | 182 | * Returns: |
104 | * The area of the triangle spawned by the three supplied vertices | 183 | * The cartesian coordinate vector |
105 | */ | 184 | */ |
106 | IntVector triangle_area(CartesianVector v1, CartesianVector v2, CartesianVector v3); | 185 | CartesianVector barycentric_to_cartesian(T |