Page 4 of 18

Re: Create your own icons for toolbars etc. with PureBasic

Posted: Sun Mar 20, 2016 11:23 pm
by davido
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

Re: Create your own icons for toolbars etc. with PureBasic

Posted: Mon Mar 21, 2016 7:16 am
by Little John
davido wrote:A few more icons: AlignLeft, AlignCentre, AlignRight & AlignJustify
Included.

Re: Create your own icons for toolbars etc. with PureBasic

Posted: Mon Mar 21, 2016 2:47 pm
by blueb
Great stuff, Little John :D

Might be a little easier if the ''default" was the current directory + an icon sub-folder.

e.g.

Code: Select all

                 Case btnSave
                        path$ = PathRequester("Choose path for saving the image files", GetCurrentDirectory())
                            ; Create sub-directory to hold icons.
                              CreateDirectory("Icons") 
                            ; Make this the current directory
                              SetCurrentDirectory(path$+"\Icons")
                              path$ = GetCurrentDirectory()
Thanks again.

Re: Create your own icons for toolbars etc. with PureBasic

Posted: Mon Mar 21, 2016 8:58 pm
by Little John
blueb wrote:Great stuff, Little John :D

You are welcome!
blueb wrote:Might be a little easier if the ''default" was the current directory + an icon sub-folder.
The icons are now saved in a separate sub-folder. Thanks for the good suggestion!
blueb wrote:e.g.

Code: Select all

                 Case btnSave
                        path$ = PathRequester("Choose path for saving the image files", GetCurrentDirectory())
                            ; Create sub-directory to hold icons.
                              CreateDirectory("Icons") 
                            ; Make this the current directory
                              SetCurrentDirectory(path$+"\Icons")
                              path$ = GetCurrentDirectory()
I implemented it the following way (Set/GetCurrentDirectory() wouldn't give an additional benefit IMHO):

Code: Select all

                     path$ = PathRequester("Choose path where to create new directory for the icon files.", GetHomeDirectory())
                     If path$ <> ""
                        path$ + "vectoricons"
                        [...]
                        CreateDirectory(path$)

Other changes
  • added: colour "gold"
  • added: five-pointed star icon aka "favourite"

Re: Create your own icons for toolbars etc. with PureBasic

Posted: Mon Mar 21, 2016 11:15 pm
by davido
@Little John,
I am listing the code for an Options Icon.
I was working on a 5 star favourite icon. :)

Code: Select all

   Procedure.i Icon_Options (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, h.d
   h = size/2
   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)
     AddPathBox(5*p,1*p,5*p,5*p)
     FillPath()
     MovePathCursor(12*p,4*p)
     AddPathLine(25*p,4*p)
     StrokePath(p)
     AddPathBox(5*p,13*p,5*p,5*p)
     FillPath()
     MovePathCursor(12*p,16*p)
     AddPathLine(25*p,16*p)
     StrokePath(p)
          AddPathBox(5*p,25*p,5*p,5*p)
     FillPath()
     MovePathCursor(12*p,27*p)
     AddPathLine(25*p,27*p)
     StrokePath(p)

     StopVectorDrawing()
   EndIf
   
   ProcedureReturn ret
 EndProcedure  
Also the code for a Compile and Compile Run Icons:

