So, hi everyone.
Here are my first serious trials with the VectorLib, so please be gracious.
If you like my poor sketches, use it and feel free to optimize code or design.
If you don't like it or find them useless, ignore them.
Code: Select all
Declare.i FirstAid (img.i, size.i, color.i, color2.i=0)
Declare.i NoEntry (img.i, size.i, color.i, color2.i=0)
Declare.i Stop3 (img.i, size.i, color.i, color2.i=0)
Declare.i ToClipboard (img.i, size.i, color.i, color2.i=0)
Declare.i FromClipboard (img.i, size.i, color.i, color2.i=0)
Declare.i Copy (img.i, size.i, color.i, color2.i=0)
Declare.i Paste (img.i, size.i, color.i, color2.i=0)
Declare.i Cut (img.i, size.i, color.i, color2.i=0)
Declare.i Undo (img.i, size.i, color.i, color2.i=0)
Declare.i Redo (img.i, size.i, color.i, color2.i=0)
Procedure.i FirstAid (img.i, size.i, color1.i, color2.i= 0)
;[org. by Omi]
Protected ret.i
Protected hw.d= size / 16.0, half= size / 2.0
ret= CreateImage(img, size, size, 32, #Background)
If ret
If img = #PB_Any
img= ret
EndIf
If StartVectorDrawing(ImageVectorOutput(img))
VectorSourceColor(color1)
;panel: round corners
AddPathBox (hw, hw, size - 2 * hw, size - 2 * hw)
FillPath ()
AddPathBox (hw, hw, size - 2 * hw, size - 2 * hw)
StrokePath (hw*2, #PB_Path_RoundCorner)
VectorSourceColor(color2)
;hor. bar
MovePathCursor(hw, half)
AddPathLine (size - 2 * hw, 0, #PB_Path_Relative)
;vert. bar
MovePathCursor(half, hw)
AddPathLine (0, size - 2 * hw, #PB_Path_Relative)
StrokePath (size/5)
StopVectorDrawing()
EndIf
EndIf
ProcedureReturn ret
EndProcedure
Procedure.i NoEntry (img.i, size.i, color1.i, color2.i= 0)
;[org. by Omi]
Protected ret.i
Protected hw.d= size / 16.0, half= size / 2.0
ret= CreateImage(img, size, size, 32, #Background)
If ret
If img = #PB_Any
img= ret
EndIf
If StartVectorDrawing(ImageVectorOutput(img))
VectorSourceColor(color1)
;panel
AddPathCircle (half, half, half)
FillPath()
;bar
VectorSourceColor(color2)
MovePathCursor (hw, half)
AddPathLine (size - 2 * hw, 0, #PB_Path_Relative)
StrokePath (size/5)
StopVectorDrawing()
EndIf
EndIf
ProcedureReturn ret
EndProcedure
Procedure.i Stop3 (img.i, size.i, color1.i, color2.i= 0)
;[org. by Omi]
Protected ret.i
Protected hw.d= size / 3.5, half= size / 2.0
ret= CreateImage(img, size, size, 32, #Background)
If ret
If img = #PB_Any
img= ret
EndIf
If StartVectorDrawing(ImageVectorOutput(img))
VectorSourceColor(color1)
;panel
AddPathCircle (half, half, half)
FillPath()
VectorSourceColor(color2)
;cross
MovePathCursor (hw, hw)
AddPathLine (size - hw, size - hw)
MovePathCursor (hw, size - hw)
AddPathLine (size - hw, hw)
StrokePath (size/12)
StopVectorDrawing()
EndIf
EndIf
ProcedureReturn ret
EndProcedure
Procedure.i ToClipboard (img.i, size.i, color1.i, color2.i= 0)
;[org. by Omi]
Protected ret.i
Protected hw.d= Round(size / 10.0, #PB_Round_Up), half= size / 2.0
ret= CreateImage(img, size, size, 32, #Background)
If ret
If img = #PB_Any
img= ret
EndIf
If StartVectorDrawing(ImageVectorOutput(img))
VectorSourceColor(color1)
;box
AddPathBox (hw, hw, size - 2 * hw, size - hw - size / 32)
StrokePath (size / 16, #PB_Path_DiagonalCorner)
;ring
AddPathCircle (half, hw+1, hw, 180, 0)
StrokePath (size / 32)
;clamb
AddPathCircle (half + hw, 3*hw, hw-1, 180, 0)
FillPath()
StrokePath (size / 16)
AddPathCircle (half - hw, 3*hw, hw-1, 180, 0)
FillPath ()
StrokePath (size / 16)
MovePathCursor(half - hw, 2 * hw)
AddPathLine (2 * hw, 0, #PB_Path_Relative)
StrokePath (2 * hw, #PB_Path_RoundCorner)
;arrow
VectorSourceColor(color2)
MovePathCursor(half + 2 * hw, half + hw)
AddPathLine (half + 2 * hw, half)
AddPathLine (half, half + hw)
AddPathLine (half + 2 * hw, half + 2 * hw)
ClosePath ()
FillPath ()
MovePathCursor(half + 2 * hw, half + hw)
AddPathLine (size, half + hw)
StrokePath (size / 16)
StopVectorDrawing()
EndIf
EndIf
ProcedureReturn ret
EndProcedure
Procedure.i FromClipboard (img.i, size.i, color1.i, color2.i= 0)
;[org. by Omi]
Protected ret.i
Protected hw.d= Round(size / 10.0, #PB_Round_Up), half= size / 2.0
ret= CreateImage(img, size, size, 32, #Background)
If ret
If img = #PB_Any
img= ret
EndIf
If StartVectorDrawing(ImageVectorOutput(img))
VectorSourceColor(color1)
;box
AddPathBox (hw, hw, size - 2 * hw, size - hw - size / 32)
StrokePath (size / 16, #PB_Path_DiagonalCorner)
;ring
AddPathCircle (half, hw + 1, hw, 180, 0)
StrokePath (size / 32 + 0.1)
;clamb
AddPathCircle (half + hw, 3*hw, hw-1, 180, 0)
FillPath ()
StrokePath (size / 16)
AddPathCircle (half - hw, 3*hw, hw-1, 180, 0)
FillPath ()
StrokePath (size / 16)
MovePathCursor(half - hw, 2 * hw)
AddPathLine (2 * hw, 0, #PB_Path_Relative)
StrokePath (2 * hw, #PB_Path_RoundCorner)
;arrow
VectorSourceColor(color2)
MovePathCursor(size - 2 * hw, half + hw)
AddPathLine (size - 2 * hw, half)
AddPathLine (size, half + hw)
AddPathLine (size - 2 * hw, half + 2 * hw)
ClosePath ()
FillPath ()
MovePathCursor(half, half + hw)
AddPathLine (size - 2 * hw, half + hw)
StrokePath (size / 16)
StopVectorDrawing()
EndIf
EndIf
ProcedureReturn ret
EndProcedure
Procedure.i Copy (img.i, size.i, color1.i, color2.i= 0)
;[org. by Omi]
Protected ret.i
Protected p.d= size / 32
Protected y.d= p * 4
Protected w.d= p * 20
Protected h.d= p * 24
ret= CreateImage(img, size, size, 32, #Background)
If ret
If img = #PB_Any
img= ret
EndIf
If StartVectorDrawing(ImageVectorOutput(img))
VectorSourceColor(color1)
;page 1
AddPathBox (p, p, w - 3 * p, h - y)
StrokePath (2 * p, #PB_Path_RoundCorner)
VectorSourceColor(color2)
AddPathBox (p, p, w - 3 * p, h - y)
FillPath ()
StrokePath (p)
;lines 1
VectorSourceColor(color1)
MovePathCursor( 3 * p, 6 * p)
AddPathLine (14 * p, 6 * p)
MovePathCursor( 3 * p, 9 * p)
AddPathLine ( 6 * p, 9 * p)
MovePathCursor( 3 * p, 12 * p)
AddPathLine (12 * p, 12 * p)
MovePathCursor( 3 * p, 15 * p)
AddPathLine (10 * p, 15 * p)
StrokePath (p)
;page 2
AddPathBox (14 * p, -p + 3 * y, w - 3 * p, h - y)
StrokePath (2 * p, #PB_Path_RoundCorner)
VectorSourceColor(color2)
AddPathBox (14 * p, -p + 3 * y, w - 3 * p, h - y)
FillPath ()
StrokePath (p)
;lines 2
; VectorSourceColor(RGBA(0, 0, 0, 255))
VectorSourceColor(color1)
MovePathCursor(17 * p, 16 * p)
AddPathLine (28 * p, 16 * p)
MovePathCursor(17 * p, 19 * p)
AddPathLine (20 * p, 19 * p)
MovePathCursor(17 * p, 22 * p)
AddPathLine (26 * p, 22 * p)
MovePathCursor(17 * p, 25 * p)
AddPathLine (24 * p, 25 * p)
StrokePath(p)
StopVectorDrawing()
EndIf
EndIf
ProcedureReturn ret
EndProcedure
Procedure.i Paste (img.i, size.i, color1.i, color2.i= 0)
;[org. by Omi]
Protected ret.i
Protected p.d = size / 32
Protected y.d = p * 4
Protected w.d = p * 20
Protected h.d = p * 24
Protected whalf.d= w / 2
ret= CreateImage(img, size, size, 32, #Background)
If ret
If img = #PB_Any
img= ret
EndIf
If StartVectorDrawing(ImageVectorOutput(img))
VectorSourceColor(color1)
;boardframe
AddPathBox (p, y, w, h)
StrokePath (p * 1.5, #PB_Path_DiagonalCorner)
;ring
AddPathCircle (p + w / 2, y, 2 * p, 180, 0)
StrokePath (1)
;clamb
MovePathCursor (p + whalf + whalf / 3, y)
AddPathLine (p + whalf + whalf / 3, y + 2 * p)
AddPathLine (3 * p + whalf + whalf / 3, y + 4 * p)
AddPathLine (-p + whalf - whalf / 3, y + 4 * p)
AddPathLine (p + whalf - whalf / 3, y + 2 * p)
AddPathLine (p + whalf - whalf / 3, y)
ClosePath ()
FillPath ()
;paper
AddPathBox (14 * p, -p + 3 * y, w - 3 * p, h - y)
StrokePath (2 * p, #PB_Path_RoundCorner)
VectorSourceColor(color2)
AddPathBox (14 * p, -p + 3 * y, w - 3 * p, h - y)
FillPath ()
StrokePath (p)
;lines
VectorSourceColor(color1)
MovePathCursor(17 * p, 16 * p)
AddPathLine (28 * p, 16 * p)
MovePathCursor(17 * p, 19 * p)
AddPathLine (20 * p, 19 * p)
MovePathCursor(17 * p, 22 * p)
AddPathLine (26 * p, 22 * p)
MovePathCursor(17 * p, 25 * p)
AddPathLine (24 * p, 25 * p)
StrokePath (p)
StopVectorDrawing()
EndIf
EndIf
ProcedureReturn ret
EndProcedure
Procedure.i Cut (img.i, size.i, color1.i, color2.i= 0)
;[org. by Omi]
Protected ret.i
Protected p.d = size / 32
Protected x.d = p * 4, x2.d = p * 6
Protected half.d= size / 2
ret= CreateImage(img, size, size, 32, #Background)
If ret
If img = #PB_Any
img= ret
EndIf
If StartVectorDrawing(ImageVectorOutput(img))
VectorSourceColor(color1)
;grips
AddPathEllipse (half, 26 * p, 2.5 * p, 4 * p)
StrokePath (p * 2.5)
RotateCoordinates(half, half + p, 45)
AddPathEllipse (half + p, 26 * p, 2.5 * p, 4 * p)
StrokePath (p * 2.5)
;blade diag.
MovePathCursor (half, 22 * p)
AddPathLine (half, x)
AddPathLine (half + 2 * p, x2)
AddPathLine (half + 2 * p, 22 * p)
StrokePath (p * 1.2)
;blade vert.
RotateCoordinates(half, half + p, -45)
MovePathCursor (half - p, 22 * p)
AddPathLine (half - p, x2)
AddPathLine (half + p, x)
AddPathLine (half + p, 22 * p)
StrokePath (p * 1.2)
;screw
VectorSourceColor(#Background)
AddPathCircle (half, half + 2 * p, 1 * p)
FillPath ()
ClosePath ()
StopVectorDrawing()
EndIf
EndIf
ProcedureReturn ret
EndProcedure
Macro UnRedo()
MovePathCursor(p4, p4)
AddPathArc (size - p8, p4, size - p8, size - p4, p4)
AddPathArc (size - p8, size - p4, p8, size - p4, p4)
AddPathLine (p4, size - p4)
StrokePath (p8 * 1.5)
MovePathCursor(p8, size - p4)
AddPathLine (p8 * 3, size - 2 * p4)
AddPathLine (p8 * 3, size)
ClosePath ()
FillPath ()
EndMacro
Procedure.i Undo (img.i, size.i, color1.i, color2.i= 0)
;[org. by Omi]
Protected ret.i
Protected p.d = size / 32
Protected p8.d= size / 8
Protected p4.d= size / 4
ret= CreateImage(img, size, size, 32, #Background)
If ret
If img = #PB_Any
img= ret
EndIf
If StartVectorDrawing(ImageVectorOutput(img))
VectorSourceColor(color1)
UnRedo()
StopVectorDrawing()
EndIf
EndIf
ProcedureReturn ret
EndProcedure
Procedure.i Redo (img.i, size.i, color1.i, color2.i= 0)
;[org. by Omi]
Protected ret.i
Protected p.d = size / 32
Protected p8.d= size / 8
Protected p4.d= size / 4
ret= CreateImage(img, size, size, 32, #Background)
If ret
If img = #PB_Any
img= ret
EndIf
If StartVectorDrawing(ImageVectorOutput(img))
VectorSourceColor(color1)
RotateCoordinates(size / 2, size / 2, 180)
UnRedo()
StopVectorDrawing()
EndIf
EndIf
ProcedureReturn ret
EndProcedure
#ImgFirstAid
#ImgNoEntry
#ImgStop3
#ImgToClipboard
#ImgFromClipboard
#ImgCopy
#ImgPaste
#ImgCut
#ImgUndo
#ImgRedo
Data.s "FirstAid", "NoEntry", "Stop3", "ToClipboard", "FromClipboard", "Copy", "Paste", "Cut", "Undo", "Redo"
VectorIcons::FirstAid(#ImgFirstAid, size, red, white)
VectorIcons::NoEntry(#ImgNoEntry, size, red, white)
VectorIcons::Stop3(#ImgStop3, size, red, white)
VectorIcons::ToClipboard(#ImgToClipboard, size, Blue, grey)
VectorIcons::FromClipboard(#ImgFromClipboard, size, Blue, grey)
VectorIcons::Copy(#ImgCopy, size, Blue, white)
VectorIcons::Paste(#ImgPaste, size, Blue, white)
VectorIcons::Cut(#ImgCut, size, Blue, white)
VectorIcons::Undo(#ImgUndo, size, green)
VectorIcons::Redo(#ImgRedo, size, green)
VectorIcons::FirstAid(#ImgFirstAid + #IconCount, size, lightgrey, darkwhite)
VectorIcons::NoEntry(#ImgNoEntry + #IconCount, size, lightgrey, darkwhite)
VectorIcons::Stop3(#ImgStop3 + #IconCount, size, lightgrey, darkwhite)
VectorIcons::ToClipboard(#ImgToClipboard + #IconCount, size, lightgrey, lightgrey)
VectorIcons::FromClipboard(#ImgFromClipboard + #IconCount, size, lightgrey, lightgrey)
VectorIcons::Copy(#ImgCopy + #IconCount, size, lightgrey, darkwhite)
VectorIcons::Paste(#ImgPaste + #IconCount, size, lightgrey, darkwhite)
VectorIcons::Cut(#ImgCut + #IconCount, size, lightgrey, darkwhite)
VectorIcons::Undo(#ImgUndo + #IconCount, size, lightgrey)
VectorIcons::Redo(#ImgRedo + #IconCount, size, lightgrey)