]> gitweb.michael.orlitzky.com - libsvgtiny.git/blob - include/svgtiny.h
Beginnings of port to core buildsystem
[libsvgtiny.git] / include / 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 #ifdef riscos
16 #define svgtiny_RGB(r, g, b) ((b) << 16 | (g) << 8 | (r))
17 #define svgtiny_RED(c) ((c) & 0xff)
18 #define svgtiny_GREEN(c) (((c) >> 8) & 0xff)
19 #define svgtiny_BLUE(c) (((c) >> 16) & 0xff)
20 #else
21 #define svgtiny_RGB(r, g, b) ((r) << 16 | (g) << 8 | (b))
22 #define svgtiny_RED(c) (((c) >> 16) & 0xff)
23 #define svgtiny_GREEN(c) (((c) >> 8) & 0xff)
24 #define svgtiny_BLUE(c) ((c) & 0xff)
25 #endif
26
27 struct svgtiny_shape {
28 float *path;
29 unsigned int path_length;
30 char *text;
31 float text_x, text_y;
32 svgtiny_colour fill;
33 svgtiny_colour stroke;
34 int stroke_width;
35 };
36
37 struct svgtiny_diagram {
38 int width, height;
39
40 struct svgtiny_shape *shape;
41 unsigned int shape_count;
42
43 unsigned short error_line;
44 const char *error_message;
45 };
46
47 typedef enum {
48 svgtiny_OK,
49 svgtiny_OUT_OF_MEMORY,
50 svgtiny_LIBXML_ERROR,
51 svgtiny_NOT_SVG,
52 svgtiny_SVG_ERROR,
53 } svgtiny_code;
54
55 enum {
56 svgtiny_PATH_MOVE,
57 svgtiny_PATH_CLOSE,
58 svgtiny_PATH_LINE,
59 svgtiny_PATH_BEZIER,
60 };
61
62 struct svgtiny_named_color {
63 const char *name;
64 svgtiny_colour color;
65 };
66
67
68 struct svgtiny_diagram *svgtiny_create(void);
69 svgtiny_code svgtiny_parse(struct svgtiny_diagram *diagram,
70 const char *buffer, size_t size, const char *url,
71 int width, int height);
72 void svgtiny_free(struct svgtiny_diagram *svg);
73
74 #endif