From 38195a70192301e7df5b69bf2266a04a0b90a532 Mon Sep 17 00:00:00 2001 From: pacien Date: Tue, 9 Jan 2018 16:14:18 +0100 Subject: Update report, add authorship to C files Signed-off-by: pacien --- doc/project-report.md | 2 ++ src/common/error.c | 7 +++++++ src/common/geom.c | 7 +++++++ src/common/mem.c | 7 +++++++ src/gui/button.c | 7 +++++++ src/gui/component.c | 7 +++++++ src/gui/group.c | 7 +++++++ src/gui/gui.c | 7 +++++++ src/gui/pictureframe.c | 7 +++++++ src/gui/window.c | 7 +++++++ src/main.c | 7 +++++++ src/morpher/matrix.c | 7 +++++++ src/morpher/morphing.c | 7 +++++++ src/morpher/quadrilateral.c | 7 +++++++ src/morpher/trianglemap.c | 7 +++++++ src/painter/canvas.c | 7 +++++++ src/painter/color.c | 7 +++++++ src/painter/rasterizer.c | 7 +++++++ test/common/geom.c | 7 +++++++ test/morpher/matrix.c | 7 +++++++ test/morpher/quadrilateral.c | 7 +++++++ test/morpher/trianglemap.c | 7 +++++++ test/painter/color.c | 7 +++++++ test/painter/rasterizer.c | 7 +++++++ 24 files changed, 163 insertions(+) diff --git a/doc/project-report.md b/doc/project-report.md index 8a8103f..4f9ccc3 100644 --- a/doc/project-report.md +++ b/doc/project-report.md @@ -119,6 +119,8 @@ triangle lookup from arbitrarily given coordinates and a simple way of traversin The painter module provides functions to apply a previously constructed morphing to a base and a target image, generating a morphed image as the output. +None of its inputs are altered, allowing later reuse of the same base morphing. + A per-triangle rasterisation algorithm has been implemented instead of the suggested per-pixel triangle lookup for performance reasons, as the whole process was meant to run in a single thread on the CPU, not benefiting the massive parallelisation possibility that a GPU would have offered. diff --git a/src/common/error.c b/src/common/error.c index f28a6cd..02ce788 100644 --- a/src/common/error.c +++ b/src/common/error.c @@ -2,6 +2,13 @@ #include #include +/** + * File: error.c + * + * Author: + * Pacien TRAN-GIRARD + */ + void rage_quit(const char *msg) { fprintf(stderr, "FATAL ERROR: %s\n", msg); exit(1); diff --git a/src/common/geom.c b/src/common/geom.c index f903fe8..65c0f4c 100644 --- a/src/common/geom.c +++ b/src/common/geom.c @@ -2,6 +2,13 @@ #include #include "morpher/matrix.h" +/** + * File: geom.c + * + * Author: + * Pacien TRAN-GIRARD + */ + static inline IntVector int_round(RealVector x) { return (IntVector) round(x); } diff --git a/src/common/mem.c b/src/common/mem.c index 855e010..02bd8c5 100644 --- a/src/common/mem.c +++ b/src/common/mem.c @@ -2,6 +2,13 @@ #include #include "common/error.h" +/** + * File: error.c + * + * Author: + * Pacien TRAN-GIRARD + */ + void *malloc_or_die(size_t size) { void *ptr = malloc(size); diff --git a/src/gui/button.c b/src/gui/button.c index 4bf3952..79abef2 100644 --- a/src/gui/button.c +++ b/src/gui/button.c @@ -6,6 +6,13 @@ #include #include "common/mem.h" +/** + * File: button.c + * + * Author: + * Adam NAILI + */ + static bool button_is_selected(int x, int y, Button *button) { assert(button != NULL); int x1 = button->component.x_pos; diff --git a/src/gui/component.c b/src/gui/component.c index c45ea4f..65435db 100644 --- a/src/gui/component.c +++ b/src/gui/component.c @@ -1,5 +1,12 @@ #include "gui/component.h" +/** + * File: component.c + * + * Author: + * Adam NAILI + */ + Mode mode = WAITING_BUTTON_SHOW; int frame = 2; diff --git a/src/gui/group.c b/src/gui/group.c index 7f5adcd..75737af 100644 --- a/src/gui/group.c +++ b/src/gui/group.c @@ -4,6 +4,13 @@ #include #include "common/mem.h" +/** + * File: group.c + * + * Author: + * Adam NAILI + */ + void group_print(Component *parameterSelf) { assert(parameterSelf != NULL); Group *self = (Group *) parameterSelf; diff --git a/src/gui/gui.c b/src/gui/gui.c index 7300196..45565e5 100644 --- a/src/gui/gui.c +++ b/src/gui/gui.c @@ -2,6 +2,13 @@ #include #include "common/mem.h" +/** + * File: gui.c + * + * Author: + * Adam NAILI + */ + GUI *gui_create(const char *fpath1, const char *fpath2) { GUI *gui = malloc_or_die(sizeof(GUI)); gui->window = window_create(500, 500, "Morphing"); diff --git a/src/gui/pictureframe.c b/src/gui/pictureframe.c index c012ece..c6d7bf6 100644 --- a/src/gui/pictureframe.c +++ b/src/gui/pictureframe.c @@ -3,6 +3,13 @@ #include #include "common/mem.h" +/** + * File: pictureframe.c + * + * Author: + * Adam NAILI + */ + static bool pictureframe_is_selected(int x, int y, PictureFrame *pictureFrame) { assert(pictureFrame != NULL); int x1 = pictureFrame->component.x_pos; diff --git a/src/gui/window.c b/src/gui/window.c index c9d200a..5d0a187 100644 --- a/src/gui/window.c +++ b/src/gui/window.c @@ -4,6 +4,13 @@ #include "painter/rasterizer.h" #include "common/mem.h" +/** + * File: window.c + * + * Author: + * Adam NAILI + */ + Window *window_create(int width, int height, char *title) { assert(width > 0); assert(height > 0); diff --git a/src/main.c b/src/main.c index ddcc6dc..193de55 100644 --- a/src/main.c +++ b/src/main.c @@ -4,6 +4,13 @@ #include #include "gui/gui.h" +/** + * File: main.c + * + * Author: + * Adam NAILI + */ + static inline void print_help() { printf("Usage: morph [--help] \n\n" "To use the morphing, you need to put two correct paths to image files.\n\n" diff --git a/src/morpher/matrix.c b/src/morpher/matrix.c index 2fe1193..564137d 100644 --- a/src/morpher/matrix.c +++ b/src/morpher/matrix.c @@ -1,5 +1,12 @@ #include "morpher/matrix.h" +/** + * File: matrix.c + * + * Author: + * Pacien TRAN-GIRARD + */ + IntVector matrix_int_det2(IntVector u11, IntVector u12, IntVector u21, IntVector u22) { diff --git a/src/morpher/morphing.c b/src/morpher/morphing.c index 7df3839..39f1146 100644 --- a/src/morpher/morphing.c +++ b/src/morpher/morphing.c @@ -2,6 +2,13 @@ #include #include "common/mem.h" +/** + * File: morphing.c + * + * Author: + * Pacien TRAN-GIRARD + */ + static inline TriangleMap *init_trianglemap(IntVector width, IntVector height) { TriangleMap *bottom_left = trianglemap_create(m(0, 0), m(0, height), m(width, height)); TriangleMap *top_right = trianglemap_create(m(0, 0), m(width, height), m(width, 0)); diff --git a/src/morpher/quadrilateral.c b/src/morpher/quadrilateral.c index d5c64b0..4a0dc27 100644 --- a/src/morpher/quadrilateral.c +++ b/src/morpher/quadrilateral.c @@ -3,6 +3,13 @@ #include #include "morpher/matrix.h" +/** + * File: quadrilateral.c + * + * Author: + * Pacien TRAN-GIRARD + */ + static inline IntVector p2(IntVector n) { return n * n; } diff --git a/src/morpher/trianglemap.c b/src/morpher/trianglemap.c index ad526bc..c261a9c 100644 --- a/src/morpher/trianglemap.c +++ b/src/morpher/trianglemap.c @@ -4,6 +4,13 @@ #include "morpher/quadrilateral.h" #include "common/mem.h" +/** + * File: trianglemap.c + * + * Author: + * Pacien TRAN-GIRARD + */ + static void propagate_delaunay(TriangleMap *start, TriangleMap *neighbor) { assert(start != NULL && neighbor != NULL); if (!quadrilateral_is_delaunay(start, neighbor)) { diff --git a/src/painter/canvas.c b/src/painter/canvas.c index 306dc9c..478173d 100644 --- a/src/painter/canvas.c +++ b/src/painter/canvas.c @@ -1,6 +1,13 @@ #include "painter/canvas.h" #include "common/mem.h" +/** + * File: canvas.c + * + * Author: + * Pacien TRAN-GIRARD + */ + Canvas *canvas_create(IntVector width, IntVector height) { Canvas *c = malloc_or_die(sizeof(Canvas)); c->mlv = MLV_create_image(width, height); diff --git a/src/painter/color.c b/src/painter/color.c index 65c4f20..bf03359 100644 --- a/src/painter/color.c +++ b/src/painter/color.c @@ -1,6 +1,13 @@ #include "painter/color.h" #include +/** + * File: color.c + * + * Author: + * Pacien TRAN-GIRARD + */ + static inline ColorComponent blend_component(ColorComponent origin, ColorComponent target, TimeVector frame) { return (ColorComponent) round(sqrt((TIME_UNIT - frame) * pow(origin, 2) + frame * pow(target, 2))); } diff --git a/src/painter/rasterizer.c b/src/painter/rasterizer.c index 1ba726c..f4b3b89 100644 --- a/src/painter/rasterizer.c +++ b/src/painter/rasterizer.c @@ -2,6 +2,13 @@ #include #include +/** + * File: rasterizer.c + * + * Author: + * Pacien TRAN-GIRARD + */ + static inline IntVector i(double (*f)(double, double), RealVector a, RealVector b) { return (IntVector) floor(f(a, b)); } diff --git a/test/common/geom.c b/test/common/geom.c index f05e0a1..1775315 100644 --- a/test/common/geom.c +++ b/test/common/geom.c @@ -1,6 +1,13 @@ #include "common/geom.h" #include +/** + * File: geom.c + * + * Author: + * Pacien TRAN-GIRARD + */ + static void test_square_area() { assert(square_area(v(0, 0), v(10, 0), v(10, 10)) == 100); assert(square_area(v(0, 0), v(0, 10), v(10, 10)) == -100); diff --git a/test/morpher/matrix.c b/test/morpher/matrix.c index 0c96fab..42bb34b 100644 --- a/test/morpher/matrix.c +++ b/test/morpher/matrix.c @@ -1,6 +1,13 @@ #include "morpher/matrix.h" #include +/** + * File: matrix.c + * + * Author: + * Pacien TRAN-GIRARD + */ + static void test_matrix_int_det2() { assert(matrix_int_det2(5, 7, 2, 3) == 1); diff --git a/test/morpher/quadrilateral.c b/test/morpher/quadrilateral.c index c632b82..b2c9a21 100644 --- a/test/morpher/quadrilateral.c +++ b/test/morpher/quadrilateral.c @@ -2,6 +2,13 @@ #include #include +/** + * File: quadrilateral.c + * + * Author: + * Pacien TRAN-GIRARD + */ + static inline bool neighbors_equals(TriangleMap *neighbors[], TriangleMap *n1, TriangleMap *n2, TriangleMap *n3) { return neighbors[0] == n1 && neighbors[1] == n2 && neighbors[2] == n3; diff --git a/test/morpher/trianglemap.c b/test/morpher/trianglemap.c index 986e406..55f5746 100644 --- a/test/morpher/trianglemap.c +++ b/test/morpher/trianglemap.c @@ -3,6 +3,13 @@ #include #include "morpher/quadrilateral.h" +/** + * File: trianglemap.c + * + * Author: + * Pacien TRAN-GIRARD + */ + static inline bool neighbors_equals(TriangleMap *neighbors[], TriangleMap *n1, TriangleMap *n2, TriangleMap *n3) { return neighbors[0] == n1 && neighbors[1] == n2 && neighbors[2] == n3; diff --git a/test/painter/color.c b/test/painter/color.c index bdfe9b3..b1b1501 100644 --- a/test/painter/color.c +++ b/test/painter/color.c @@ -1,6 +1,13 @@ #include "painter/color.h" #include +/** + * File: color.c + * + * Author: + * Pacien TRAN-GIRARD + */ + static void test_color_blend() { Color a = {{1, 10, 100, 200}}, b = {{100, 1, 200, 10}}; assert(color_equals(color_blend(a, b, TIME_ORIGIN), a)); diff --git a/test/painter/rasterizer.c b/test/painter/rasterizer.c index 99a70b4..a16fa19 100644 --- a/test/painter/rasterizer.c +++ b/test/painter/rasterizer.c @@ -1,6 +1,13 @@ #include "painter/rasterizer.h" #include +/** + * File: rasterizer.c + * + * Author: + * Pacien TRAN-GIRARD + */ + static void test_rasterize() { Morphing *morphing; Canvas *origin, *target, *result; -- cgit v1.2.3