Code : Tout sélectionner
EnableExplicit
;Left
Procedure VectorArrowL(Xi.d, Yi.d, Length.d, Amplitude.d, Thickness.d, Flag.i = #PB_Path_RoundEnd)
MovePathCursor(xi, yi)
AddPathLine(xi+Length, yi)
StrokePath(Thickness, Flag)
MovePathCursor(xi-Amplitude, yi)
AddPathLine(xi+Amplitude,yi-Amplitude)
AddPathLine(xi,yi)
AddPathLine(xi+Amplitude,yi+Amplitude)
ClosePath()
FillPath()
EndProcedure
;Right
Procedure VectorArrowR(Xi.d, Yi.d, Length.d, Amplitude.d, Thickness.d, Flag.i = #PB_Path_RoundEnd)
Protected xf.d=xi+Length, yf.d=yi
MovePathCursor(xi, yi)
AddPathLine(xi+Length, yi)
StrokePath(Thickness, Flag)
MovePathCursor(xf+Amplitude, yf)
AddPathLine(xf-Amplitude,yf-Amplitude)
AddPathLine(xf,yf)
AddPathLine(xf-Amplitude,yf+Amplitude)
ClosePath()
FillPath()
EndProcedure
;Down
Procedure VectorArrowD(Xi.d, Yi.d, Length.d, Amplitude.d, Thickness.d, Flag.i = #PB_Path_RoundEnd)
Protected xf.d=xi, yf.d=yi+Length
MovePathCursor(xi, yi)
AddPathLine(xf, yf)
StrokePath(Thickness, Flag)
MovePathCursor(xf, yf+Amplitude)
AddPathLine(xf-Amplitude,yf-Amplitude)
AddPathLine(xf, yf)
AddPathLine(xf+Amplitude,yf-Amplitude)
ClosePath()
FillPath()
EndProcedure
;Up
Procedure VectorArrowU(Xi.d, Yi.d, Length.d, Amplitude.d, Thickness.d, Flag.i = #PB_Path_RoundEnd)
Protected xf.d=xi, yf.d=yi+Length
MovePathCursor(xi, yi)
AddPathLine(xf, yf)
StrokePath(Thickness, Flag)
MovePathCursor(xi, yi-Amplitude)
AddPathLine(xi-Amplitude,yi+Amplitude)
AddPathLine(xi,yi)
AddPathLine(xi+Amplitude,yi+Amplitude)
ClosePath()
FillPath()
EndProcedure
;Right
Procedure VectorArrowTailR(Xi.d, Yi.d, Length.d, Amplitude.d, Thickness.d, Flag.i = #PB_Path_RoundEnd)
Protected xf.d=xi+Length, yf.d=yi
MovePathCursor(xi, yi)
AddPathLine(xf, yf)
StrokePath(Thickness, Flag)
MovePathCursor(xf+Amplitude, yf)
AddPathLine(xf+2*Amplitude,yf-Amplitude)
AddPathLine(xf-Amplitude,yf)
AddPathLine(xf+2*Amplitude,yf+Amplitude)
ClosePath()
FillPath()
EndProcedure
;Left
Procedure VectorArrowTailL(Xi.d, Yi.d, Length.d, Amplitude.d, Thickness.d, Flag.i = #PB_Path_RoundEnd)
Protected xf.d=xi+Length, yf.d=yi
MovePathCursor(xi, yi)
AddPathLine(xf, yf)
StrokePath(Thickness, Flag)
MovePathCursor(xi-Amplitude, yi)
AddPathLine(xi-2*Amplitude,yi-Amplitude)
AddPathLine(xi+Amplitude,yi)
AddPathLine(xi-2*Amplitude,yi+Amplitude)
ClosePath()
FillPath()
EndProcedure
;Down
Procedure VectorArrowTailD(Xi.d, Yi.d, Length.d, Amplitude.d, Thickness.d, Flag.i = #PB_Path_RoundEnd)
Protected xf.d=xi, yf.d=yi+Length
MovePathCursor(xi, yi)
AddPathLine(xf, yf)
StrokePath(Thickness, Flag)
MovePathCursor(xf, yf+Amplitude)
AddPathLine(xf-Amplitude,yf+2*Amplitude)
AddPathLine(xf, yf-Amplitude)
AddPathLine(xf+Amplitude,yf+2*Amplitude)
ClosePath()
FillPath()
EndProcedure
;Up
Procedure VectorArrowTailU(Xi.d, Yi.d, Length.d, Amplitude.d, Thickness.d, Flag.i = #PB_Path_RoundEnd)
Protected xf.d=xi, yf.d=yi+Length
MovePathCursor(xi, yi)
AddPathLine(xf, yf)
StrokePath(Thickness, Flag)
MovePathCursor(xi, yi-Amplitude)
AddPathLine(xi-Amplitude,yi-2*Amplitude)
AddPathLine(xi, yi+Amplitude)
AddPathLine(xi+Amplitude,yi-2*Amplitude)
ClosePath()
FillPath() ; U can try to comment this line...
EndProcedure
Procedure VectorArrowXY(xi.d, yi.d, xf.d, yf.d, Amplitude.d, Thickness.d, Flag.i = #PB_Path_RoundEnd, Angle.d = 40)
Protected.d xx1, yy1, xx2, yy2, xxx1, yyy1, xxx2, yyy2, Anglef
Angle = Abs(Angle*#PI/180.0)
MovePathCursor(xi, yi)
AddPathLine(xf, yf)
StrokePath(Thickness, Flag)
xx1 = -1.0*Cos(Angle) * Amplitude
yy1 = Sin(Angle) * Amplitude
xx2 = -1.0*Cos(Angle) * Amplitude
yy2 = -1.0*Sin(Angle) * Amplitude
Anglef.d = ATan2((xf - xi),(yi - yf))
xxx1 = Cos(Anglef)*xx1 + Sin(Anglef)*yy1
yyy1 = Cos(Anglef)*yy1 - Sin(Anglef)*xx1
xxx2 = Cos(Anglef)*xx2 + Sin(Anglef)*yy2
yyy2 = Cos(Anglef)*yy2 - Sin(Anglef)*xx2
MovePathCursor(xf, yf)
AddPathLine(xf + xxx1, yf + yyy1)
MovePathCursor(xf, yf)
AddPathLine(xf + xxx2, yf + yyy2)
StrokePath(Thickness, Flag)
EndProcedure
CompilerIf #PB_Compiler_IsMainFile
If OpenWindow(0, 0, 0, 800, 600, "VectorDrawing", #PB_Window_SystemMenu | #PB_Window_ScreenCentered)
CanvasGadget(0, 0, 0, 800, 600)
If StartVectorDrawing(CanvasVectorOutput(0))
VectorSourceColor($FF0000FF)
;Arrows
VectorArrowD(50, 10, 100, 20, 10)
VectorArrowU(350, 30, 100, 20, 10)
VectorArrowR(150, 50, 100, 20, 10)
VectorArrowL(150, 100,100, 20, 10)
;Tails
VectorArrowTailR(150, 350, 100, 20, 10)
VectorArrowTailL(150, 400, 100, 20, 10)
VectorArrowTailD(50, 200, 100, 20, 10)
VectorArrowTailU(350, 200, 100, 20, 10)
;Arrows + tail
VectorArrowL(150, 500,100, 20, 10)
VectorArrowTailR(150, 500, 100, 20, 10)
VectorArrowD(50, 450, 100, 20, 10)
VectorArrowTailU(50, 450, 100, 20, 10)
;Double arrow
VectorArrowL(150, 550,100, 20, 10)
VectorArrowR(150, 550,100, 20, 10)
VectorArrowU(350, 450, 100, 20, 10)
VectorArrowD(350, 450, 100, 20, 10)
;Free
;Arrow
VectorArrowXY(550, 25, 650, 50, 40, 10)
;Tail
VectorArrowXY(550, 200, 650, 150, -40, 10)
;Double Arrow
VectorArrowXY(550, 400, 650, 250, 40, 10)
VectorArrowXY(650, 250, 550, 400, 40, 10)
;Arrow+tail
VectorArrowXY(550, 550, 650, 400, -40, 10)
VectorArrowXY(650, 400, 550, 550, 40, 10)
;Oblique
RotateCoordinates(0, 0, 45)
TranslateCoordinates(250, 00)
VectorArrowL(0, 0, 100, 20, 10)
VectorArrowTailR(0, 0, 100, 20, 10)
RotateCoordinates(0, 0, 90)
TranslateCoordinates(-50, -50)
VectorArrowL(0, 0, 100, 20, 10)
VectorArrowTailR(0, 0, 100, 20, 10)
StopVectorDrawing()
EndIf
Define Event
Repeat
Event = WaitWindowEvent()
Until Event = #PB_Event_CloseWindow
EndIf
CompilerEndIf