Clearing out rectangles

Sarah Reichelt sarah.reichelt at gmail.com
Fri Dec 30 20:50:09 EST 2005


> I'm trying to draw a bar graph in Revolution using values from an
> array.  I use the following code, repeated for each bar, to draw the
> graph:
>
> create invisible graphic
> set the style of it to rectangle
> set the opaque of it to true
> set the rectangle of it to startY,tDrawX,tDrawY,startX
> set the foregroundColor of it to "#000000"
> set the backgroundColor of it to "#9198A0"
> set the lineSize of it to 1
> show it
>
> This all works very well, but the next time I come to draw the graph,
> the old rectangles are still sitting there.  How can I get rid of them?
>

Have a loop at the start of your drawing routine that goes through and
deletes them all. If you have no other graphics, you can do:

   repeat the number of graphics times
        delete graphic 1
    end repeat

If you have other graphics that shouldn't be deleted, then I suggest
you name your chart graphics as they are made, and do something like
this:

    repeat with x = the number of graphics down to 1
        if the short name of graphic x contains "Chart" then delete graphic x
    end repeat

HTH,
Sarah



More information about the use-livecode mailing list