32 float c = cosf(angle);
33 float s = sinf(angle);
72 float a = left->
a * right->
a + left->
b * right->
c;
73 float b = left->
a * right->
b + left->
b * right->
d;
74 float c = left->
c * right->
a + left->
d * right->
c;
75 float d = left->
c * right->
b + left->
d * right->
d;
76 float e = left->
e * right->
a + left->
f * right->
c + right->
e;
77 float f = left->
e * right->
b + left->
f * right->
d + right->
f;
87 float inv_det = 1.f / det;
113 for(
int i = 0; i < count; ++i) {
123 p[1].
x = src->
x + src->
w;
125 p[2].
x = src->
x + src->
w;
126 p[2].
y = src->
y + src->
h;
128 p[3].
y = src->
y + src->
h;
136 for(
int i = 1; i < 4; i++) {
137 if(p[i].x < l) l = p[i].
x;
138 if(p[i].x > r) r = p[i].
x;
139 if(p[i].y < t) t = p[i].
y;
140 if(p[i].y > b) b = p[i].
y;
154 int max_count = required + optional;
155 bool has_trailing_comma =
false;
156 for(; count < max_count; ++count) {
163 if(!has_trailing_comma && (count == required || count == max_count)
176 length = strlen(data);
177 const char* it = data;
178 const char* end = it + length;
179 bool has_trailing_comma =
false;
186 matrix_t m = { values[0], values[1], values[2], values[3], values[4], values[5] };
233 return !has_trailing_comma;
NOVASVG_INLINE void matrix_map_point(const matrix_t *matrix, const point_t *src, point_t *dst)
Transforms the src point using matrix and stores the result in dst.
NOVASVG_INLINE void matrix_map(const matrix_t *matrix, float x, float y, float *xx, float *yy)
Transforms the point (x, y) using matrix and stores the result in (xx, yy).
NOVASVG_INLINE bool parse_number(const char **begin, const char *end, float *number)
NOVASVG_INLINE bool skip_ws_or_comma(const char **begin, const char *end, bool *has_comma)
NOVASVG_INLINE void matrix_map_points(const matrix_t *matrix, const point_t *src, point_t *dst, int count)
Transforms an array of src points using matrix and stores the results in dst.
NOVASVG_INLINE void matrix_init_rotate(matrix_t *matrix, float angle)
Initializes a 2D transformation matrix for rotation.
NOVASVG_INLINE bool skip_ws_and_delim(const char **begin, const char *end, char delim)
NOVASVG_INLINE void matrix_init_identity(matrix_t *matrix)
Initializes a 2D transformation matrix to the identity matrix.
NOVASVG_INLINE bool matrix_parse(matrix_t *matrix, const char *data, int length)
Parses an SVG transform string into a matrix.
NOVASVG_INLINE bool skip_delim(const char **begin, const char *end, const char delim)
NOVASVG_INLINE bool skip_string(const char **begin, const char *end, const char *data)
NOVASVG_INLINE bool skip_ws(const char **begin, const char *end)
NOVASVG_INLINE void matrix_shear(matrix_t *matrix, float shx, float shy)
Shears the matrix by factors shx and shy.
NOVASVG_INLINE void matrix_init_scale(matrix_t *matrix, float sx, float sy)
Initializes a 2D transformation matrix for scaling.
NOVASVG_INLINE bool matrix_invert(const matrix_t *matrix, matrix_t *inverse)
Calculates the inverse of matrix and stores it in inverse.
NOVASVG_INLINE int parse_matrix_parameters(const char **begin, const char *end, float values[6], int required, int optional)
NOVASVG_INLINE void skip_css_unit(const char **begin, const char *end, float *number)
NOVASVG_INLINE void matrix_scale(matrix_t *matrix, float sx, float sy)
Scales the matrix by factors sx and sy
NOVASVG_INLINE void matrix_init_shear(matrix_t *matrix, float shx, float shy)
Initializes a 2D transformation matrix for shearing.
NOVASVG_INLINE void matrix_multiply(matrix_t *matrix, const matrix_t *left, const matrix_t *right)
Multiplies left and right matrices and stores the result in matrix.
NOVASVG_INLINE void matrix_rotate(matrix_t *matrix, float angle)
Rotates the matrix by the specified angle (in radians).
NOVASVG_INLINE void matrix_init(matrix_t *matrix, float a, float b, float c, float d, float e, float f)
Initializes a 2D transformation matrix.
NOVASVG_INLINE void matrix_init_translate(matrix_t *matrix, float tx, float ty)
Initializes a 2D transformation matrix for translation.
NOVASVG_INLINE void matrix_translate(matrix_t *matrix, float tx, float ty)
Adds a translation with offsets tx and ty to the matrix.
NOVASVG_INLINE void matrix_map_rect(const matrix_t *matrix, const rect_t *src, rect_t *dst)
Transforms the src rectangle using matrix and stores the result in dst.
Main namespace for the NovaSVG library.
#define NOVASVG_DEG2RAD(x)
A structure representing a 2D transformation matrix.
float d
The vertical scaling factor.
float c
The horizontal shearing factor.
float f
The vertical translation offset.
float e
The horizontal translation offset.
float b
The vertical shearing factor.
float a
The horizontal scaling factor.
A structure representing a point in 2D space.
float y
The y-coordinate of the point.
float x
The x-coordinate of the point.
A structure representing a rectangle in 2D space.
float x
The x-coordinate of the top-left corner of the rectangle.
float w
The width of the rectangle.
float h
The height of the rectangle.
float y
The y-coordinate of the top-left corner of the rectangle.