summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAdam NAILI2017-12-28 16:23:17 +0100
committerAdam NAILI2017-12-28 16:23:17 +0100
commit9e4eb30f33867bcb37d5accfb5588cfb3b450f90 (patch)
tree57cc389a1c302d8278246fb8334ada216be82a01
parentaaf57e5ee1e0cf74afdbdf56293f1afd7e79e6b0 (diff)
parent426ddbdd27d21383a3870980f9b787a8c58237aa (diff)
downloadmorpher-9e4eb30f33867bcb37d5accfb5588cfb3b450f90.tar.gz
Merge remote-tracking branch 'origin/master' into gui
-rw-r--r--doc/topics/build.txt7
-rw-r--r--include/blender/blender.h26
-rw-r--r--include/blender/canvas.h79
-rw-r--r--include/common/geom.h93
-rw-r--r--include/common/time.h7
-rw-r--r--include/painter/canvas.h92
-rw-r--r--include/painter/color.h (renamed from include/blender/color.h)17
-rw-r--r--include/painter/rasterizer.h41
-rw-r--r--makefile24
-rw-r--r--src/blender/blender.c39
-rw-r--r--src/blender/canvas.c23
-rw-r--r--src/blender/color.c8
-rw-r--r--src/common/geom.c27
-rw-r--r--src/morpher/trianglemap.c2
-rw-r--r--src/painter/canvas.c33
-rw-r--r--src/painter/color.c20
-rw-r--r--src/painter/rasterizer.c86
-rw-r--r--test/blender/blender.c29
-rw-r--r--test/common/geom.c21
-rw-r--r--test/painter/color.c14
-rw-r--r--test/painter/rasterizer.c27
21 files changed, 497 insertions, 218 deletions
diff --git a/doc/topics/build.txt b/doc/topics/build.txt
index c461434..979d172 100644
--- a/doc/topics/build.txt
+++ b/doc/topics/build.txt
@@ -29,3 +29,10 @@ About: Project report
29> make report 29> make report
30 30
31Generates the project report using Pandoc. 31Generates the project report using Pandoc.
32
33
34About: Project archive
35
36> make archive
37
38Generates a compressed tarball containing the project sources and the compiled report as PDF.
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 */
24void 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 */
19typedef 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 */
32void 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 */
41void 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 */
52void 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 */
65Color 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 */
77CartesianVector 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 @@
15typedef int32_t IntVector; 15typedef int32_t IntVector;
16 16
17/** 17/**
18 * Type: RealVector
19 * An abstract 1-D real vector.
20 */
21typedef 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 */
44typedef 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 */
67typedef 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);
66CartesianVector v(int x, int y); 95CartesianVector 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 */
108BarycentricVector 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);
92bool vector_equals(CartesianVector v1, CartesianVector v2); 134bool 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 */
147bool 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.