From 987835afe8fc5d46cb3a6359ec80c9f035e72801 Mon Sep 17 00:00:00 2001 From: pacien Date: Tue, 28 Nov 2017 19:01:51 +0100 Subject: Add module spec headers Signed-off-by: pacien --- include/blender/blender.h | 42 +++++++++++++++++++++++++ include/blender/canvas.h | 79 +++++++++++++++++++++++++++++++++++++++++++++++ include/blender/color.h | 27 ++++++++++++++++ include/common/geom.h | 32 +++++++++++++++++++ include/common/matrix.h | 34 ++++++++++++++++++++ include/common/time.h | 23 ++++++++++++++ include/gui/gui.h | 14 +++++++++ include/morpher/morpher.h | 64 ++++++++++++++++++++++++++++++++++++++ 8 files changed, 315 insertions(+) create mode 100644 include/blender/blender.h create mode 100644 include/blender/canvas.h create mode 100644 include/blender/color.h create mode 100644 include/common/geom.h create mode 100644 include/common/matrix.h create mode 100644 include/common/time.h create mode 100644 include/gui/gui.h create mode 100644 include/morpher/morpher.h diff --git a/include/blender/blender.h b/include/blender/blender.h new file mode 100644 index 0000000..356c68e --- /dev/null +++ b/include/blender/blender.h @@ -0,0 +1,42 @@ +#ifndef UPEM_MORPHING_BLENDER +#define UPEM_MORPHING_BLENDER + +/** + * File: blender.h + * Will it blend? That is the question. + */ + +#include "common/time.h" +#include "blender/canvas.h" +#include "blender/color.h" +#include "morpher/morpher.h" + +/** + * Function: blender_blend_canvas + * Blends two canvas by applying the given morphing at the requested time frame. + * + * Parameters: + * *canvas - pointer to the canvas to paint + * *source - source image + * *target - target image + * *morphing - morphing transform to apply + * frame - the interpolation distance from the origin canvas [0;1] + */ +void blender_blend_canvas(Canvas *canvas, Canvas *source, Canvas *target, Morphing *morphing, TimeVector frame); + +/** + * Function: blender_blend_colors + * Properly blends two coloured pixels, interpolated at the given time frame. + * (https://www.youtube.com/watch?v=LKnqECcg6Gw) + * + * Parameters: + * origin - the origin colour + * target - the target colour + * frame - the interpolation distance from the origin colour [0;1] + * + * Returns: + * The blended coloured pixel + */ +Color blender_blend_colors(Color origin, Color target, TimeVector frame); + +#endif diff --git a/include/blender/canvas.h b/include/blender/canvas.h new file mode 100644 index 0000000..12f7ce1 --- /dev/null +++ b/include/blender/canvas.h @@ -0,0 +1,79 @@ +#ifndef UPEM_MORPHING_CANVAS +#define UPEM_MORPHING_CANVAS + +/** + * File: canvas.h + * + * See also: + * Freedom, according to Bob Ross + */ + +#include +#include "common/geom.h" +#include "color.h" + +/** + * Type: Canvas + * Represents a fixed size RGBa pixel matrix. + */ +typedef struct { + MLV_Image mlv; +} Canvas; + +/** + * Function: canvas_init + * Initialises a canvas of the given size + * + * Parameters: + * *canvas - the canvas to initialise + * width - the width in pixels + * height - the height in pixels + */ +void canvas_init(Canvas *canvas, IntVector width, IntVector height); + +/** + * Function: canvas_free + * Frees all memory allocated to a canvas. + * + * Parameters: + * *canvas - the canvas to destroy + */ +void canvas_free(Canvas *canvas); + +/** + * Function: canvas_set_pixel + * Sets the pixel colour at the given coordinates. + * + * Parameters: + * *canvas - the canvas to alter + * position - the cartesian coordinates of the pixel to set + * color - the new colour to set + */ +void canvas_set_pixel(Canvas *canvas, CartesianVector position, Color color); + +/** + * Function: canvas_get_pixel + * Returns the colour of the pixel at the given position. + * + * Parameters: + * *canvas - the base canvas + * position - the position in cartesian coordinates + * + * Returns: + * The colour of the requested pixel + */ +Color canvas_get_pixel(Canvas *canvas, CartesianVector position); + +/** + * Function: canvas_get_size + * Returns the size (in pixels) of the given canvas. + * + * Parameters: + * *canvas - the canvas + * + * Returns: + * The size of the canvas + */ +CartesianVector canvas_get_size(Canvas *canvas); + +#endif diff --git a/include/blender/color.h b/include/blender/color.h new file mode 100644 index 0000000..cdf488a --- /dev/null +++ b/include/blender/color.h @@ -0,0 +1,27 @@ +#ifndef UPEM_MORPHING_COLOR +#define UPEM_MORPHING_COLOR + +/** + * File: color.h + * + * See also: + * A rainbow + */ + +/** + * Type: ColorComponent + * Represents a single colour component of 32-bits RGBa tuple. + */ +typedef uint8_t ColorComponent; + +/** + * Type: ColorPixel + * Represents a single RGBa coloured pixel. + * Compatible with the libMLV representation. + */ +typedef union { + ColorComponent r, g, b, a; + MLV_Color mlv; +} Color; + +#endif diff --git a/include/common/geom.h b/include/common/geom.h new file mode 100644 index 0000000..15a1d57 --- /dev/null +++ b/include/common/geom.h @@ -0,0 +1,32 @@ +#ifndef UPEM_MORPHING_GEOM +#define UPEM_MORPHING_GEOM + +/** + * File: geom.h + */ + +#include + +/** + * Type: IntVector + * An abstract 1-D vector. + */ +typedef int32_t IntVector; + +/** + * Type: CartesianVector + * An abstract 2-D vector in cartesian coordinates. + */ +typedef struct { + IntVector x, y; +} CartesianVector; + +/** + * Type: CartesianMapping + * A tuple of cartesian vectors representing a mapping. + */ +typedef struct { + CartesianVector origin, target; +} CartesianMapping; + +#endif diff --git a/include/common/matrix.h b/include/common/matrix.h new file mode 100644 index 0000000..6c35cc0 --- /dev/null +++ b/include/common/matrix.h @@ -0,0 +1,34 @@ +#ifndef UPEM_MORPHING_MATRIX +#define UPEM_MORPHING_MATRIX + +/** + * File: matrix.h + * + * See also: + * The film + */ + +#include "geom.h" + +/** + * Type: IntSquareMatrix + * Represents a square integer matrix. + */ +typedef struct { + IntVector *elements; + IntVector dim; +} IntSquareMatrix; + +/** + * Function: matrix_int_det + * Computes and returns the determinant of a square integer matrix. + * + * Parameters: + * *matrix - pointer to input matrix + * + * Returns: + * The integer determinant + */ +IntVector matrix_int_det(IntSquareMatrix *matrix); + +#endif diff --git a/include/common/time.h b/include/common/time.h new file mode 100644 index 0000000..060b7be --- /dev/null +++ b/include/common/time.h @@ -0,0 +1,23 @@ +#ifndef UPEM_MORPHING_TIME +#define UPEM_MORPHING_TIME + +/** + * File: time.h + */ + +/** + * Type: TimeVector + * An abstract time vector. + */ +typedef float TimeVector; + +/** + * Constants: Time vectors + * + * TIME_ORIGIN - the origin of times + * TIME_UNIT - a unit time vector + */ +const TimeVector TIME_ORIGIN = 0; +const TimeVector TIME_UNIT = 1; + +#endif diff --git a/include/gui/gui.h b/include/gui/gui.h new file mode 100644 index 0000000..14bdcf2 --- /dev/null +++ b/include/gui/gui.h @@ -0,0 +1,14 @@ +#ifndef UPEM_MORPHING_GUI +#define UPEM_MORPHING_GUI + +/** + * File: gui.h + */ + +/** + * Function: gui_open + * Builds and opens the graphical user interface. + */ +void gui_open(void); + +#endif diff --git a/include/morpher/morpher.h b/include/morpher/morpher.h new file mode 100644 index 0000000..4b795d3 --- /dev/null +++ b/include/morpher/morpher.h @@ -0,0 +1,64 @@ +#ifndef UPEM_MORPHING_MORPHER +#define UPEM_MORPHING_MORPHER + +/** + * File: morpher.h + * Coordinate mapping for morphing transforms. + */ + +#include "common/geom.h" + +/** + * Type: Morphing + * Represents an abstract coordinate transform from a source to a destination coordinate matrix, + * constrained by a given set of points. + */ +typedef Morphing; + +/** + * Function: morpher_init + * Initialises a morphing. + * + * Parameters: + * *morphing - pointer to the morphing to initialise + * width - coordinate matrix width in pixels + * height - coordinate matrix height in pixels + */ +void morpher_init(Morphing *morphing, IntVector width, IntVector height); + +/** + * Function: morpher_free + * Frees any resources allocated to a morphing. + * + * Parameters: + * *morphin* - pointer to the morphing to destroy + */ +void morpher_free(Morphing *morphing); + +/** + * Function: morpher_add_constraint + * Adds a constraint point to a morphing. + * + * Parameters: + * *morphing - pointer to the morphing to alter + * origin - constraint point coordinates on the origin matrix + * destination - constraint point coordinates on the target matrix + */ +void morpher_add_constraint(Morphing *morphing, CartesianVector origin, CartesianVector destination); + +/** + * Function: morpher_get_point_mapping + * Computes and returns the coordinates of a given point at the given transform step + * in the origin and destination matrices. + * + * Parameters: + * *morphing - the base morphing + * point - point to map in cartesian coordinates + * frame - time coefficient corresponding to the transform state, [0;1] + * + * Returns: + * A cartesian coordinate mapping from the origin to the target matrix of the given point + */ +CartesianMapping morpher_get_point_mapping(Morphing *morphing, CartesianVector point, TimeVector frame); + +#endif -- cgit v1.2.3