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
{
28 struct svgtiny_diagram
*diagram
;
29 dom_document
*document
;
32 float viewport_height
;
34 /* current transformation matrix */
36 float a
, b
, c
, d
, e
, f
;
39 /*struct css_style style;*/
41 /* paint attributes */
43 svgtiny_colour stroke
;
47 unsigned int linear_gradient_stop_count
;
48 const char *gradient_x1
, *gradient_y1
, *gradient_x2
, *gradient_y2
;
49 struct svgtiny_gradient_stop gradient_stop
[svgtiny_MAX_STOPS
];
50 bool gradient_user_space_on_use
;
52 float a
, b
, c
, d
, e
, f
;
59 float svgtiny_parse_length(const char *s
, int viewport_size
,
60 const struct svgtiny_parse_state state
);
61 void svgtiny_parse_color(const char *s
, svgtiny_colour
*c
,
62 struct svgtiny_parse_state
*state
);
63 void svgtiny_parse_transform(char *s
, float *ma
, float *mb
,
64 float *mc
, float *md
, float *me
, float *mf
);
65 struct svgtiny_shape
*svgtiny_add_shape(struct svgtiny_parse_state
*state
);
66 void svgtiny_transform_path(float *p
, unsigned int n
,
67 struct svgtiny_parse_state
*state
);
68 #if defined(_GNU_SOURCE)
72 char *svgtiny_strndup(const char *s
, size_t n
);
73 #define strndup svgtiny_strndup
76 /* svgtiny_gradient.c */
77 void svgtiny_find_gradient(const char *id
, struct svgtiny_parse_state
*state
);
78 svgtiny_code
svgtiny_add_path_linear_gradient(float *p
, unsigned int n
,
79 struct svgtiny_parse_state
*state
);
80 dom_node
*svgtiny_find_element_by_id(dom_node
*node
, const char *id
);
83 struct svgtiny_list
*svgtiny_list_create(size_t item_size
);
84 unsigned int svgtiny_list_size(struct svgtiny_list
*list
);
85 svgtiny_code
svgtiny_list_resize(struct svgtiny_list
*list
,
86 unsigned int new_size
);
87 void *svgtiny_list_get(struct svgtiny_list
*list
,
89 void *svgtiny_list_push(struct svgtiny_list
*list
);
90 void svgtiny_list_free(struct svgtiny_list
*list
);
93 const struct svgtiny_named_color
*
94 svgtiny_color_lookup(register const char *str
,
95 register unsigned int len
);