new parameter -s textonly
[swftools.git] / lib / gfxtools.h
1 /* gfxtools.h 
2
3    Various utility functions for dealing with gfxdevices (header file).
4
5    Part of the swftools package.
6
7    Copyright (c) 2005 Matthias Kramm <kramm@quiss.org> 
8
9    This program is free software; you can redistribute it and/or modify
10    it under the terms of the GNU General Public License as published by
11    the Free Software Foundation; either version 2 of the License, or
12    (at your option) any later version.
13
14    This program is distributed in the hope that it will be useful,
15    but WITHOUT ANY WARRANTY; without even the implied warranty of
16    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
17    GNU General Public License for more details.
18
19    You should have received a copy of the GNU General Public License
20    along with this program; if not, write to the Free Software
21    Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA */
22
23 #ifndef __gfxtools_h__
24 #define __gfxtools_h__
25
26 #ifdef __cplusplus
27 extern "C" {
28 #endif
29
30 #include <stdio.h>
31 #include "../lib/mem.h"
32 #include "../lib/gfxdevice.h"
33
34 typedef struct _gfxdrawer
35 {
36     void*internal;
37     gfxcoord_t x,y;
38     void (*moveTo)(struct _gfxdrawer*d, gfxcoord_t x, gfxcoord_t y);
39     void (*lineTo)(struct _gfxdrawer*d, gfxcoord_t x, gfxcoord_t y);
40     void (*splineTo)(struct _gfxdrawer*d, gfxcoord_t sx, gfxcoord_t sy, gfxcoord_t x, gfxcoord_t y);
41     void (*close)(struct _gfxdrawer*d);
42     void* (*result)(struct _gfxdrawer*d);
43 } gfxdrawer_t;
44
45 typedef struct _gfxpoint
46 {
47     gfxcoord_t x,y;
48 } gfxpoint_t;
49
50 typedef struct _gfxfontlist
51 {
52     gfxfont_t*font;
53     void*user;
54     struct _gfxfontlist*next;
55 } gfxfontlist_t;
56
57 void gfxdrawer_target_gfxline(gfxdrawer_t*d);
58
59 void gfxtool_draw_dashed_line(gfxdrawer_t*d, gfxline_t*line, float*dashes, float phase);
60 gfxline_t* gfxtool_dash_line(gfxline_t*line, float*dashes, float phase);
61
62 void gfxline_dump(gfxline_t*l, FILE*fi, char*prefix);
63 gfxline_t* gfxline_append(gfxline_t*line1, gfxline_t*line2);
64 void gfxline_free(gfxline_t*l);
65 gfxline_t* gfxline_clone(gfxline_t*line);
66 void gfxline_optimize(gfxline_t*line);
67
68 void gfxdraw_cubicTo(gfxdrawer_t*draw, double c1x, double c1y, double c2x, double c2y, double x, double y, double quality);
69 void gfxdraw_conicTo(gfxdrawer_t*draw, double cx, double cy, double tox, double toy, double quality);
70
71 gfxbbox_t gfxline_getbbox(gfxline_t*line);
72 gfxbbox_t gfxbbox_expand_to_point(gfxbbox_t box, gfxcoord_t x, gfxcoord_t y);
73 void gfxbbox_intersect(gfxbbox_t*box1, gfxbbox_t*box2);
74
75 void gfxline_transform(gfxline_t*line, gfxmatrix_t*matrix);
76
77 /* tries to remove unnecessary moveTos from the gfxline */
78 gfxline_t* gfxline_restitch(gfxline_t*line);
79 /* reverses in place */
80 gfxline_t* gfxline_reverse(gfxline_t*line);
81
82 void gfxmatrix_dump(gfxmatrix_t*l, FILE*fi, char*prefix);
83 void gfxmatrix_transform(gfxmatrix_t*m, gfxcoord_t* v1, gfxcoord_t*dest);
84 void gfxmatrix_invert(gfxmatrix_t*src, gfxmatrix_t*dest);
85 void gfxmatrix_unit(gfxmatrix_t*m);
86 void gfxmatrix_multiply(gfxmatrix_t*m1, gfxmatrix_t*m2, gfxmatrix_t*dest);
87
88 gfxfontlist_t* gfxfontlist_create();
89 gfxfontlist_t*gfxfontlist_addfont(gfxfontlist_t*list, gfxfont_t*font);
90 gfxfontlist_t*gfxfontlist_addfont2(gfxfontlist_t*list, gfxfont_t*font, void*user);
91 gfxfont_t*gfxfontlist_findfont(gfxfontlist_t*list, char*id);
92 char gfxfontlist_hasfont(gfxfontlist_t*list, gfxfont_t*font);
93 void* gfxfontlist_getuserdata(gfxfontlist_t*list, const char*id);
94 void gfxfontlist_free(gfxfontlist_t*list, char deletefonts);
95
96 gfxbbox_t* gfxline_isrectangle(gfxline_t*_l);
97 gfxbbox_t gfxbbox_expand_to_bbox(gfxbbox_t box, gfxbbox_t box2);
98
99 gfxline_t*gfxline_makerectangle(double x1, double y1, double x2, double y2);
100 gfxline_t*gfxline_makecircle(double x,double y,double rx, double ry);
101 void gfxline_show(gfxline_t*line, FILE*fi);
102
103 void gfxgradient_destroy(gfxgradient_t*gradient);
104
105 typedef struct _gfxparam {
106     const char*key;
107     const char*value;
108     struct _gfxparam* next;
109 } gfxparam_t;
110 typedef struct _gfxparams {
111     gfxparam_t*params;
112     gfxparam_t*last;
113 } gfxparams_t;
114 gfxparams_t* gfxparams_new();
115 void gfxparams_store(gfxparams_t*params, const char*name, const char*value);
116 void gfxparams_free(gfxparams_t*params);
117
118 #ifdef __cplusplus
119 }
120 #endif
121
122 #endif //__gfxtools_h__