Create your own icons for toolbars etc. with PureBasic

Share your advanced PureBasic knowledge/code with the community.
Little John
Addict
Addict
Posts: 4527
Joined: Thu Jun 07, 2007 3:25 pm
Location: Berlin, Germany

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

Post by Little John »

Hi davido,

collection updated. :-)
davido
Addict
Addict
Posts: 1890
Joined: Fri Nov 09, 2012 11:04 pm
Location: Uttoxeter, UK

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

Post by davido »

Hi Little John,

I would like to add two more icons: Book and Library:

Code: Select all

Declare.i Book (file$, img.i, size.i, color1.i, color2.i, color3.i)
Declare.i Library (file$, img.i, size.i, color1.i, color2.i, color3.i,color4)

Procedure.i Book (file$, img.i, size.i, color1.i, color2.i, color3.i)
     ; file$: name of SVG file which is to be created (only supported on Linux),
     ;        or "" for creating an image in memory
     ; 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
      ;      color3: foreground color #3
      ; out: return value: if img = #Pb_Any => number of the created image,
      ;                    error => 0

      ; [by davido]
      Protected ret.i, p.d

      ret = StartVectorIconOutput(file$, img, size)

      p = size / 32.0

      If ret
        ;Lower edge
         VectorSourceColor(color2)
         MovePathCursor(2*p,14.5*p)
         AddPathLine(2*p,20.5*p)
         AddPathLine(14*p,30.5*p)
         AddPathLine(14*p,24.5*p)
         ClosePath()
         FillPath()
         ;Front edge
         VectorSourceColor(color3)
         MovePathCursor(14*p,24.5*p)
         AddPathLine(14*p,30.5*p)
         AddPathLine(30.5*p,16*p)
         AddPathLine(30.5*p,10*p)
         ClosePath()
         FillPath()
         ;Front Cover
         VectorSourceColor(color1)
         MovePathCursor(14*p,24.5*p)
         AddPathLine(31*p,10*p)
         AddPathLine(18*p,1*p)
         AddPathLine(1.6*p,14*p)
         ClosePath()
         FillPath()
         ;Back cover edges
         MovePathCursor(2*p,14*p)
         AddPathLine(2*p,20.5*p)
         AddPathLine(14*p,30.5*p)
         AddPathLine(31*p,16*p)
         StrokePath(1.0*p)
         VectorSourceColor(color2)
         MovePathCursor(15*p,7.1*p)
         AddPathLine(23*p,13.2*p)
         StrokePath(2.0*p,#PB_Path_RoundEnd)
         StopVectorDrawing()
      EndIf

      ProcedureReturn ret
   EndProcedure

   Procedure.i Library (file$, img.i, size.i, color1.i, color2.i, color3.i,color4)
     ; file$: name of SVG file which is to be created (only supported on Linux),
     ;        or "" for creating an image in memory
     ; 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
     ;      color3: foreground color #3
     ;      color3: foreground color #4
     ; out: return value: if img = #Pb_Any => number of the created image,
     ;                    error => 0
     
     ; [by davido]
     Protected ret.i, p.d
     
     ret = StartVectorIconOutput(file$, img, size)
     
     p = size / 32.0
     
     If ret
       ;Bookcase
       VectorSourceColor(color1)
       MovePathCursor(1*p,12*p)
       AddPathLine(1*p,31*p)
       AddPathLine(31*p,31*p)
       AddPathLine(31*p,12*p)
       StrokePath(2*p)
       ;Book1
       VectorSourceColor(color2)
       AddPathBox(3.5*p,8*p,5*p,21.9*p)
       FillPath()
       ;Book2
       AddPathBox(10*p,7*p,5*p,22.9*p)
       FillPath()
       SaveVectorState()
       ;Book3
       RotateCoordinates(18.5*p,16*p,-23.5)
       AddPathBox(18.5*p,7.3*p,5*p,24*p)
       FillPath()
       RestoreVectorState()
       ;Spine/cover 'hinge' book1
       VectorSourceColor(color3)
       MovePathCursor(4*p,8*p)
       AddPathLine(4*p,29.9*p)
       MovePathCursor(8*p,8*p)
       AddPathLine(8*p,29.9*p)
       ;Spine/cover 'hinge' book2
       MovePathCursor(10.5*p,7*p)
       AddPathLine(10.5*p,29.9*p)
       MovePathCursor(14.5*p,7*p)
       AddPathLine(14.5*p,29.9*p)
       ;Spine/cover 'hinge' book3
       SaveVectorState()
       RotateCoordinates(18.5*p,16*p,-23.5)
       MovePathCursor(19*p,7.3*p)
       AddPathLine(19*p,31.2*p)
       MovePathCursor(23*p,7.3*p)
       AddPathLine(23*p,31.2*p)
       StrokePath(0.25*p)
       RestoreVectorState()
       ;Add labels
       VectorSourceColor(color4)
       MovePathCursor(6*p,12*p)
       AddPathLine(6*p,18*p)
       MovePathCursor(12.5*p,12*p)
       AddPathLine(12.5*p,18*p)
       RotateCoordinates(18.5*p,16*p,-23.5)
       MovePathCursor(21*p,12*p)
       AddPathLine(21*p,18*p)
       StrokePath(1*p)
       StopVectorDrawing()
     EndIf
     
     ProcedureReturn ret
   EndProcedure
   
   , "Book", "Library"
   
      NewIcon( Book (file$, img.i, size.i, #CSS_Black, #CSS_LightGrey, #CSS_LightGoldenRodYellow))
      NewIcon( Library (file$, img.i, size.i, #CSS_SaddleBrown, #CSS_BurlyWood, #CSS_DarkGoldenRod, #CSS_Gold))
      
       NewIcon( Book (file$, img.i, size.i, #CSS_Silver, #CSS_Silver, #CSS_Silver))
      NewIcon( Library (file$, img.i, size.i, #CSS_Silver, #CSS_Silver, #CSS_Silver, #CSS_WhiteSmoke))
DE AA EB
Little John
Addict
Addict
Posts: 4527
Joined: Thu Jun 07, 2007 3:25 pm
Location: Berlin, Germany

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

Post by Little John »

Thank you, davido! Very nice. I've added the icons to the collection.
In the "disabled" version of the "Book" icon, I have replaced the last two color values with #CSS_WhiteSmoke. Is that OK?
davido
Addict
Addict
Posts: 1890
Joined: Fri Nov 09, 2012 11:04 pm
Location: Uttoxeter, UK

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

Post by davido »

Hi Little John,
I am quite happy with any changes you make to any icons that I offer for you to include in your collection.

I have a few chess icons to offer:

Code: Select all

Declare.i WhitePawn (file$, img.i, size.i, color1.i, color2.i)
Declare.i BlackPawn (file$, img.i, size.i, color1.i, color2.i)
Declare.i WhiteRook (file$, img.i, size.i, color1.i, color2.i)
Declare.i BlackRook (file$, img.i, size.i, color1.i, color2.i)
Declare.i WhiteKnight (file$, img.i, size.i, color1.i, color2.i)
Declare.i BlackKnight (file$, img.i, size.i, color1.i, color2.i)
Declare.i WhiteBishop (file$, img.i, size.i, color1.i, color2.i)
Declare.i BlackBishop (file$, img.i, size.i, color1.i, color2.i)
Declare.i WhiteKing (file$, img.i, size.i, color1.i, color2.i)
Declare.i BlackKing (file$, img.i, size.i, color1.i, color2.i)
Declare.i WhiteQueen (file$, img.i, size.i, color1.i, color2.i)
Declare.i BlackQueen (file$, img.i, size.i, color1.i, color2.i)

Procedure.i WhitePawn (file$, img.i, size.i, color1.i, color2.i)
     ; file$: name of SVG file which is to be created (only supported on Linux),
     ;        or "" for creating an image in memory
     ; 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
      ; out: return value: if img = #Pb_Any => number of the created image,
      ;                    error => 0

      ; [by davido]
      Protected ret.i, p.d

      ret = StartVectorIconOutput(file$, img, size)

      p = size / 32.0

      If ret
         VectorSourceColor(color1)
         MovePathCursor(4*p,31*p)
         AddPathLine(28*p,31*p)
         AddPathLine(28*p,22*p)
         AddPathCircle(16*p,31*p,15*p,217,251)
         AddPathCircle(16*p,31*p,15*p,289,323)
         MovePathCursor(4*p,22*p)
         AddPathLine(4*p,31*p)
         AddPathLine(6*p,31*p)
         AddPathCircle(16*p,13*p,6*p,142,233)
         AddPathCircle(16*p,13*p,6*p,305,39)
         AddPathCircle(16*p,6*p,4*p,150,30)
         StrokePath(0.5*p,#PB_Path_RoundCorner | #PB_Path_RoundEnd)
         StopVectorDrawing()
      EndIf

      ProcedureReturn ret
   EndProcedure

Procedure.i BlackPawn (file$, img.i, size.i, color1.i, color2.i)
     ; file$: name of SVG file which is to be created (only supported on Linux),
     ;        or "" for creating an image in memory
     ; 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
      ; out: return value: if img = #Pb_Any => number of the created image,
      ;                    error => 0

      ; [by davido]
      Protected ret.i, p.d

      ret = StartVectorIconOutput(file$, img, size)

      p = size / 32.0

      If ret
         VectorSourceColor(color1)
         MovePathCursor(4*p,31*p)
         AddPathLine(28*p,31*p)
         AddPathLine(28*p,22*p)
         AddPathCircle(16*p,31*p,15*p,217,323)
         MovePathCursor(4*p,22*p)
         AddPathLine(4*p,31*p)
         AddPathLine(6*p,31*p)
         AddPathCircle(16*p,13*p,6*p)
         AddPathCircle(16*p,6*p,4*p)
         StrokePath(0.5*p,#PB_Path_RoundCorner | #PB_Path_RoundEnd)
         ;Fill in black
         AddPathBox(4*p,21.9*p,24*p,9*p)
         FillPath()
         AddPathCircle(16*p,31*p,15*p,217,323)
         ClosePath()
         FillPath()
         AddPathCircle(16*p,13*p,6*p)
         FillPath()
         AddPathCircle(16*p,6*p,4*p)
         FillPath()
         StopVectorDrawing()
      EndIf

      ProcedureReturn ret
   EndProcedure

Procedure.i WhiteRook (file$, img.i, size.i, color1.i, color2.i)
     ; file$: name of SVG file which is to be created (only supported on Linux),
     ;        or "" for creating an image in memory
     ; 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
      ; out: return value: if img = #Pb_Any => number of the created image,
      ;                    error => 0

      ; [by davido]
      Protected ret.i, p.d

      ret = StartVectorIconOutput(file$, img, size)

      p = size / 32.0

      If ret
         VectorSourceColor(color1)
         AddPathBox(11*p,10*p,10*p,10*p)
         AddPathBox(5*p,28*p,22*p,3*p)
         MovePathCursor(11*p,20*p)
         AddPathLine(8*p,24*p)
         AddPathLine(8*p,28*p)
         MovePathCursor(21*p,20*p)
         AddPathLine(24*p,24*p)
         AddPathLine(24*p,28*p)
         MovePathCursor(8*p,24*p)
         AddPathLine(24*p,24*p)
         MovePathCursor(11*p,10*p)
         AddPathLine(7*p,7*p)
         AddPathLine(7*p,2*p)
         AddPathLine(11*p,2*p)
         AddPathLine(11*p,4*p)
         AddPathLine(14*p,4*p)
         AddPathLine(14*p,2*p)
         AddPathLine(18*p,2*p)
         AddPathLine(18*p,4*p)
         AddPathLine(21*p,4*p)
         AddPathLine(21*p,2*p)
         AddPathLine(25*p,2*p)
         AddPathLine(25*p,7*p)
         AddPathLine(21*p,10*p)
         MovePathCursor(7*p,7*p)
         AddPathLine(25*p,7*p)
         StrokePath(0.5*p)
         StopVectorDrawing()
      EndIf

      ProcedureReturn ret
   EndProcedure

Procedure.i BlackRook (file$, img.i, size.i, color1.i, color2.i)
     ; file$: name of SVG file which is to be created (only supported on Linux),
     ;        or "" for creating an image in memory
     ; 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
      ; out: return value: if img = #Pb_Any => number of the created image,
      ;                    error => 0

      ; [by davido]
      Protected ret.i, p.d

      ret = StartVectorIconOutput(file$, img, size)

      p = size / 32.0

      If ret
         VectorSourceColor(color1)
         AddPathBox(11*p,10*p,10*p,10*p)
         AddPathBox(5*p,28*p,22*p,3*p)
         MovePathCursor(11*p,20*p)
         AddPathLine(8*p,24*p)
         AddPathLine(8*p,28*p)
         MovePathCursor(21*p,20*p)
         AddPathLine(24*p,24*p)
         AddPathLine(24*p,28*p)
         MovePathCursor(8*p,24*p)
         AddPathLine(24*p,24*p)
         MovePathCursor(11*p,10*p)
         AddPathLine(7*p,7*p)
         AddPathLine(7*p,2*p)
         AddPathLine(11*p,2*p)
         AddPathLine(11*p,4*p)
         AddPathLine(14*p,4*p)
         AddPathLine(14*p,2*p)
         AddPathLine(18*p,2*p)
         AddPathLine(18*p,4*p)
         AddPathLine(21*p,4*p)
         AddPathLine(21*p,2*p)
         AddPathLine(25*p,2*p)
         AddPathLine(25*p,7*p)
         AddPathLine(21*p,10*p)
;          MovePathCursor(7*p,7*p)
;          AddPathLine(25*p,7*p)
         StrokePath(0.5*p)
         ;Fill in with black
         AddPathBox(11*p,10*p,10*p,10*p)
         AddPathBox(5*p,28*p,22*p,3*p)
         AddPathBox(8*p,24*p,16*p,4*p)
         MovePathCursor(8*p,24*p)
         AddPathLine(11*p,20*p)
         AddPathLine(21*p,20*p)
         AddPathLine(24*p,24*p)
         ClosePath()
         MovePathCursor(11*p,10*p)
         AddPathLine(7*p,7*p)
         AddPathLine(7*p,2*p)
         AddPathLine(11*p,2*p)
         AddPathLine(11*p,4*p)
         AddPathLine(14*p,4*p)
         AddPathLine(14*p,2*p)
         AddPathLine(18*p,2*p)
         AddPathLine(18*p,4*p)
         AddPathLine(21*p,4*p)
         AddPathLine(21*p,2*p)
         AddPathLine(25*p,2*p)
         AddPathLine(25*p,7*p)
         AddPathLine(21*p,10*p)
         FillPath()
         ;Add Lines to add 3d look
         VectorSourceColor(color2)
         MovePathCursor(8*p,27.5*p)
         AddPathLine(24*p,27.5*p)
         MovePathCursor(8.25*p,23.5*p)
         AddPathLine(23.75*p,23.5*p)
         MovePathCursor(11*p,19.5*p)
         AddPathLine(21*p,19.5*p)
         MovePathCursor(11*p,10.5*p)
         AddPathLine(21*p,10.5*p)
         MovePathCursor(7*p,7*p)
         AddPathLine(25*p,7*p)
         StrokePath(0.5*p)
         StopVectorDrawing()
      EndIf

      ProcedureReturn ret
   EndProcedure

Procedure.i WhiteKnight (file$, img.i, size.i, color1.i, color2.i)
     ; file$: name of SVG file which is to be created (only supported on Linux),
     ;        or "" for creating an image in memory
     ; 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
      ; out: return value: if img = #Pb_Any => number of the created image,
      ;                    error => 0

      ; [by davido]
      Protected ret.i, p.d

      ret = StartVectorIconOutput(file$, img, size)
      
      p = size / 32.0

      If ret
        VectorSourceColor(color1)
        MovePathCursor(9.8*p,31*p)
        AddPathLine(31*p,31*p)
        AddPathCircle(p,31*p,29.5*p,300,0)
        StrokePath(p)
        AddPathCircle(p,31*p,27.5*p,320,350)
        DashPath(0.5*p,p,#PB_Path_RoundEnd)
        MovePathCursor(16*p,5.7*p)
        AddPathLine(14*p,2*p)
        AddPathLine(12*p,5.7*p)
        AddPathLine(9*p,3*p)
        AddPathLine(9*p,7*p)
        AddPathLine(7*p,8*p)
        AddPathLine(7*p,12*p)
        AddPathLine(2.2*p,18*p)
        AddPathCircle(4.5*p,19*p,2.5*p,25,235)
        MovePathCursor(6.7*p,20*p)
        AddPathLine(6.7*p,23*p)
        AddPathLine(12*p,18*p)
        AddPathLine(16*p,13*p)
        AddPathLine(16*p,17.25*p)
        AddPathCircle(32*p,32*p,21.75*p,183,222)
        MovePathCursor(4*p,19*p)
        AddPathLine(4*p,19.5*p)
        StrokePath(p,#PB_Path_RoundCorner | #PB_Path_RoundEnd)
        AddPathEllipse(9*p,11*p,p,0.5*p)
        FillPath()
        StopVectorDrawing()
      EndIf

      ProcedureReturn ret
   EndProcedure

Procedure.i BlackKnight (file$, img.i, size.i, color1.i, color2.i)
     ; file$: name of SVG file which is to be created (only supported on Linux),
     ;        or "" for creating an image in memory
     ; 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
      ; out: return value: if img = #Pb_Any => number of the created image,
      ;                    error => 0

      ; [by davido]
      Protected ret.i, p.d

      ret = StartVectorIconOutput(file$, img, size)

      p = size / 32.0

      If ret
        VectorSourceColor(color1)
        MovePathCursor(9.8*p,31*p)
        AddPathLine(31*p,31*p)
        AddPathCircle(p,31*p,29.5*p,300,0)
        StrokePath(p)
        MovePathCursor(16*p,5.7*p)
        AddPathLine(14*p,2*p)
        AddPathLine(12*p,5.7*p)
        AddPathLine(9*p,3*p)
        AddPathLine(9*p,7*p)
        AddPathLine(7*p,8*p)
        AddPathLine(7*p,12*p)
        AddPathLine(2.2*p,18*p)
        AddPathCircle(4.5*p,19*p,2.5*p,25,235)
        MovePathCursor(6.7*p,20*p)
        AddPathLine(6.7*p,23*p)
        AddPathLine(12*p,18*p)
        AddPathLine(16*p,13*p)
        AddPathLine(16*p,17.25*p)
        AddPathCircle(32*p,32*p,21.75*p,183,222)
        StrokePath(p,#PB_Path_RoundCorner | #PB_Path_RoundEnd)
        ;Fill in body
        VectorSourceColor(color1)
        MovePathCursor(31*p,31*p)
        AddPathLine(28*p,18*p)
        AddPathLine(23.7*p,12.5*p)
        AddPathLine(15.5*p,4.9*p)
        AddPathLine(13.5*p,2.5*p)
        AddPathLine(12*p,6*p)
        AddPathLine(8.6*p,2.5*p)
        AddPathLine(8.6*p,7.5*p)
        AddPathLine(6.5*p,9*p)
        AddPathLine(6.5*p,12.5*p)
        AddPathLine(2*p,19*p)
        AddPathLine(4.25*p,22*p)
        AddPathLine(6.5*p,20.5*p)
        AddPathLine(6.5*p,23*p)
        AddPathLine(16.6*p,12.5*p)
        AddPathLine(16*p,12.2*p)
        AddPathLine(16*p,18*p)
        AddPathLine(11.5*p,23.5*p)
        AddPathLine(10*p,31*p)
        ClosePath()
        FillPath()
        AddPathCircle(16.5*p,12*p,p)
        FillPath()
        ;Add in 'Mane'
        VectorSourceColor(color2)
        AddPathCircle(p,31*p,27.5*p,320,350)
        DashPath(0.5*p,p,#PB_Path_RoundEnd)
        ;Add in Eye and Nostril
        MovePathCursor(4*p,19*p)
        AddPathLine(4*p,19.5*p)
        StrokePath(p,#PB_Path_RoundCorner | #PB_Path_RoundEnd)
        AddPathEllipse(9*p,11*p,p,0.5*p)
        FillPath()
        StopVectorDrawing()
      EndIf

      ProcedureReturn ret
   EndProcedure

Procedure.i WhiteBishop (file$, img.i, size.i, color1.i, color2.i)
     ; file$: name of SVG file which is to be created (only supported on Linux),
     ;        or "" for creating an image in memory
     ; 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
      ; out: return value: if img = #Pb_Any => number of the created image,
      ;                    error => 0

      ; [by davido]
      Protected ret.i, p.d

      ret = StartVectorIconOutput(file$, img, size)

      p = size / 32.0

      If ret
        ;Feet
         VectorSourceColor(color1)
         AddPathCircle(10*p,25*p,5.5*p,360,150)
         AddPathLine(2*p,27.8*p)
         MovePathCursor(30*p,27.8*p)
         AddPathLine(27*p,27.8*p)
         AddPathCircle(22*p,25*p,5.5*p,30,180)
         StrokePath(2.5*p,#PB_Path_RoundCorner | #PB_Path_RoundEnd)
         VectorSourceColor(color2)
         AddPathCircle(10*p,25*p,5.5*p,350,150)
         AddPathLine(2*p,27.8*p)
         MovePathCursor(30*p,27.8*p)
         AddPathLine(27*p,27.8*p)
         AddPathCircle(22*p,25*p,5.5*p,30,190)
         StrokePath(1.5*p,#PB_Path_RoundCorner | #PB_Path_RoundEnd)
         ;Base
         VectorSourceColor(color1)
         AddPathCircle(16*p,24*p,6*p,180,360)
         ClosePath()
         ;body
         AddPathCircle(16*p,13*p,7*p,120,60)
         AddPathEllipse(16*p,3.5*p,2*p,2.5*p)
         StrokePath(p)
         DrawPlus(16*p,12.5*p,3*p,1.3*p)
         StopVectorDrawing()
      EndIf

      ProcedureReturn ret
   EndProcedure

Procedure.i BlackBishop (file$, img.i, size.i, color1.i, color2.i)
     ; file$: name of SVG file which is to be created (only supported on Linux),
     ;        or "" for creating an image in memory
     ; 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
      ; out: return value: if img = #Pb_Any => number of the created image,
      ;                    error => 0

      ; [by davido]
      Protected ret.i, p.d

      ret = StartVectorIconOutput(file$, img, size)

      p = size / 32.0

      If ret
        ;Feet
         VectorSourceColor(color1)
         AddPathCircle(10*p,25*p,5.5*p,360,150)
         AddPathLine(2*p,27.8*p)
         MovePathCursor(30*p,27.8*p)
         AddPathLine(27*p,27.8*p)
         AddPathCircle(22*p,25*p,5.5*p,30,180)
         StrokePath(2.5*p,#PB_Path_RoundCorner | #PB_Path_RoundEnd)
         ;Base
         VectorSourceColor(color1)
         AddPathCircle(16*p,24.5*p,6.5*p,180,360)
         ClosePath()
         FillPath()
         ;body
         AddPathCircle(16*p,13*p,7*p,120,60)
         AddPathEllipse(16*p,3.5*p,2*p,2.5*p)
         FillPath()
         VectorSourceColor(color2)
         DrawPlus(16*p,12.5*p,3*p,2*p)
         StopVectorDrawing()
      EndIf

      ProcedureReturn ret
   EndProcedure

Procedure.i WhiteKing (file$, img.i, size.i, color1.i, color2.i)
     ; file$: name of SVG file which is to be created (only supported on Linux),
     ;        or "" for creating an image in memory
     ; 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
      ; out: return value: if img = #Pb_Any => number of the created image,
      ;                    error => 0

      ; [by davido]
      Protected ret.i, p.d

      ret = StartVectorIconOutput(file$, img, size)

      p = size / 32.0

      If ret
        SaveVectorState()
         VectorSourceColor(color1)
         RotateCoordinates(16*p,25*p,45)
         AddPathEllipse(16*p,16*p,4.5*p,8*p)
         StrokePath(P)
         RotateCoordinates(16*p,25*p,-90)
         AddPathEllipse(16*p,16*p,4.5*p,8*p)
         StrokePath(P)
         ;Base
         RestoreVectorState()
         VectorSourceColor(color2)
         AddPathBox(7*p,22*p,18*p,8*p)
         FillPath()
        VectorSourceColor(color1)
        AddPathBox(7*p,22*p,18*p,8*p)
         MovePathCursor(7*p,28*p)
         AddPathLine(25*p,28*p)
         StrokePath(p)
         ;Base decoration
         DrawPlus(10*p,25*p,1.5*p,p)
         DrawPlus(16*p,25*p,1.5*p,p)
         DrawPlus(22*p,25*p,1.5*p,p)
         ;Top
         AddPathCircle(16*p,12*p,4.5*P)
         StrokePath(p)
         DrawPlus(16*p,5*p,2.5*p,1.5*p)
         StopVectorDrawing()
      EndIf

      ProcedureReturn ret
   EndProcedure

Procedure.i BlackKing (file$, img.i, size.i, color1.i, color2.i)
     ; file$: name of SVG file which is to be created (only supported on Linux),
     ;        or "" for creating an image in memory
     ; 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
      ; out: return value: if img = #Pb_Any => number of the created image,
      ;                    error => 0

      ; [by davido]
      Protected ret.i, p.d

      ret = StartVectorIconOutput(file$, img, size)

      p = size / 32.0

      If ret
        VectorSourceColor(color1)
        SaveVectorState()
         RotateCoordinates(16*p,25*p,45)
         AddPathEllipse(16*p,16*p,5*p,8*p)
         FillPath()
         VectorSourceColor(color2)
         AddPathEllipse(16*p,16*p,3*p,6*p)
         StrokePath(0.5*p)
         VectorSourceColor(color1)
         RotateCoordinates(16*p,25*p,-90)
         AddPathEllipse(16*p,16*p,5*p,8*p)
         FillPath()
         VectorSourceColor(color2)
         AddPathEllipse(16*p,16*p,3*p,6*p)
         StrokePath(0.5*p)

         ;Base
         RestoreVectorState()
         VectorSourceColor(color1)
         AddPathBox(7*p,22*p,18*p,8*p)
         FillPath()
        VectorSourceColor(color1)
        AddPathBox(7*p,22*p,18*p,8*p)
         StrokePath(p)
         ;Base decoration
         VectorSourceColor(color2)
         DrawPlus(10*p,25*p,1.5*p,p)
         DrawPlus(16*p,25*p,1.5*p,p)
         DrawPlus(22*p,25*p,1.5*p,p)
         ;Top
         VectorSourceColor(color1)
         AddPathCircle(16*p,12*p,5*P)
         FillPath()
         VectorSourceColor(color2)
         AddPathCircle(16*p,12*p,3*P)
         StrokePath(0.5*p)
         VectorSourceColor(color1)
         DrawPlus(16*p,5*p,2.5*p,1.5*p)
         StopVectorDrawing()
      EndIf

      ProcedureReturn ret
   EndProcedure

Procedure.i WhiteQueen (file$, img.i, size.i, color1.i, color2.i)
     ; file$: name of SVG file which is to be created (only supported on Linux),
     ;        or "" for creating an image in memory
     ; 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
      ; out: return value: if img = #Pb_Any => number of the created image,
      ;                    error => 0

      ; [by davido]
      Protected ret.i, p.d

      ret = StartVectorIconOutput(file$, img, size)

      p = size / 32.0

      If ret
        ;Base
        VectorSourceColor(color1)
        AddPathBox(7*p,22*p,18*p,8*p)
         MovePathCursor(7*p,28*p)
         AddPathLine(25*p,28*p)
         StrokePath(p)
         ;Tips of crown
         AddPathCircle(3*p,7*p,2*p)
         AddPathCircle(9*p,5*p,2*p)
         AddPathCircle(16*p,4*p,2*p)
         AddPathCircle(23*p,5*p,2*p)
         AddPathCircle(29*p,7*p,2*p)
         StrokePath(p)
         ;Body of crown
         MovePathCursor(7.2*p,22.3*p)
         AddPathLine(3.5*p,8.75*p)
         StrokePath(p)
         MovePathCursor(4*p,9*p)
         AddPathLine(8*p,17*p)
         AddPathLine(9*p,6.5*p)
         StrokePath(p)
         MovePathCursor(9*p,6.75*p)
         AddPathLine(13*p,16*p)
         AddPathLine(16*p,6*p)
         StrokePath(p)
         MovePathCursor(16*p,6*p)
         AddPathLine(19*p,16*p)
         AddPathLine(22.5*p,7*p)
         StrokePath(p)
         MovePathCursor(22.5*p,7*p)
         AddPathLine(24*p,17*p)
         AddPathLine(28*p,9*p)
         StrokePath(p)
         MovePathCursor(28*p,9*p)
         AddPathLine(25*p,22*p)
         StrokePath(p)
         ;Base decoration
         MovePathCursor(16*p,24*p)
         AddPathLine(18*p,25*p)
         AddPathLine(16*p,26*p)
         AddPathLine(14*p,25*p)
         ClosePath()

         MovePathCursor(10*p,24*p)
         AddPathLine(12*p,25*p)
         AddPathLine(10*p,26*p)
         AddPathLine(8*p,25*p)
         ClosePath()
         
         MovePathCursor(22*p,24*p)
         AddPathLine(24*p,25*p)
         AddPathLine(22*p,26*p)
         AddPathLine(20*p,25*p)
         ClosePath()
         FillPath()
         StopVectorDrawing()

      EndIf

      ProcedureReturn ret
   EndProcedure

Procedure.i BlackQueen (file$, img.i, size.i, color1.i, color2.i)
     ; file$: name of SVG file which is to be created (only supported on Linux),
     ;        or "" for creating an image in memory
     ; 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
      ; out: return value: if img = #Pb_Any => number of the created image,
      ;                    error => 0

      ; [by davido]
      Protected ret.i, p.d

      ret = StartVectorIconOutput(file$, img, size)

      p = size / 32.0

      If ret
         VectorSourceColor(color1)
        AddPathBox(6.5*p,21.5*p,19*p,9*p)
        FillPath()
         ;Tips of crown
         VectorSourceColor(color1)
         AddPathCircle(3*p,7*p,2.5*p)
         AddPathCircle(9*p,5*p,2.5*p)
         AddPathCircle(16*p,4*p,2.5*p)
         AddPathCircle(23*p,5*p,2.5*p)
         AddPathCircle(29*p,7*p,2.5*p)
         FillPath()
         ;Body of crown
         MovePathCursor(7.2*p,22.3*p)
         AddPathLine(3.5*p,8.75*p)
         StrokePath(p)
         MovePathCursor(4*p,9*p)
         AddPathLine(8*p,17*p)
         AddPathLine(9*p,6.5*p)
         StrokePath(p)
         MovePathCursor(9*p,6.75*p)
         AddPathLine(13*p,16*p)
         AddPathLine(16*p,6*p)
         StrokePath(p)
         MovePathCursor(16*p,6*p)
         AddPathLine(19*p,16*p)
         AddPathLine(22.5*p,7*p)
         StrokePath(p)
         MovePathCursor(22.5*p,7*p)
         AddPathLine(24*p,17*p)
         AddPathLine(28*p,9*p)
         StrokePath(p)
         MovePathCursor(28*p,9*p)
         AddPathLine(25*p,22*p)
         StrokePath(p)
         MovePathCursor(6.5*p,20*p)
         AddPathLine(25.5*p,20*p)
         StrokePath(2*p)
         ;Base decoration
         VectorSourceColor(color2)
         MovePathCursor(16*p,24*p)
         AddPathLine(18*p,25*p)
         AddPathLine(16*p,26*p)
         AddPathLine(14*p,25*p)
         ClosePath()

         MovePathCursor(10*p,24*p)
         AddPathLine(12*p,25*p)
         AddPathLine(10*p,26*p)
         AddPathLine(8*p,25*p)
         ClosePath()
         
         MovePathCursor(22*p,24*p)
         AddPathLine(24*p,25*p)
         AddPathLine(22*p,26*p)
         AddPathLine(20*p,25*p)
         ClosePath()
         FillPath()
         StopVectorDrawing()
      EndIf

      ProcedureReturn ret
    EndProcedure
    
    "Black Pawn", "White Rook", "Black Rook", "White Knight", "Black Knight", "White Bishop", "Black Bishop", "White King"
    "Black King", "White Queen", "Black Queen"
    
    NewIcon( WhitePawn (file$, img.i, size.i, #CSS_Black, #CSS_WhiteSmoke))
NewIcon( BlackPawn (file$, img.i, size.i, #CSS_Black, #CSS_WhiteSmoke))
NewIcon( WhiteRook (file$, img.i, size.i, #CSS_Black, #CSS_WhiteSmoke))
NewIcon( BlackRook (file$, img.i, size.i, #CSS_Black, #CSS_Silver))
NewIcon( WhiteKnight (file$, img.i, size.i, #CSS_Black, #CSS_WhiteSmoke))
NewIcon( BlackKnight (file$, img.i, size.i, #CSS_Black, #CSS_WhiteSmoke))
NewIcon( WhiteBishop (file$, img.i, size.i, #CSS_Black, #CSS_WhiteSmoke))
NewIcon( BlackBishop (file$, img.i, size.i, #CSS_Black, #CSS_WhiteSmoke))
NewIcon( WhiteKing (file$, img.i, size.i, #CSS_Black, #CSS_WhiteSmoke))
NewIcon( BlackKing (file$, img.i, size.i, #CSS_Black, #CSS_WhiteSmoke))
NewIcon( WhiteQueen (file$, img.i, size.i, #CSS_Black, #CSS_WhiteSmoke))
NewIcon( BlackQueen (file$, img.i, size.i, #CSS_Black, #CSS_WhiteSmoke))

NewIcon( WhitePawn (file$, img.i, size.i, #CSS_Silver, #CSS_WhiteSmoke))
NewIcon( BlackPawn (file$, img.i, size.i, #CSS_Silver, #CSS_WhiteSmoke))
NewIcon( WhiteRook (file$, img.i, size.i, #CSS_Silver, #CSS_WhiteSmoke))
NewIcon( BlackRook (file$, img.i, size.i, #CSS_Silver, #CSS_WhiteSmoke))
NewIcon( WhiteKnight (file$, img.i, size.i, #CSS_Silver, #CSS_WhiteSmoke))
NewIcon( BlackKnight (file$, img.i, size.i, #CSS_Silver, #CSS_WhiteSmoke))
NewIcon( WhiteBishop (file$, img.i, size.i, #CSS_Silver, #CSS_WhiteSmoke))
NewIcon( BlackBishop (file$, img.i, size.i, #CSS_Silver, #CSS_WhiteSmoke))
NewIcon( WhiteKing (file$, img.i, size.i, #CSS_Silver, #CSS_WhiteSmoke))
NewIcon( BlackKing (file$, img.i, size.i, #CSS_Silver, #CSS_WhiteSmoke))
NewIcon( WhiteQueen (file$, img.i, size.i, #CSS_Silver, #CSS_WhiteSmoke))
NewIcon( BlackQueen (file$, img.i, size.i, #CSS_Silver, #CSS_WhiteSmoke))
DE AA EB
Little John
Addict
Addict
Posts: 4527
Joined: Thu Jun 07, 2007 3:25 pm
Location: Berlin, Germany

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

Post by Little John »

Hi davido,

your chess icons look fantastic :!:

I have not yet integrated them into the collection, because I realized that the "white" pieces are not really white, but transparent:

Image
Is this intended?

And I have one wish: Please only define parameters in an icon procedure that are actually used in that procedure.
For instance, the parameter 'color2' of the BlackPawn() procedure is never used, so it shouldn't be there at all.
I don't have time to take care of those things, I just stumbled over this issue by accident.
Thank you.
davido
Addict
Addict
Posts: 1890
Joined: Fri Nov 09, 2012 11:04 pm
Location: Uttoxeter, UK

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

Post by davido »

Hi Little John,
Apologies for overlooking the unused color.

Thank you for pointing out that the white pieces are transparent. :oops:
They were intended to be white with black edges to define them.
I'll go away and correct them and then re-post in a day or so.

In the meantime I have another icon to add: USB

Code: Select all

Declare.i USB (file$, img.i, size.i, color.i)

Procedure.i USB (file$, img.i, size.i, color.i)
     ; file$: name of SVG file which is to be created (only supported on Linux),
     ;        or "" for creating an image in memory
     ; in : img   : number of the image which is to be created, or #PB_Any
     ;      size  : width and height (number of pixels)
      ;      color: foreground color
      ; out: return value: if img = #Pb_Any => number of the created image,
      ;                    error => 0

      ; [by davido]
      Protected ret.i, p.d

      ret = StartVectorIconOutput(file$, img, size)

      p = size / 32.0

      If ret
         VectorSourceColor(color)
         AddPathCircle(4*p,16*p,3*p)
         AddPathCircle(20*p,11*p,2*p)
         AddPathBox(23*p,20*p,4*p,4*p)
         ;Triangle
         MovePathCursor(27*p,13*p)
         AddPathLine(31*p,16*p)
         AddPathLine(27*p,19*p)
         ClosePath()
         FillPath()
         MovePathCursor(6*p,16*p)
         AddPathLine(29*p,16*p)
         MovePathCursor(10*p,16*p)
         AddPathLine(14*p,11*p)
         AddPathLine(19*p,11*p)
         MovePathCursor(14*p,16*p)
         AddPathLine(19*p,22*p)
         AddPathLine(23*p,22*p)
         StrokePath(p,#PB_Path_RoundCorner)
         StopVectorDrawing()
      EndIf

      ProcedureReturn ret
    EndProcedure
    
    "USB"
    
    NewIcon( USB (file$, img.i, size.i, #CSS_Black))
    
    NewIcon( USB (file$, img.i, size.i, #CSS_Silver))
DE AA EB
Little John
Addict
Addict
Posts: 4527
Joined: Thu Jun 07, 2007 3:25 pm
Location: Berlin, Germany

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

Post by Little John »

Hi davido,

I've added your "USB" icon to the collection.
davido
Addict
Addict
Posts: 1890
Joined: Fri Nov 09, 2012 11:04 pm
Location: Uttoxeter, UK

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

Post by davido »

Hi Little John,
I've repaired and improved my offering of the chess pieces.
Thank you for seeing through my inept previous attempt. :oops:

Code: Select all

Declare.i WhitePawn (file$, img.i, size.i, color1.i, color2.i)
Declare.i BlackPawn (file$, img.i, size.i, color1.i, color2.i)
Declare.i WhiteRook (file$, img.i, size.i, color1.i, color2.i)
Declare.i BlackRook (file$, img.i, size.i, color1.i, color2.i)
Declare.i WhiteKnight (file$, img.i, size.i, color1.i, color2.i)
Declare.i BlackKnight (file$, img.i, size.i, color1.i, color2.i)
Declare.i WhiteBishop (file$, img.i, size.i, color1.i, color2.i)
Declare.i BlackBishop (file$, img.i, size.i, color1.i, color2.i)
Declare.i WhiteKing (file$, img.i, size.i, color1.i, color2.i)
Declare.i BlackKing (file$, img.i, size.i, color1.i, color2.i)
Declare.i WhiteQueen (file$, img.i, size.i, color1.i, color2.i)
Declare.i BlackQueen (file$, img.i, size.i, color1.i, color2.i)

Procedure.i WhitePawn (file$, img.i, size.i, color1.i, color2.i)
     ; file$: name of SVG file which is to be created (only supported on Linux),
     ;        or "" for creating an image in memory
     ; 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
      ; out: return value: if img = #Pb_Any => number of the created image,
      ;                    error => 0

      ; [by davido]
      Protected ret.i, p.d

      ret = StartVectorIconOutput(file$, img, size)

      p = size / 32.0

      If ret
         VectorSourceColor(color1)
         MovePathCursor(4*p,31*p)
         AddPathLine(28*p,31*p)
         AddPathLine(28*p,22*p)
         AddPathCircle(16*p,31*p,15*p,217,251)
         AddPathCircle(16*p,31*p,15*p,289,323)
         MovePathCursor(4*p,22*p)
         AddPathLine(4*p,31*p)
         AddPathLine(6*p,31*p)
         AddPathCircle(16*p,13*p,6*p,142,233)
         AddPathCircle(16*p,13*p,6*p,305,39)
         AddPathCircle(16*p,6*p,4*p,150,30)
         StrokePath(1*p,#PB_Path_RoundCorner | #PB_Path_RoundEnd)
         ;Fill in white
         VectorSourceColor(color2)
         AddPathBox(4*p,21.9*p,24*p,9*p)
         FillPath()
         AddPathCircle(16*p,31*p,15*p,217,323)
         ClosePath()
         FillPath()
         AddPathCircle(16*p,13*p,6*p)
         FillPath()
         AddPathCircle(16*p,6*p,4*p)
         FillPath()
         StopVectorDrawing()
      EndIf

      ProcedureReturn ret
   EndProcedure

Procedure.i BlackPawn (file$, img.i, size.i, color1.i, color2.i)
     ; file$: name of SVG file which is to be created (only supported on Linux),
     ;        or "" for creating an image in memory
     ; 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
      ; out: return value: if img = #Pb_Any => number of the created image,
      ;                    error => 0

      ; [by davido]
      Protected ret.i, p.d

      ret = StartVectorIconOutput(file$, img, size)

      p = size / 32.0

      If ret
         VectorSourceColor(color1)
         MovePathCursor(4*p,31*p)
         AddPathLine(28*p,31*p)
         AddPathLine(28*p,22*p)
         AddPathCircle(16*p,31*p,15*p,217,323)
         MovePathCursor(4*p,22*p)
         AddPathLine(4*p,31*p)
         AddPathLine(6*p,31*p)
         AddPathCircle(16*p,13*p,6*p)
         AddPathCircle(16*p,6*p,4*p)
         StrokePath(0.5*p,#PB_Path_RoundCorner | #PB_Path_RoundEnd)
         ;Fill in black
         AddPathBox(4*p,21.9*p,24*p,9*p)
         FillPath()
         AddPathCircle(16*p,31*p,15*p,217,323)
         ClosePath()
         FillPath()
         AddPathCircle(16*p,13*p,6*p)
         FillPath()
         AddPathCircle(16*p,6*p,4*p)
         FillPath()
         StopVectorDrawing()
      EndIf

      ProcedureReturn ret
   EndProcedure

Procedure.i WhiteRook (file$, img.i, size.i, color1.i, color2.i)
     ; file$: name of SVG file which is to be created (only supported on Linux),
     ;        or "" for creating an image in memory
     ; 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
      ; out: return value: if img = #Pb_Any => number of the created image,
      ;                    error => 0

      ; [by davido]
      Protected ret.i, p.d

      ret = StartVectorIconOutput(file$, img, size)

      p = size / 32.0

      If ret
         VectorSourceColor(color1)
         AddPathBox(11*p,10*p,10*p,10*p)
         AddPathBox(5*p,28*p,22*p,3*p)
         MovePathCursor(11*p,20*p)
         AddPathLine(8*p,24*p)
         AddPathLine(8*p,28*p)
         MovePathCursor(21*p,20*p)
         AddPathLine(24*p,24*p)
         AddPathLine(24*p,28*p)
         MovePathCursor(8*p,24*p)
         AddPathLine(24*p,24*p)
         ;Add in the castellations
         MovePathCursor(11*p,10*p)
         AddPathLine(7*p,7*p)
         AddPathLine(7*p,2*p)
         AddPathLine(11*p,2*p)
         AddPathLine(11*p,4*p)
         AddPathLine(14*p,4*p)
         AddPathLine(14*p,2*p)
         AddPathLine(18*p,2*p)
         AddPathLine(18*p,4*p)
         AddPathLine(21*p,4*p)
         AddPathLine(21*p,2*p)
         AddPathLine(25*p,2*p)
         AddPathLine(25*p,7*p)
         AddPathLine(21*p,10*p)
         MovePathCursor(7*p,7*p)
         AddPathLine(25*p,7*p)
         StrokePath(1*p)

         StrokePath(0.5*p)
         ;Fill in with white
         VectorSourceColor(color2)
         AddPathBox(11*p,10*p,10*p,10*p)
         AddPathBox(5*p,28*p,22*p,3*p)
         AddPathBox(8*p,24*p,16*p,4*p)
         MovePathCursor(8*p,24*p)
         AddPathLine(11*p,20*p)
         AddPathLine(21*p,20*p)
         AddPathLine(24*p,24*p)
         ClosePath()
         MovePathCursor(11*p,10*p)
         AddPathLine(7*p,7*p)
         AddPathLine(7*p,2*p)
         AddPathLine(11*p,2*p)
         AddPathLine(11*p,4*p)
         AddPathLine(14*p,4*p)
         AddPathLine(14*p,2*p)
         AddPathLine(18*p,2*p)
         AddPathLine(18*p,4*p)
         AddPathLine(21*p,4*p)
         AddPathLine(21*p,2*p)
         AddPathLine(25*p,2*p)
         AddPathLine(25*p,7*p)
         AddPathLine(21*p,10*p)
         FillPath()
         ;Add Lines to add 3d look
         VectorSourceColor(color1)
         MovePathCursor(8*p,27.5*p)
         AddPathLine(24*p,27.5*p)
         MovePathCursor(8.25*p,23.5*p)
         AddPathLine(23.75*p,23.5*p)
         MovePathCursor(11*p,19.5*p)
         AddPathLine(21*p,19.5*p)
         MovePathCursor(11*p,10.5*p)
         AddPathLine(21*p,10.5*p)
         MovePathCursor(7*p,7*p)
         AddPathLine(25*p,7*p)
         StrokePath(0.5*p)
         StopVectorDrawing()
      EndIf

      ProcedureReturn ret
   EndProcedure

Procedure.i BlackRook (file$, img.i, size.i, color1.i, color2.i)
     ; file$: name of SVG file which is to be created (only supported on Linux),
     ;        or "" for creating an image in memory
     ; 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
      ; out: return value: if img = #Pb_Any => number of the created image,
      ;                    error => 0

      ; [by davido]
      Protected ret.i, p.d

      ret = StartVectorIconOutput(file$, img, size)

      p = size / 32.0

      If ret
         VectorSourceColor(color1)
         AddPathBox(11*p,10*p,10*p,10*p)
         AddPathBox(5*p,28*p,22*p,3*p)
         MovePathCursor(11*p,20*p)
         AddPathLine(8*p,24*p)
         AddPathLine(8*p,28*p)
         MovePathCursor(21*p,20*p)
         AddPathLine(24*p,24*p)
         AddPathLine(24*p,28*p)
         MovePathCursor(8*p,24*p)
         AddPathLine(24*p,24*p)
         ;Add in the castellations
         MovePathCursor(11*p,10*p)
         AddPathLine(7*p,7*p)
         AddPathLine(7*p,2*p)
         AddPathLine(11*p,2*p)
         AddPathLine(11*p,4*p)
         AddPathLine(14*p,4*p)
         AddPathLine(14*p,2*p)
         AddPathLine(18*p,2*p)
         AddPathLine(18*p,4*p)
         AddPathLine(21*p,4*p)
         AddPathLine(21*p,2*p)
         AddPathLine(25*p,2*p)
         AddPathLine(25*p,7*p)
         AddPathLine(21*p,10*p)
         StrokePath(0.5*p)
         ;Fill in with black
         AddPathBox(11*p,10*p,10*p,10*p)
         AddPathBox(5*p,28*p,22*p,3*p)
         AddPathBox(8*p,24*p,16*p,4*p)
         MovePathCursor(8*p,24*p)
         AddPathLine(11*p,20*p)
         AddPathLine(21*p,20*p)
         AddPathLine(24*p,24*p)
         ClosePath()
         MovePathCursor(11*p,10*p)
         AddPathLine(7*p,7*p)
         AddPathLine(7*p,2*p)
         AddPathLine(11*p,2*p)
         AddPathLine(11*p,4*p)
         AddPathLine(14*p,4*p)
         AddPathLine(14*p,2*p)
         AddPathLine(18*p,2*p)
         AddPathLine(18*p,4*p)
         AddPathLine(21*p,4*p)
         AddPathLine(21*p,2*p)
         AddPathLine(25*p,2*p)
         AddPathLine(25*p,7*p)
         AddPathLine(21*p,10*p)
         FillPath()
         ;Add Lines to add 3d look
         VectorSourceColor(color2)
         MovePathCursor(8*p,27.5*p)
         AddPathLine(24*p,27.5*p)
         MovePathCursor(8.25*p,23.5*p)
         AddPathLine(23.75*p,23.5*p)
         MovePathCursor(11*p,19.5*p)
         AddPathLine(21*p,19.5*p)
         MovePathCursor(11*p,10.5*p)
         AddPathLine(21*p,10.5*p)
         MovePathCursor(7*p,7*p)
         AddPathLine(25*p,7*p)
         StrokePath(1*p)
         StopVectorDrawing()
      EndIf

      ProcedureReturn ret
   EndProcedure

Procedure.i WhiteKnight (file$, img.i, size.i, color1.i, color2.i)
     ; file$: name of SVG file which is to be created (only supported on Linux),
     ;        or "" for creating an image in memory
     ; 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
      ; out: return value: if img = #Pb_Any => number of the created image,
      ;                    error => 0

      ; [by davido]
      Protected ret.i, p.d

      ret = StartVectorIconOutput(file$, img, size)
      
      p = size / 32.0

      If ret
        ;Draw the body
        VectorSourceColor(color1)
        AddPathCircle(32*p,32*p,21.75*p,183,222)
        AddPathLine(PathCursorX(),13*p)
        AddPathLine(12*p,18*p)
        AddPathLine(6.7*p,23*p)
        AddPathLine(6.7*p,20*p)
        AddPathCircle(4.5*p,19*p,2.5*p,25,235,#PB_Path_Connected)
        AddPathLine(7*p,12*p)
        AddPathLine(7*p,8*p)
        AddPathLine(9*p,7*p)
        AddPathLine(9*p,3*p)
        AddPathLine(12*p,5.7*p)
        AddPathLine(14*p,2*p)
        AddPathLine(16*p,5.7*p)
        AddPathCircle(p,31*p,29.5*p,301.5,0,#PB_Path_Connected)
        AddPathLine(10.25*p,PathCursorY())
        StrokePath(p,#PB_Path_RoundCorner | #PB_Path_RoundEnd)

;         ;Fill in body
         VectorSourceColor(color2)
        AddPathCircle(32*p,32*p,21.75*p,183,222)
        AddPathLine(PathCursorX(),13*p)
        AddPathLine(12*p,18*p)
        AddPathLine(6.7*p,23*p)
        AddPathLine(6.7*p,20*p)
        AddPathCircle(4.5*p,19*p,2.5*p,25,235,#PB_Path_Connected)
        AddPathLine(7*p,12*p)
        AddPathLine(7*p,8*p)
        AddPathLine(9*p,7*p)
        AddPathLine(9*p,3*p)
        AddPathLine(12*p,5.7*p)
        AddPathLine(14*p,2*p)
        AddPathLine(16*p,5.7*p)
        AddPathCircle(p,31*p,29.5*p,301.5,0,#PB_Path_Connected)
        AddPathLine(10.25*p,PathCursorY())
        FillPath()
        ;Add in 'Mane'
        VectorSourceColor(color1)
        AddPathCircle(p,31*p,27.5*p,320,350)
        DashPath(0.5*p,p,#PB_Path_RoundEnd)
        ;Add in Eye and Nostril
        MovePathCursor(4*p,19*p)
        AddPathLine(4*p,19.5*p)
        StrokePath(1.5*p,#PB_Path_RoundCorner | #PB_Path_RoundEnd)
        AddPathEllipse(9*p,11*p,p,1*p)
        FillPath()
        StopVectorDrawing()
      EndIf

      ProcedureReturn ret
   EndProcedure

Procedure.i BlackKnight (file$, img.i, size.i, color1.i, color2.i)
     ; file$: name of SVG file which is to be created (only supported on Linux),
     ;        or "" for creating an image in memory
     ; 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
      ; out: return value: if img = #Pb_Any => number of the created image,
      ;                    error => 0

      ; [by davido]
      Protected ret.i, p.d

      ret = StartVectorIconOutput(file$, img, size)

      p = size / 32.0

      If ret
        ;Draw the body
        VectorSourceColor(color1)
        AddPathCircle(32*p,32*p,21.75*p,183,222)
        AddPathLine(PathCursorX(),13*p)
        AddPathLine(12*p,18*p)
        AddPathLine(6.7*p,23*p)
        AddPathLine(6.7*p,20*p)
        AddPathCircle(4.5*p,19*p,2.5*p,25,235,#PB_Path_Connected)
        AddPathLine(7*p,12*p)
        AddPathLine(7*p,8*p)
        AddPathLine(9*p,7*p)
        AddPathLine(9*p,3*p)
        AddPathLine(12*p,5.7*p)
        AddPathLine(14*p,2*p)
        AddPathLine(16*p,5.7*p)
        AddPathCircle(p,31*p,29.5*p,301.5,0,#PB_Path_Connected)
        AddPathLine(10.25*p,PathCursorY())
        StrokePath(p,#PB_Path_RoundCorner | #PB_Path_RoundEnd)

        ;Fill in body
        AddPathCircle(32*p,32*p,21.75*p,183,222)
        AddPathLine(PathCursorX(),13*p)
        AddPathLine(12*p,18*p)
        AddPathLine(6.7*p,23*p)
        AddPathLine(6.7*p,20*p)
        AddPathCircle(4.5*p,19*p,2.5*p,25,235,#PB_Path_Connected)
        AddPathLine(7*p,12*p)
        AddPathLine(7*p,8*p)
        AddPathLine(9*p,7*p)
        AddPathLine(9*p,3*p)
        AddPathLine(12*p,5.7*p)
        AddPathLine(14*p,2*p)
        AddPathLine(16*p,5.7*p)
        AddPathCircle(p,31*p,29.5*p,301.5,0,#PB_Path_Connected)
        AddPathLine(10.25*p,PathCursorY())
        FillPath()
        ;Add in 'Mane'
        VectorSourceColor(color2)
        AddPathCircle(p,31*p,27.5*p,320,350)
        DashPath(0.5*p,p,#PB_Path_RoundEnd)
        ;Add in Eye and Nostril
        MovePathCursor(4*p,19*p)
        AddPathLine(4*p,19.5*p)
        StrokePath(1.5*p,#PB_Path_RoundCorner | #PB_Path_RoundEnd)
        AddPathEllipse(9*p,11*p,p,1*p)
        FillPath()
        StopVectorDrawing()
      EndIf

      ProcedureReturn ret
   EndProcedure

Procedure.i WhiteBishop (file$, img.i, size.i, color1.i, color2.i)
     ; file$: name of SVG file which is to be created (only supported on Linux),
     ;        or "" for creating an image in memory
     ; 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
      ; out: return value: if img = #Pb_Any => number of the created image,
      ;                    error => 0

      ; [by davido]
      Protected ret.i, p.d

      ret = StartVectorIconOutput(file$, img, size)

      p = size / 32.0

      If ret
        ;Feet
         VectorSourceColor(color1)
         AddPathCircle(10*p,25*p,5.5*p,360,150)
         AddPathLine(2*p,27.8*p)
         MovePathCursor(30*p,27.8*p)
         AddPathLine(27*p,27.8*p)
         AddPathCircle(22*p,25*p,5.5*p,30,180)
         StrokePath(2.5*p,#PB_Path_RoundCorner | #PB_Path_RoundEnd)
         VectorSourceColor(color2)
         AddPathCircle(10*p,25*p,5.5*p,350,150)
         AddPathLine(2*p,27.8*p)
         MovePathCursor(30*p,27.8*p)
         AddPathLine(27*p,27.8*p)
         AddPathCircle(22*p,25*p,5.5*p,30,190)
         StrokePath(1.5*p,#PB_Path_RoundCorner | #PB_Path_RoundEnd)
         ;Base
         VectorSourceColor(color1)
         AddPathCircle(16*p,24*p,6*p,180,360)
         ClosePath()
         StrokePath(p)
         VectorSourceColor(color2)
         AddPathCircle(16*p,24*p,6*p,180,360)
         ClosePath()
         FillPath()
         ;body
         VectorSourceColor(color1)
         AddPathCircle(16*p,13*p,7*p,120,60)
         StrokePath(p)
         VectorSourceColor(color2)
         AddPathCircle(16*p,13*p,7*p,120,60)
         FillPath()
         VectorSourceColor(color1)
         AddPathEllipse(16*p,3.5*p,2*p,2.5*p)
         StrokePath(p)
         VectorSourceColor(color2)
         AddPathEllipse(16*p,3.5*p,2*p,2.5*p)
         FillPath()
         VectorSourceColor(color1)
         DrawPlus(16*p,12.5*p,3*p,1.3*p)
         StopVectorDrawing()
      EndIf

      ProcedureReturn ret
   EndProcedure

Procedure.i BlackBishop (file$, img.i, size.i, color1.i, color2.i)
     ; file$: name of SVG file which is to be created (only supported on Linux),
     ;        or "" for creating an image in memory
     ; 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
      ; out: return value: if img = #Pb_Any => number of the created image,
      ;                    error => 0

      ; [by davido]
      Protected ret.i, p.d

      ret = StartVectorIconOutput(file$, img, size)

      p = size / 32.0

      If ret
        ;Feet
         VectorSourceColor(color1)
         AddPathCircle(10*p,25*p,5.5*p,360,150)
         AddPathLine(2*p,27.8*p)
         MovePathCursor(30*p,27.8*p)
         AddPathLine(27*p,27.8*p)
         AddPathCircle(22*p,25*p,5.5*p,30,180)
         StrokePath(2.5*p,#PB_Path_RoundCorner | #PB_Path_RoundEnd)
         ;Base
         VectorSourceColor(color1)
         AddPathCircle(16*p,24.5*p,6.5*p,180,360)
         ClosePath()
         FillPath()
         ;body
         AddPathCircle(16*p,13*p,7*p,120,60)
         AddPathEllipse(16*p,3.5*p,2*p,2.5*p)
         FillPath()
         
         VectorSourceColor(color2)
         DrawPlus(16*p,12.5*p,3*p,2*p)
         StopVectorDrawing()
      EndIf

      ProcedureReturn ret
   EndProcedure

Procedure.i WhiteKing (file$, img.i, size.i, color1.i, color2.i)
     ; file$: name of SVG file which is to be created (only supported on Linux),
     ;        or "" for creating an image in memory
     ; 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
      ; out: return value: if img = #Pb_Any => number of the created image,
      ;                    error => 0

      ; [by davido]
      Protected ret.i, p.d

      ret = StartVectorIconOutput(file$, img, size)

      p = size / 32.0

      If ret
        ;Body - right side
        VectorSourceColor(color1)
        SaveVectorState()
        RotateCoordinates(16*p,25*p,45)
        AddPathEllipse(16*p,16*p,5*p,8*p)
        StrokePath(0.5*p)
        VectorSourceColor(color2)
        AddPathEllipse(16*p,16*p,5*p,8*p)
        FillPath()
        VectorSourceColor(color1)
        AddPathEllipse(16*p,16*p,3*p,6*p)
        StrokePath(0.5*p)
        ;Body - left side
        VectorSourceColor(color1)
        RotateCoordinates(16*p,25*p,-90)
        AddPathEllipse(16*p,16*p,5*p,8*p)
        StrokePath(0.5*p)
        VectorSourceColor(color2)
        AddPathEllipse(16*p,16*p,5*p,8*p)
        FillPath()
        VectorSourceColor(color1)
        AddPathEllipse(16*p,16*p,3*p,6*p)
        StrokePath(0.5*p)
        RestoreVectorState()
        VectorSourceColor(color2)
        AddPathBox(14.75*p,19*p,2*p,3*p)
        FillPath()
 
        ;Base
        VectorSourceColor(color1)
        AddPathBox(6*p,22*p,20*p,8*p)
        StrokePath(0.5*p)
        VectorSourceColor(color2)
        AddPathBox(6*p,22*p,20*p,8*p)
        FillPath()
        ;Base decoration
        VectorSourceColor(color1)
        DrawPlus(10*p,25*p,1.5*p,p)
        DrawPlus(16*p,25*p,1.5*p,p)
        DrawPlus(22*p,25*p,1.5*p,p)
        MovePathCursor(7*p,28.5*p)
        AddPathLine(25*p,28.5*p)
        StrokePath(0.5*p)
        ;Top
        VectorSourceColor(color1)
        AddPathCircle(16*p,11.5*p,4.5*P)
        FillPath()
        VectorSourceColor(color2)
        AddPathCircle(16*p,11.5*p,4*P)
        FillPath()
        VectorSourceColor(color1)
        AddPathCircle(16*p,11.5*p,2.5*P)
        StrokePath(0.5*p)
        DrawPlus(16*p,5*p,2.5*p,1.5*p)
        VectorSourceColor(color2)
        DrawPlus(16*p,5*p,2.0*p,0.5*p)
        StopVectorDrawing()
      EndIf

      ProcedureReturn ret
   EndProcedure

Procedure.i BlackKing (file$, img.i, size.i, color1.i, color2.i)
     ; file$: name of SVG file which is to be created (only supported on Linux),
     ;        or "" for creating an image in memory
     ; 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
      ; out: return value: if img = #Pb_Any => number of the created image,
      ;                    error => 0

      ; [by davido]
      Protected ret.i, p.d

      ret = StartVectorIconOutput(file$, img, size)

      p = size / 32.0

      If ret
        VectorSourceColor(color1)
        SaveVectorState()
        RotateCoordinates(16*p,25*p,45)
        AddPathEllipse(16*p,16*p,5*p,8*p)
        FillPath()
        VectorSourceColor(color2)
        AddPathEllipse(16*p,16*p,3*p,6*p)
        StrokePath(1*p)
        VectorSourceColor(color1)
        RotateCoordinates(16*p,25*p,-90)
        AddPathEllipse(16*p,16*p,5*p,8*p)
        FillPath()
        VectorSourceColor(color2)
        AddPathEllipse(16*p,16*p,3*p,6*p)
        StrokePath(1*p)
        
        ;Base
        RestoreVectorState()
        VectorSourceColor(color1)
        AddPathBox(6*p,22*p,20*p,8*p)
        FillPath()
        VectorSourceColor(color1)
        AddPathBox(6*p,22*p,20*p,8*p)
        StrokePath(p)
        ;Base decoration
        VectorSourceColor(color2)
        DrawPlus(10*p,25*p,2*p,p)
        DrawPlus(16*p,25*p,2*p,p)
        DrawPlus(22*p,25*p,2*p,p)

        MovePathCursor(7*p,28.5*p)
        AddPathLine(25*p,28.5*p)
        StrokePath(1*p)
        ;Top
        VectorSourceColor(color1)
        AddPathCircle(16*p,11.5*p,4.75*P)
        FillPath()
        VectorSourceColor(color2)
        AddPathCircle(16*p,11.5*p,2.5*P)
        StrokePath(0.5*p)
        VectorSourceColor(color1)
        DrawPlus(16*p,5*p,2.5*p,1.5*p)
        StopVectorDrawing()
      EndIf

      ProcedureReturn ret
   EndProcedure

Procedure.i WhiteQueen (file$, img.i, size.i, color1.i, color2.i)
     ; file$: name of SVG file which is to be created (only supported on Linux),
     ;        or "" for creating an image in memory
     ; 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
      ; out: return value: if img = #Pb_Any => number of the created image,
      ;                    error => 0

      ; [by davido]
      Protected ret.i, p.d

      ret = StartVectorIconOutput(file$, img, size)

      p = size / 32.0

      If ret
        ;Base
        VectorSourceColor(color1)
        AddPathBox(7*p,22*p,18*p,8*p)
        MovePathCursor(7*p,28*p)
        AddPathLine(25*p,28*p)
        StrokePath(p)
        ;Body of crown
        VectorSourceColor(color1)
        MovePathCursor(7.2*p,22.3*p)
        AddPathLine(3.5*p,8.75*p)
        AddPathLine(8*p,17*p)
        AddPathLine(9*p,6.5*p)
        AddPathLine(13*p,16*p)
        AddPathLine(16*p,6*p)
        AddPathLine(19*p,16*p)
        AddPathLine(22.5*p,7*p)
        AddPathLine(24*p,17*p)
        AddPathLine(28*p,9*p)
        AddPathLine(25*p,22*p)
        StrokePath(p)
        VectorSourceColor(color2)
        MovePathCursor(7.2*p,22.3*p)
        AddPathLine(3.5*p,8.75*p)
        AddPathLine(8*p,17*p)
        AddPathLine(9*p,6.5*p)
        AddPathLine(13*p,16*p)
        AddPathLine(16*p,6*p)
        AddPathLine(19*p,16*p)
        AddPathLine(22.5*p,7*p)
        AddPathLine(24*p,17*p)
        AddPathLine(28*p,9*p)
        AddPathLine(25*p,22*p)
        FillPath()
        ;Tips of crown
        VectorSourceColor(color1)
        AddPathCircle(3*p,7*p,2*p)
        AddPathCircle(9*p,5*p,2*p)
        AddPathCircle(16*p,4*p,2*p)
        AddPathCircle(23*p,5*p,2*p)
        AddPathCircle(29*p,7*p,2*p)
        StrokePath(p)
        VectorSourceColor(color2)
        AddPathCircle(3*p,7*p,2*p)
        AddPathCircle(9*p,5*p,2*p)
        AddPathCircle(16*p,4*p,2*p)
        AddPathCircle(23*p,5*p,2*p)
        AddPathCircle(29*p,7*p,2*p)
        FillPath()
        ;Base decoration
        VectorSourceColor(color1)
        MovePathCursor(7*p,20*p)
        AddPathLine(25*p,20*p)
        StrokePath(p)
        
        MovePathCursor(16*p,24*p)
        AddPathLine(18*p,25*p)
        AddPathLine(16*p,26*p)
        AddPathLine(14*p,25*p)
        ClosePath()
        
        MovePathCursor(10*p,24*p)
        AddPathLine(12*p,25*p)
        AddPathLine(10*p,26*p)
        AddPathLine(8*p,25*p)
        ClosePath()
        
        MovePathCursor(22*p,24*p)
        AddPathLine(24*p,25*p)
        AddPathLine(22*p,26*p)
        AddPathLine(20*p,25*p)
        ClosePath()
        FillPath()
        StopVectorDrawing()

      EndIf

      ProcedureReturn ret
   EndProcedure

Procedure.i BlackQueen (file$, img.i, size.i, color1.i, color2.i)
     ; file$: name of SVG file which is to be created (only supported on Linux),
     ;        or "" for creating an image in memory
     ; 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
      ; out: return value: if img = #Pb_Any => number of the created image,
      ;                    error => 0

      ; [by davido]
      Protected ret.i, p.d

      ret = StartVectorIconOutput(file$, img, size)

      p = size / 32.0

      If ret
        VectorSourceColor(color1)
        AddPathBox(6.5*p,21.5*p,19*p,9*p)
        FillPath()
        ;Tips of crown
        VectorSourceColor(color1)
        AddPathCircle(3*p,7*p,2.5*p)
        AddPathCircle(9*p,5*p,2.5*p)
        AddPathCircle(16*p,4*p,2.5*p)
        AddPathCircle(23*p,5*p,2.5*p)
        AddPathCircle(29*p,7*p,2.5*p)
        FillPath()
        ;Body of crown
        VectorSourceColor(color1)
        MovePathCursor(7.2*p,22.3*p)
        AddPathLine(3.5*p,8.75*p)
        AddPathLine(8*p,17*p)
        AddPathLine(9*p,6.5*p)
        AddPathLine(13*p,16*p)
        AddPathLine(16*p,6*p)
        AddPathLine(19*p,16*p)
        AddPathLine(22.5*p,7*p)
        AddPathLine(24*p,17*p)
        AddPathLine(28*p,9*p)
        AddPathLine(25*p,22*p)
        StrokePath(p)
        MovePathCursor(7.2*p,22.3*p)
        AddPathLine(3.5*p,8.75*p)
        AddPathLine(8*p,17*p)
        AddPathLine(9*p,6.5*p)
        AddPathLine(13*p,16*p)
        AddPathLine(16*p,6*p)
        AddPathLine(19*p,16*p)
        AddPathLine(22.5*p,7*p)
        AddPathLine(24*p,17*p)
        AddPathLine(28*p,9*p)
        AddPathLine(25*p,22*p)
        FillPath()
        ;Base decoration
        VectorSourceColor(color2)
        MovePathCursor(7*p,20*p)
        AddPathLine(25*p,20*p)
        MovePathCursor(7*p,29*p)
        AddPathLine(25*p,29*p)
        StrokePath(1.3*p)
        MovePathCursor(16*p,24*p)
        AddPathLine(18*p,25*p)
        AddPathLine(16*p,26*p)
        AddPathLine(14*p,25*p)
        ClosePath()
        
        MovePathCursor(10*p,24*p)
        AddPathLine(12*p,25*p)
        AddPathLine(10*p,26*p)
        AddPathLine(8*p,25*p)
        ClosePath()
        
        MovePathCursor(22*p,24*p)
        AddPathLine(24*p,25*p)
        AddPathLine(22*p,26*p)
        AddPathLine(20*p,25*p)
        ClosePath()
        FillPath()
        StopVectorDrawing()
      EndIf

      ProcedureReturn ret
    EndProcedure
    
 "White Pawn", "Black Pawn", "White Rook", "Black Rook", "White Knight", "Black Knight"
 "White Bishop", "Black Bishop", "White King" "Black King", "White Queen", "Black Queen"
 
NewIcon( WhitePawn (file$, img.i, size.i, #CSS_Black, #CSS_WhiteSmoke))
NewIcon( BlackPawn (file$, img.i, size.i, #CSS_Black, #CSS_WhiteSmoke))
NewIcon( WhiteRook (file$, img.i, size.i, #CSS_Black, #CSS_WhiteSmoke))
NewIcon( BlackRook (file$, img.i, size.i, #CSS_Black, #CSS_Silver))
NewIcon( WhiteKnight (file$, img.i, size.i, #CSS_Black, #CSS_WhiteSmoke))
NewIcon( BlackKnight (file$, img.i, size.i, #CSS_Black, #CSS_WhiteSmoke))
NewIcon( WhiteBishop (file$, img.i, size.i, #CSS_Black, #CSS_WhiteSmoke))
NewIcon( BlackBishop (file$, img.i, size.i, #CSS_Black, #CSS_WhiteSmoke))
NewIcon( WhiteKing (file$, img.i, size.i, #CSS_Black, #CSS_WhiteSmoke))
NewIcon( BlackKing (file$, img.i, size.i, #CSS_Black, #CSS_WhiteSmoke))
NewIcon( WhiteQueen (file$, img.i, size.i, #CSS_Black, #CSS_WhiteSmoke))
NewIcon( BlackQueen (file$, img.i, size.i, #CSS_Black, #CSS_WhiteSmoke))

NewIcon( WhitePawn (file$, img.i, size.i, #CSS_Silver, #CSS_WhiteSmoke))
NewIcon( BlackPawn (file$, img.i, size.i, #CSS_Silver, #CSS_WhiteSmoke))
NewIcon( WhiteRook (file$, img.i, size.i, #CSS_Silver, #CSS_WhiteSmoke))
NewIcon( BlackRook (file$, img.i, size.i, #CSS_Silver, #CSS_WhiteSmoke))
NewIcon( WhiteKnight (file$, img.i, size.i, #CSS_Silver, #CSS_WhiteSmoke))
NewIcon( BlackKnight (file$, img.i, size.i, #CSS_Silver, #CSS_WhiteSmoke))
NewIcon( WhiteBishop (file$, img.i, size.i, #CSS_Silver, #CSS_WhiteSmoke))
NewIcon( BlackBishop (file$, img.i, size.i, #CSS_Silver, #CSS_WhiteSmoke))
NewIcon( WhiteKing (file$, img.i, size.i, #CSS_Silver, #CSS_WhiteSmoke))
NewIcon( BlackKing (file$, img.i, size.i, #CSS_Silver, #CSS_WhiteSmoke))
NewIcon( WhiteQueen (file$, img.i, size.i, #CSS_Silver, #CSS_WhiteSmoke))
NewIcon( BlackQueen (file$, img.i, size.i, #CSS_Silver, #CSS_WhiteSmoke))
DE AA EB
Little John
Addict
Addict
Posts: 4527
Joined: Thu Jun 07, 2007 3:25 pm
Location: Berlin, Germany

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

Post by Little John »

Thank you, davido!
I'll update the collection as soon as possible.
davido
Addict
Addict
Posts: 1890
Joined: Fri Nov 09, 2012 11:04 pm
Location: Uttoxeter, UK

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

Post by davido »

Hi Little John,

I have another couple of icons to add: History and Danger!

Code: Select all

Declare.i History (file$, img.i, size.i, color1.i, color2.i, color3.i, color4.i)
Declare.i Danger (file$, img.i, size.i, color1.i, color2.i)

Procedure.i History (file$, img.i, size.i, color1.i, color2.i, color3.i, color4.i)
     ; file$: name of SVG file which is to be created (only supported on Linux),
     ;        or "" for creating an image in memory
     ; 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
      ;      color3: foreground color #3
      ;      color4: foreground color #4
      ; out: return value: if img = #Pb_Any => number of the created image,
      ;                    error => 0

      ; [by davido]
      Protected ret.i, p.d

      ret = StartVectorIconOutput(file$, img, size)

      p = size / 32.0

      If ret
        ;White centre
        VectorSourceColor(color4)
        AddPathCircle(16*p,16*p,13*p)
        FillPath()
         VectorSourceColor(color2)
         AddPathCircle(16*p,16*p,13*p,270,150)
         StrokePath(3*p)
         ;Minutehand
         MovePathCursor(13*p,17*p)
         AddPathLine(19*p,17*p)
         AddPathLine(16*p,6*p)
         ClosePath()
         FillPath()
         ;Hourhand
         MovePathCursor(13.5*p,13.5*p)
         AddPathLine(13.5*p,18.5*p)
         AddPathLine(24*p,16*p)
         ClosePath()
         FillPath()
         AddPathCircle(16*p,16*p,3.5*p)
         FillPath()
         VectorSourceColor(color3)
         AddPathCircle(16*p,16*p,13*p,150,270)
         StrokePath(3*p)
         MovePathCursor(7.5*p,22*p)
         AddPathLine(2.75*p,23.5*p)
         AddPathLine(6.25*p,24.55*p)
         ClosePath()
         FillPath()
         MovePathCursor(7.5*p,21.25 *p)
         AddPathLine(2.5*p,23.5*p)
         AddPathLine(6.25*p,24.25*p)
         ClosePath()
         StrokePath(1.2*p)
         VectorSourceColor(color1)
         AddPathCircle(16*p,16*p,1.5*p)
         FillPath()
         StopVectorDrawing()
      EndIf

      ProcedureReturn ret
   EndProcedure

Procedure.i Danger (file$, img.i, size.i, color1.i, color2.i)
     ; file$: name of SVG file which is to be created (only supported on Linux),
     ;        or "" for creating an image in memory
     ; in : img   : number of the image which is to be created, or #PB_Any
     ;      size  : width and height (number of pixels)
      ;      color: foreground color
      ; out: return value: if img = #Pb_Any => number of the created image,
      ;                    error => 0

      ; [by davido]
      Protected ret.i, p.d

      ret = StartVectorIconOutput(file$, img, size)

      p = size / 32.0

      If ret
        VectorSourceColor(color1)
        AddPathCircle(16*p,8*p,7*p,200,340)
        AddPathLine(PathCursorX(),12*p)
        AddPathLine(20*p,15*p)
        AddPathLine(19*p,17*p)
        AddPathLine(13*p,17*p)
        AddPathLine(12*p,15*p)
        AddPathLine(9.5*p,12*p)
        AddPathLine(9.5*p,5*p)
        StrokePath(2*p,#PB_Path_RoundCorner)
        AddPathCircle(16*p,8*p,7*p,200,340)
        AddPathLine(PathCursorX(),12*p)
        AddPathLine(20*p,15*p)
        AddPathLine(19*p,17*p)
        AddPathLine(13*p,17*p)
        AddPathLine(12*p,15*p)
        AddPathLine(9.5*p,12*p)
        AddPathLine(9.5*p,5*p)
        FillPath()
        ;Eyes and Nose
        VectorSourceColor(color2)
        AddPathEllipse(12.5*p,9*p,2.5*p,1.5*p)
        AddPathEllipse(20*p,9*p,2.5*p,1.5*p)
        AddPathEllipse(16*p,14*p,1.2*p,2*p)
        FillPath()
        ;Crossed bones
        VectorSourceColor(color1)
        RotateCoordinates(16*p,22*p,25)
         MovePathCursor(4*p,22*p)
         AddPathLine(29*p,22*p)
         StrokePath(3*p)
         AddPathCircle(4*p,20.5*p,1.5*p)
         AddPathCircle(29*p,20.5*p,1.5*p)
         FillPath()
         AddPathCircle(4*p,23.5*p,2*p)
         AddPathCircle(29*p,23.5*p,2*p)
         FillPath()
        RotateCoordinates(16*p,22*p,-50)
         MovePathCursor(4*p,22*p)
         AddPathLine(29*p,22*p)
         StrokePath(3*p)
         AddPathCircle(4*p,20.5*p,1.5*p)
         AddPathCircle(29*p,20.5*p,1.5*p)
         FillPath()
         AddPathCircle(4*p,23.5*p,2*p)
         AddPathCircle(29*p,23.5*p,2*p)
         FillPath()
         StopVectorDrawing()
      EndIf

      ProcedureReturn ret
    EndProcedure
    
    "History", "Danger"
    
    
NewIcon( History (file$, img.i, size.i, #CSS_Black, #CSS_SteelBlue, #CSS_OrangeRed, #CSS_WhiteSmoke))
NewIcon( Danger (file$, img.i, size.i, #CSS_Black, #CSS_WhiteSmoke))

NewIcon( History (file$, img.i, size.i, #CSS_DarkGrey, #CSS_Grey, #CSS_Silver, #CSS_White))
NewIcon( Danger (file$, img.i, size.i, #CSS_Silver, #CSS_WhiteSmoke))
DE AA EB
Little John
Addict
Addict
Posts: 4527
Joined: Thu Jun 07, 2007 3:25 pm
Location: Berlin, Germany

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

Post by Little John »

Hi davido,

I just included your most recent 14 icons in the collection. Great!
Personally, I especially love your chess icons. Thank you!
User avatar
Fangbeast
PureBasic Protozoa
PureBasic Protozoa
Posts: 4749
Joined: Fri Apr 25, 2003 3:08 pm
Location: Not Sydney!!! (Bad water, no goats)

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

Post by Fangbeast »

You blokes are lean, mean icon machines. Puts anything I ever did to shame:):)
Amateur Radio, D-STAR/VK3HAF
Little John
Addict
Addict
Posts: 4527
Joined: Thu Jun 07, 2007 3:25 pm
Location: Berlin, Germany

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

Post by Little John »

Small change in the demo code in order to work around this bug
http://www.purebasic.fr/english/viewtop ... 23&t=65712
User avatar
VB6_to_PBx
Enthusiast
Enthusiast
Posts: 625
Joined: Mon May 09, 2011 9:36 am

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

Post by VB6_to_PBx »

Little John ,

This is a great thing you created ,

although i'm not good enough yet with enough experience with the VectorDrawing library ,

i have a wish someone would create Weather Icons to add to your List
 
PureBasic .... making tiny electrons do what you want !

"With every mistake we must surely be learning" - George Harrison
davido
Addict
Addict
Posts: 1890
Joined: Fri Nov 09, 2012 11:04 pm
Location: Uttoxeter, UK

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

Post by davido »

Hi Little John,

Thank you for your kind words regarding my chess icons.
Having seen some code by oma which used #PB_Path_Preserve. It occurred to me that I could remove some duplicated code in a few of the 'Chess' icons.
It is probably of no matter, but I could re-post if you wish.

I have another icon to add, if I may: The Sun

Code: Select all

Declare.i TheSun (file$, img.i, size.i, color.i, color2.i)

   Procedure.i TheSun (file$, img.i, size.i, color1.i, color2.i)
     ; file$: name of SVG file which is to be created (only supported on Linux),
     ;        or "" for creating an image in memory
     ; 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
     ; out: return value: if img = #Pb_Any => number of the created image,
     ;                    error => 0
     
     ; [by davido]
     Protected ret.i, p.d, M.i
     
     ret = StartVectorIconOutput(file$, img, size)
     
     p = size / 32.0
     
     If ret
       VectorSourceColor(color1)
       FillVectorOutput()
       VectorSourceColor(color2)
       AddPathCircle(16*p,16*p,7*p)
       FillPath()
       For M = 1 To 10
         MovePathCursor(16*p,3*p)
         AddPathLine(16*p,8*p)
         RotateCoordinates(16*p,16*p,36)
       Next M
       StrokePath(2*p,#PB_Path_RoundEnd)
       StopVectorDrawing()
     EndIf
     
     ProcedureReturn ret
   EndProcedure
   
   "The Sun"
   
   NewIcon( TheSun (file$, img.i, size.i, #CSS_LightSkyBlue, #CSS_Gold))
   
   NewIcon( TheSun (file$, img.i, size.i, #CSS_WhiteSmoke, #CSS_Silver))
@VB6_to_PBx ,

Did you have any particular 'Weather' icons in mind?
Perhaps the icon above, "The Sun" might be a good start?
DE AA EB
Post Reply