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