Re: Create your own icons for toolbars etc. with PureBasic
Posted: Sun Mar 20, 2016 11:23 pm
A few more icons: AlignLeft, AlignCentre, AlignRight & AlignJustify
Code: Select all
Procedure.i Icon_AlignLeft (img.i, size.i, color.i)
; in : img : number of the image which is to be created, or #PB_Any
; size : number of pixels (width and height)
; color: foreground color of the image (background is transparent)
; out: return value: if img = #Pb_Any => number of the created image,
; error => 0
Protected.i ret.i, w.d, p.d
w = size / 8
p = size / 32
ret = CreateImage(img, size, size, 32, #PB_Image_Transparent)
If img = #PB_Any
img = ret
EndIf
If ret And StartVectorDrawing(ImageVectorOutput(img))
VectorSourceColor(color)
MovePathCursor(4*p,2*p)
AddPathLine(24*p,2*p)
MovePathCursor(4*p,9*p)
AddPathLine(12*p,9*p)
MovePathCursor(4*p,16*p)
AddPathLine(16*p,16*p)
MovePathCursor(4*p,23*p)
AddPathLine(12*p,23*p)
MovePathCursor(4*p,30*p)
AddPathLine(24*p,30*p)
StrokePath(p*2)
StopVectorDrawing()
EndIf
ProcedureReturn ret
EndProcedure
Procedure.i Icon_AlignCentre (img.i, size.i, color.i)
; in : img : number of the image which is to be created, or #PB_Any
; size : number of pixels (width and height)
; color: foreground color of the image (background is transparent)
; out: return value: if img = #Pb_Any => number of the created image,
; error => 0
Protected.i ret.i, w.d, p.d
w = size / 8
p = size / 32
ret = CreateImage(img, size, size, 32, #PB_Image_Transparent)
If img = #PB_Any
img = ret
EndIf
If ret And StartVectorDrawing(ImageVectorOutput(img))
VectorSourceColor(color)
MovePathCursor(6*p,2*p)
AddPathLine(26*p,2*p)
MovePathCursor(12*p,9*p)
AddPathLine(20*p,9*p)
MovePathCursor(10*p,16*p)
AddPathLine(22*p,16*p)
MovePathCursor(12*p,23*p)
AddPathLine(20*p,23*p)
MovePathCursor(6*p,30*p)
AddPathLine(26*p,30*p)
StrokePath(p*2)
StopVectorDrawing()
EndIf
ProcedureReturn ret
EndProcedure
Procedure.i Icon_AlignRight (img.i, size.i, color.i)
; in : img : number of the image which is to be created, or #PB_Any
; size : number of pixels (width and height)
; color: foreground color of the image (background is transparent)
; out: return value: if img = #Pb_Any => number of the created image,
; error => 0
Protected.i ret.i, p.d
p = size / 32
ret = CreateImage(img, size, size, 32, #PB_Image_Transparent)
If img = #PB_Any
img = ret
EndIf
If ret And StartVectorDrawing(ImageVectorOutput(img))
VectorSourceColor(color)
MovePathCursor(8*p,2*p)
AddPathLine(28*p,2*p)
MovePathCursor(20*p,9*p)
AddPathLine(28*p,9*p)
MovePathCursor(16*p,16*p)
AddPathLine(28*p,16*p)
MovePathCursor(20*p,23*p)
AddPathLine(28*p,23*p)
MovePathCursor(8*p,30*p)
AddPathLine(28*p,30*p)
StrokePath(p*2)
StopVectorDrawing()
EndIf
ProcedureReturn ret
EndProcedure
Procedure.i Icon_AlignJustify (img.i, size.i, color.i)
; in : img : number of the image which is to be created, or #PB_Any
; size : number of pixels (width and height)
; color: foreground color of the image (background is transparent)
; out: return value: if img = #Pb_Any => number of the created image,
; error => 0
Protected.i ret.i, w.d, p.d
w = size / 8
p = size / 32
ret = CreateImage(img, size, size, 32, #PB_Image_Transparent)
If img = #PB_Any
img = ret
EndIf
If ret And StartVectorDrawing(ImageVectorOutput(img))
VectorSourceColor(color)
MovePathCursor(4*p,2*p)
AddPathLine(28*p,2*p)
MovePathCursor(4*p,9*p)
AddPathLine(28*p,9*p)
MovePathCursor(4*p,16*p)
AddPathLine(28*p,16*p)
MovePathCursor(4*p,23*p)
AddPathLine(28*p,23*p)
MovePathCursor(4*p,30*p)
AddPathLine(28*p,30*p)
StrokePath(p*2)
StopVectorDrawing()
EndIf
ProcedureReturn ret
EndProcedure