
Anyway here is my attempt. I only need it for rectangles, which is good as the thought of doing it with other shapes scares me

First is a manual one-box-at-a-time, which looks good but its currently just black-to-white (anyone know how to do a fade from color-to-shadowcolor instead?). Also I discovered PB's gradient functions for a proper color-to-color transition (shown here) which is what id like the first one to do instead of black-to-white:

Code: Select all
Procedure CreateBevelBoxBW(color, bevelwidth, width, height)
Protected hImg, w, h, pct.f
hImg = CreateImage(#PB_Any, width, height, 24, color)
If hImg
If StartDrawing(ImageOutput(hImg))
If bevelwidth > 0
DrawingMode(#PB_2DDrawing_Outlined)
For i = 0 To bevelwidth-1
pct = (i / bevelwidth-1) * 255
FrontColor(RGB(pct,pct,pct))
Box(0+i, 0+i, width-(i*2),height-(i*2))
Next i
EndIf
StopDrawing()
EndIf
ProcedureReturn hImg
EndIf
EndProcedure
Procedure CreateBevelBox(color, shadowcolor, bevelwidth, width, height)
Protected hImg, w, h, pct.f
hImg = CreateImage(#PB_Any, width, height, 24, color)
If hImg
If StartDrawing(ImageOutput(hImg))
If bevelwidth > 0
DrawingMode(#PB_2DDrawing_Gradient)
GradientColor(0.0, color)
GradientColor(1.0 - (bevelwidth*0.01), color)
GradientColor(1.0, shadowcolor)
BoxedGradient(0,0,width,height)
Box(0,0,width,height)
EndIf
StopDrawing()
EndIf
ProcedureReturn hImg
EndIf
EndProcedure
width = 400: height = 200
color = RGB(0,200,200)
shadowcolor = RGB(0,0,50)
bevelwidth = 10
If OpenWindow(0, 0, 0, width, height, "Bevel box", #PB_Window_SystemMenu | #PB_Window_ScreenCentered)
hImg = CreateBevelBox(color, shadowcolor, bevelwidth, width, height)
;hImg = CreateBevelBoxBW(color, bevelwidth, width, height)
If IsImage(hImg): ImageGadget(0, 0, 0, width, height, ImageID(hImg)): EndIf
Repeat
Event = WaitWindowEvent()
Until Event = #PB_Event_CloseWindow
EndIf