[Edu-sig] Re: Teaching graphics with Python (was Introductoryhighschool programming)

John Zelle john.zelle at wartburg.edu
Sun May 9 20:54:03 EDT 2004



Kirby Urner wrote:

>Re: www.4dsolutions.net/ocn/python/nks.py
>
>  
>
>>individually.  I should try it with rectangles.
>>
>>    
>>
>
>Definitely faster with rectangles.
>
>In Tk, getting down to the actual pixel level (pixelsize=1), even with Point
>(tried in place of Rectangle), I get a fuzzy picture.  
>
>  
>
>Might be some problem with my algorithm I didn't catch.
>
>  
>
Actually, Tk doesn't give you pixel level control. In my graphics 
package, I fake it with small rectangles. So yes, using rectangles would 
be much better. Another problem with rendering speed is that my graphics 
package automatically flushes the graphics window after every operation. 
This makes simple animations easier, but when you are doing lots of 
small updates, this is very inefficient. My latest version of the 
package (still in testing) adds an option to turn off the auto-flush. 
Using this option, you can do a bunch of draws before actually updating 
the view. I think the result would be a much faster draw, but it's still 
going to be slower than PIL

If you're interested, I could post the latest version of graphics.py.

>An advantage of the PIL method is you're building something savable.  With
>graphics.py, I don't see a way to save the canvas to a file.
>
>
>  
>
This is problem with graphics.py. Tk provides a method to dump canvases 
to postscript, but the last time I checked it only worked under 
Unix/Linux. I'm not sure if this has been brought into the Windows world 
as well, I haven't looked recently.

--John

>(for color coded view, in browser, use:
>http://www.4dsolutions.net/cgi-bin/py2html.cgi?script=/ocn/python/nks.py
>
>Kirby
>
>
>
>
>  
>




More information about the Edu-sig mailing list