added f_Matrix2()
[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_Matrix2(MATRIX* m)
251 {
252     PyObject*self = (PyObject*)PyObject_New(MatrixObject, &MatrixClass);
253     MatrixObject*matrix = (MatrixObject*)self;
254     matrix->matrix = *m;
255     return self;
256 }
257
258 PyObject* f_Matrix(PyObject* _self, PyObject* args, PyObject* kwargs)
259 {
260     PyObject*self = (PyObject*)PyObject_New(MatrixObject, &MatrixClass);
261     MatrixObject*matrix = (MatrixObject*)self;
262     mylog("+%08x(%d) f_Matrix", self, self->ob_refcnt);
263     static char *kwlist[] = {"x", "y", "scale", "rotate", "pivotx", "pivoty", NULL};
264     float x=0,y=0,scale=1.0,rotate=0,pivotx=0,pivoty=0;
265     if (!PyArg_ParseTupleAndKeywords(args, kwargs, "|ffffff", kwlist, &x,&y,&scale,&rotate,&pivotx,&pivoty))
266         return NULL;
267     mylog(" %08x(%d) f_Matrix: x=%f y=%f scale=%f rotate=%f", self, self->ob_refcnt, x,y,scale,rotate);
268     swf_GetMatrix(0, &matrix->matrix);
269
270     matrix->matrix.tx = (int)(x*20);
271     matrix->matrix.ty = (int)(y*20);
272
273     if(!rotate) {
274         matrix->matrix.sx = (int)(scale*65536);
275         matrix->matrix.sy = (int)(scale*65536);
276     } else {
277         matrix->matrix.sx = (int)(scale*cos(rotate)*65536);
278         matrix->matrix.sy = (int)(scale*cos(rotate)*65536);
279         matrix->matrix.r0 = (int)(scale*sin(rotate)*65536);
280         matrix->matrix.r1 = (int)(-scale*sin(rotate)*65536);
281     }
282     if(pivotx || pivoty) {
283         SPOINT p,d;
284         p.x = (int)(pivotx*20);
285         p.y = (int)(pivoty*20);
286         p = swf_TurnPoint(p, &matrix->matrix);
287         matrix->matrix.tx += matrix->matrix.tx-p.x;
288         matrix->matrix.ty += matrix->matrix.ty-p.y;
289     }
290
291     /* TODO: rotate */
292     return self;
293 }
294 static PyObject* matrix_getattr(PyObject * self, char* a)
295 {
296     PY_ASSERT_TYPE(self,&MatrixClass);
297     return NULL;
298 }
299 static int matrix_setattr(PyObject * self, char* a, PyObject* o)
300 {
301     PY_ASSERT_TYPE(self,&MatrixClass);
302     return 0;
303 }
304 MATRIX matrix_getMatrix(PyObject*self)
305 {
306     mylog(" %08x(%d) matrix_getMatrix", self, self->ob_refcnt);
307     PY_ASSERT_TYPE(self,&MatrixClass);
308     MatrixObject*matrix = (MatrixObject*)self;
309     return matrix->matrix;
310 }
311 void matrix_dealloc(PyObject* self)
312 {
313     mylog("-%08x(%d) matrix_dealloc", self, self->ob_refcnt);
314     PyObject_Del(self);
315 }
316 //SPOINT swf_TurnPoint(SPOINT p, MATRIX* m);
317 //SRECT swf_TurnRect(SRECT r, MATRIX* m);
318 PyTypeObject MatrixClass = 
319 {
320     PyObject_HEAD_INIT(NULL)
321     0,
322     tp_name: "Matrix",
323     tp_basicsize: sizeof(MatrixObject),
324     tp_itemsize: 0,
325     tp_dealloc: matrix_dealloc,
326     tp_print: 0,
327     tp_getattr: matrix_getattr,
328     tp_setattr: matrix_setattr,
329     tp_compare: 0,
330     tp_repr: 0,
331     tp_as_number: 0,
332     tp_as_sequence: 0,
333     tp_as_mapping: 0,
334     tp_hash: 0,     // dict(x)
335     tp_call: 0,     // x()
336     tp_str: 0       // str(x)
337 };
338 //----------------------------------------------------------------------------
339 typedef struct {
340     PyObject_HEAD
341     CXFORM cxform;
342 } CXFormObject;
343
344 PyObject* f_ColorTransform(PyObject* self, PyObject* args, PyObject* kwargs)
345 {
346     return NULL;
347 }
348 static PyObject* colortransform_getattr(PyObject * self, char* a)
349 {
350     return NULL;
351 }
352 static int colortransform_setattr(PyObject * self, char* a, PyObject* o)
353 {
354     return 0;
355 }
356 CXFORM colortransform_getCXForm(PyObject*self)
357 {
358     CXFormObject*cxform= 0;
359     if (!PyArg_Parse(self, "O!", &CXFormClass, &cxform)) {
360         CXFORM dummy;
361         memset(&dummy, 0, sizeof(dummy));
362         mylog("Error: wrong type for function color_getRGBA");
363         return dummy;
364     }
365     return cxform->cxform;
366 }
367 void colortransform_dealloc(PyObject* self)
368 {
369     mylog("-%08x(%d) colortransform_dealloc", self, self->ob_refcnt);
370     PyObject_Del(self);
371 }
372 PyTypeObject CXFormClass = 
373 {
374     PyObject_HEAD_INIT(NULL)
375     0,
376     tp_name: "ColorTransform",
377     tp_basicsize: sizeof(CXFormObject),
378     tp_itemsize: 0,
379     tp_dealloc: colortransform_dealloc,
380     tp_print: 0,
381     tp_getattr: colortransform_getattr,
382     tp_setattr: colortransform_setattr,
383 };
384 //----------------------------------------------------------------------------
385 typedef struct {
386     PyObject_HEAD
387     GRADIENT gradient;
388 } GradientObject;
389
390 PyObject* f_Gradient(PyObject* self, PyObject* args, PyObject* kwargs)
391 {
392     return NULL;
393 }
394 static PyObject* gradient_getattr(PyObject * self, char* a)
395 {
396     return NULL;
397 }
398 static int gradient_setattr(PyObject * self, char* a, PyObject* o)
399 {
400     return 0;
401 }
402 GRADIENT gradient_getGradient(PyObject*self)
403 {
404     GradientObject*gradient = 0;
405     if (!PyArg_Parse(self, "O!", &gradient, &gradient)) {
406         GRADIENT dummy;
407         memset(&dummy, 0, sizeof(dummy));
408         mylog("Error: wrong type for function color_getRGBA");
409         return dummy;
410     }
411     return gradient->gradient;
412 }
413 void gradient_dealloc(PyObject* self)
414 {
415     mylog("-%08x(%d) gradient_dealloc", self, self->ob_refcnt);
416     PyObject_Del(self);
417 }
418 PyTypeObject GradientClass = 
419 {
420     PyObject_HEAD_INIT(NULL)
421     0,
422     tp_name: "Gradient",
423     tp_basicsize: sizeof(GradientObject),
424     tp_itemsize: 0,
425     tp_dealloc: gradient_dealloc,
426     tp_print: 0,
427     tp_getattr: gradient_getattr,
428     tp_setattr: gradient_setattr,
429 };
430 //----------------------------------------------------------------------------
431
432 typedef struct {
433     PyObject_HEAD
434     LINESTYLE ls;
435 } LineStyleObject;
436
437 PyObject* f_LineStyle2(RGBA color, int width) 
438 {
439     LineStyleObject* self = PyObject_New(LineStyleObject, &LineStyleClass);
440     self->ls.color = color;
441     self->ls.width = width;
442     return (PyObject*)self;
443 }
444 PyObject* f_LineStyle3(LINESTYLE ls)
445 {
446     LineStyleObject* self = PyObject_New(LineStyleObject, &LineStyleClass);
447     self->ls = ls;
448     return (PyObject*)self;
449 }
450 PyObject* f_LineStyle(PyObject* _self, PyObject* args, PyObject* kwargs)
451 {
452     static char *kwlist[] = {"line", "color", NULL};
453     float linewidth;
454     PyObject*color;
455     if(!kwargs) {
456         if (!PyArg_ParseTuple(args, "fO!", &linewidth, &ColorClass, &color))
457             return NULL;
458     }
459     return f_LineStyle2(color_getRGBA(color), (int)(linewidth*20));
460 }
461 LINESTYLE linestyle_getLineStyle(PyObject*_self)
462 {
463     LineStyleObject* self = (LineStyleObject*)_self;
464     return self->ls;
465 }
466 static PyObject* linestyle_getattr(PyObject * _self, char* a)
467 {
468     LineStyleObject*self = (LineStyleObject*)_self;
469     if(!strcmp(a, "width")) {
470         return Py_BuildValue("i", self->ls.width);
471     } else if(!strcmp(a, "color")) {
472         return f_Color2(self->ls.color.r, self->ls.color.g, self->ls.color.b, self->ls.color.a);
473     }
474     return NULL;
475 }
476 static int linestyle_setattr(PyObject * _self, char* a, PyObject* o)
477 {
478     LineStyleObject*self = (LineStyleObject*)_self;
479     if(!strcmp(a, "color")) {
480         self->ls.color = color_getRGBA(o);
481         return 0;
482     }
483     return -1;
484 }
485 static LINESTYLE linestyle_getlinestyle(PyObject*_self)
486 {
487     LineStyleObject*self = (LineStyleObject*)_self;
488     return self->ls;
489 }
490 static void linestyle_dealloc(PyObject* self)
491 {
492     mylog("-%08x(%d) linestyle_dealloc", self, self->ob_refcnt);
493     PyObject_Del(self);
494 }
495 static int linestyle_print(PyObject * _self, FILE *fi, int flags) //flags&Py_PRINT_RAW
496 {
497     LineStyleObject* self = (LineStyleObject*)_self;
498     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);
499     return 0;
500 }
501 PyTypeObject LineStyleClass = 
502 {
503     PyObject_HEAD_INIT(NULL)
504     0,
505     tp_name: "linestyle",
506     tp_basicsize: sizeof(LineStyleObject),
507     tp_itemsize: 0,
508     tp_dealloc: linestyle_dealloc,
509     tp_print: linestyle_print,
510     tp_getattr: linestyle_getattr,
511     tp_setattr: linestyle_setattr,
512 };
513 //----------------------------------------------------------------------------
514
515 typedef struct {
516     PyObject_HEAD
517     FILLSTYLE fs;
518 } FillStyleObject;
519
520 PyObject* f_FillStyle2(FILLSTYLE fs)
521 {
522     FillStyleObject* self = PyObject_New(FillStyleObject, &FillStyleClass);
523     self->fs = fs;
524     return (PyObject*)self;
525 }
526 PyObject* f_SolidFillStyle2(RGBA color)
527 {
528     FillStyleObject* self = PyObject_New(FillStyleObject, &FillStyleClass);
529     self->fs.type = FILL_SOLID;
530     self->fs.color = color;
531     return (PyObject*)self;
532 }
533 PyObject* f_SolidFillStyle(PyObject* _self, PyObject* args, PyObject* kwargs)
534 {
535     static char *kwlist[] = {"color", NULL};
536     PyObject*color;
537     if(!kwargs) {
538         if (!PyArg_ParseTuple(args, "O!", &ColorClass, &color))
539             return NULL;
540     }
541     return f_SolidFillStyle2(color_getRGBA(color));
542 }
543 FILLSTYLE fillstyle_getFillStyle(PyObject*_self)
544 {
545     FillStyleObject* self = (FillStyleObject*)_self;
546     return self->fs;
547 }
548 static void fillstyle_dealloc(PyObject* self)
549 {
550     mylog("-%08x(%d) linestyle_dealloc", self, self->ob_refcnt);
551     PyObject_Del(self);
552 }
553 static int fillstyle_print(PyObject * _self, FILE *fi, int flags) //flags&Py_PRINT_RAW
554 {
555     FillStyleObject* self = (FillStyleObject*)_self;
556     if(self->fs.type == FILL_SOLID)
557         fprintf(fi, "fill-solid(%02x%02x%02x%02x)", self->fs.color.r, self->fs.color.g, self->fs.color.b, self->fs.color.a);
558     else
559         fprintf(fi, "fill-%02x", self->fs.type);
560     return 0;
561 }
562 PyObject* fillstyle_issolid(PyObject*_self, PyObject*args)
563 {
564     FillStyleObject* self = (FillStyleObject*)_self;
565     int b = self->fs.type == FILL_SOLID;
566     return PyInt_FromLong(b);
567 }
568 static PyMethodDef FillStyleMethods[] = 
569 {
570     /* Module functions */
571     {"isSolid", fillstyle_issolid, METH_VARARGS, "Queries whether this is a solid fill"},
572     {0,0,0,0}
573 };
574 static PyObject* fillstyle_getattr(PyObject * _self, char* a)
575 {
576     FillStyleObject* self = (FillStyleObject*)_self;
577     if(!strcmp(a, "color")) {
578         return f_Color2(self->fs.color.r, self->fs.color.g, self->fs.color.b, self->fs.color.a);
579     }
580     return Py_FindMethod(FillStyleMethods, _self, a);
581 }
582 static int fillstyle_setattr(PyObject * _self, char* a, PyObject* o)
583 {
584     FillStyleObject*self = (FillStyleObject*)_self;
585     if(!strcmp(a, "color")) {
586         self->fs.color = color_getRGBA(o);
587         return 0;
588     }
589     return -1;
590 }
591
592 PyTypeObject FillStyleClass = 
593 {
594     PyObject_HEAD_INIT(NULL)
595     0,
596     tp_name: "fillstyle",
597     tp_basicsize: sizeof(FillStyleObject),
598     tp_itemsize: 0,
599     tp_dealloc: fillstyle_dealloc,
600     tp_print: fillstyle_print,
601     tp_getattr: fillstyle_getattr,
602     tp_setattr: fillstyle_setattr,
603 };
604 //----------------------------------------------------------------------------
605 static PyMethodDef primitive_methods[] = 
606 {
607     {"Color", (PyCFunction)f_Color, METH_KEYWORDS, "Create a new color object."},
608     {"Gradient", (PyCFunction)f_Gradient, METH_KEYWORDS, "Create a new gradient object."},
609     {"ColorTransform", (PyCFunction)f_ColorTransform, METH_KEYWORDS, "Create a new colortransform object."},
610     {"Matrix", (PyCFunction)f_Matrix, METH_KEYWORDS, "Create a new matrix object."},
611     {"BBox", (PyCFunction)f_BBox, METH_KEYWORDS, "Create a new bounding box object."},
612     {"SolidFillStyle", (PyCFunction)f_SolidFillStyle, METH_KEYWORDS, "Creates a new solid fill style."},
613     {"LineStyle", (PyCFunction)f_SolidFillStyle, METH_KEYWORDS, "Creates a new line style."},
614     {NULL, NULL, 0, NULL}
615 };
616
617 PyMethodDef* primitive_getMethods()
618 {
619     GradientClass.ob_type = &PyType_Type;
620     CXFormClass.ob_type = &PyType_Type;
621     BBoxClass.ob_type = &PyType_Type;
622     MatrixClass.ob_type = &PyType_Type;
623     return primitive_methods;
624 }
625
626