55e80d069b3f1247de3c7347466a1a17b25048aa
[swftools.git] / lib / python / primitives.c
1 /* primitives.c
2
3    Python wrapper for librfxswf- primitive objects (implementation)
4
5    Part of the swftools package.
6
7    Copyright (c) 2003 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 #include <Python.h>
24 #undef HAVE_STAT
25 #include "../rfxswf.h"
26 #include "../log.h"
27 #include "./pyutils.h"
28 #include "primitives.h"
29
30 //----------------------------------------------------------------------------
31 typedef struct {
32     PyObject_HEAD
33     RGBA rgba;
34 } ColorObject;
35
36 PyObject* f_Color2(U8 r, U8 g, U8 b, U8 a)
37 {
38     ColorObject* color = PyObject_New(ColorObject, &ColorClass);
39     color->rgba.r = r;
40     color->rgba.g = g;
41     color->rgba.b = b;
42     color->rgba.a = a;
43     return (PyObject*)color;
44 }
45 PyObject* f_Color(PyObject* self, PyObject* args, PyObject* kwargs)
46 {
47     static char *kwlist[] = {"r", "g", "b", "a", NULL};
48     ColorObject* color;
49     int r=0,g=0,b=0,a=255;
50     if (!PyArg_ParseTupleAndKeywords(args, kwargs, "iii|i", kwlist, &r,&g,&b,&a)) {
51         char*s= 0;
52         int mya = -1;
53         PyErr_Clear();
54         static char *kwlist[] = {"col", "alpha", NULL};
55         if (!PyArg_ParseTupleAndKeywords(args, kwargs, "s|i", kwlist, &s, &mya))
56             return NULL;
57         if(mya>=0) a=mya;
58         sscanf(s, "%02x%02x%02x%02x",&r,&g,&b,&a);
59     }
60     color = PyObject_New(ColorObject, &ColorClass);
61     mylog("+%08x(%d) color_new(%d,%d,%d,%d)\n", (int)color, color->ob_refcnt, r,g,b,a);
62     return f_Color2(r,g,b,a);
63 }
64 static PyObject* color_getattr(PyObject * self, char* a)
65 {
66     ColorObject*color = (ColorObject*)self;
67     if(!strcmp(a, "r")) {
68         return Py_BuildValue("i", color->rgba.r);
69     } else if(!strcmp(a, "g")) {
70         return Py_BuildValue("i", color->rgba.g);
71     } else if(!strcmp(a, "b")) {
72         return Py_BuildValue("i", color->rgba.b);
73     } else if(!strcmp(a, "a")) {
74         return Py_BuildValue("i", color->rgba.a);
75     } else if(!strcmp(a, "alpha")) {
76         return Py_BuildValue("i", color->rgba.a);
77     } else if(!strcmp(a, "rgb")) {
78         char text[80];
79         sprintf(text, "%02x%02x%02x", color->rgba.r, color->rgba.g, color->rgba.b);
80         return PyString_FromString(text);
81     } else if(!strcmp(a, "rgba")) {
82         char text[80];
83         sprintf(text, "%02x%02x%02x%02x", color->rgba.r, color->rgba.g, color->rgba.b, color->rgba.a);
84         return PyString_FromString(text);
85     }
86     return PY_ERROR("bad attribute");
87 }
88 static int color_setattr(PyObject * self, char* attr, PyObject* o)
89 {
90     ColorObject*color = (ColorObject*)self;
91     if(!strcmp(attr, "r")) {
92         if (!PyArg_Parse(o, "d", &color->rgba.r)) goto err;
93         return 0;
94     } else if(!strcmp(attr, "g")) {
95         if (!PyArg_Parse(o, "d", &color->rgba.g)) goto err;
96         return 0;
97     } else if(!strcmp(attr, "b")) {
98         if (!PyArg_Parse(o, "d", &color->rgba.b)) goto err;
99         return 0;
100     } else if(!strcmp(attr, "a")) {
101         if (!PyArg_Parse(o, "d", &color->rgba.a)) goto err;
102         return 0;
103     } 
104 err:
105     mylog("swf_setattr %08x(%d) %s = ? (%08x)\n", (int)self, self->ob_refcnt, attr, o);
106     return 1;
107 }
108 RGBA color_getRGBA(PyObject*self)
109 {
110     ColorObject*color = 0;
111     if (!PyArg_Parse(self, "O!", &ColorClass, &color)) {
112         RGBA dummy;
113         memset(&dummy, 0, sizeof(dummy));
114         mylog("Error: wrong type for function color_getRGBA");
115         return dummy;
116     }
117     return color->rgba;
118 }
119 void color_dealloc(PyObject* self)
120 {
121     mylog("-%08x(%d) color_dealloc\n", (int)self, self->ob_refcnt);
122     PyObject_Del(self);
123 }
124 PyTypeObject ColorClass = 
125 {
126     PyObject_HEAD_INIT(NULL)
127     0,
128     tp_name: "Color",
129     tp_basicsize: sizeof(ColorObject),
130     tp_itemsize: 0,
131     tp_dealloc: color_dealloc,
132     tp_print: 0,
133     tp_getattr: color_getattr,
134     tp_setattr: color_setattr,
135 };
136 //----------------------------------------------------------------------------
137 typedef struct {
138     PyObject_HEAD
139     SRECT bbox;
140 } BBoxObject;
141 //void swf_ExpandRect(SRECT*src, SPOINT add);
142 //void swf_ExpandRect2(SRECT*src, SRECT*add);
143
144 PyObject* f_BBox(PyObject* self, PyObject* args, PyObject* kwargs)
145 {
146     static char *kwlist[] = {"xmin", "ymin", "xmax", "ymax", NULL};
147     BBoxObject* bbox;
148     float xmin,ymin,xmax,ymax;
149     if(!kwargs) {
150         if (!PyArg_ParseTuple(args, "ffff", &xmin, &ymin, &xmax, &ymax))
151             return NULL;
152     } else {
153         if (!PyArg_ParseTupleAndKeywords(args, kwargs, "ffff", kwlist, &xmin, &ymin, &xmax, &ymax))
154             return NULL;
155     }
156     SRECT box;
157     box.xmin = (int)(xmin*20);
158     box.ymin = (int)(ymin*20);
159     box.xmax = (int)(xmax*20);
160     box.ymax = (int)(ymax*20);
161     mylog("+%08x(%d) bbox_new(%d,%d,%d,%d)\n", (int)self, self?self->ob_refcnt:0, box.xmin, box.ymin, box.xmax,box.ymax);
162     bbox = PyObject_New(BBoxObject, &BBoxClass);
163     bbox->bbox = box;
164     return (PyObject*)bbox;
165 }
166 PyObject* f_BBox2(SRECT box)
167 {
168     BBoxObject* bbox;
169     bbox = PyObject_New(BBoxObject, &BBoxClass);
170     bbox->bbox = box;
171     return (PyObject*)bbox;
172 }
173 static PyObject* bbox_getattr(PyObject * self, char* a)
174 {
175     BBoxObject*bbox = (BBoxObject*)self;
176     if(!strcmp(a, "xmin")) {
177         return Py_BuildValue("f", bbox->bbox.xmin/20.0);
178     } else if(!strcmp(a, "ymin")) {
179         return Py_BuildValue("f", bbox->bbox.ymin/20.0);
180     } else if(!strcmp(a, "xmax")) {
181         return Py_BuildValue("f", bbox->bbox.xmax/20.0);
182     } else if(!strcmp(a, "ymax")) {
183         return Py_BuildValue("f", bbox->bbox.ymax/20.0);
184     }
185     return NULL;
186 }
187 static int bbox_setattr(PyObject * self, char* a, PyObject* o)
188 {
189     BBoxObject*bbox= (BBoxObject*)self;
190     if(!strcmp(a, "xmin")) {
191         float xmin;
192         if (!PyArg_Parse(o, "f", &xmin)) goto err;
193         bbox->bbox.xmin = (int)(xmin*20);
194         return 0;
195     } else if(!strcmp(a, "ymin")) {
196         float ymin;
197         if (!PyArg_Parse(o, "f", &ymin)) goto err;
198         bbox->bbox.ymin = (int)(ymin*20);
199         return 0;
200     } else if(!strcmp(a, "xmax")) {
201         float xmax;
202         if (!PyArg_Parse(o, "f", &xmax)) goto err;
203         bbox->bbox.xmax = (int)(xmax*20);
204         return 0;
205     } else if(!strcmp(a, "ymax")) {
206         float ymax;
207         if (!PyArg_Parse(o, "f", &ymax)) goto err;
208         bbox->bbox.ymax = (int)(ymax*20);
209         return 0;
210     } 
211 err:
212     mylog("swf_setattr %08x(%d) %s = ? (%08x)\n", (int)self, self->ob_refcnt, a, o);
213     return 1;
214 }
215 void bbox_dealloc(PyObject* self)
216 {
217     mylog("-%08x(%d) bbox_dealloc\n", (int)self, self->ob_refcnt);
218     PyObject_Del(self);
219 }
220 SRECT bbox_getSRECT(PyObject*self)
221 {
222     BBoxObject*bbox= 0;
223     if (!PyArg_Parse(self, "O!", &BBoxClass, &bbox)) {
224         SRECT dummy;
225         memset(&dummy, 0, sizeof(dummy));
226         mylog("Error: wrong type for function color_getRGBA");
227         return dummy;
228     }
229     return bbox->bbox;
230 }
231 PyTypeObject BBoxClass = 
232 {
233     PyObject_HEAD_INIT(NULL)
234     0,
235     tp_name: "BBox",
236     tp_basicsize: sizeof(BBoxObject),
237     tp_itemsize: 0,
238     tp_dealloc: bbox_dealloc,
239     tp_print: 0,
240     tp_getattr: bbox_getattr,
241     tp_setattr: bbox_setattr,
242 };
243 SRECT bbox_getBBox(PyObject*self);
244 //----------------------------------------------------------------------------
245 typedef struct {
246     PyObject_HEAD
247     MATRIX matrix;
248 } MatrixObject;
249
250 PyObject* f_Matrix(PyObject* _self, PyObject* args, PyObject* kwargs)
251 {
252     PyObject*self = (PyObject*)PyObject_New(MatrixObject, &MatrixClass);
253     MatrixObject*matrix = (MatrixObject*)self;
254     mylog("+%08x(%d) f_Matrix", self, self->ob_refcnt);
255     static char *kwlist[] = {"x", "y", "scale", "rotate", "pivotx", "pivoty", NULL};
256     float x=0,y=0,scale=1.0,rotate=0,pivotx=0,pivoty=0;
257     if (!PyArg_ParseTupleAndKeywords(args, kwargs, "|ffffff", kwlist, &x,&y,&scale,&rotate,&pivotx,&pivoty))
258         return NULL;
259     mylog(" %08x(%d) f_Matrix: x=%f y=%f scale=%f rotate=%f", self, self->ob_refcnt, x,y,scale,rotate);
260     swf_GetMatrix(0, &matrix->matrix);
261
262     matrix->matrix.tx = (int)(x*20);
263     matrix->matrix.ty = (int)(y*20);
264
265     if(!rotate) {
266         matrix->matrix.sx = (int)(scale*65536);
267         matrix->matrix.sy = (int)(scale*65536);
268     } else {
269         matrix->matrix.sx = (int)(scale*cos(rotate)*65536);
270         matrix->matrix.sy = (int)(scale*cos(rotate)*65536);
271         matrix->matrix.r0 = (int)(scale*sin(rotate)*65536);
272         matrix->matrix.r1 = (int)(-scale*sin(rotate)*65536);
273     }
274     if(pivotx || pivoty) {
275         SPOINT p,d;
276         p.x = (int)(pivotx*20);
277         p.y = (int)(pivoty*20);
278         p = swf_TurnPoint(p, &matrix->matrix);
279         matrix->matrix.tx += matrix->matrix.tx-p.x;
280         matrix->matrix.ty += matrix->matrix.ty-p.y;
281     }
282
283     /* TODO: rotate */
284     return self;
285 }
286 static PyObject* matrix_getattr(PyObject * self, char* a)
287 {
288     PY_ASSERT_TYPE(self,&MatrixClass);
289     return NULL;
290 }
291 static int matrix_setattr(PyObject * self, char* a, PyObject* o)
292 {
293     PY_ASSERT_TYPE(self,&MatrixClass);
294     return 0;
295 }
296 MATRIX matrix_getMatrix(PyObject*self)
297 {
298     mylog(" %08x(%d) matrix_getMatrix", self, self->ob_refcnt);
299     PY_ASSERT_TYPE(self,&MatrixClass);
300     MatrixObject*matrix = (MatrixObject*)self;
301     return matrix->matrix;
302 }
303 void matrix_dealloc(PyObject* self)
304 {
305     mylog("-%08x(%d) matrix_dealloc", self, self->ob_refcnt);
306     PyObject_Del(self);
307 }
308 //SPOINT swf_TurnPoint(SPOINT p, MATRIX* m);
309 //SRECT swf_TurnRect(SRECT r, MATRIX* m);
310 PyTypeObject MatrixClass = 
311 {
312     PyObject_HEAD_INIT(NULL)
313     0,
314     tp_name: "Matrix",
315     tp_basicsize: sizeof(MatrixObject),
316     tp_itemsize: 0,
317     tp_dealloc: matrix_dealloc,
318     tp_print: 0,
319     tp_getattr: matrix_getattr,
320     tp_setattr: matrix_setattr,
321     tp_compare: 0,
322     tp_repr: 0,
323     tp_as_number: 0,
324     tp_as_sequence: 0,
325     tp_as_mapping: 0,
326     tp_hash: 0,     // dict(x)
327     tp_call: 0,     // x()
328     tp_str: 0       // str(x)
329 };
330 //----------------------------------------------------------------------------
331 typedef struct {
332     PyObject_HEAD
333     CXFORM cxform;
334 } CXFormObject;
335
336 PyObject* f_ColorTransform(PyObject* self, PyObject* args, PyObject* kwargs)
337 {
338     return NULL;
339 }
340 static PyObject* colortransform_getattr(PyObject * self, char* a)
341 {
342     return NULL;
343 }
344 static int colortransform_setattr(PyObject * self, char* a, PyObject* o)
345 {
346     return 0;
347 }
348 CXFORM colortransform_getCXForm(PyObject*self)
349 {
350     CXFormObject*cxform= 0;
351     if (!PyArg_Parse(self, "O!", &CXFormClass, &cxform)) {
352         CXFORM dummy;
353         memset(&dummy, 0, sizeof(dummy));
354         mylog("Error: wrong type for function color_getRGBA");
355         return dummy;
356     }
357     return cxform->cxform;
358 }
359 void colortransform_dealloc(PyObject* self)
360 {
361     mylog("-%08x(%d) colortransform_dealloc", self, self->ob_refcnt);
362     PyObject_Del(self);
363 }
364 PyTypeObject CXFormClass = 
365 {
366     PyObject_HEAD_INIT(NULL)
367     0,
368     tp_name: "ColorTransform",
369     tp_basicsize: sizeof(CXFormObject),
370     tp_itemsize: 0,
371     tp_dealloc: colortransform_dealloc,
372     tp_print: 0,
373     tp_getattr: colortransform_getattr,
374     tp_setattr: colortransform_setattr,
375 };
376 //----------------------------------------------------------------------------
377 typedef struct {
378     PyObject_HEAD
379     GRADIENT gradient;
380 } GradientObject;
381
382 PyObject* f_Gradient(PyObject* self, PyObject* args, PyObject* kwargs)
383 {
384     return NULL;
385 }
386 static PyObject* gradient_getattr(PyObject * self, char* a)
387 {
388     return NULL;
389 }
390 static int gradient_setattr(PyObject * self, char* a, PyObject* o)
391 {
392     return 0;
393 }
394 GRADIENT gradient_getGradient(PyObject*self)
395 {
396     GradientObject*gradient = 0;
397     if (!PyArg_Parse(self, "O!", &gradient, &gradient)) {
398         GRADIENT dummy;
399         memset(&dummy, 0, sizeof(dummy));
400         mylog("Error: wrong type for function color_getRGBA");
401         return dummy;
402     }
403     return gradient->gradient;
404 }
405 void gradient_dealloc(PyObject* self)
406 {
407     mylog("-%08x(%d) gradient_dealloc", self, self->ob_refcnt);
408     PyObject_Del(self);
409 }
410 PyTypeObject GradientClass = 
411 {
412     PyObject_HEAD_INIT(NULL)
413     0,
414     tp_name: "Gradient",
415     tp_basicsize: sizeof(GradientObject),
416     tp_itemsize: 0,
417     tp_dealloc: gradient_dealloc,
418     tp_print: 0,
419     tp_getattr: gradient_getattr,
420     tp_setattr: gradient_setattr,
421 };
422 //----------------------------------------------------------------------------
423
424 typedef struct {
425     PyObject_HEAD
426     LINESTYLE ls;
427 } LineStyleObject;
428
429 PyObject* f_LineStyle2(RGBA color, int width) 
430 {
431     LineStyleObject* self = PyObject_New(LineStyleObject, &LineStyleClass);
432     self->ls.color = color;
433     self->ls.width = width;
434     return (PyObject*)self;
435 }
436 PyObject* f_LineStyle3(LINESTYLE ls)
437 {
438     LineStyleObject* self = PyObject_New(LineStyleObject, &LineStyleClass);
439     self->ls = ls;
440     return (PyObject*)self;
441 }
442 PyObject* f_LineStyle(PyObject* _self, PyObject* args, PyObject* kwargs)
443 {
444     static char *kwlist[] = {"line", "color", NULL};
445     float linewidth;
446     PyObject*color;
447     if(!kwargs) {
448         if (!PyArg_ParseTuple(args, "fO!", &linewidth, &ColorClass, &color))
449             return NULL;
450     }
451     return f_LineStyle2(color_getRGBA(color), (int)(linewidth*20));
452 }
453 LINESTYLE linestyle_getLineStyle(PyObject*_self)
454 {
455     LineStyleObject* self = (LineStyleObject*)_self;
456     return self->ls;
457 }
458 static PyObject* linestyle_getattr(PyObject * _self, char* a)
459 {
460     LineStyleObject*self = (LineStyleObject*)_self;
461     if(!strcmp(a, "width")) {
462         return Py_BuildValue("i", self->ls.width);
463     } else if(!strcmp(a, "color")) {
464         return f_Color2(self->ls.color.r, self->ls.color.g, self->ls.color.b, self->ls.color.a);
465     }
466     return NULL;
467 }
468 static int linestyle_setattr(PyObject * _self, char* a, PyObject* o)
469 {
470     LineStyleObject*self = (LineStyleObject*)_self;
471     if(!strcmp(a, "color")) {
472         self->ls.color = color_getRGBA(o);
473         return 0;
474     }
475     return -1;
476 }
477 static LINESTYLE linestyle_getlinestyle(PyObject*_self)
478 {
479     LineStyleObject*self = (LineStyleObject*)_self;
480     return self->ls;
481 }
482 static void linestyle_dealloc(PyObject* self)
483 {
484     mylog("-%08x(%d) linestyle_dealloc", self, self->ob_refcnt);
485     PyObject_Del(self);
486 }
487 static int linestyle_print(PyObject * _self, FILE *fi, int flags) //flags&Py_PRINT_RAW
488 {
489     LineStyleObject* self = (LineStyleObject*)_self;
490     fprintf(fi, "line-%d-%02x%02x%02x%02x", self->ls.width, self->ls.color.r, self->ls.color.g, self->ls.color.b, self->ls.color.a);
491     return 0;
492 }
493 PyTypeObject LineStyleClass = 
494 {
495     PyObject_HEAD_INIT(NULL)
496     0,
497     tp_name: "linestyle",
498     tp_basicsize: sizeof(LineStyleObject),
499     tp_itemsize: 0,
500     tp_dealloc: linestyle_dealloc,
501     tp_print: linestyle_print,
502     tp_getattr: linestyle_getattr,
503     tp_setattr: linestyle_setattr,
504 };
505 //----------------------------------------------------------------------------
506
507 typedef struct {
508     PyObject_HEAD
509     FILLSTYLE fs;
510 } FillStyleObject;
511
512 PyObject* f_FillStyle2(FILLSTYLE fs)
513 {
514     FillStyleObject* self = PyObject_New(FillStyleObject, &FillStyleClass);
515     self->fs = fs;
516     return (PyObject*)self;
517 }
518 PyObject* f_SolidFillStyle2(RGBA color)
519 {
520     FillStyleObject* self = PyObject_New(FillStyleObject, &FillStyleClass);
521     self->fs.type = FILL_SOLID;
522     self->fs.color = color;
523     return (PyObject*)self;
524 }
525 PyObject* f_SolidFillStyle(PyObject* _self, PyObject* args, PyObject* kwargs)
526 {
527     static char *kwlist[] = {"color", NULL};
528     PyObject*color;
529     if(!kwargs) {
530         if (!PyArg_ParseTuple(args, "O!", &ColorClass, &color))
531             return NULL;
532     }
533     return f_SolidFillStyle2(color_getRGBA(color));
534 }
535 FILLSTYLE fillstyle_getFillStyle(PyObject*_self)
536 {
537     FillStyleObject* self = (FillStyleObject*)_self;
538     return self->fs;
539 }
540 static void fillstyle_dealloc(PyObject* self)
541 {
542     mylog("-%08x(%d) linestyle_dealloc", self, self->ob_refcnt);
543     PyObject_Del(self);
544 }
545 static int fillstyle_print(PyObject * _self, FILE *fi, int flags) //flags&Py_PRINT_RAW
546 {
547     FillStyleObject* self = (FillStyleObject*)_self;
548     if(self->fs.type == FILL_SOLID)
549         fprintf(fi, "fill-solid(%02x%02x%02x%02x)", self->fs.color.r, self->fs.color.g, self->fs.color.b, self->fs.color.a);
550     else
551         fprintf(fi, "fill-%02x", self->fs.type);
552     return 0;
553 }
554 PyObject* fillstyle_issolid(PyObject*_self, PyObject*args)
555 {
556     FillStyleObject* self = (FillStyleObject*)_self;
557     int b = self->fs.type == FILL_SOLID;
558     return PyInt_FromLong(b);
559 }
560 static PyMethodDef FillStyleMethods[] = 
561 {
562     /* Module functions */
563     {"isSolid", fillstyle_issolid, METH_VARARGS, "Queries whether this is a solid fill"},
564     {0,0,0,0}
565 };
566 static PyObject* fillstyle_getattr(PyObject * _self, char* a)
567 {
568     FillStyleObject* self = (FillStyleObject*)_self;
569     if(!strcmp(a, "color")) {
570         return f_Color2(self->fs.color.r, self->fs.color.g, self->fs.color.b, self->fs.color.a);
571     }
572     return Py_FindMethod(FillStyleMethods, _self, a);
573 }
574 static int fillstyle_setattr(PyObject * _self, char* a, PyObject* o)
575 {
576     FillStyleObject*self = (FillStyleObject*)_self;
577     if(!strcmp(a, "color")) {
578         self->fs.color = color_getRGBA(o);
579         return 0;
580     }
581     return -1;
582 }
583
584 PyTypeObject FillStyleClass = 
585 {
586     PyObject_HEAD_INIT(NULL)
587     0,
588     tp_name: "fillstyle",
589     tp_basicsize: sizeof(FillStyleObject),
590     tp_itemsize: 0,
591     tp_dealloc: fillstyle_dealloc,
592     tp_print: fillstyle_print,
593     tp_getattr: fillstyle_getattr,
594     tp_setattr: fillstyle_setattr,
595 };
596 //----------------------------------------------------------------------------
597 static PyMethodDef primitive_methods[] = 
598 {
599     {"Color", (PyCFunction)f_Color, METH_KEYWORDS, "Create a new color object."},
600     {"Gradient", (PyCFunction)f_Gradient, METH_KEYWORDS, "Create a new gradient object."},
601     {"ColorTransform", (PyCFunction)f_ColorTransform, METH_KEYWORDS, "Create a new colortransform object."},
602     {"Matrix", (PyCFunction)f_Matrix, METH_KEYWORDS, "Create a new matrix object."},
603     {"BBox", (PyCFunction)f_BBox, METH_KEYWORDS, "Create a new bounding box object."},
604     {"SolidFillStyle", (PyCFunction)f_SolidFillStyle, METH_KEYWORDS, "Creates a new solid fill style."},
605     {"LineStyle", (PyCFunction)f_SolidFillStyle, METH_KEYWORDS, "Creates a new line style."},
606     {NULL, NULL, 0, NULL}
607 };
608
609 PyMethodDef* primitive_getMethods()
610 {
611     GradientClass.ob_type = &PyType_Type;
612     CXFormClass.ob_type = &PyType_Type;
613     BBoxClass.ob_type = &PyType_Type;
614     MatrixClass.ob_type = &PyType_Type;
615     return primitive_methods;
616 }
617
618