Thursday, April 12, 2007

holy colored triangle, batman!

Another day, another apparent Pyrex. This time it seems subclasses must have the same number of arguments as their superclass or the compiled code will segfault.
I wonder, can this really be the first time someone has tried using a different number of arguments in __new__ with class inheritance? *grumble*

This explains why the Projector subclass I was working on kept segfaulting on creation.

I boiled the problem down to render a single static triangle, worked fine, added a 2nd argument for an object of type soy.Color and, after finally (2 days) figuring out where the problem was and throwing in a hack to fix it, we got a color-able triangle.

Changes to the color object, surprise surprise, change the triangle's color in realtime. I can run this in a loop to rotate it's color and watch the results, more evidence the coreloop is working properly.

This PySoy code for this is in SVN. The Python code for this demo is:
>>> import soy
>>> red = soy.Color('#f02')
>>> red
<Color #00ff0022>
>>> win = soy.Window('Triangle Test')
>>> tri = soy.widgets.Triangle(win, red)
>>>

No comments: