Speeding up Simple Canvas Loop
Randall Hopper
aa8vb at vislab.epa.gov
Mon May 10 08:51:52 EDT 1999
Michael P. Reilly:
|Randall Hopper <aa8vb at vislab.epa.gov> wrote:
|: create_line = canvas.create_line
|: for line in lines:
|: create_line( line, width=0 )
|
|You can either use one call to create_line or use create_polygon.
|
| # just get the first endpoint of each line
| vertices = map(lambda a, b: a, lines)
| # add the first vertex to the end to close the polygon
| canvas.create_line( vertices + vertices[:1], width=0 )
I don't understand this. Correct me if I'm wrong, but this will simply
draw one multi-segment line which connects all the first-points of the
lines.
I believe it also assumes each line in "lines" is a 2-point line. In fact,
these lines each have a variable number of points (2 to hundreds) already.
|or
| canvas.create_polygon( vertices, width=0 )
These are distinct multi-point lines, so I can't just connect all the
points together.
Randall
More information about the Python-list
mailing list