NovaSVG 0.10.0
A header-only SVG library
Loading...
Searching...
No Matches
render.h
Go to the documentation of this file.
1/*
2 * Copyright (c) 2020-2025 Samuel Ugochukwu <sammycageagle@gmail.com>
3 *
4 * Permission is hereby granted, free of charge, to any person obtaining a copy
5 * of this software and associated documentation files (the "Software"), to deal
6 * in the Software without restriction, including without limitation the rights
7 * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
8 * copies of the Software, and to permit persons to whom the Software is
9 * furnished to do so, subject to the following conditions:
10 *
11 * The above copyright notice and this permission notice shall be included in all
12 * copies or substantial portions of the Software.
13 *
14 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
15 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
16 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
17 * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
18 * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
19 * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
20 * SOFTWARE.
21*/
22
23#ifndef NOVASVG_RENDER_H
24#define NOVASVG_RENDER_H
25
26#include <stdbool.h>
27
28// NOVASVG_MAX/NOVASVG_MIN are defined in novasvg.h, which #includes
29// (transitively, via canvas.h) this header -- always available by the
30// time any of the macros below are actually used at a call site.
31
32// Pure C++ project: no separate C translation units link against this,
33// so the extern "C" wrapper this file used to have (for use as a
34// standalone C library) has been dropped along with the novasvg_ prefix
35// below -- everything here now lives in namespace novasvg::render
36// instead.
37namespace novasvg {
38namespace render {
39
40// NovaSVG is header-only: every function is NOVASVG_INLINE, so the default
41// linkage must NOT be dllimport/dllexport. On MSVC, __declspec(dllimport) on
42// an inline-defined function suppresses the inline body and produces LNK2019
43// unresolved externals. Shared-library decoration is therefore opt-in via
44// NOVASVG_BUILD_SHARED.
45#if defined(NOVASVG_BUILD_STATIC) || !defined(NOVASVG_BUILD_SHARED)
46#define NOVASVG_EXPORT
47#define NOVASVG_IMPORT
48#elif (defined(_WIN32) || defined(__CYGWIN__))
49#define NOVASVG_EXPORT __declspec(dllexport)
50#define NOVASVG_IMPORT __declspec(dllimport)
51#elif defined(__GNUC__) && (__GNUC__ >= 4)
52#define NOVASVG_EXPORT __attribute__((__visibility__("default")))
53#define NOVASVG_IMPORT
54#else
55#define NOVASVG_EXPORT
56#define NOVASVG_IMPORT
57#endif
58
59#ifdef NOVASVG_BUILD
60#define NOVASVG_API NOVASVG_EXPORT
61#else
62#define NOVASVG_API NOVASVG_IMPORT
63#endif
64
65#define NOVASVG_RENDER_VERSION_MAJOR 1
66#define NOVASVG_RENDER_VERSION_MINOR 3
67#define NOVASVG_RENDER_VERSION_MICRO 2
68
69#define NOVASVG_RENDER_VERSION_ENCODE(major, minor, micro) (((major) * 10000) + ((minor) * 100) + ((micro) * 1))
70#define NOVASVG_RENDER_VERSION NOVASVG_RENDER_VERSION_ENCODE(NOVASVG_RENDER_VERSION_MAJOR, NOVASVG_RENDER_VERSION_MINOR, NOVASVG_RENDER_VERSION_MICRO)
71
72#define NOVASVG_RENDER_VERSION_XSTRINGIZE(major, minor, micro) #major"."#minor"."#micro
73#define NOVASVG_RENDER_VERSION_STRINGIZE(major, minor, micro) NOVASVG_RENDER_VERSION_XSTRINGIZE(major, minor, micro)
74#define NOVASVG_RENDER_VERSION_STRING NOVASVG_RENDER_VERSION_STRINGIZE(NOVASVG_RENDER_VERSION_MAJOR, NOVASVG_RENDER_VERSION_MINOR, NOVASVG_RENDER_VERSION_MICRO)
75
81
86NOVASVG_API const char* render_version_string(void);
87
92typedef void (*destroy_func_t)(void* closure);
93
100typedef void (*write_func_t)(void* closure, void* data, int size);
101
102#define NOVASVG_PI 3.14159265358979323846f
103#define NOVASVG_TWO_PI 6.28318530717958647693f
104#define NOVASVG_HALF_PI 1.57079632679489661923f
105#define NOVASVG_SQRT2 1.41421356237309504880f
106#define NOVASVG_KAPPA 0.55228474983079339840f
107
108#define NOVASVG_DEG2RAD(x) ((x) * (NOVASVG_PI / 180.0f))
109#define NOVASVG_RAD2DEG(x) ((x) * (180.0f / NOVASVG_PI))
110
114typedef struct point {
115 float x;
116 float y;
118
119#define NOVASVG_MAKE_POINT(x, y) (point_t{x, y})
120#define NOVASVG_EMPTY_POINT NOVASVG_MAKE_POINT(0, 0)
121
125typedef struct rect {
126 float x;
127 float y;
128 float w;
129 float h;
131
132#define NOVASVG_MAKE_RECT(x, y, w, h) (rect_t{x, y, w, h})
133#define NOVASVG_EMPTY_RECT NOVASVG_MAKE_RECT(0, 0, 0, 0)
134
138typedef struct matrix {
139 float a;
140 float b;
141 float c;
142 float d;
143 float e;
144 float f;
145} matrix_t;
146
147#define NOVASVG_MAKE_MATRIX(a, b, c, d, e, f) (matrix_t{a, b, c, d, e, f})
148#define NOVASVG_MAKE_SCALE(x, y) NOVASVG_MAKE_MATRIX(x, 0, 0, y, 0, 0)
149#define NOVASVG_MAKE_TRANSLATE(x, y) NOVASVG_MAKE_MATRIX(1, 0, 0, 1, x, y)
150#define NOVASVG_IDENTITY_MATRIX NOVASVG_MAKE_MATRIX(1, 0, 0, 1, 0, 0)
151
162NOVASVG_API void matrix_init(matrix_t* matrix, float a, float b, float c, float d, float e, float f);
163
169
176NOVASVG_API void matrix_init_translate(matrix_t* matrix, float tx, float ty);
177
184NOVASVG_API void matrix_init_scale(matrix_t* matrix, float sx, float sy);
185
191NOVASVG_API void matrix_init_rotate(matrix_t* matrix, float angle);
192
199NOVASVG_API void matrix_init_shear(matrix_t* matrix, float shx, float shy);
200
207NOVASVG_API void matrix_translate(matrix_t* matrix, float tx, float ty);
208
215NOVASVG_API void matrix_scale(matrix_t* matrix, float sx, float sy);
216
222NOVASVG_API void matrix_rotate(matrix_t* matrix, float angle);
223
230NOVASVG_API void matrix_shear(matrix_t* matrix, float shx, float shy);
231
239NOVASVG_API void matrix_multiply(matrix_t* matrix, const matrix_t* left, const matrix_t* right);
240
251NOVASVG_API bool matrix_invert(const matrix_t* matrix, matrix_t* inverse);
252
261NOVASVG_API void matrix_map(const matrix_t* matrix, float x, float y, float* xx, float* yy);
262
270NOVASVG_API void matrix_map_point(const matrix_t* matrix, const point_t* src, point_t* dst);
271
280NOVASVG_API void matrix_map_points(const matrix_t* matrix, const point_t* src, point_t* dst, int count);
281
289NOVASVG_API void matrix_map_rect(const matrix_t* matrix, const rect_t* src, rect_t* dst);
290
300NOVASVG_API bool matrix_parse(matrix_t* matrix, const char* data, int length);
301
305typedef struct path path_t;
306
316
358
367
375
383
392
399
407
418
426
436NOVASVG_API int path_get_elements(const path_t* path, const path_element_t** elements);
437
448NOVASVG_API void path_move_to(path_t* path, float x, float y);
449
460NOVASVG_API void path_line_to(path_t* path, float x, float y);
461
475NOVASVG_API void path_quad_to(path_t* path, float x1, float y1, float x2, float y2);
476
492NOVASVG_API void path_cubic_to(path_t* path, float x1, float y1, float x2, float y2, float x3, float y3);
493
511NOVASVG_API void path_arc_to(path_t* path, float rx, float ry, float angle, bool large_arc_flag, bool sweep_flag, float x, float y);
512
523
534NOVASVG_API void path_get_current_point(const path_t* path, float* x, float* y);
535
545NOVASVG_API void path_reserve(path_t* path, int count);
546
555
567NOVASVG_API void path_add_rect(path_t* path, float x, float y, float w, float h);
568
583NOVASVG_API void path_add_round_rect(path_t* path, float x, float y, float w, float h, float rx, float ry);
584
596NOVASVG_API void path_add_ellipse(path_t* path, float cx, float cy, float rx, float ry);
597
608NOVASVG_API void path_add_circle(path_t* path, float cx, float cy, float r);
609
624NOVASVG_API void path_add_arc(path_t* path, float cx, float cy, float r, float a0, float a1, bool ccw);
625
636NOVASVG_API void path_add_path(path_t* path, const path_t* source, const matrix_t* matrix);
637
647
658typedef void (*path_traverse_func_t)(void* closure, path_command_t command, const point_t* points, int npoints);
659
667NOVASVG_API void path_traverse(const path_t* path, path_traverse_func_t traverse_func, void* closure);
668
676NOVASVG_API void path_traverse_flatten(const path_t* path, path_traverse_func_t traverse_func, void* closure);
677
688NOVASVG_API void path_traverse_dashed(const path_t* path, float offset, const float* dashes, int ndashes, path_traverse_func_t traverse_func, void* closure);
689
697
705
715NOVASVG_API path_t* path_clone_dashed(const path_t* path, float offset, const float* dashes, int ndashes);
716
725NOVASVG_API float path_extents(const path_t* path, rect_t* extents, bool tight);
726
733NOVASVG_API float path_length(const path_t* path);
734
743NOVASVG_API bool path_parse(path_t* path, const char* data, int length);
744
754
764
768typedef unsigned int codepoint_t;
769
778NOVASVG_API void text_iterator_init(text_iterator_t* it, const void* text, int length, text_encoding_t encoding);
779
787
795
799typedef struct font_face font_face_t;
800
808NOVASVG_API font_face_t* font_face_load_from_file(const char* filename, int ttcindex);
809
820NOVASVG_API font_face_t* font_face_load_from_data(const void* data, unsigned int length, int ttcindex, destroy_func_t destroy_func, void* closure);
821
829
836
844
855NOVASVG_API void font_face_get_metrics(const font_face_t* face, float size, float* ascent, float* descent, float* line_gap, rect_t* extents);
856
867NOVASVG_API void font_face_get_glyph_metrics(font_face_t* face, float size, codepoint_t codepoint, float* advance_width, float* left_side_bearing, rect_t* extents);
868
880NOVASVG_API float font_face_get_glyph_path(font_face_t* face, float size, float x, float y, codepoint_t codepoint, path_t* path);
881
894NOVASVG_API float font_face_traverse_glyph_path(font_face_t* face, float size, float x, float y, codepoint_t codepoint, path_traverse_func_t traverse_func, void* closure);
895
907NOVASVG_API float font_face_text_extents(font_face_t* face, float size, const void* text, int length, text_encoding_t encoding, rect_t* extents);
908
913
920
928
935
943
950
960NOVASVG_API void font_face_cache_add(font_face_cache_t* cache, const char* family, bool bold, bool italic, font_face_t* face);
961
973NOVASVG_API bool font_face_cache_add_file(font_face_cache_t* cache, const char* family, bool bold, bool italic, const char* filename, int ttcindex);
974
984NOVASVG_API font_face_t* font_face_cache_get(font_face_cache_t* cache, const char* family, bool bold, bool italic);
985
993NOVASVG_API int font_face_cache_load_file(font_face_cache_t* cache, const char* filename);
994
1004NOVASVG_API int font_face_cache_load_dir(font_face_cache_t* cache, const char* dirname);
1005
1015
1019typedef struct color {
1020 float r;
1021 float g;
1022 float b;
1023 float a;
1025
1026#define NOVASVG_MAKE_COLOR(r, g, b, a) (color_t{r, g, b, a})
1027
1028#define NOVASVG_BLACK_COLOR NOVASVG_MAKE_COLOR(0, 0, 0, 1)
1029#define NOVASVG_WHITE_COLOR NOVASVG_MAKE_COLOR(1, 1, 1, 1)
1030#define NOVASVG_RED_COLOR NOVASVG_MAKE_COLOR(1, 0, 0, 1)
1031#define NOVASVG_GREEN_COLOR NOVASVG_MAKE_COLOR(0, 1, 0, 1)
1032#define NOVASVG_BLUE_COLOR NOVASVG_MAKE_COLOR(0, 0, 1, 1)
1033#define NOVASVG_YELLOW_COLOR NOVASVG_MAKE_COLOR(1, 1, 0, 1)
1034#define NOVASVG_CYAN_COLOR NOVASVG_MAKE_COLOR(0, 1, 1, 1)
1035#define NOVASVG_MAGENTA_COLOR NOVASVG_MAKE_COLOR(1, 0, 1, 1)
1036
1045NOVASVG_API void color_init_rgb(color_t* color, float r, float g, float b);
1046
1056NOVASVG_API void color_init_rgba(color_t* color, float r, float g, float b, float a);
1057
1066NOVASVG_API void color_init_rgb8(color_t* color, int r, int g, int b);
1067
1077NOVASVG_API void color_init_rgba8(color_t* color, int r, int g, int b, int a);
1078
1085NOVASVG_API void color_init_rgba32(color_t* color, unsigned int value);
1086
1093NOVASVG_API void color_init_argb32(color_t* color, unsigned int value);
1094
1103NOVASVG_API void color_init_hsl(color_t* color, float h, float s, float l);
1104
1114NOVASVG_API void color_init_hsla(color_t* color, float h, float s, float l, float a);
1115
1123NOVASVG_API unsigned int color_to_rgba32(const color_t* color);
1124
1132NOVASVG_API unsigned int color_to_argb32(const color_t* color);
1133
1143NOVASVG_API int color_parse(color_t* color, const char* data, int length);
1144
1152typedef struct surface surface_t;
1153
1161NOVASVG_API surface_t* surface_create(int width, int height);
1162
1172NOVASVG_API surface_t* surface_create_for_data(unsigned char* data, int width, int height, int stride);
1173
1181
1189NOVASVG_API surface_t* surface_load_from_image_data(const void* data, int length);
1190
1198NOVASVG_API surface_t* surface_load_from_image_base64(const char* data, int length);
1199
1207
1214
1222
1229NOVASVG_API unsigned char* surface_get_data(const surface_t* surface);
1230
1238
1246
1254
1262
1275NOVASVG_API void convert_argb_to_rgba(unsigned char* dst, const unsigned char* src, int width, int height, int stride);
1276
1289NOVASVG_API void convert_rgba_to_argb(unsigned char* dst, const unsigned char* src, int width, int height, int stride);
1290
1298
1307
1311typedef struct {
1312 float offset;
1315
1319typedef struct paint paint_t;
1320
1329NOVASVG_API paint_t* paint_create_rgb(float r, float g, float b);
1330
1340NOVASVG_API paint_t* paint_create_rgba(float r, float g, float b, float a);
1341
1349
1363NOVASVG_API paint_t* paint_create_linear_gradient(float x1, float y1, float x2, float y2,
1364 spread_method_t spread, const gradient_stop_t* stops, int nstops, const matrix_t* matrix);
1365
1381NOVASVG_API paint_t* paint_create_radial_gradient(float cx, float cy, float cr, float fx, float fy, float fr,
1382 spread_method_t spread, const gradient_stop_t* stops, int nstops, const matrix_t* matrix);
1383
1394
1402
1409
1417
1425
1451
1460
1469
1473typedef struct canvas canvas_t;
1474
1482
1490
1497
1505
1513
1520
1527
1538NOVASVG_API void canvas_set_rgb(canvas_t* canvas, float r, float g, float b);
1539
1551NOVASVG_API void canvas_set_rgba(canvas_t* canvas, float r, float g, float b, float a);
1552
1562
1578NOVASVG_API void canvas_set_linear_gradient(canvas_t* canvas, float x1, float y1, float x2, float y2,
1579 spread_method_t spread, const gradient_stop_t* stops, int nstops, const matrix_t* matrix);
1580
1598NOVASVG_API void canvas_set_radial_gradient(canvas_t* canvas, float cx, float cy, float cr, float fx, float fy, float fr,
1599 spread_method_t spread, const gradient_stop_t* stops, int nstops, const matrix_t* matrix);
1600
1613
1623
1634
1642
1650
1660NOVASVG_API void canvas_add_font_face(canvas_t* canvas, const char* family, bool bold, bool italic, font_face_t* face);
1661
1673NOVASVG_API bool canvas_add_font_file(canvas_t* canvas, const char* family, bool bold, bool italic, const char* filename, int ttcindex);
1674
1684NOVASVG_API bool canvas_select_font_face(canvas_t* canvas, const char* family, bool bold, bool italic);
1685
1695NOVASVG_API void canvas_set_font(canvas_t* canvas, font_face_t* face, float size);
1696
1706
1716
1726
1736
1746
1756
1766
1776
1785NOVASVG_API void canvas_set_opacity(canvas_t* canvas, float opacity);
1786
1796
1805NOVASVG_API void canvas_set_line_width(canvas_t* canvas, float line_width);
1806
1816
1826
1836
1846
1856
1865NOVASVG_API void canvas_set_miter_limit(canvas_t* canvas, float miter_limit);
1866
1876
1887NOVASVG_API void canvas_set_dash(canvas_t* canvas, float offset, const float* dashes, int ndashes);
1888
1898
1908
1918NOVASVG_API void canvas_set_dash_array(canvas_t* canvas, const float* dashes, int ndashes);
1919
1929NOVASVG_API int canvas_get_dash_array(const canvas_t* canvas, const float** dashes);
1930
1937NOVASVG_API void canvas_translate(canvas_t* canvas, float tx, float ty);
1938
1945NOVASVG_API void canvas_scale(canvas_t* canvas, float sx, float sy);
1946
1953NOVASVG_API void canvas_shear(canvas_t* canvas, float shx, float shy);
1954
1960NOVASVG_API void canvas_rotate(canvas_t* canvas, float angle);
1961
1968
1974
1981
1988
1997NOVASVG_API void canvas_map(const canvas_t* canvas, float x, float y, float* xx, float* yy);
1998
2006NOVASVG_API void canvas_map_point(const canvas_t* canvas, const point_t* src, point_t* dst);
2007
2015NOVASVG_API void canvas_map_rect(const canvas_t* canvas, const rect_t* src, rect_t* dst);
2016
2027NOVASVG_API void canvas_move_to(canvas_t* canvas, float x, float y);
2028
2039NOVASVG_API void canvas_line_to(canvas_t* canvas, float x, float y);
2040
2053NOVASVG_API void canvas_quad_to(canvas_t* canvas, float x1, float y1, float x2, float y2);
2054
2069NOVASVG_API void canvas_cubic_to(canvas_t* canvas, float x1, float y1, float x2, float y2, float x3, float y3);
2070
2087NOVASVG_API void canvas_arc_to(canvas_t* canvas, float rx, float ry, float angle, bool large_arc_flag, bool sweep_flag, float x, float y);
2088
2100NOVASVG_API void canvas_rect(canvas_t* canvas, float x, float y, float w, float h);
2101
2116NOVASVG_API void canvas_round_rect(canvas_t* canvas, float x, float y, float w, float h, float rx, float ry);
2117
2129NOVASVG_API void canvas_ellipse(canvas_t* canvas, float cx, float cy, float rx, float ry);
2130
2141NOVASVG_API void canvas_circle(canvas_t* canvas, float cx, float cy, float r);
2142
2158NOVASVG_API void canvas_arc(canvas_t* canvas, float cx, float cy, float r, float a0, float a1, bool ccw);
2159
2169
2178
2187
2198NOVASVG_API void canvas_get_current_point(const canvas_t* canvas, float* x, float* y);
2199
2209
2224NOVASVG_API bool canvas_fill_contains(canvas_t* canvas, float x, float y);
2225
2240NOVASVG_API bool canvas_stroke_contains(canvas_t* canvas, float x, float y);
2241
2256NOVASVG_API bool canvas_clip_contains(canvas_t* canvas, float x, float y);
2257
2271
2285
2299
2308
2317
2326
2334
2343
2352
2361
2372NOVASVG_API void canvas_fill_rect(canvas_t* canvas, float x, float y, float w, float h);
2373
2382
2393NOVASVG_API void canvas_stroke_rect(canvas_t* canvas, float x, float y, float w, float h);
2394
2403
2414NOVASVG_API void canvas_clip_rect(canvas_t* canvas, float x, float y, float w, float h);
2415
2424
2434NOVASVG_API float canvas_add_glyph(canvas_t* canvas, codepoint_t codepoint, float x, float y);
2435
2447NOVASVG_API float canvas_add_text(canvas_t* canvas, const void* text, int length, text_encoding_t encoding, float x, float y);
2448
2461NOVASVG_API float canvas_fill_text(canvas_t* canvas, const void* text, int length, text_encoding_t encoding, float x, float y);
2462
2475NOVASVG_API float canvas_stroke_text(canvas_t* canvas, const void* text, int length, text_encoding_t encoding, float x, float y);
2476
2489NOVASVG_API float canvas_clip_text(canvas_t* canvas, const void* text, int length, text_encoding_t encoding, float x, float y);
2490
2500NOVASVG_API void canvas_font_metrics(const canvas_t* canvas, float* ascent, float* descent, float* line_gap, rect_t* extents);
2501
2511NOVASVG_API void canvas_glyph_metrics(canvas_t* canvas, codepoint_t codepoint, float* advance_width, float* left_side_bearing, rect_t* extents);
2512
2523NOVASVG_API float canvas_text_extents(canvas_t* canvas, const void* text, int length, text_encoding_t encoding, rect_t* extents);
2524
2525} // namespace render
2526} // namespace novasvg
2527
2528#endif // NOVASVG_RENDER_H
NOVASVG_INLINE float canvas_get_dash_offset(const canvas_t *canvas)
Retrieves the current dash offset.
Definition canvas.h:362
NOVASVG_INLINE void canvas_stroke_rect(canvas_t *canvas, float x, float y, float w, float h)
Strokes a rectangle with the current stroke settings.
Definition canvas.h:636
NOVASVG_INLINE void canvas_clip(canvas_t *canvas)
A drawing operator that intersects the current clipping region with the current path according to the...
Definition canvas.h:572
NOVASVG_INLINE int canvas_get_reference_count(const canvas_t *canvas)
Retrieves the reference count of the canvas.
Definition canvas.h:132
NOVASVG_INLINE font_face_t * canvas_get_font_face(const canvas_t *canvas)
Retrieves the current font face used for text rendering on the canvas.
Definition canvas.h:266
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.
Definition matrix.h:106
NOVASVG_INLINE void canvas_arc(canvas_t *canvas, float cx, float cy, float r, float a0, float a1, bool ccw)
Adds an arc to the current path.
Definition canvas.h:480
NOVASVG_INLINE void paint_destroy(paint_t *paint)
Decrements the reference count and destroys the paint if the count reaches zero.
Definition paint.h:494
NOVASVG_INLINE void canvas_move_to(canvas_t *canvas, float x, float y)
Moves the current point to a new position.
Definition canvas.h:435
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).
Definition matrix.h:100
NOVASVG_INLINE void color_init_rgb(color_t *color, float r, float g, float b)
Initializes a color using RGB components in the 0-1 range.
Definition paint.h:11
NOVASVG_INLINE path_t * path_create(void)
Creates a new path object.
Definition path.h:43
NOVASVG_INLINE void font_face_cache_add(font_face_cache_t *cache, const char *family, bool bold, bool italic, font_face_t *face)
Add a font face to the cache with the specified family and style.
Definition font.h:5770
NOVASVG_INLINE void color_init_rgba32(color_t *color, unsigned int value)
Initializes a color from a 32-bit unsigned RGBA value.
Definition paint.h:34
NOVASVG_INLINE bool canvas_clip_contains(canvas_t *canvas, float x, float y)
Tests whether a point lies within the current clipping region.
Definition canvas.h:522
path_command
Enumeration defining path commands.
Definition render.h:310
@ NOVASVG_PATH_COMMAND_CUBIC_TO
Draws a cubic Bézier curve to a new point.
Definition render.h:313
@ NOVASVG_PATH_COMMAND_CLOSE
Closes the current path by drawing a line to the starting point.
Definition render.h:314
@ NOVASVG_PATH_COMMAND_LINE_TO
Draws a straight line to a new point.
Definition render.h:312
@ NOVASVG_PATH_COMMAND_MOVE_TO
Moves the current point to a new position.
Definition render.h:311
NOVASVG_INLINE void font_face_cache_destroy(font_face_cache_t *cache)
Decrement the reference count of a font‐face cache and destroy it when it reaches zero.
Definition font.h:5708
NOVASVG_INLINE void canvas_map_point(const canvas_t *canvas, const point_t *src, point_t *dst)
Transforms the src point using the current transformation matrix and stores the result in dst.
Definition canvas.h:425
NOVASVG_INLINE float font_face_text_extents(font_face_t *face, float size, const void *text, int length, text_encoding_t encoding, rect_t *extents)
Computes the bounding box of a text string and its advance width.
Definition font.h:5616
NOVASVG_INLINE void canvas_set_rgba(canvas_t *canvas, float r, float g, float b, float a)
Sets the current paint to a solid color.
Definition canvas.h:170
texture_type_t
Defines the type of texture, either plain or tiled.
Definition render.h:1294
@ NOVASVG_TEXTURE_TYPE_TILED
Tiled texture.
Definition render.h:1296
@ NOVASVG_TEXTURE_TYPE_PLAIN
Plain texture.
Definition render.h:1295
NOVASVG_INLINE void canvas_clip_extents(canvas_t *canvas, rect_t *extents)
Gets the bounding box of the current clipping region.
Definition canvas.h:548
surface_t * surface_create_for_data(unsigned char *data, int width, int height, int stride)
Creates an image surface using existing pixel data.
Definition surface.h:7761
NOVASVG_INLINE void canvas_fill_rect(canvas_t *canvas, float x, float y, float w, float h)
Fills a rectangle according to the current fill rule.
Definition canvas.h:622
NOVASVG_INLINE void canvas_add_path(canvas_t *canvas, const path_t *path)
Adds a path to the current path.
Definition canvas.h:485
void(* write_func_t)(void *closure, void *data, int size)
A function pointer type for a write callback.
Definition render.h:100
NOVASVG_INLINE fill_rule_t canvas_get_fill_rule(const canvas_t *canvas)
Retrieves the current fill rule.
Definition canvas.h:286
NOVASVG_INLINE float canvas_get_line_width(const canvas_t *canvas)
Retrieves the current line width.
Definition canvas.h:316
struct novasvg::render::matrix matrix_t
A structure representing a 2D transformation matrix.
Definition novasvg.h:110
NOVASVG_INLINE int font_face_cache_load_dir(font_face_cache_t *cache, const char *dirname)
Load all font faces from files in a directory recursively and add them to the cache.
Definition font.h:6199
NOVASVG_INLINE void canvas_quad_to(canvas_t *canvas, float x1, float y1, float x2, float y2)
Adds a quadratic Bézier curve to the current path.
Definition canvas.h:445
NOVASVG_INLINE void path_iterator_init(path_iterator_t *it, const path_t *path)
Initializes a path iterator for a given path.
Definition path.h:11
NOVASVG_INLINE void canvas_font_metrics(const canvas_t *canvas, float *ascent, float *descent, float *line_gap, rect_t *extents)
Retrieves font metrics for the current font.
Definition canvas.h:719
NOVASVG_INLINE paint_t * canvas_get_paint(const canvas_t *canvas, color_t *color)
Retrieves the current paint.
Definition canvas.h:209
NOVASVG_INLINE void canvas_set_matrix(canvas_t *canvas, const matrix_t *matrix)
Resets the current transformation matrix to the specified matrix.
Definition canvas.h:410
NOVASVG_INLINE void font_face_destroy(font_face_t *face)
Decrements the reference count and potentially destroys the font face.
Definition font.h:5340
NOVASVG_INLINE void canvas_destroy(canvas_t *canvas)
Decreases the reference count and destroys the canvas when it reaches zero.
Definition canvas.h:108
NOVASVG_INLINE void path_move_to(path_t *path, float x, float y)
Moves the current point to a new position.
Definition path.h:93
NOVASVG_INLINE void canvas_set_line_join(canvas_t *canvas, line_join_t line_join)
Sets the line join style.
Definition canvas.h:331
enum novasvg::render::path_command path_command_t
Enumeration defining path commands.
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.
Definition matrix.h:111
NOVASVG_INLINE void matrix_init_rotate(matrix_t *matrix, float angle)
Initializes a 2D transformation matrix for rotation.
Definition matrix.h:30
NOVASVG_INLINE void path_arc_to(path_t *path, float rx, float ry, float angle, bool large_arc_flag, bool sweep_flag, float x, float y)
Adds an elliptical arc to the path.
Definition path.h:131
NOVASVG_INLINE float font_face_traverse_glyph_path(font_face_t *face, float size, float x, float y, codepoint_t codepoint, path_traverse_func_t traverse_func, void *closure)
Traverses the path of a glyph and calls a callback for each path element.
Definition font.h:5495
NOVASVG_INLINE void path_cubic_to(path_t *path, float x1, float y1, float x2, float y2, float x3, float y3)
Adds a cubic Bézier curve to the path.
Definition path.h:120
NOVASVG_INLINE float canvas_get_font_size(const canvas_t *canvas)
Retrieves the current font size used for text rendering on the canvas.
Definition canvas.h:276
NOVASVG_INLINE void canvas_scale(canvas_t *canvas, float sx, float sy)
Scales the current transformation matrix by factors sx and sy.
Definition canvas.h:385
int surface_get_width(const surface_t *surface)
Gets the width of the surface.
Definition surface.h:7943
NOVASVG_INLINE void canvas_stroke_extents(canvas_t *canvas, rect_t *extents)
Computes the bounding box of the area that would be affected by a stroke operation.
Definition canvas.h:542
NOVASVG_INLINE float path_extents(const path_t *path, rect_t *extents, bool tight)
Computes the bounding box and total length of the path.
Definition path.h:701
unsigned int codepoint_t
Represents a Unicode code point.
Definition render.h:768
void convert_rgba_to_argb(unsigned char *dst, const unsigned char *src, int width, int height, int stride)
Converts pixel data from RGBA to premultiplied ARGB format.
Definition surface.h:7999
NOVASVG_INLINE int font_face_cache_reference_count(const font_face_cache_t *cache)
Retrieve the current reference count of a font‐face cache.
Definition font.h:5717
NOVASVG_INLINE void canvas_stroke(canvas_t *canvas)
A drawing operator that strokes the current path according to the current stroke settings.
Definition canvas.h:566
NOVASVG_INLINE void canvas_circle(canvas_t *canvas, float cx, float cy, float r)
Adds a circle to the current path.
Definition canvas.h:475
NOVASVG_INLINE float canvas_text_extents(canvas_t *canvas, const void *text, int length, text_encoding_t encoding, rect_t *extents)
Retrieves the extents of a text.
Definition canvas.h:756
NOVASVG_INLINE void canvas_stroke_path(canvas_t *canvas, const path_t *path)
Strokes a path with the current stroke settings.
Definition canvas.h:643
NOVASVG_INLINE int font_face_get_reference_count(const font_face_t *face)
Retrieves the current reference count of a font face.
Definition font.h:5351
NOVASVG_INLINE float canvas_clip_text(canvas_t *canvas, const void *text, int length, text_encoding_t encoding, float x, float y)
Intersects the current clipping region with text at the specified origin.
Definition canvas.h:711
NOVASVG_INLINE void path_add_path(path_t *path, const path_t *source, const matrix_t *matrix)
Adds a sub-path to the path.
Definition path.h:380
NOVASVG_INLINE void color_init_hsla(color_t *color, float h, float s, float l, float a)
Initializes a color with the specified HSLA color values.
Definition paint.h:64
NOVASVG_INLINE bool canvas_stroke_contains(canvas_t *canvas, float x, float y)
Tests whether a point lies within the current stroke region.
Definition canvas.h:516
NOVASVG_INLINE float canvas_add_text(canvas_t *canvas, const void *text, int length, text_encoding_t encoding, float x, float y)
Adds text to the current path at the specified origin.
Definition canvas.h:672
NOVASVG_INLINE void color_init_rgba(color_t *color, float r, float g, float b, float a)
Initializes a color using RGBA components in the 0-1 range.
Definition paint.h:16
NOVASVG_INLINE void canvas_new_path(canvas_t *canvas)
Starts a new path on the canvas.
Definition canvas.h:490
NOVASVG_INLINE bool canvas_fill_contains(canvas_t *canvas, float x, float y)
Tests whether a point lies within the current fill region.
Definition canvas.h:510
int surface_get_height(const surface_t *surface)
Gets the height of the surface.
Definition surface.h:7948
NOVASVG_INLINE void canvas_shear(canvas_t *canvas, float shx, float shy)
Shears the current transformation matrix by factors shx and shy.
Definition canvas.h:390
NOVASVG_INLINE unsigned int color_to_argb32(const color_t *color)
Converts a color to a 32-bit unsigned ARGB value.
Definition paint.h:84
NOVASVG_INLINE void color_init_rgba8(color_t *color, int r, int g, int b, int a)
Initializes a color using RGBA components in the 0-255 range.
Definition paint.h:29
struct novasvg::render::path_iterator path_iterator_t
Iterator for traversing path elements in a path.
NOVASVG_INLINE font_face_cache_t * font_face_cache_reference(font_face_cache_t *cache)
Increments the reference count of a font‐face cache.
Definition font.h:5702
NOVASVG_INLINE float canvas_get_opacity(const canvas_t *canvas)
Retrieves the current global opacity.
Definition canvas.h:306
NOVASVG_INLINE path_t * canvas_get_path(const canvas_t *canvas)
Gets the current path from the canvas.
Definition canvas.h:505
NOVASVG_INLINE void canvas_set_font_size(canvas_t *canvas, float size)
Sets the font size for text rendering on the canvas.
Definition canvas.h:271
NOVASVG_INLINE void canvas_save(canvas_t *canvas)
Saves the current state of the canvas.
Definition canvas.h:142
NOVASVG_INLINE canvas_t * canvas_reference(canvas_t *canvas)
Increases the reference count of the canvas.
Definition canvas.h:102
NOVASVG_INLINE float canvas_stroke_text(canvas_t *canvas, const void *text, int length, text_encoding_t encoding, float x, float y)
Strokes a text at the specified origin.
Definition canvas.h:703
NOVASVG_INLINE void path_get_current_point(const path_t *path, float *x, float *y)
Retrieves the current point of the path.
Definition path.h:225
NOVASVG_INLINE paint_t * paint_reference(paint_t *paint)
Increments the reference count of a paint object.
Definition paint.h:488
NOVASVG_INLINE font_face_t * font_face_load_from_data(const void *data, unsigned int length, int ttcindex, destroy_func_t destroy_func, void *closure)
Loads a font face from memory.
Definition font.h:5310
void(* path_traverse_func_t)(void *closure, path_command_t command, const point_t *points, int npoints)
Callback function type for traversing a path.
Definition render.h:658
struct novasvg::render::text_iterator text_iterator_t
Iterator for traversing code points in text data.
NOVASVG_INLINE void canvas_fill(canvas_t *canvas)
A drawing operator that fills the current path according to the current fill rule.
Definition canvas.h:560
NOVASVG_INLINE font_face_t * font_face_load_from_file(const char *filename, int ttcindex)
Loads a font face from a file.
Definition font.h:5278
NOVASVG_INLINE void path_destroy(path_t *path)
Decreases the reference count of a path object.
Definition path.h:61
NOVASVG_INLINE void path_close(path_t *path)
Closes the current sub-path.
Definition path.h:217
NOVASVG_INLINE void canvas_line_to(canvas_t *canvas, float x, float y)
Adds a straight line segment to the current path.
Definition canvas.h:440
NOVASVG_INLINE void canvas_set_dash_offset(canvas_t *canvas, float offset)
Sets the dash offset.
Definition canvas.h:357
NOVASVG_INLINE void font_face_get_glyph_metrics(font_face_t *face, float size, codepoint_t codepoint, float *advance_width, float *left_side_bearing, rect_t *extents)
Retrieves metrics for a specified glyph at a given size.
Definition font.h:5441
NOVASVG_INLINE float canvas_get_miter_limit(const canvas_t *canvas)
Retrieves the current miter limit.
Definition canvas.h:346
NOVASVG_INLINE bool path_iterator_has_next(const path_iterator_t *it)
Checks if there are more elements to iterate over.
Definition path.h:18
int surface_get_stride(const surface_t *surface)
Gets the stride of the surface.
Definition surface.h:7953
surface_t * surface_create(int width, int height)
Creates a new image surface with the specified dimensions.
Definition surface.h:7753
NOVASVG_INLINE void canvas_arc_to(canvas_t *canvas, float rx, float ry, float angle, bool large_arc_flag, bool sweep_flag, float x, float y)
Adds an elliptical arc to the current path.
Definition canvas.h:455
NOVASVG_INLINE void path_reserve(path_t *path, int count)
Reserves space for path elements.
Definition path.h:238
NOVASVG_INLINE bool path_parse(path_t *path, const char *data, int length)
Parses SVG path data into a path_t object.
Definition path.h:748
NOVASVG_INLINE void canvas_set_fill_rule(canvas_t *canvas, fill_rule_t winding)
Sets the fill rule.
Definition canvas.h:281
surface_t * surface_load_from_image_data(const void *data, int length)
Loads an image surface from raw image data.
Definition surface.h:7790
void surface_destroy(surface_t *surface)
Decrements the reference count and destroys the surface if the count reaches zero.
Definition surface.h:7926
NOVASVG_INLINE font_face_t * font_face_cache_get(font_face_cache_t *cache, const char *family, bool bold, bool italic)
Retrieve a font face from the cache by family and style.
Definition font.h:5812
NOVASVG_INLINE void canvas_set_opacity(canvas_t *canvas, float opacity)
Sets the global opacity.
Definition canvas.h:301
NOVASVG_INLINE void matrix_init_identity(matrix_t *matrix)
Initializes a 2D transformation matrix to the identity matrix.
Definition matrix.h:15
NOVASVG_INLINE bool matrix_parse(matrix_t *matrix, const char *data, int length)
Parses an SVG transform string into a matrix.
Definition matrix.h:171
NOVASVG_INLINE bool canvas_select_font_face(canvas_t *canvas, const char *family, bool bold, bool italic)
Selects and sets the current font face on the canvas.
Definition canvas.h:242
NOVASVG_INLINE surface_t * canvas_get_surface(const canvas_t *canvas)
Gets the surface associated with the canvas.
Definition canvas.h:137
NOVASVG_INLINE void canvas_ellipse(canvas_t *canvas, float cx, float cy, float rx, float ry)
Adds an ellipse to the current path.
Definition canvas.h:470
NOVASVG_INLINE void canvas_set_radial_gradient(canvas_t *canvas, float cx, float cy, float cr, float fx, float fy, float fr, spread_method_t spread, const gradient_stop_t *stops, int nstops, const matrix_t *matrix)
Sets the current paint to a radial gradient.
Definition canvas.h:188
void(* destroy_func_t)(void *closure)
A function pointer type for a cleanup callback.
Definition render.h:92
line_join_t
Defines the shape used at the corners of paths.
Definition render.h:1464
@ NOVASVG_LINE_JOIN_BEVEL
Beveled join with a flattened corner.
Definition render.h:1467
@ NOVASVG_LINE_JOIN_MITER
Miter join with sharp corners.
Definition render.h:1465
@ NOVASVG_LINE_JOIN_ROUND
Rounded join.
Definition render.h:1466
NOVASVG_INLINE paint_t * paint_create_rgba(float r, float g, float b, float a)
Creates a solid RGBA paint.
Definition paint.h:409
surface_t * surface_load_from_image_file(const char *filename)
Loads an image surface from a file.
Definition surface.h:7781
NOVASVG_INLINE void matrix_shear(matrix_t *matrix, float shx, float shy)
Shears the matrix by factors shx and shy.
Definition matrix.h:63
NOVASVG_INLINE path_t * path_reference(path_t *path)
Increases the reference count of a path object.
Definition path.h:55
NOVASVG_INLINE unsigned int color_to_rgba32(const color_t *color)
Converts a color to a 32-bit unsigned RGBA value.
Definition paint.h:75
fill_rule_t
Defines fill rule types for filling paths.
Definition render.h:1421
@ NOVASVG_FILL_RULE_NON_ZERO
Non-zero winding fill rule.
Definition render.h:1422
@ NOVASVG_FILL_RULE_EVEN_ODD
Even-odd fill rule.
Definition render.h:1423
NOVASVG_INLINE void canvas_map_rect(const canvas_t *canvas, const rect_t *src, rect_t *dst)
Transforms the src rectangle using the current transformation matrix and stores the result in dst.
Definition canvas.h:430
NOVASVG_INLINE canvas_t * canvas_create(surface_t *surface)
Creates a drawing context on a surface.
Definition canvas.h:87
NOVASVG_INLINE paint_t * paint_create_color(const color_t *color)
Creates a solid color paint.
Definition paint.h:422
NOVASVG_INLINE void matrix_init_scale(matrix_t *matrix, float sx, float sy)
Initializes a 2D transformation matrix for scaling.
Definition matrix.h:25
NOVASVG_INLINE void canvas_set_rgb(canvas_t *canvas, float r, float g, float b)
Sets the current paint to a solid color.
Definition canvas.h:165
NOVASVG_INLINE line_join_t canvas_get_line_join(const canvas_t *canvas)
Retrieves the current line join style.
Definition canvas.h:336
NOVASVG_INLINE bool matrix_invert(const matrix_t *matrix, matrix_t *inverse)
Calculates the inverse of matrix and stores it in inverse.
Definition matrix.h:81
NOVASVG_INLINE void path_traverse(const path_t *path, path_traverse_func_t traverse_func, void *closure)
Traverses the path and calls the callback for each element.
Definition path.h:417
NOVASVG_INLINE void canvas_get_current_point(const canvas_t *canvas, float *x, float *y)
Retrieves the current point of the canvas.
Definition canvas.h:500
NOVASVG_INLINE void path_add_ellipse(path_t *path, float cx, float cy, float rx, float ry)
Adds an ellipse to the path.
Definition path.h:291
NOVASVG_INLINE void canvas_set_paint(canvas_t *canvas, paint_t *paint)
Sets the current paint.
Definition canvas.h:202
NOVASVG_INLINE void canvas_paint(canvas_t *canvas)
A drawing operator that paints the current clipping region using the current paint.
Definition canvas.h:578
NOVASVG_INLINE void path_add_arc(path_t *path, float cx, float cy, float r, float a0, float a1, bool ccw)
Adds an arc to the path.
Definition path.h:315
NOVASVG_INLINE void canvas_fill_path(canvas_t *canvas, const path_t *path)
Fills a path according to the current fill rule.
Definition canvas.h:629
NOVASVG_INLINE line_cap_t canvas_get_line_cap(const canvas_t *canvas)
Retrieves the current line cap style.
Definition canvas.h:326
NOVASVG_INLINE path_t * path_clone_flatten(const path_t *path)
Creates a copy of the path with Bézier curves flattened to line segments.
Definition path.h:649
NOVASVG_INLINE float path_length(const path_t *path)
Calculates the total length of the path.
Definition path.h:720
NOVASVG_INLINE void path_quad_to(path_t *path, float x1, float y1, float x2, float y2)
Adds a quadratic Bézier curve to the path.
Definition path.h:109
NOVASVG_INLINE void canvas_add_font_face(canvas_t *canvas, const char *family, bool bold, bool italic, font_face_t *face)
Add a font face to the canvas using the specified family and style.
Definition canvas.h:228
NOVASVG_INLINE void canvas_translate(canvas_t *canvas, float tx, float ty)
Translates the current transformation matrix by offsets tx and ty.
Definition canvas.h:380
NOVASVG_INLINE void canvas_set_font_face(canvas_t *canvas, font_face_t *face)
Sets the font face for text rendering on the canvas.
Definition canvas.h:259
enum novasvg::render::text_encoding text_encoding_t
Text encodings used for converting text data to code points.
NOVASVG_INLINE void canvas_get_matrix(const canvas_t *canvas, matrix_t *matrix)
Stores the current transformation matrix in matrix.
Definition canvas.h:415
NOVASVG_INLINE void canvas_reset_matrix(canvas_t *canvas)
Resets the current transformation matrix to the identity matrix.
Definition canvas.h:405
NOVASVG_INLINE font_face_cache_t * canvas_get_font_face_cache(const canvas_t *canvas)
Returns the font-face cache associated with the canvas.
Definition canvas.h:223
line_cap_t
Defines the shape used at the ends of open subpaths.
Definition render.h:1455
@ NOVASVG_LINE_CAP_SQUARE
Square ends at the end of the stroke.
Definition render.h:1458
@ NOVASVG_LINE_CAP_ROUND
Rounded ends at the end of the stroke.
Definition render.h:1457
@ NOVASVG_LINE_CAP_BUTT
Flat edge at the end of the stroke.
Definition render.h:1456
NOVASVG_INLINE void canvas_stroke_preserve(canvas_t *canvas)
A drawing operator that strokes the current path according to the current stroke settings.
Definition canvas.h:599
NOVASVG_INLINE paint_t * paint_create_linear_gradient(float x1, float y1, float x2, float y2, spread_method_t spread, const gradient_stop_t *stops, int nstops, const matrix_t *matrix)
Creates a linear gradient paint.
Definition paint.h:453
NOVASVG_INLINE int render_version(void)
Gets the version of the novasvg rendering library.
Definition canvas.h:9
NOVASVG_INLINE void canvas_transform(canvas_t *canvas, const matrix_t *matrix)
Multiplies the current transformation matrix with the specified matrix.
Definition canvas.h:400
NOVASVG_INLINE void font_face_cache_reset(font_face_cache_t *cache)
Remove all entries from a font‐face cache.
Definition font.h:5722
int surface_get_reference_count(const surface_t *surface)
Gets the current reference count of a surface.
Definition surface.h:7933
NOVASVG_INLINE paint_t * paint_create_rgb(float r, float g, float b)
Creates a solid RGB paint.
Definition paint.h:404
void convert_argb_to_rgba(unsigned char *dst, const unsigned char *src, int width, int height, int stride)
Converts pixel data from premultiplied ARGB to RGBA format.
Definition surface.h:7967
NOVASVG_INLINE void path_reset(path_t *path)
Resets the path.
Definition path.h:243
NOVASVG_INLINE void path_add_round_rect(path_t *path, float x, float y, float w, float h, float rx, float ry)
Adds a rounded rectangle to the path.
Definition path.h:263
NOVASVG_INLINE operator_t canvas_get_operator(const canvas_t *canvas)
Retrieves the current compositing operator.
Definition canvas.h:296
NOVASVG_INLINE void canvas_set_texture(canvas_t *canvas, surface_t *surface, texture_type_t type, float opacity, const matrix_t *matrix)
Sets the current paint to a texture.
Definition canvas.h:195
operator_t
Defines compositing operations.
Definition render.h:1429
@ NOVASVG_OPERATOR_CLEAR
Clears the destination (resulting in a fully transparent image).
Definition render.h:1430
@ NOVASVG_OPERATOR_DST_IN
Destination within source.
Definition render.h:1436
@ NOVASVG_OPERATOR_SRC_IN
Source within destination (only the overlapping part of source is shown).
Definition render.h:1435
@ NOVASVG_OPERATOR_EXCLUSION
Like difference, with lower contrast.
Definition render.h:1449
@ NOVASVG_OPERATOR_DST_ATOP
Destination atop source (destination shown over source but only in the source's bounds).
Definition render.h:1440
@ NOVASVG_OPERATOR_SRC
Source replaces destination.
Definition render.h:1431
@ NOVASVG_OPERATOR_MULTIPLY
Backdrop * source: darkens, white is neutral.
Definition render.h:1444
@ NOVASVG_OPERATOR_LIGHTEN
The lighter of backdrop and source, per channel.
Definition render.h:1447
@ NOVASVG_OPERATOR_DST_OUT
Destination outside source.
Definition render.h:1438
@ NOVASVG_OPERATOR_DARKEN
The darker of backdrop and source, per channel.
Definition render.h:1446
@ NOVASVG_OPERATOR_DST
Destination is kept, source is ignored.
Definition render.h:1432
@ NOVASVG_OPERATOR_DST_OVER
Destination is composited over source.
Definition render.h:1434
@ NOVASVG_OPERATOR_SRC_OVER
Source is composited over destination.
Definition render.h:1433
@ NOVASVG_OPERATOR_DIFFERENCE
Absolute difference of backdrop and source, per channel.
Definition render.h:1448
@ NOVASVG_OPERATOR_SCREEN
Inverse of multiply: lightens, black is neutral.
Definition render.h:1445
@ NOVASVG_OPERATOR_SRC_OUT
Source outside destination (non-overlapping part of source is shown).
Definition render.h:1437
@ NOVASVG_OPERATOR_XOR
Source and destination are combined, but their overlapping regions are cleared.
Definition render.h:1441
@ NOVASVG_OPERATOR_SRC_ATOP
Source atop destination (source shown over destination but only in the destination's bounds).
Definition render.h:1439
NOVASVG_INLINE codepoint_t text_iterator_next(text_iterator_t *it)
Retrieves the next code point and advances the iterator.
Definition font.h:5046
text_encoding
Text encodings used for converting text data to code points.
Definition render.h:748
@ NOVASVG_TEXT_ENCODING_UTF16
UTF-16 encoding.
Definition render.h:751
@ NOVASVG_TEXT_ENCODING_UTF32
UTF-32 encoding.
Definition render.h:752
@ NOVASVG_TEXT_ENCODING_UTF8
UTF-8 encoding.
Definition render.h:750
@ NOVASVG_TEXT_ENCODING_LATIN1
Latin-1 encoding.
Definition render.h:749
NOVASVG_INLINE bool canvas_add_font_file(canvas_t *canvas, const char *family, bool bold, bool italic, const char *filename, int ttcindex)
Load a font face from a file and add it to the canvas using the specified family and style.
Definition canvas.h:235
NOVASVG_INLINE void canvas_set_miter_limit(canvas_t *canvas, float miter_limit)
Sets the miter limit.
Definition canvas.h:341
struct novasvg::render::rect rect_t
A structure representing a rectangle in 2D space.
NOVASVG_INLINE paint_t * paint_create_texture(surface_t *surface, texture_type_t type, float opacity, const matrix_t *matrix)
Creates a texture paint from a surface.
Definition paint.h:475
NOVASVG_INLINE int color_parse(color_t *color, const char *data, int length)
Parses a color from a string using CSS color syntax.
Definition paint.h:144
NOVASVG_INLINE void canvas_set_operator(canvas_t *canvas, operator_t op)
Sets the compositing operator.
Definition canvas.h:291
NOVASVG_INLINE void canvas_set_linear_gradient(canvas_t *canvas, float x1, float y1, float x2, float y2, spread_method_t spread, const gradient_stop_t *stops, int nstops, const matrix_t *matrix)
Sets the current paint to a linear gradient.
Definition canvas.h:181
NOVASVG_INLINE int path_get_reference_count(const path_t *path)
Retrieves the reference count of a path object.
Definition path.h:69
NOVASVG_INLINE void font_face_get_metrics(const font_face_t *face, float size, float *ascent, float *descent, float *line_gap, rect_t *extents)
Retrieves metrics for a font face at a specified size.
Definition font.h:5422
NOVASVG_INLINE void canvas_fill_preserve(canvas_t *canvas)
A drawing operator that fills the current path according to the current fill rule.
Definition canvas.h:588
NOVASVG_INLINE float canvas_add_glyph(canvas_t *canvas, codepoint_t codepoint, float x, float y)
Adds a glyph to the current path at the specified origin.
Definition canvas.h:664
NOVASVG_INLINE bool text_iterator_has_next(const text_iterator_t *it)
Checks if there are more code points to iterate.
Definition font.h:5041
NOVASVG_INLINE int font_face_cache_load_file(font_face_cache_t *cache, const char *filename)
Load all font faces from a file and add them to the cache.
Definition font.h:5976
NOVASVG_INLINE void color_init_argb32(color_t *color, unsigned int value)
Initializes a color from a 32-bit unsigned ARGB value.
Definition paint.h:43
NOVASVG_INLINE void canvas_fill_extents(canvas_t *canvas, rect_t *extents)
Computes the bounding box of the area that would be affected by a fill operation.
Definition canvas.h:536
NOVASVG_INLINE void canvas_set_line_width(canvas_t *canvas, float line_width)
Sets the line width.
Definition canvas.h:311
NOVASVG_INLINE void canvas_set_line_cap(canvas_t *canvas, line_cap_t line_cap)
Sets the line cap style.
Definition canvas.h:321
NOVASVG_INLINE void matrix_scale(matrix_t *matrix, float sx, float sy)
Scales the matrix by factors sx and sy
Definition matrix.h:49
NOVASVG_INLINE bool font_face_cache_add_file(font_face_cache_t *cache, const char *family, bool bold, bool italic, const char *filename, int ttcindex)
Load a font face from a file and add it to the cache with the specified family and style.
Definition font.h:5788
NOVASVG_INLINE void path_line_to(path_t *path, float x, float y)
Adds a straight line segment to the path.
Definition path.h:101
NOVASVG_INLINE void matrix_init_shear(matrix_t *matrix, float shx, float shy)
Initializes a 2D transformation matrix for shearing.
Definition matrix.h:37
NOVASVG_INLINE void canvas_set_color(canvas_t *canvas, const color_t *color)
Sets the current paint to a solid color.
Definition canvas.h:176
NOVASVG_INLINE path_t * path_clone_dashed(const path_t *path, float offset, const float *dashes, int ndashes)
Creates a copy of the path with a dashed pattern applied.
Definition path.h:657
union novasvg::render::path_element path_element_t
NOVASVG_INLINE float font_face_get_glyph_path(font_face_t *face, float size, float x, float y, codepoint_t codepoint, path_t *path)
Retrieves the path of a glyph and its advance width.
Definition font.h:5490
struct novasvg::render::point point_t
A structure representing a point in 2D space.
NOVASVG_INLINE int font_face_cache_load_sys(font_face_cache_t *cache)
Load all available system font faces and add them to the cache.
Definition font.h:6231
NOVASVG_INLINE void canvas_cubic_to(canvas_t *canvas, float x1, float y1, float x2, float y2, float x3, float y3)
Adds a cubic Bézier curve to the current path.
Definition canvas.h:450
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.
Definition matrix.h:70
NOVASVG_INLINE int canvas_get_dash_array(const canvas_t *canvas, const float **dashes)
Retrieves the current dash pattern.
Definition canvas.h:373
NOVASVG_INLINE int paint_get_reference_count(const paint_t *paint)
Retrieves the reference count of a paint object.
Definition paint.h:506
NOVASVG_INLINE void canvas_close_path(canvas_t *canvas)
Closes the current path.
Definition canvas.h:495
NOVASVG_INLINE paint_t * paint_create_radial_gradient(float cx, float cy, float cr, float fx, float fy, float fr, spread_method_t spread, const gradient_stop_t *stops, int nstops, const matrix_t *matrix)
Creates a radial gradient paint.
Definition paint.h:463
spread_method_t
Defines the spread method for gradients.
Definition render.h:1302
@ NOVASVG_SPREAD_METHOD_PAD
Pad the gradient's edges.
Definition render.h:1303
@ NOVASVG_SPREAD_METHOD_REFLECT
Reflect the gradient beyond its bounds.
Definition render.h:1304
@ NOVASVG_SPREAD_METHOD_REPEAT
Repeat the gradient pattern.
Definition render.h:1305
NOVASVG_INLINE void canvas_set_font_face_cache(canvas_t *canvas, font_face_cache_t *cache)
Assigns a font-face cache to the canvas for font management.
Definition canvas.h:216
NOVASVG_INLINE void path_traverse_flatten(const path_t *path, path_traverse_func_t traverse_func, void *closure)
Traverses the path with Bézier curves flattened to line segments.
Definition path.h:469
struct novasvg::render::color color_t
Represents a color with red, green, blue, and alpha components.
NOVASVG_INLINE void matrix_rotate(matrix_t *matrix, float angle)
Rotates the matrix by the specified angle (in radians).
Definition matrix.h:56
NOVASVG_INLINE void color_init_rgb8(color_t *color, int r, int g, int b)
Initializes a color using RGB components in the 0-255 range.
Definition paint.h:24
NOVASVG_INLINE path_command_t path_iterator_next(path_iterator_t *it, point_t points[3])
Retrieves the current command and its associated points, then advances the iterator.
Definition path.h:23
NOVASVG_INLINE void canvas_set_font(canvas_t *canvas, font_face_t *face, float size)
Sets the font face and size for text rendering on the canvas.
Definition canvas.h:253
NOVASVG_INLINE void canvas_map(const canvas_t *canvas, float x, float y, float *xx, float *yy)
Transforms the point (x, y) using the current transformation matrix and stores the result in (xx,...
Definition canvas.h:420
NOVASVG_INLINE void canvas_restore(canvas_t *canvas)
Restores the canvas to the most recently saved state.
Definition canvas.h:154
NOVASVG_INLINE void text_iterator_init(text_iterator_t *it, const void *text, int length, text_encoding_t encoding)
Initializes a text iterator.
Definition font.h:5031
surface_t * surface_load_from_image_base64(const char *data, int length)
Loads an image surface from base64-encoded data.
Definition surface.h:7909
NOVASVG_INLINE void path_add_circle(path_t *path, float cx, float cy, float r)
Adds a circle to the path.
Definition path.h:310
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.
Definition matrix.h:8
NOVASVG_INLINE void canvas_rotate(canvas_t *canvas, float angle)
Rotates the current transformation matrix by the specified angle (in radians).
Definition canvas.h:395
NOVASVG_INLINE void canvas_rect(canvas_t *canvas, float x, float y, float w, float h)
Adds a rectangle to the current path.
Definition canvas.h:460
NOVASVG_INLINE void canvas_clip_preserve(canvas_t *canvas)
A drawing operator that intersects the current clipping region with the current path according to the...
Definition canvas.h:610
surface_t * surface_reference(surface_t *surface)
Increments the reference count for a surface.
Definition surface.h:7920
NOVASVG_INLINE void canvas_set_dash_array(canvas_t *canvas, const float *dashes, int ndashes)
Sets the dash pattern.
Definition canvas.h:367
NOVASVG_INLINE void matrix_init_translate(matrix_t *matrix, float tx, float ty)
Initializes a 2D transformation matrix for translation.
Definition matrix.h:20
NOVASVG_INLINE const char * render_version_string(void)
Gets the version of the novasvg rendering library as a string.
Definition canvas.h:14
NOVASVG_INLINE float canvas_fill_text(canvas_t *canvas, const void *text, int length, text_encoding_t encoding, float x, float y)
Fills a text at the specified origin.
Definition canvas.h:695
NOVASVG_INLINE void matrix_translate(matrix_t *matrix, float tx, float ty)
Adds a translation with offsets tx and ty to the matrix.
Definition matrix.h:42
NOVASVG_INLINE path_t * path_clone(const path_t *path)
Creates a copy of the path.
Definition path.h:619
NOVASVG_INLINE void path_traverse_dashed(const path_t *path, float offset, const float *dashes, int ndashes, path_traverse_func_t traverse_func, void *closure)
Traverses the path with a dashed pattern and calls the callback for each segment.
Definition path.h:584
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.
Definition matrix.h:118
void surface_clear(surface_t *surface, const color_t *color)
Clears the entire surface with the specified color.
Definition surface.h:7958
NOVASVG_INLINE font_face_t * font_face_reference(font_face_t *face)
Increments the reference count of a font face.
Definition font.h:5334
NOVASVG_INLINE void canvas_set_dash(canvas_t *canvas, float offset, const float *dashes, int ndashes)
Sets the dash pattern.
Definition canvas.h:351
NOVASVG_INLINE font_face_cache_t * font_face_cache_create(void)
Create a new, empty font‐face cache.
Definition font.h:5690
NOVASVG_INLINE void canvas_glyph_metrics(canvas_t *canvas, codepoint_t codepoint, float *advance_width, float *left_side_bearing, rect_t *extents)
Retrieves metrics for a specific glyph.
Definition canvas.h:738
NOVASVG_INLINE int path_get_elements(const path_t *path, const path_element_t **elements)
Retrieves the elements of a path.
Definition path.h:74
NOVASVG_INLINE void canvas_clip_path(canvas_t *canvas, const path_t *path)
Intersects the current clipping region with a path according to the current fill rule.
Definition canvas.h:657
NOVASVG_INLINE void path_add_rect(path_t *path, float x, float y, float w, float h)
Adds a rectangle to the path.
Definition path.h:252
NOVASVG_INLINE void canvas_clip_rect(canvas_t *canvas, float x, float y, float w, float h)
Intersects the current clipping region with a rectangle according to the current fill rule.
Definition canvas.h:650
unsigned char * surface_get_data(const surface_t *surface)
Gets the pixel data of the surface.
Definition surface.h:7938
NOVASVG_INLINE void path_transform(path_t *path, const matrix_t *matrix)
Applies a transformation matrix to the path.
Definition path.h:361
NOVASVG_INLINE void color_init_hsl(color_t *color, float h, float s, float l)
Initializes a color with the specified HSL color values.
Definition paint.h:52
NOVASVG_INLINE void canvas_round_rect(canvas_t *canvas, float x, float y, float w, float h, float rx, float ry)
Adds a rounded rectangle to the current path.
Definition canvas.h:465
Main namespace for the NovaSVG library.
Definition bitmap.h:23
#define NOVASVG_API
Definition render.h:62
Represents a color with red, green, blue, and alpha components.
Definition render.h:1019
float b
Blue component (0 to 1).
Definition render.h:1022
float g
Green component (0 to 1).
Definition render.h:1021
float a
Alpha (opacity) component (0 to 1).
Definition render.h:1023
float r
Red component (0 to 1).
Definition render.h:1020
Represents a gradient stop.
Definition render.h:1311
color_t color
The color of the gradient stop.
Definition render.h:1313
float offset
The offset of the gradient stop, as a value between 0 and 1.
Definition render.h:1312
A structure representing a 2D transformation matrix.
Definition render.h:138
float d
The vertical scaling factor.
Definition render.h:142
float c
The horizontal shearing factor.
Definition render.h:141
float f
The vertical translation offset.
Definition render.h:144
float e
The horizontal translation offset.
Definition render.h:143
float b
The vertical shearing factor.
Definition render.h:140
float a
The horizontal scaling factor.
Definition render.h:139
Iterator for traversing path elements in a path.
Definition render.h:362
const path_element_t * elements
Pointer to the array of path elements.
Definition render.h:363
int index
Current position in the array.
Definition render.h:365
int size
Total number of elements in the array.
Definition render.h:364
A structure representing a point in 2D space.
Definition render.h:114
float y
The y-coordinate of the point.
Definition render.h:116
float x
The x-coordinate of the point.
Definition render.h:115
A structure representing a rectangle in 2D space.
Definition render.h:125
float x
The x-coordinate of the top-left corner of the rectangle.
Definition render.h:126
float w
The width of the rectangle.
Definition render.h:128
float h
The height of the rectangle.
Definition render.h:129
float y
The y-coordinate of the top-left corner of the rectangle.
Definition render.h:127
Iterator for traversing code points in text data.
Definition render.h:758
text_encoding_t encoding
Encoding format of the text data.
Definition render.h:761
int length
Length of the text data.
Definition render.h:760
const void * text
Pointer to the text data.
Definition render.h:759
int index
Current position in the text data.
Definition render.h:762
std::string text
UTF-8; ' ' marks a forced line break ( ,.
point_t point
A coordinate point in the path.
Definition render.h:356
struct novasvg::render::path_element::@14 header
Header for path commands.
int length
Number of elements including the header.
Definition render.h:354
path_command_t command
The path command.
Definition render.h:353