help with speedy graphics

Alex Tweedly alex at tweedly.net
Tue Jul 13 19:45:46 EDT 2004


There's a big question and a small question.

Big one:
I want to create a large number of shapes (probably rectangles) on the 
screen (somewhere in the 5-10,000 range) for a visualization application. 
Each rectangle represents one point in my dataset, they will all be the 
same size, but each will be a different colour (probably < 16 different 
colours used), and obviously each will be in a different location.


Any suggestions on the best way to do this ?

The docs said (in "Revolution for Hypercard programmers") that it was 
faster to draw graphic objects than paint shapes. But I worry about the 
overhead of making each of them a control, when  there are so many of them 
(and when I'm not going to take any real advantage - I would in some cases 
be able to simply change the colour, but many of the user controls will 
cause the positions to change also).

Small question:
I tried this out, but obviously have missed something.

The script (see below) uses (tries to use) templateGraphic to set the size 
and colour, but this doesn't seem to have any effect.  It also uses 
lockscreen - but I see each rectangle being drawn one-by-one - I had 
expected that with lockscreen set, I would see nothing until all the 
rectangles were drawn and lockscreen was set false again.

Script is :

on mouseUp
   put the filename of this stack & cr into field "Field 1"
   put 0  into Kbase
   put the ticks into startTime
   put 10 into N
   set the style of templateGraphic to rectangle
   set the width of  templateGraphic  to 8
   set the height of templateGraphic  to 6
   set the foregroundColor of templategraphic  to "Firebrick3"

   set the lockScreen to true
   repeat with k1 = 1 to N
     repeat with k2 = 1  to N
       put Kbase + N*k1 + k2 into Kounter
       put "G"&Kounter into G
       create graphic G
       --      set the style of graphic G to rectangle
       set the location of graphic G to (100+10*k1,100+10*k2)
       --      set the width of  graphic G to 8
       --      set the height of graphic G to 6
       --      set the foregroundColor of graphic G to "Firebrick3"
     end repeat
   end repeat
   set the lockScreen to false
   put the ticks -startTime & cr after field "Field 1"

end mouseUp

Please feel free to comment on, or improve, any part of it - not just the 
questions I asked ...
-- Alex.
-------------- next part --------------

---
Outgoing mail is certified Virus Free.
Checked by AVG anti-virus system (http://www.grisoft.com).
Version: 6.0.719 / Virus Database: 475 - Release Date: 12/07/2004


More information about the use-livecode mailing list