[Bf-blender-cvs] SVN commit: /data/svn/bf-blender [17283] branches/animsys2/source/blender/ python/api2_2x: AnimSys2: PyAPI Access for Per-Segment Interpolation
Joshua Leung
aligorith at gmail.com
Sun Nov 2 04:03:08 CET 2008
Revision: 17283
http://projects.blender.org/plugins/scmsvn/viewcvs.php?view=rev&root=bf-blender&revision=17283
Author: aligorith
Date: 2008-11-02 04:02:58 +0100 (Sun, 02 Nov 2008)
Log Message:
-----------
AnimSys2: PyAPI Access for Per-Segment Interpolation
Modified Paths:
--------------
branches/animsys2/source/blender/python/api2_2x/BezTriple.c
branches/animsys2/source/blender/python/api2_2x/doc/BezTriple.py
Modified: branches/animsys2/source/blender/python/api2_2x/BezTriple.c
===================================================================
--- branches/animsys2/source/blender/python/api2_2x/BezTriple.c 2008-11-02 00:25:39 UTC (rev 17282)
+++ branches/animsys2/source/blender/python/api2_2x/BezTriple.c 2008-11-02 03:02:58 UTC (rev 17283)
@@ -54,6 +54,8 @@
static int BezTriple_setPoints( BPy_BezTriple * self, PyObject * args );
static PyObject *BezTriple_getPoints( BPy_BezTriple * self );
static PyObject *BezTriple_getTriple( BPy_BezTriple * self );
+static PyObject *BezTriple_setInterpolation( BPy_BezTriple * self, PyObject * value );
+static PyObject *BezTriple_getInterpolation( BPy_BezTriple * self );
/****************************************************************************
Python method structure definition for Blender.BezTriple module:
@@ -79,6 +81,10 @@
"() - return BezTriple knot point x and y coordinates"},
{"getTriple", ( PyCFunction ) BezTriple_getTriple, METH_NOARGS,
"() - return list of 3 floating point triplets. order is H1, knot, H2"},
+ {"setInterpolation", ( PyCFunction ) BezTriple_setInterpolation,
+ METH_O, "(str) - Sets the interpolation type of the segment starting from this BezTriple"},
+ {"getInterpolation", ( PyCFunction ) BezTriple_getInterpolation,
+ METH_NOARGS, "() - Gets the interpolation type of the segment starting from this BezTriple"},
{NULL, NULL, 0, NULL}
};
@@ -401,6 +407,53 @@
return 0;
}
+static PyObject *BezTriple_getInterpolation( BPy_BezTriple * self )
+{
+ char *str = 0;
+ BezTriple *bezt = self->beztriple;
+
+ switch( bezt->ipo ) {
+ case IPO_BEZ:
+ str = "Bezier";
+ break;
+ case IPO_CONST:
+ str = "Constant";
+ break;
+ case IPO_LIN:
+ str = "Linear";
+ break;
+ default:
+ return EXPP_ReturnPyObjError( PyExc_TypeError,
+ "unknown interpolation type" );
+ }
+
+ return PyString_FromString( str );
+}
+
+static PyObject *BezTriple_setInterpolation( BPy_BezTriple * self, PyObject *value )
+{
+ char *interpolationtype = PyString_AsString(value);
+ short id= IPO_BEZ;
+
+ if( !interpolationtype )
+ return EXPP_ReturnPyObjError( PyExc_TypeError,
+ "expected string argument" );
+
+ if( !strcmp( interpolationtype, "Bezier" ) )
+ id = IPO_BEZ;
+ else if( !strcmp( interpolationtype, "Constant" ) )
+ id = IPO_CONST;
+ else if( !strcmp( interpolationtype, "Linear" ) )
+ id = IPO_LIN;
+ else
+ return EXPP_ReturnPyObjError( PyExc_TypeError,
+ "bad interpolation type" );
+
+ self->beztriple->ipo= id;
+ Py_RETURN_NONE;
+}
+
+
static PyObject *BezTriple_getHandles( BPy_BezTriple * self )
{
BezTriple *bezt = self->beztriple;
Modified: branches/animsys2/source/blender/python/api2_2x/doc/BezTriple.py
===================================================================
--- branches/animsys2/source/blender/python/api2_2x/doc/BezTriple.py 2008-11-02 00:25:39 UTC (rev 17282)
+++ branches/animsys2/source/blender/python/api2_2x/doc/BezTriple.py 2008-11-02 03:02:58 UTC (rev 17283)
@@ -60,6 +60,9 @@
@ivar handleTypes: the types of the point's two handles. See
L{HandleTypes} for a complete description.
@type handleTypes list of two ints
+ @ivar interpolation: The BezTriple's interpolation mode. See L{InterpTypes} for
+ values.
+ @type interpolation: int
@ivar selects: the select status for [handle, knot, handle]. True/nonzero
if the point is selected.
@type selects: list of three ints
More information about the Bf-blender-cvs
mailing list