I am currently working on an application, which uses a video projector to create an effect similar to a real laser. A really nice example of what I'm trying to archive can be seen on Youtube here.
Basically that application needs to draw simple moving shapes in various colors. I have a pretty complicated setup using pycairo allowing the primitives to pass through a set of modifiers to change position, scale and rotation. This allows for a great deal of flexibility.
Unfortunately pycairo seems to be pretty slow at drawing dashed circles. I tried drawing 30 circles like this:
# setup, transforms...
# Example color-scheme:
self._colors = [(0.0, 1.0, 0.0)]
# drawing dashes one after another
for count, color in enumerate(self._colors):
cr.set_dash(dash_len, self._dash_len * count)
cr.set_source_rgb(color[0], color[1], color[2])
cr.arc(0, 0, self.radius(), 0, 2 * math.pi)
cr.stroke()
The whole thing looks like this. This is not able to sustain 25fps with on 800x600 using a Core2Duo.
Is there a faster way to draw circles? Quality is not really an issue.
Thanks for your help!
cr.set_tolerance(0.5)
in my setup code, is there more? – Subterrane