Please, need help for optimisation

BlitzMax Forums/BlitzMax Programming/Please, need help for optimisation

The main problems appear to be the events.

Your drawing code is wrapped up inside the paint function.
You might find it will work better if you call the drawing functions as part of your mouse move/down/up code, rather than forcing a redraw of the gadget.
The time before the gadget is actually redrawn is undetermined, especially since you appear to be updating it 60 times a second anyways.

You could always only refresh the canvas when it needs to be refreshed (ie. after you've changed the underlying pixmap in some way).

Also, drawing the pixmap every frame (instead of its Image), is slow.