Toujours pour les besoin d'animatoon, mon soft2D que je réalise pour nos jeux (Arkeos et 3arks), voici un petit code que j'ai adapté d'un code trouvé sur le forum Anglais, afin de concevoir des bouton images sans bordure et sans fond :
Code : Tout sélectionner
Procedure ButtonImageGadgetAlpha_(gadget,x,y,w,h,img,alpha=0,color=14933984)
; by Rashad
; adapted by blendman
container = ContainerGadget(#PB_Any,x,y,w,h)
If container
If alpha = 0 ; on veut un bouton transparent
tempimg = CopyImage(img, #PB_Any)
x1 = - 16
y1 = -16
w1 = 32
h1 = 32
If StartDrawing(ImageOutput(tempimg))
DrawingMode(#PB_2DDrawing_AlphaChannel)
Box(x1,y1,ImageWidth(img)+w1,ImageHeight(img)+h1 , RGBA(0,0,0,255))
DrawingMode(#PB_2DDrawing_Default)
Box(x1,y1,ImageWidth(img)+w1,ImageHeight(img)+h1 , color)
DrawingMode(#PB_2DDrawing_AlphaBlend)
DrawAlphaImage(ImageID(img),0,0)
StopDrawing()
EndIf
ButtonImageGadget(gadget, x1, y1, w+w1, h+h1, ImageID(tempimg))
FreeImage(tempimg)
Else
ButtonImageGadget(gadget, -4, -4, w+8, h+8, ImageID(img))
EndIf
CloseGadgetList()
EndIf
EndProcedure
Enumeration
#button
#button2
EndEnumeration
#image = 0
OpenWindow(0, 0, 0, 600, 400, "Button Image Bordeless", #PB_Window_SystemMenu | #PB_Window_ScreenCentered)
UsePNGImageDecoder()
LoadImage(#image,"add.png")
ButtonImageGadgetAlpha_(#button,50,50,22,22,#image)
ButtonImageGadgetAlpha_(#button2,100,50,30,30,#image,1)
Repeat
Select WaitWindowEvent()
Case #PB_Event_CloseWindow
Quit = 1
Case #PB_Event_Gadget
Select EventGadget()
Case #button
Debug "OK"
EndSelect
EndSelect
Until Quit = 1
