]> gitweb.michael.orlitzky.com - libsvgtiny.git/blob - svgtiny.h
Implement svgtiny_free() and fix memory usage.
[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 int width, height;
29
30 struct svgtiny_shape *shape;
31 unsigned int shape_count;
32 };
33
34 typedef enum {
35 svgtiny_OK,
36 svgtiny_OUT_OF_MEMORY,
37 svgtiny_LIBXML_ERROR,
38 svgtiny_NOT_SVG,
39 } svgtiny_code;
40
41 enum {
42 svgtiny_PATH_MOVE,
43 svgtiny_PATH_CLOSE,
44 svgtiny_PATH_LINE,
45 svgtiny_PATH_BEZIER,
46 };
47
48 struct svgtiny_named_color {
49 const char *name;
50 svgtiny_colour color;
51 };
52
53
54 struct svgtiny_diagram *svgtiny_create(void);
55 svgtiny_code svgtiny_parse(struct svgtiny_diagram *diagram,
56 const char *buffer, size_t size, const char *url,
57 int width, int height);
58 void svgtiny_free(struct svgtiny_diagram *svg);
59
60 const struct svgtiny_named_color *
61 svgtiny_color_lookup (register const char *str, register unsigned int len);
62
63 #endif