Transparent background for canvas ?
Posted: Sat Nov 30, 2013 2:59 pm
Hi,
I'd like to have three-states buttons (on, hot and off), so I use canvas to make them, with custom images. My problem is that canvas has a white background by default, and I'm unable to make it 100% transparent. That way, I could have alpha gradients on my buttons and disregard the background color of my window, which can use alpha channel too.
What I'm currently doing is something like this :
... and in that case, if the image of my button uses the alpha channel, then the white background color of the canvas will appear and mess things up.
I'd like to have three-states buttons (on, hot and off), so I use canvas to make them, with custom images. My problem is that canvas has a white background by default, and I'm unable to make it 100% transparent. That way, I could have alpha gradients on my buttons and disregard the background color of my window, which can use alpha channel too.
What I'm currently doing is something like this :
Code: Select all
; ...
CanvasGadget(0, 0, 0, 50, 50)
SetGadgetAttribute(0, #PB_Canvas_Image, ImageID(#CanvasOff)) ; I use a Redraw() procedure to make it persistent when the user moves the window out of the screen
ImageGadget(1, 0, 0, 640, 480, ImageID(#BackgroundImage))
BindGadgetEvent(0, @CanvasMouseEnter(), #PB_EventType_MouseEnter)
BindGadgetEvent(0, @CanvasMouseLeave(), #PB_EventType_MouseLeave)
BindGadgetEvent(0, @CanvasMouseClick(), #PB_EventType_LeftClick)
; and I use SetGadgetAttribute() in each procedure to change the image of the canvas