2 * Hic Est Leo -- SVG Output
4 * (c) 2014 Martin Mares <mj@ucw.cz>
10 // FIXME: Passing SVG pointers everywhere is ugly, using global context less so.
14 struct svg_element **stack;
16 struct fbpool *fb_pool;
17 struct fastbuf *str_fb; // fb_pool cast to the right type
18 double scale; // 1mm is converted to this many px
20 struct icon_table *icon_hash;
25 byte type; // XML_NODE_xxx
26 byte flags; // SVG_EF_xxx
28 int indent; // -1 = inline
35 const char *key, *val;
38 enum svg_element_flags {
40 SVG_EF_START_TAG = 2, // Internal: start tag has been already printed
41 SVG_EF_HAS_CHILDREN = 4,
44 struct svg *svg_open(char *filename);
45 void svg_close(struct svg *svg);
47 struct svg_element *svg_push_element(struct svg *svg, const char *name);
48 struct svg_element *svg_push_chars(struct svg *svg);
49 struct svg_element *svg_push_comment(struct svg *svg);
50 void svg_pop(struct svg *svg);
52 void svg_set_attr(struct svg *svg, const char *key, const char *val);
53 void svg_set_attr_ref(struct svg *svg, const char *key, const char *val);
54 void svg_set_attr_int(struct svg *svg, const char *key, int val);
55 void svg_set_attr_float(struct svg *svg, const char *key, double val);
56 void svg_set_attr_dimen(struct svg *svg, const char *key, double val);
57 void svg_set_attr_color(struct svg *svg, const char *key, color_t color);
58 void svg_set_attr_format(struct svg *svg, const char *key, const char *fmt, ...) FORMAT_CHECK(printf,3,4);
60 struct fastbuf *svg_fb_open(struct svg *svg);
61 const char *svg_fb_close(struct svg *svg);
62 void svg_fb_close_as_attr(struct svg *svg, const char *key);
64 struct svg_element *svg_push_path(struct svg *svg);
65 void svg_path_end(struct svg *svg);
66 void svg_path_move_to(struct svg *svg, double x, double y);
67 void svg_path_move_to_rel(struct svg *svg, double x, double y);
68 void svg_path_line_to(struct svg *svg, double x, double y);
69 void svg_path_line_to_rel(struct svg *svg, double x, double y);
70 void svg_path_close(struct svg *svg);
72 char *svg_format_dimen(struct svg *svg, double val);
79 struct xml_context *ctx;
80 struct xml_node *root;
85 struct svg_icon *svg_icon_load(struct svg *svg, const char *name);
86 void svg_icon_dump_library(struct svg *svg);
88 void svg_icon_init(struct svg *svg); // Called from svg_open()
89 void svg_icon_cleanup(struct svg *svg); // Called from svg_close()
91 struct svg_icon_request {
92 struct svg_icon *icon;
97 void svg_icon_put(struct svg *svg, struct svg_icon_request *sir);
99 struct svg_pattern_request {
100 struct svg_icon *icon;
101 double width, height;
107 struct svg_icon *icon;
108 double width, height;
112 struct svg_pattern *svg_icon_to_pattern(struct svg *svg, struct svg_pattern_request *spr);