Code: Select all

 Macro Cog()
   MovePathCursor(px-3*p,py+p)
   AddPathLine(px-2*p,py)
   AddPathLine(px-p,py-3*p)
   AddPathLine(px+p,py-3*p)
   AddPathLine(px+2*p,py)
   AddPathLine(px+3*p,py+p)
 EndMacro

 Procedure.i Icon_Compile (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, d.d, p.d, h.d, M.i, px.d, py.d
   
   h = size/2
   p = size / 32
   d = 11*p
   px=h
   py=h-d

   
   ret = CreateImage(img, size, size, 32, #PB_Image_Transparent)
   If img = #PB_Any
     img = ret
   EndIf
   
   If ret And StartVectorDrawing(ImageVectorOutput(img))
     VectorSourceColor(color)
     AddPathCircle(h,h,d,30,330)
     AddPathCircle(h,h,5*p,30,330)
     ResetCoordinates()
     Cog()
     For M = 1 To 7
       RotateCoordinates(h,h,45)
       If M <> 2
         Cog()
       EndIf
     Next M
     StrokePath(p*3)
     StopVectorDrawing()
   EndIf
   
   ProcedureReturn ret
 EndProcedure 
 
  Procedure.i Icon_CompileRun (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, d.d, p.d, h.d, M.i, px.d, py.d
   
   h = size/2
   p = size / 32
   d = 11*p
   px=h
   py=h-d
   
   ret = CreateImage(img, size, size, 32, #PB_Image_Transparent)
   If img = #PB_Any
     img = ret
   EndIf
   
   If ret And StartVectorDrawing(ImageVectorOutput(img))
     VectorSourceColor(color)
     AddPathCircle(h,h,d,30,330)
     MovePathCursor(10*p,16*p)
     AddPathLine(28*p,16*p)
     MovePathCursor(20*p,13*p)
     AddPathLine(20*p,19*p)
     AddPathLine(31*p,16*p)
     ClosePath()
     Cog()
     For M = 1 To 7
       RotateCoordinates(h,h,45)
        If M<> 2
         Cog()
        EndIf 
     Next M

     StrokePath(p*3)

     StopVectorDrawing()
   EndIf
   
   ProcedureReturn ret
 EndProcedure 

Re: Create your own icons for toolbars etc. with PureBasic

Posted: Tue Mar 22, 2016 9:10 am
by Fangbeast
The way this is going, I might end up with a fulls et of icons for my recipe program soon:):) Bloody brilliant (Old Australian expression)

Re: Create your own icons for toolbars etc. with PureBasic

Posted: Tue Mar 22, 2016 2:29 pm
by deanathpc
I love what I'm seeing here. But dumb question for all of you. Are there detail instructions if you will on how to implement this? For us new folks who haven't done this before.

Re: Create your own icons for toolbars etc. with PureBasic

Posted: Tue Mar 22, 2016 4:19 pm
by infratec
Example:

Code: Select all

Enumeration
  #ImgMediaBegin
  #ImgMediaFastBack
  #ImgMediaBack
  #ImgMediaPlay
  #ImgMediaStop
  #ImgMediaForward
  #ImgMediaFastForward
  #ImgMediaEnd
EndEnumeration
  

#Size = 40

IncludeFile "VectorIcons.pbi"

blue = RGBA(32, 32, 128, 255)

VectorIcons::MediaPlay(#ImgMediaPlay, #Size, blue)
VectorIcons::MediaStop(#ImgMediaStop, #Size, blue)
VectorIcons::MediaBegin(#ImgMediaBegin, #Size, blue)
VectorIcons::MediaEnd(#ImgMediaEnd, #Size, blue)
VectorIcons::MediaForward(#ImgMediaForward, #Size, blue)
VectorIcons::MediaFastForward(#ImgMediaFastForward, #Size, blue)
VectorIcons::MediaBack(#ImgMediaBack, #Size, blue)
VectorIcons::MediaFastBack(#ImgMediaFastBack, #Size, blue)

OpenWindow(0, 0, 0, 400, 300, "VectorIcon Example", #PB_Window_SystemMenu|#PB_Window_ScreenCentered)

For i = #ImgMediaBegin To #ImgMediaEnd
  ButtonImageGadget(i, (i - #ImgMediaBegin) * #Size, 0, #Size, #Size, ImageID(i))
Next i

Repeat : Until WaitWindowEvent() = #PB_Event_CloseWindow
!!! Attention !!! Alpha needed !
I only used #Blue and searched for half an hour why the image was not on the button :oops:

Bernd

Re: Create your own icons for toolbars etc. with PureBasic

Posted: Tue Mar 22, 2016 5:47 pm
by davido
@Little John,
Thank you for the PM regarding the format of Icon code.
I have re-posted the last three which I hope will be satisfactory.

Code: Select all


Declare.i Compile (img.i, size.i, color1.i, color2.i=0)
Declare.i CompileRun (img.i, size.i, color1.i, color2.i=0)
Declare.i Options (img.i, size.i, color1.i, color2.i=0)


Macro Cog()
  MovePathCursor(px-3*p,py+p)
  AddPathLine(px-2*p,py)
  AddPathLine(px-p,py-3*p)
  AddPathLine(px+p,py-3*p)
  AddPathLine(px+2*p,py)
  AddPathLine(px+3*p,py+p)
EndMacro

Procedure.i Compile (img.i, size.i, color1.i, color2.i=0)
  ; in : img   : number of the image which is to be created, or #PB_Any
  ;      size  : width and height (number of pixels)
  ;      color1: foreground color #1
  ;      color2: foreground color #2 (default = 0: 100% transparent)
  ; out: return value: if img = #Pb_Any => number of the created image,
  ;                    error => 0
  ; [by davido]
  Protected.i ret.i, d.d, p.d, h.d, M.i, px.d, py.d
  
  h = size/2
  p = size / 32
  d = 11*p
  px=h
  py=h-d
  
  ret = CreateImage(img, size, size, 32, #PB_Image_Transparent)
  If img = #PB_Any
    img = ret
  EndIf
  
  If ret And StartVectorDrawing(ImageVectorOutput(img))
    VectorSourceColor(color1)
    AddPathCircle(h,h,d,30,330)
    AddPathCircle(h,h,5*p,30,330)
    ResetCoordinates()
    Cog()
    For M = 1 To 7
      RotateCoordinates(h,h,45)
      If M <> 2
        Cog()
      EndIf
    Next M
    StrokePath(p*3)
    StopVectorDrawing()
  Else
    FreeImage(img)
    ret = 0
  EndIf
  
  ProcedureReturn ret
EndProcedure

Procedure.i CompileRun (img.i, size.i, color1.i, color2.i=0)
  ; in : img   : number of the image which is to be created, or #PB_Any
  ;      size  : width and height (number of pixels)
  ;      color1: foreground color #1
  ;      color2: foreground color #2 (default = 0: 100% transparent)
  ; out: return value: if img = #Pb_Any => number of the created image,
  ;                    error => 0
  ; [by davido]
  Protected.i ret.i, d.d, p.d, h.d, M.i, px.d, py.d
  
  h = size/2
  p = size / 32
  d = 11*p
  px=h
  py=h-d
  
  ret = CreateImage(img, size, size, 32, #PB_Image_Transparent)
  If img = #PB_Any
    img = ret
  EndIf
  
  If ret And StartVectorDrawing(ImageVectorOutput(img))
    VectorSourceColor(color1)
    AddPathCircle(h,h,d,30,330)
    MovePathCursor(10*p,16*p)
    AddPathLine(28*p,16*p)
    MovePathCursor(20*p,13*p)
    AddPathLine(20*p,19*p)
    AddPathLine(31*p,16*p)
    ClosePath()
    Cog()
    For M = 1 To 7
      RotateCoordinates(h,h,45)
      If M<> 2
        Cog()
      EndIf 
    Next M
    
    StrokePath(p*3)
    
    StopVectorDrawing()
  Else
    FreeImage(img)
    ret = 0
  EndIf
  
  ProcedureReturn ret
EndProcedure

Procedure.i Options (img.i, size.i, color1.i, color2.i=0)
  ; in : img   : number of the image which is to be created, or #PB_Any
  ;      size  : width and height (number of pixels)
  ;      color1: foreground color #1
  ;      color2: foreground color #2 (default = 0: 100% transparent)
  ; out: return value: if img = #Pb_Any => number of the created image,
  ;                    error => 0
  ; [by davido]
  Protected.i ret.i, p.d, h.d
  h = size/2
  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(color1)
    AddPathBox(5*p,1*p,5*p,5*p)
    FillPath()
    MovePathCursor(12*p,4*p)
    AddPathLine(25*p,4*p)
    StrokePath(p)
    AddPathBox(5*p,13*p,5*p,5*p)
    FillPath()
    MovePathCursor(12*p,16*p)
    AddPathLine(25*p,16*p)
    StrokePath(p)
    AddPathBox(5*p,25*p,5*p,5*p)
    FillPath()
    MovePathCursor(12*p,27*p)
    AddPathLine(25*p,27*p)
    StrokePath(p)
    
    StopVectorDrawing()
  Else
    FreeImage(img)
    ret = 0
  EndIf
  
  ProcedureReturn ret
EndProcedure

#ImgCompile
#ImgCompileRun
#ImgOptions

"compile", "compilerun", "Options",

VectorIcons::Compile(#ImgCompile, size, blue)
VectorIcons::CompileRun(#ImgCompileRun, size, blue)
VectorIcons::Options(#ImgOptions, size, blue)

VectorIcons::Compile(#ImgCompile + #IconCount, size, lightgrey)
VectorIcons::CompileRun(#ImgCompileRun + #IconCount, size, lightgrey)
VectorIcons::Options(#ImgOptions + #IconCount, size, lightgrey)

Re: Create your own icons for toolbars etc. with PureBasic

Posted: Wed Mar 23, 2016 12:30 am
by Little John
Hi davido,

thank you for your recent icons! I've added them to the collection.

The source code is too big now for posting it on the forum.
I have left just one procedure here as example, the full source code is now in a ZIP file in my Dropbox (download link in the first post).
davido wrote:@Little John,
Thank you for the PM regarding the format of Icon code.
I have re-posted the last three which I hope will be satisfactory.
This is not exactly what I meant. :-)
For instance, I do not use #PB_Image_Transparent inside the procedures anymore.
Also, I do not use the line

Code: Select all

If ret And StartVectorDrawing(ImageVectorOutput(img))
anymore.

I were grateful if you could use the "Add()" procedure in the code in the first post as template for future contributions.

By the way: I think a complete cog without anything inside would be a good "Settings" icon.
I wanted to create something like that, but this time you were faster. :-)

Re: Create your own icons for toolbars etc. with PureBasic

Posted: Wed Mar 23, 2016 4:14 pm
by Little John
Fangbeast wrote:The way this is going, I might end up with a fulls et of icons for my recipe program soon:):)
I don't know whether your collection contains any receipes for hot drinks. At least you have an icon for that category now. :-)
The icon can also be used with the meaning "make a pause". E.g. I know a statistics program that offers a "pause" option. After choosing that option, you can play a little game.

Re: Create your own icons for toolbars etc. with PureBasic

Posted: Wed Mar 23, 2016 5:42 pm
by Oma
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. :wink:

Contains icons for ...
- NoEntry
- Stop (another one)
- ToClipboard (more as a dummy)
- FromClipboard ( ")
- Copy
- Paste
- Cut
- Undo
- Redo

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)

Best Regards,
Charly

Re: Create your own icons for toolbars etc. with PureBasic

Posted: Wed Mar 23, 2016 6:16 pm
by Little John
Hi Charly,

I just took a quick look, and I'm very impressed. Many thanks for those beautiful and useful icons!

But this is how the Undo/Redo icons look on my system (Windows):
<image removed>
There seems to be something wrong.
I'll include your icons into the collection ASAP when I've got a bit more time.

Re: Create your own icons for toolbars etc. with PureBasic

Posted: Thu Mar 24, 2016 12:04 am
by davido
Hi Little John,

Thank you your patience!
I shall use the 'Add Procedure' as my template in future.

I had intended to post 3 of those posted by oma. :)
On reflection, however, it is good that others are adding to the list.

I'll post the 'Select Icon' to which you referred and possibly others if I haven't been anticipated.

Do you have problems with more than 2 colours?

Re: Create your own icons for toolbars etc. with PureBasic

Posted: Thu Mar 24, 2016 12:31 am
by StarBootics
Little John wrote:But this is how the Undo/Redo icons look on my system (Windows):
Image
There seems to be something wrong.
It's probably a Bug in the Windows version because here on Ubuntu Gnome they look right.

Best regards
StarBootics