Draw a circle onto a canvas

This is most probably going to be simple or not as difficult as I am making it to be but I am missing something here. I have a canvas - Canvas1 with a picture. I have relative locations to Canvas1 stored as my_x and my_y.

How do I draw a red circle with a known diameter of my_d using my_x and my_y anytime I want to do this into Canvas1. Next once I have accomplished that make the red circle blink at an interval of my_t. The interval is most probably a Timer but again I am missing how to control the Paint event of Canvas1 other than when the program starts

Suggestions welcomed - thanks

canvas1.invalidate
will force the canvas to execute the PAINT event at the next idle cycle

canvas1.refresh forces it to repaint “now”… Invalidate is the more reccommended method

As Dave says

in the paint event of the canvas

[code]if someboolean = true then
g.drawoval my_x,my_y,my_d,my_d

end if
[/code]

Use a timer set to a period
In the timer event, do this

someboolean = not someboolean mycanvas.invalidate

Thanks - I knew it was not going to be as difficult as I thought. Now onto organizing x and y coordinates into an array for multiple effects.

Dave and Jeff - thank you

[quote=144923:@Dave S]canvas1.invalidate
will force the canvas to execute the PAINT event at the next idle cycle

canvas1.refresh forces it to repaint “now”… Invalidate is the more reccommended method[/quote]

[quote=144923:@Dave S]canvas1.invalidate
will force the canvas to execute the PAINT event at the next idle cycle

canvas1.refresh forces it to repaint “now”… Invalidate is the more reccommended method[/quote]
So is it not that inefficient to use the invalidate method multiple times when you only need one refresh?

Not at all.
Whats inefficient is using refresh after every change.
You could be forcing 15 repaints when 1 will do.

One call to invalidate, or 200 calls to invalidate: it just sets the area as dirty, and then when the OS is ready it paints it.
Once.
Then not again unless its marked dirty again.

One paint event is much less expensive than 200 ‘mark the area as dirty’ calls.
And hugely less expensive than 200 ‘paint the whole thing now’ calls

yeah… what Jeff just said :slight_smile:

and particularly if REFRESH is called in the MIDDLE (or during) the execution of the PAINT EVENT… it will cause it to start over again

Invalidate would wait at least until PAINT completed before calling it again

Thanks for that. What the Refresh function does is what I thought the Invalidate function does and I had no idea what the difference was. All I knew was to avoid the refresh function.

Thanks

Thanks for that. What the Refresh function does is what I thought the Invalidate function does and I had no idea what the difference was. All I knew was to avoid the refresh function.

Thanks