more fiddling with edgestyles
[swftools.git] / lib / python / primitives.c
index be62671..eaaeef2 100644 (file)
@@ -189,22 +189,22 @@ static int bbox_setattr(PyObject * self, char* a, PyObject* o)
     BBoxObject*bbox= (BBoxObject*)self;
     if(!strcmp(a, "xmin")) {
        float xmin;
-       if (!PyArg_Parse(o, "i", &xmin)) goto err;
+       if (!PyArg_Parse(o, "f", &xmin)) goto err;
        bbox->bbox.xmin = (int)(xmin*20);
        return 0;
     } else if(!strcmp(a, "ymin")) {
        float ymin;
-       if (!PyArg_Parse(o, "i", &ymin)) goto err;
+       if (!PyArg_Parse(o, "f", &ymin)) goto err;
        bbox->bbox.ymin = (int)(ymin*20);
        return 0;
     } else if(!strcmp(a, "xmax")) {
        float xmax;
-       if (!PyArg_Parse(o, "i", &xmax)) goto err;
+       if (!PyArg_Parse(o, "f", &xmax)) goto err;
        bbox->bbox.xmax = (int)(xmax*20);
        return 0;
     } else if(!strcmp(a, "ymax")) {
        float ymax;
-       if (!PyArg_Parse(o, "i", &ymax)) goto err;
+       if (!PyArg_Parse(o, "f", &ymax)) goto err;
        bbox->bbox.ymax = (int)(ymax*20);
        return 0;
     } 
@@ -247,6 +247,14 @@ typedef struct {
     MATRIX matrix;
 } MatrixObject;
 
+PyObject* f_Matrix2(MATRIX* m)
+{
+    PyObject*self = (PyObject*)PyObject_New(MatrixObject, &MatrixClass);
+    MatrixObject*matrix = (MatrixObject*)self;
+    matrix->matrix = *m;
+    return self;
+}
+
 PyObject* f_Matrix(PyObject* _self, PyObject* args, PyObject* kwargs)
 {
     PyObject*self = (PyObject*)PyObject_New(MatrixObject, &MatrixClass);
@@ -286,6 +294,17 @@ PyObject* f_Matrix(PyObject* _self, PyObject* args, PyObject* kwargs)
 static PyObject* matrix_getattr(PyObject * self, char* a)
 {
     PY_ASSERT_TYPE(self,&MatrixClass);
+    MatrixObject*matrix = (MatrixObject*)self;
+    if(!strcmp(a, "entries")) {
+       return Py_BuildValue("(ffffff)",
+               matrix->matrix.sx/65536.0,
+               matrix->matrix.r0/65536.0,
+               matrix->matrix.r1/65536.0,
+               matrix->matrix.sy/65536.0,
+               matrix->matrix.tx/20.0,
+               matrix->matrix.ty/20.0
+               );
+    }
     return NULL;
 }
 static int matrix_setattr(PyObject * self, char* a, PyObject* o)
@@ -333,9 +352,25 @@ typedef struct {
     CXFORM cxform;
 } CXFormObject;
 
-PyObject* f_ColorTransform(PyObject* self, PyObject* args, PyObject* kwargs)
+PyObject* f_ColorTransform(PyObject* _self, PyObject* args, PyObject* kwargs)
 {
-    return NULL;
+    int r0=256,g0=256,b0=256,a0=256,r1=0,g1=0,b1=0,a1=0;
+    static char *kwlist[] = {"r_mul", "g_mul", "b_mul", "a_mul", "r_add", "g_add", "b_add", "a_add", NULL};
+    PyObject*color;
+    if(!kwargs) {
+       if (!PyArg_ParseTupleAndKeywords(args, kwargs, "|iiiiiiii", kwlist,
+               &r0,&g0,&b0,&a0,
+               &r1,&g1,&b1,&a1))
+           return NULL;
+    }
+
+    CXFORM c;
+    c.r0 = r0; c.g0 = g0; c.b0 = b0; c.a0 = a0;
+    c.r1 = r1; c.g1 = g1; c.b1 = b1; c.a1 = a1;
+
+    CXFormObject*self = PyObject_New(CXFormObject, &CXFormClass);
+    self->cxform = c;
+    return (PyObject*)self;
 }
 static PyObject* colortransform_getattr(PyObject * self, char* a)
 {
@@ -612,6 +647,8 @@ PyMethodDef* primitive_getMethods()
     CXFormClass.ob_type = &PyType_Type;
     BBoxClass.ob_type = &PyType_Type;
     MatrixClass.ob_type = &PyType_Type;
+    FillStyleClass.ob_type = &PyType_Type;
+    LineStyleClass.ob_type = &PyType_Type;
     return primitive_methods;
 }