Code: Select all
XIncludeFile("...") ;<--- my vectordrawing lib
Macro cola(col,a=$ff):(col|(a<<24)):EndMacro
Procedure piece(type,li.f,lp.f,sh.f,sd.f,sb.f,sg.f,x,y)
Protected dx,dy
Macro forme(l,sh,sd,sb,sg,dec)
dx=lp+dec
dy=lp+dec
MovePathCursor(dx-li,dy-li)
AddPathCurve(dx,dy+(-1-sh)*li, dx,dy+ (-1+sh)*li,dx+ li,dy-li)
AddPathCurve(dx+(1+sd)*li,dy,dx+ (1-sd)*li, dy, dx+li,dy+ li)
AddPathCurve( dx,dy+ (1+sb)*li, dx,dy+ (1-sb)*li,dx -li,dy+li)
AddPathCurve( dx+(-1-sg)*li, dy,dx+ (-1+sg)*li, dy, dy-li,dy -li)
ClosePath()
EndMacro
la=1
VectorSourceColor(cola($888888)):FillVectorOutput()
forme(li,sh,sd,sb,sg,0):ClipPath():MovePathCursor(-x,-y):DrawVectorImage(ImageID(0))
forme(li,sh,sd,sb,sg, la):VectorSourceColor(cola($ffffff,$44)):StrokePath(la*2)
forme(li,sh,sd,sb,sg,-la):VectorSourceColor(cola($000000,$44)):StrokePath(la*2)
EndProcedure
ex=800
ey=600
OpenWindow(0, 0, 0, ex,ey, "", #PB_Window_SystemMenu | #PB_Window_ScreenCentered)
ImageGadget(0, 0, 0, ex,ey,0)
; image source
CreateImage(0,256,256,32,$ff888888)
StartVectorDrawing(ImageVectorOutput(0))
For i=0 To 100:AddPathCircle(Random(256),Random(256),Random(20)+20):VectorSourceColor(Random($ffffffff)):FillPath():Next
StopVectorDrawing()
limage=128 ; image width
lpiece=limage*1.2 ; piece width (+20 %)
posx=100 ; position x inside image
posy=100 ; position y inside image
Ipiece=CreateImage(-1,lpiece,lpiece,32,#PB_Image_Transparent)
StartVectorDrawing(ImageVectorOutput(ipiece))
piece(0,limage/2,lpiece/2,0.5,0.5,0.5,0.5,posx,posy)
StopVectorDrawing()
SetGadgetState(0,ImageID(ipiece))
CompilerIf #PB_Compiler_OS <> #PB_OS_Web
Repeat:Event = WaitWindowEvent():Until Event = #PB_Event_CloseWindow
CompilerEndIf