[Implemented] Canvas Back-Color

Got an idea for enhancing PureBasic? New command(s) you'd like to see?
IdeasVacuum
Always Here
Always Here
Posts: 6426
Joined: Fri Oct 23, 2009 2:33 am
Location: Wales, UK
Contact:

Re: Canvas Back-Color

Post by IdeasVacuum »

.....I haven't had a flicker problem but a pre-defined background colour might be useful at times, though if any redrawing is nescessary than the background needs to be re-drawn first.
IdeasVacuum
If it sounds simple, you have not grasped the complexity.
User avatar
idle
Always Here
Always Here
Posts: 5840
Joined: Fri Sep 21, 2007 5:52 am
Location: New Zealand

Re: Canvas Back-Color

Post by idle »

make sure you're not making multiple StartDrawing StopDrawing to the canvas output while compositing the output
otherwise it will be alpha blending the whole canvas on each stopdrawing call.
It's better to composite the output into an image and then draw that to the canvas once it's complete.
Windows 11, Manjaro, Raspberry Pi OS
Image
swan
Enthusiast
Enthusiast
Posts: 225
Joined: Sat Jul 03, 2004 9:04 am
Location: Sydney Australia
Contact:

Re: Canvas Back-Color

Post by swan »

I've often gone looking to see how to set the back color of a canvas gadget, can it be done ?
User avatar
Danilo
Addict
Addict
Posts: 3036
Joined: Sat Apr 26, 2003 8:26 am
Location: Planet Earth

Re: Canvas Back-Color

Post by Danilo »

What mevedia.de is talking about is CanvasGadget re-size. If you re-size the CanvasGadget
using ResizeGadget to a larger size, PureBasic fills the new area with white color.
After that you redraw the content of the canvas, but there is white flickering for a moment.
Especially with large (screen size) CanvasGadget the repainting process takes some time, so
you see the white flickering. Changing the default background color would reduce it little bit
for dark CanvasGadget content, but there would still be flickering because the new area is first
filled with the background color and then again filled with the content.
Maybe another solution could be to disable automatic CanvasGadget redrawing with ResizeGadget
for a moment, draw on canvas, and then update display?
Could there be a platform independent callback get added to the CanvasGadget officially, so it does
not fill the new background automatically with a color? Instead it calls the user callback function,
if one was set using SetGadgetAttribute() or something like this. This would also avoid the 2 times re-painting,
first automatically by PB and then by the user, so the whole process could be faster...?
Joris
Addict
Addict
Posts: 890
Joined: Fri Oct 16, 2009 10:12 am
Location: BE

Re: Canvas Back-Color

Post by Joris »

idle wrote:make sure you're not making multiple StartDrawing StopDrawing to the canvas output while compositing the output
otherwise it will be alpha blending the whole canvas on each stopdrawing call.
It's better to composite the output into an image and then draw that to the canvas once it's complete.
This looks like the Windows function ValidateRect() is simulated somewhere in that stopdrawing call, is it ?
Yeah I know, but keep in mind ... Leonardo da Vinci was also an autodidact.
User avatar
idle
Always Here
Always Here
Posts: 5840
Joined: Fri Sep 21, 2007 5:52 am
Location: New Zealand

Re: Canvas Back-Color

Post by idle »

Don't know exactly what it's doing Joris, it was just an assumption based on observation

Don't have any thoughts about how to avoid the flicker on resizing
Windows 11, Manjaro, Raspberry Pi OS
Image
User avatar
Danilo
Addict
Addict
Posts: 3036
Joined: Sat Apr 26, 2003 8:26 am
Location: Planet Earth

Re: Canvas Back-Color

Post by Danilo »

idle wrote:Don't have any thoughts about how to avoid the flicker on resizing
Move the topic to feature requests and wish list. ;)
User avatar
idle
Always Here
Always Here
Posts: 5840
Joined: Fri Sep 21, 2007 5:52 am
Location: New Zealand

Re: Canvas Back-Color

Post by idle »

+1
Windows 11, Manjaro, Raspberry Pi OS
Image
Little John
Addict
Addict
Posts: 4779
Joined: Thu Jun 07, 2007 3:25 pm
Location: Berlin, Germany

Re: Canvas Back-Color

Post by Little John »

Alexi wrote:The Canvas should be also able to use Alpha-Channel.
Yes, that would be very useful!

See for instance the following topics:
PNG + Transparency woes
Any gadget allowing transparent background?
Transparent background for canvas ?
Post Reply