Graphic Objects & Memory Use

Alex Tweedly alex at
Sat Jan 1 14:26:24 EST 2005

Gordon Webster wrote:

>Dear Revolutionaries
>I have a question or two about rev's graphic objects
>Since the rev graphic objects such as lines and shapes
>are objects that can have their own properties, styles
>etc., is there a big memory overhead in using them to
>create complicated graphics? 
I'm sure there is some overhead - but not too much. (Note - this is 
speculation on my part - I have no inside knowledge.)
I'd be concerned about storing a million objects each of which is a 
single line - but not about a few thousand of them (though it can be 
expensive in time to create many graphics - or even worse to delete them 

Note that there are some very clever things you can do with polygon 
objects that in some cases allow you to achieve the drawing effects you 
want with many fewer graphic objects (and much more speed).

For instance, you can put a "marker" on each vertex of a polygon  (this 
is a quick way to draw many similar shapes - set the marker of a polygon 
to the shape you want to draw, and then simply adding a vertex to the 
polygon gives you a whole extra shape. This is often used in combination 
with the other unusual feature - a blank line in the list of vertices 
results in a "non-visible" edge; so a list of points like

will result in two disjoint line line segments.

>What would be the best way in rev to do the equivalent
>of double-buffering the graphics i.e. invisibly
>drawing the next frame of a complex graphic in
>background and then displaying it?
The simple answer is that you probably don't need to double-buffer it. 
Of course there are cases where the simple answer is wrong :-)

If you have a few thousand graphic shapes, and want to redraw them, then 
you may need to. On the other hand, if you can use the clever features 
of polygons above, then you can get very smooth animation effects at 
very high speed without double-buffering.

If you need to double-buffer, you can do
  set lockscreen to true
  -- draw the "next" screen now
  set lockscreen to false

If you haven't already, take a look at Malte's libRMC (latest version 
announced on the list within the last few weeks)

-- Alex.

No virus found in this outgoing message.
Checked by AVG Anti-Virus.
Version: 7.0.298 / Virus Database: 265.6.7 - Release Date: 30/12/2004

More information about the Use-livecode mailing list