2 * This file is part of Libsvgtiny
3 * Licensed under the MIT License,
4 * http://opensource.org/licenses/mit-license.php
5 * Copyright 2008 James Bursa <james@semichrome.net>
8 #ifndef SVGTINY_INTERNAL_H
9 #define SVGTINY_INTERNAL_H
16 #define UNUSED(x) ((void) (x))
19 struct svgtiny_gradient_stop
{
24 #define svgtiny_MAX_STOPS 10
25 #define svgtiny_LINEAR_GRADIENT 0x2000000
27 struct svgtiny_parse_state_gradient
{
28 unsigned int linear_gradient_stop_count
;
29 dom_string
*gradient_x1
, *gradient_y1
, *gradient_x2
, *gradient_y2
;
30 struct svgtiny_gradient_stop gradient_stop
[svgtiny_MAX_STOPS
];
31 bool gradient_user_space_on_use
;
33 float a
, b
, c
, d
, e
, f
;
37 struct svgtiny_parse_state
{
38 struct svgtiny_diagram
*diagram
;
39 dom_document
*document
;
42 float viewport_height
;
44 /* current transformation matrix */
46 float a
, b
, c
, d
, e
, f
;
49 /*struct css_style style;*/
51 /* paint attributes */
53 svgtiny_colour stroke
;
57 struct svgtiny_parse_state_gradient fill_grad
;
58 struct svgtiny_parse_state_gradient stroke_grad
;
60 /* Interned strings */
61 #define SVGTINY_STRING_ACTION2(n,nn) dom_string *interned_##n;
62 #include "svgtiny_strings.h"
63 #undef SVGTINY_STRING_ACTION2
70 float svgtiny_parse_length(dom_string
*s
, int viewport_size
,
71 const struct svgtiny_parse_state state
);
72 void svgtiny_parse_color(dom_string
*s
, svgtiny_colour
*c
,
73 struct svgtiny_parse_state_gradient
*grad
,
74 struct svgtiny_parse_state
*state
);
75 void svgtiny_parse_transform(char *s
, float *ma
, float *mb
,
76 float *mc
, float *md
, float *me
, float *mf
);
77 struct svgtiny_shape
*svgtiny_add_shape(struct svgtiny_parse_state
*state
);
78 void svgtiny_transform_path(float *p
, unsigned int n
,
79 struct svgtiny_parse_state
*state
);
80 #if (defined(_GNU_SOURCE) && !defined(__APPLE__) || defined(__amigaos4__) || defined(__HAIKU__) || (defined(_POSIX_C_SOURCE) && ((_POSIX_C_SOURCE - 0) >= 200809L)))
84 char *svgtiny_strndup(const char *s
, size_t n
);
85 #define strndup svgtiny_strndup
88 /* svgtiny_gradient.c */
89 void svgtiny_find_gradient(const char *id
,
90 struct svgtiny_parse_state_gradient
*grad
,
91 struct svgtiny_parse_state
*state
);
92 svgtiny_code
svgtiny_add_path_linear_gradient(float *p
, unsigned int n
,
93 struct svgtiny_parse_state
*state
);
96 struct svgtiny_list
*svgtiny_list_create(size_t item_size
);
97 unsigned int svgtiny_list_size(struct svgtiny_list
*list
);
98 svgtiny_code
svgtiny_list_resize(struct svgtiny_list
*list
,
99 unsigned int new_size
);
100 void *svgtiny_list_get(struct svgtiny_list
*list
,
102 void *svgtiny_list_push(struct svgtiny_list
*list
);
103 void svgtiny_list_free(struct svgtiny_list
*list
);