]> gitweb.michael.orlitzky.com - libsvgtiny.git/blob - svgtiny.h
a5017d1ff6a1d09882eea954bb6d8429600a4b5b
[libsvgtiny.git] / svgtiny.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_H
9 #define SVGTINY_H
10
11 #include <libxml/parser.h>
12
13 typedef int svgtiny_colour;
14 #define svgtiny_TRANSPARENT 0x1000000
15 #define svgtiny_RGB(r, g, b) ((r) << 16 | (g) << 8 | (b))
16
17 struct svgtiny_shape {
18 float *path;
19 unsigned int path_length;
20 char *text;
21 float text_x, text_y;
22 svgtiny_colour fill;
23 svgtiny_colour stroke;
24 int stroke_width;
25 };
26
27 struct svgtiny_diagram {
28 xmlDoc *doc;
29 xmlNode *svg;
30
31 int width, height;
32
33 struct svgtiny_shape *shape;
34 unsigned int shape_count;
35 };
36
37 typedef enum {
38 svgtiny_OK,
39 svgtiny_OUT_OF_MEMORY,
40 svgtiny_LIBXML_ERROR,
41 svgtiny_NOT_SVG,
42 } svgtiny_code;
43
44 enum {
45 svgtiny_PATH_MOVE,
46 svgtiny_PATH_CLOSE,
47 svgtiny_PATH_LINE,
48 svgtiny_PATH_BEZIER,
49 };
50
51 struct svgtiny_named_color {
52 const char *name;
53 svgtiny_colour color;
54 };
55
56
57 struct svgtiny_diagram *svgtiny_create(void);
58 svgtiny_code svgtiny_parse(struct svgtiny_diagram *diagram,
59 const char *buffer, size_t size, const char *url,
60 int width, int height);
61 void svgtiny_free(struct svgtiny_diagram *svg);
62
63 const struct svgtiny_named_color *
64 svgtiny_color_lookup (register const char *str, register unsigned int len);
65
66 #endif