Here's an example which uses extra a large radius and wide light/shadow stripes to demonstrate the issues. Anyone good in math do create an universally working solution?
Code: Select all
Procedure Min(a,b)
If a<b
ProcedureReturn a
Else
ProcedureReturn b
EndIf
EndProcedure
Procedure AddPathRoundBox(x.d,y.d,w.d,h.d,radius.d,flags=#PB_Path_Default)
If radius>h/2 : radius=h/2 : EndIf
If radius>w/2 : radius=w/2 : EndIf
If radius<0
radius=0
EndIf
MovePathCursor(x+radius,y,flags)
AddPathArc(w-radius,0,w-radius,radius,radius,#PB_Path_Relative)
AddPathArc(0,h-radius,-radius,h-radius,radius,#PB_Path_Relative)
AddPathArc(-w+radius,0,-w+radius,-radius,radius,#PB_Path_Relative)
AddPathArc(0,-h+radius,radius,-h+radius,radius,#PB_Path_Relative)
ClosePath()
MovePathCursor(-radius,0,#PB_Path_Relative)
EndProcedure
Procedure AddPathHighlight(x.d,y.d,w.d,h.d,r.d,angle.d,flags=#PB_Path_Default)
Protected t1.d,t2.d,t3.d,t4.d,t5.d
t1=Cos(angle*#PI/180); 1-89°
t2=Sin(angle*#PI/180)
t3=r*t1
t4=r*t2
t5=2*r-t4
MovePathCursor(x,y+r,flags)
AddPathCircle(r,0,r,180,270,#PB_Path_Relative)
AddPathLine(w-r*2,0,#PB_Path_Relative)
AddPathCircle(0,r,r,270,270+angle,#PB_Path_Relative|#PB_Path_Connected)
AddPathLine(-w+t5,0,#PB_Path_Relative)
AddPathCircle(0,t3,t3,270,180,#PB_Path_Relative|#PB_Path_Connected|#PB_Path_CounterClockwise)
AddPathLine(0,h-t5,#PB_Path_Relative)
AddPathCircle(t3,-t4,r,180-angle,180,#PB_Path_Relative|#PB_Path_Connected)
ClosePath()
EndProcedure
Procedure AddPathShadow(x.d,y.d,w.d,h.d,r.d,angle.d,flags=#PB_Path_Default)
Protected ro.d
Protected t1.d,t2.d,t3.d,t4.d,t5.d
ro=Min(Min(r,h/2),w/2)
t1=Cos(angle*#PI/180); 1-89°
t2=Sin(angle*#PI/180)
t3=r*t1
t4=r*t2
t5=2*r-t4
r=ro
Debug ro
MovePathCursor(x+w,y+h-r,flags)
AddPathCircle(-r,0,r,0,90,#PB_Path_Relative)
AddPathLine(-w+r*2,0,#PB_Path_Relative)
AddPathCircle(0,-r,r,90,90+angle,#PB_Path_Relative|#PB_Path_Connected)
AddPathLine(w-t5,0,#PB_Path_Relative)
AddPathCircle(0,-t3,t3,90,0,#PB_Path_Relative|#PB_Path_Connected|#PB_Path_CounterClockwise)
AddPathLine(0,-h+t5,#PB_Path_Relative)
AddPathCircle(-t3,t4,r,360-angle,360,#PB_Path_Relative|#PB_Path_Connected)
ClosePath()
EndProcedure
Procedure boxs(x,y,w,h,radius,col,extra=8)
AddPathRoundBox(x,y,w,h,radius)
VectorSourceColor($a0000000|col)
FillPath(#PB_Path_Preserve)
VectorSourceColor($60000000)
StrokePath(1)
VectorSourceColor($40ffffff)
AddPathHighlight(x,y,w,h,radius,extra*2)
FillPath()
AddPathHighlight(x,y,w,h,radius,extra*3)
FillPath()
VectorSourceColor($20000000)
AddPathShadow(x,y,w,h,radius,extra*2)
FillPath()
AddPathShadow(x,y,w,h,radius,extra*3)
FillPath()
; Debug "Data.i "+Str(boxnr)+", "+Str(x)+","+Str(y)+", "+Str(w)+","+Str(h)+"; "+Str(size)
EndProcedure
Procedure show()
Protected i
StartVectorDrawing(CanvasVectorOutput(0))
AddPathBox(0,0,VectorOutputWidth(),VectorOutputHeight())
VectorSourceColor($Ff000000|#White)
FillPath()
boxs(50,50,300,200,90,$F3D1AD)
boxs(50,350,300,100,40,$F3D1AD,20); smaller radius
boxs(400,100,300,100,90,$9AF0B8)
boxs(500,250,100,300,90,$9AF0B8,20)
StopVectorDrawing()
EndProcedure
Procedure main()
#X=800
#Y=600
OpenWindow(0,0,0,#X,#Y,"")
CanvasGadget(0,0,0,#X,#Y)
show()
Repeat
Select WaitWindowEvent()
Case #PB_Event_CloseWindow
End
Case #WM_CHAR
End
EndSelect
ForEver
EndProcedure
main()