]> gitweb.michael.orlitzky.com - libsvgtiny.git/blob - src/svgtiny_internal.h
Make more svg elements parse again
[libsvgtiny.git] / src / svgtiny_internal.h
1 /*
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>
6 */
7
8 #ifndef SVGTINY_INTERNAL_H
9 #define SVGTINY_INTERNAL_H
10
11 #include <stdbool.h>
12
13 #include <dom/dom.h>
14
15 #ifndef UNUSED
16 #define UNUSED(x) ((void) (x))
17 #endif
18
19 struct svgtiny_gradient_stop {
20 float offset;
21 svgtiny_colour color;
22 };
23
24 #define svgtiny_MAX_STOPS 10
25 #define svgtiny_LINEAR_GRADIENT 0x2000000
26
27 struct svgtiny_parse_state {
28 struct svgtiny_diagram *diagram;
29 dom_document *document;
30
31 float viewport_width;
32 float viewport_height;
33
34 /* current transformation matrix */
35 struct {
36 float a, b, c, d, e, f;
37 } ctm;
38
39 /*struct css_style style;*/
40
41 /* paint attributes */
42 svgtiny_colour fill;
43 svgtiny_colour stroke;
44 int stroke_width;
45
46 /* gradients */
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;
51 struct {
52 float a, b, c, d, e, f;
53 } gradient_transform;
54
55 /* Interned strings */
56 #define SVGTINY_STRING_ACTION(n) dom_string *interned_##n;
57 #include "svgtiny_strings.h"
58 #undef SVGTINY_STRING_ACTION
59
60 };
61
62 struct svgtiny_list;
63
64 /* svgtiny.c */
65 float svgtiny_parse_length(dom_string *s, int viewport_size,
66 const struct svgtiny_parse_state state);
67 void svgtiny_parse_color(const char *s, svgtiny_colour *c,
68 struct svgtiny_parse_state *state);
69 void svgtiny_parse_transform(char *s, float *ma, float *mb,
70 float *mc, float *md, float *me, float *mf);
71 struct svgtiny_shape *svgtiny_add_shape(struct svgtiny_parse_state *state);
72 void svgtiny_transform_path(float *p, unsigned int n,
73 struct svgtiny_parse_state *state);
74 #if defined(_GNU_SOURCE)
75 #define HAVE_STRNDUP
76 #else
77 #undef HAVE_STRNDUP
78 char *svgtiny_strndup(const char *s, size_t n);
79 #define strndup svgtiny_strndup
80 #endif
81
82 /* svgtiny_gradient.c */
83 void svgtiny_find_gradient(const char *id, struct svgtiny_parse_state *state);
84 svgtiny_code svgtiny_add_path_linear_gradient(float *p, unsigned int n,
85 struct svgtiny_parse_state *state);
86 dom_node *svgtiny_find_element_by_id(dom_node *node, const char *id);
87
88 /* svgtiny_list.c */
89 struct svgtiny_list *svgtiny_list_create(size_t item_size);
90 unsigned int svgtiny_list_size(struct svgtiny_list *list);
91 svgtiny_code svgtiny_list_resize(struct svgtiny_list *list,
92 unsigned int new_size);
93 void *svgtiny_list_get(struct svgtiny_list *list,
94 unsigned int i);
95 void *svgtiny_list_push(struct svgtiny_list *list);
96 void svgtiny_list_free(struct svgtiny_list *list);
97
98 /* colors.gperf */
99 const struct svgtiny_named_color *
100 svgtiny_color_lookup(register const char *str,
101 register unsigned int len);
102
103 #endif