Welcome to mirror list, hosted at ThFree Co, Russian Federation.

git.blender.org/blender.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorCampbell Barton <ideasman42@gmail.com>2010-04-20 02:02:53 +0400
committerCampbell Barton <ideasman42@gmail.com>2010-04-20 02:02:53 +0400
commit4d39e0410288497455ace549a931d2b07fe49f86 (patch)
tree8a359045b118e7cd05b3446b23fa8c04eef19229 /source/blender/python/generic/mathutils_color.c
parent4a993039674403815ab144cbaad80c805e9c36b4 (diff)
change mathutils 'repr' functions to closer match input
Diffstat (limited to 'source/blender/python/generic/mathutils_color.c')
-rw-r--r--source/blender/python/generic/mathutils_color.c15
1 files changed, 12 insertions, 3 deletions
diff --git a/source/blender/python/generic/mathutils_color.c b/source/blender/python/generic/mathutils_color.c
index d44515d1551..564afbdd038 100644
--- a/source/blender/python/generic/mathutils_color.c
+++ b/source/blender/python/generic/mathutils_color.c
@@ -104,13 +104,22 @@ static PyObject *Color_copy(ColorObject * self, PyObject *args)
//print the object to screen
static PyObject *Color_repr(ColorObject * self)
{
- char str[64];
+ PyObject *r, *g, *b, *ret;
if(!BaseMath_ReadCallback(self))
return NULL;
- sprintf(str, "[%.6f, %.6f, %.6f](color)", self->col[0], self->col[1], self->col[2]);
- return PyUnicode_FromString(str);
+ r= PyFloat_FromDouble(self->col[0]);
+ g= PyFloat_FromDouble(self->col[1]);
+ b= PyFloat_FromDouble(self->col[2]);
+
+ ret= PyUnicode_FromFormat("Color(%R, %R, %R)", r, g, b);
+
+ Py_DECREF(r);
+ Py_DECREF(g);
+ Py_DECREF(b);
+
+ return ret;
}
//------------------------tp_richcmpr
//returns -1 execption, 0 false, 1 true