Page 5 of 18

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

Posted: Thu Mar 24, 2016 5:38 am
by Oma
Thank you, Little John :)
But this is how the Undo/Redo icons look on my system (Windows):
[Image]
There seems to be something wrong.
Yes, you're right starbootics. It has to do with this windows bugreport http://www.purebasic.fr/english/viewtop ... =4&t=63582
A small workaround within Macro UnRedo() seems to work on my Win XP ...

Code: Select all

	Macro UnRedo()
		MovePathCursor(p4, p4)
		AddPathArc    (size - p8, p4, size - p8, size - p4, p8)
		AddPathArc    (size - p8, size - p4, p8, size - p4-0.01, p8); workaround for windows
		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
Best Regards, Charly
ps:
I had anyway a hard fight with "AddPathArc". Through this bug, i saw the first time, that the Windows Help PB got a few clarifying graphic :evil: :D

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

Posted: Thu Mar 24, 2016 7:47 am
by Little John
davido wrote:Do you have problems with more than 2 colours?
No, not at all. Please feel free to use additional parameters or an array for the colour values.
Oma wrote:It has to do with this windows bugreport http://www.purebasic.fr/english/viewtop ... =4&t=63582
A small workaround within Macro UnRedo() seems to work on my Win XP ...
Ooops. I wasn't aware of that bug.
Thank you for the code with the workaround.
I'm currently still short of time, so I'll post the updated collection this afternoon.

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

Posted: Thu Mar 24, 2016 8:45 pm
by davido
Hi Little John,

I would like to add four more Icons:
Toggle
Toggle1
Save
Settings

Code: Select all

Declare.i Toggle (img.i, size.i, color.i, color1.i=0, color2.i=0)
Declare.i Toggle1 (img.i, size.i, color.i, color1.i=0, color2.i=0)
Declare.i Save (img.i, size.i, color.i)
Declare.i Settings (img.i, size.i, color.i)

Procedure.i Settings (img.i, size.i, color.i)
  ; 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, 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, #Background)
  
  If ret
    If img = #PB_Any
      img = ret
    EndIf
    
    If StartVectorDrawing(ImageVectorOutput(img))
      VectorSourceColor(color)
      
      AddPathCircle(h, h, d)
      ResetCoordinates()
      Cog()
      For M = 1 To 7
        RotateCoordinates(h, h, 45)
        Cog()
      Next M
      StrokePath(3*p)
      
      StopVectorDrawing()
    Else
      FreeImage(img)
      ret = 0
    EndIf
  EndIf
  
  ProcedureReturn ret
EndProcedure

Procedure.i Toggle (img.i, size.i, color.i, color1.i=0, color2.i=0)
  ; 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, w.i, half.d
  
  w = Int(size / 3.0) - (size % 3)
  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(color)
      AddPathBox(2,2,30,12)
      FillPath()
      VectorSourceColor(color2)
      AddPathCircle(8,8,4)
      FillPath()
      VectorSourceColor(color1)
      AddPathBox(2,18,30,12)
      FillPath()
      VectorSourceColor(color2)
      AddPathCircle(24,24,4)
      FillPath()
      
      StopVectorDrawing()
    Else
      FreeImage(img)
      ret = 0
    EndIf
  EndIf
  
  ProcedureReturn ret
EndProcedure

Procedure.i Toggle1 (img.i, size.i, color.i, color1.i=0, color2.i=0)
  ; 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, w.i, half.d
  
  w = Int(size / 3.0) - (size % 3)
  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(color)
      
      AddPathBox(2,2,30,12)
      AddPathBox(2,18,30,12)
      FillPath()
      VectorSourceColor(color1)
      AddPathCircle(8,8,4)
      FillPath()
      VectorSourceColor(color2)
      AddPathCircle(24,24,4)
      FillPath()
      
      StopVectorDrawing()
    Else
      FreeImage(img)
      ret = 0
    EndIf
  EndIf
  
  ProcedureReturn ret
EndProcedure

Procedure.i Save (img.i, size.i, color.i)
  ; 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
  
  p = size / 32
  
  ret = CreateImage(img, size, size, 32, #Background)
  
  If ret
    If img = #PB_Any
      img = ret
    EndIf
    
    If StartVectorDrawing(ImageVectorOutput(img))
      ; If Alpha(color2) = 0, then this part is invisible.
      VectorSourceColor(color)
      MovePathCursor(8*p,2*p)
      AddPathLine(20,3)
      AddPathLine(20,12)
      AddPathLine(8,12)
      ClosePath()
      FillPath()
      MovePathCursor(24,3)
      AddPathLine(30,12)
      AddPathLine(30,30)
      AddPathLine(2,30)
      AddPathLine(2,2)
      AddPathLine(24,3)
      StrokePath(4,#PB_Path_RoundCorner)
      MovePathCursor(8,18)
      AddPathLine(24,18)
      MovePathCursor(8,22)
      AddPathLine(24,22)
      StrokePath(1)
      StopVectorDrawing()
    Else
      FreeImage(img)
      ret = 0
    EndIf
  EndIf
  
  ProcedureReturn ret
EndProcedure


      #ImgToggle
      #ImgToggle1
      #ImgSave
      #ImgSettings
      
      
 , "toggle", "toggle1", "save", "settings"
      
      
      VectorIcons::Toggle(#ImgToggle, size, red, green, silver)
      VectorIcons::Toggle1(#ImgToggle1, size, silver, green, red)
      VectorIcons::Save(#ImgSave, size, blue)
      VectorIcons::Settings(#ImgSettings, size, blue)
      
      
      
      VectorIcons::Toggle(#ImgToggle + #IconCount, size, lightgrey, lightgrey, darkwhite)
      VectorIcons::Toggle1(#ImgToggle1 + #IconCount, size, lightgrey, grey, grey)
      VectorIcons::Save(#ImgSave + #IconCount, size, lightgrey)
      VectorIcons::Settings(#ImgSettings + #IconCount, size, lightgrey)
      
      
      silver    = RGBA(192, 192, 192, 255)

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

Posted: Fri Mar 25, 2016 2:08 am
by Little John
Hi Oma!
Oma wrote:A small workaround within Macro UnRedo() seems to work on my Win XP ...
With this workaround, it looks fine also here on Windows 10, thank you. Your 10 icons are now included in the collection.

Hi davido!
Your icons "Toggle", "Toggle1", and "Save" seem to be made only for a size of 32x32 pixels.
Using e.g. a size of 64x64 pixels, they look like this:

<image removed>

This happens because of the use of absolute values, e.g.
davido wrote:

Code: Select all

AddPathBox(2, 2, 30, 12)
Instead, all values should be relative to size, such as

Code: Select all

AddPathBox(f1*size, f2*size, f3*size, f4*size)
I'll be grateful if you could post corrected code for the 3 icons.
davido wrote:

Code: Select all

silver    = RGBA(192, 192, 192, 255)
This color is already there (named "lightgrey"). :-)
I don't want to have several different names for the same color.

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

Posted: Fri Mar 25, 2016 8:12 am
by davido
Hi Little John,
Apologies for rushing and not checking that the code was relative.
Also apologies for the tarnished silver.

I re-post the code for the 3 offending icons below:

Code: Select all

   Procedure.i Toggle1 (img.i, size.i, color.i, color1.i=0, color2.i=0)
      ; 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, w.i, p.d
      
      p = size / 32
      
      ret = CreateImage(img, size, size, 32, #Background)
      
      If ret
         If img = #PB_Any
            img = ret
         EndIf
         
         If StartVectorDrawing(ImageVectorOutput(img))
            VectorSourceColor(color)
            AddPathBox(2*p,2*p,30*p,12*p)
            FillPath()
            VectorSourceColor(color2)
            AddPathCircle(8*p,8*p,4*p)
            FillPath()
            VectorSourceColor(color1)
            AddPathBox(2*p,18*p,30*p,12*p)
            FillPath()
            VectorSourceColor(color2)
            AddPathCircle(24*p,24*p,4*p)
            FillPath()
            
            StopVectorDrawing()
         Else
            FreeImage(img)
            ret = 0
         EndIf
      EndIf
      
      ProcedureReturn ret
   EndProcedure
   
   Procedure.i Toggle2 (img.i, size.i, color.i, color1.i=0, color2.i=0)
      ; 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, w.i, p.d
      
      p = size / 32
      
      ret = CreateImage(img, size, size, 32, #Background)
      
      If ret
         If img = #PB_Any
            img = ret
         EndIf
         
         If StartVectorDrawing(ImageVectorOutput(img))
            VectorSourceColor(color)
            
            AddPathBox(2*p,2*p,30*p,12*p)
            AddPathBox(2*p,18*p,30*p,12*p)
            FillPath()
            VectorSourceColor(color1)
            AddPathCircle(8*p,8*p,4*p)
            FillPath()
            VectorSourceColor(color2)
            AddPathCircle(24*p,24*p,4*p)
            FillPath()
            
            StopVectorDrawing()
         Else
            FreeImage(img)
            ret = 0
         EndIf
      EndIf
      
      ProcedureReturn ret
   EndProcedure
   
  Procedure.i Save (img.i, size.i, color.i)
         ; 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
   
   p = size / 32
   
   ret = CreateImage(img, size, size, 32, #Background)
   
   If ret
     If img = #PB_Any
       img = ret
     EndIf
     
     If StartVectorDrawing(ImageVectorOutput(img))
       ; If Alpha(color2) = 0, then this part is invisible.
       ;Add shield
       VectorSourceColor(color)
       MovePathCursor(8*p,2*p)
       AddPathLine(20*p,2*p)
       AddPathLine(20*p,12*p)
       AddPathLine(8*p,12*p)
       ;ClosePath()
       FillPath()
       ;Add outer box
       MovePathCursor(25*p,2*p) ;Covers gap at joint
       AddPathLine(30*p,12*p)
       AddPathLine(30*p,30*p)
       AddPathLine(2*p,30*p)
       AddPathLine(2*p,2*p)
       AddPathLine(24*p,2*p)
       StrokePath(4*p,#PB_Path_RoundCorner | #PB_Path_RoundEnd) 
       ;Add text
       MovePathCursor(8*p,18*p)
       AddPathLine(24*p,18*p)
       MovePathCursor(8*p,22*p)
       AddPathLine(24*p,22*p)
       StrokePath(p)
       StopVectorDrawing()
            Else
               FreeImage(img)
               ret = 0
            EndIf
         EndIf
         
         ProcedureReturn ret
      EndProcedure
Hi Oma,
Just taken a good look at your icons.
They are really nice. Impressive!

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

Posted: Fri Mar 25, 2016 11:13 am
by Little John
Hi davido,
no problem. And thank you for the revised code.
First post here and content of the ZIP archive updated.

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

Posted: Fri Mar 25, 2016 7:23 pm
by davido
Hi Little John,
I've had the audacity to transmogrify one your Icons into two others!?
I've taken the 'Search' Icon and made: ZoomIn and ZoomOut.

Code: Select all

Declare.i ZoomIn (img.i, size.i, color.i)
Declare.i ZoomOut (img.i, size.i, color.i)

Procedure.i ZoomIn (img.i, size.i, color.i)
  ; 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 - Modification of 'search' Icon by Little John]
  Protected ret.i, m.d, w.d
  
  m = 0.35 * size
  w = size / 14.0  
  ret = CreateImage(img, size, size, 32, #Background)
  
  If ret
    If img = #PB_Any
      img = ret
    EndIf
    
    If StartVectorDrawing(ImageVectorOutput(img))
      VectorSourceColor(color)
      
      AddPathCircle(m, m, 0.29*size)
      StrokePath(w)
      ;Insert the 'plus' sign
      MovePathCursor(m - size / 5,m)
      AddPathLine(m + size / 5,m)
      MovePathCursor(m,m - size / 5)
      AddPathLine(m,m + size / 5)
      StrokePath(0.8*w)
      
      MovePathCursor(0.61*size, 0.61*size)
      AddPathLine(0.92*size, 0.92*size)
      StrokePath(1.8*w)
      
      StopVectorDrawing()
    Else
      FreeImage(img)
      ret = 0
    EndIf
  EndIf
  
  ProcedureReturn ret
EndProcedure

Procedure.i ZoomOut (img.i, size.i, color.i)
  ; 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 - Modification of 'search' Icon by Little John]
  Protected ret.i, m.d, w.d
  
  m = 0.35 * size
  w = size / 14.0    
  ret = CreateImage(img, size, size, 32, #Background)
  
  If ret
    If img = #PB_Any
      img = ret
    EndIf
    
    If StartVectorDrawing(ImageVectorOutput(img))
      VectorSourceColor(color)
      
      AddPathCircle(m, m, 0.29*size)
      StrokePath(w)
      ;Insert the 'minus' sign
      MovePathCursor(m - size / 5,m)
      AddPathLine(m + size / 5,m)
      StrokePath(0.8*w)
      
      MovePathCursor(0.61*size, 0.61*size)
      AddPathLine(0.92*size, 0.92*size)
      StrokePath(1.8*w)
      
      StopVectorDrawing()
    Else
      FreeImage(img)
      ret = 0
    EndIf
  EndIf
  
  ProcedureReturn ret
EndProcedure 

#ImgZoomIn
#ImgZoomOut

; , "zoomin", "zoomout"

VectorIcons::ZoomIn(#ImgZoomIn, size, black)
VectorIcons::ZoomOut(#ImgZoomOut, size, black)

VectorIcons::ZoomIn(#ImgZoomIn + #IconCount, size, lightgrey)
VectorIcons::ZoomOut(#ImgZoomOut + #IconCount, size, lightgrey)
If you accept these icons feel free to change the credits.

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

Posted: Sat Mar 26, 2016 8:09 am
by Oma
@davido
Thank you, but i must return the compliment - especially for your Setting-based icons. :)
I thought of them, but hadn't the courage to launch them, the same with the diskette symbol for 'Save'.

Here I still have another few icon trials - I think for the moment the last ones.
- Download
- New1
- Open1
- Open2
;- Open3 (commented out due to Window AddPathArc-problems and the bad design)
- Save2
- SaveAs2
- Printer1

Among the 'Open' icons i had 3 to choose from.
With the 'folder'-design i've gotten some color problems and as quick way out, i defined 2 new colors: goldenrod, goldenrod4 (CSS names)
Please convert them in your idea of the color scheme and -set. And again feel free to improve the code or designs.
And: What about using OS indepentent CSS-colors? I have a table here, usable with PB, API (mirrored color ordner), CSS-themes, HTML, ... :?:

But first a smarter Update for the Macro UnRedo() (originally i've posted the old, unpolished one)

Code: Select all

Macro UnRedo()
		MovePathCursor(p4 - p, p4 + p)
		AddPathArc    (size - p8, p4+p, size - p8, size - p4 - p, p4 - p)
		AddPathArc    (size - p8, size - p4 - p, p8, size - p4 - p-0.001, p4 - p); workaround for windows
		AddPathLine   (p4, size - p4 - p)
		StrokePath    (p8 * 1.5)
		MovePathCursor(p8, size - p4 - p)
		AddPathLine   (p8 * 3, size - 2 * p4 - p)
		AddPathLine   (p8 * 3, size - p)
		ClosePath()
		FillPath()
	EndMacro
The Icon (again untested on Windows, because in the meanwhile this is very awkward )

Code: Select all

Declare.i Download (img.i, size.i, color.i, color2.i=0)
Declare.i New1 (img.i, size.i, color.i, color2.i)
Declare.i Open1 (img.i, size.i, color.i, color2.i=0)
Declare.i Open2 (img.i, size.i, color1.i, color2.i, color3.i= 0)
;Declare.i Open3 (img.i, size.i, color.i, color2.i=0)
Declare.i Save2 (img.i, size.i, color.i, color2.i=0)
Declare.i SaveAs2 (img.i, size.i, color.i, color2.i=0)
Declare.i Printer1 (img.i, size.i, color.i, color2.i, color3.i)


#ImgDownload
#ImgNew1
#ImgOpen1
#ImgOpen2
;#ImgOpen3
#ImgSave2
#ImgSaveAs2
#ImgPrinter1


Data.s "Download", "New1", "Open1", "Open2", "Save2", "SaveAs2", "Printer1";, "Open3"


;temp. color defs...
;", goldenrod, goldenrod4"

goldenrod = RGBA(218, 165, 32, 255)
goldenrod4= RGBA(139, 105, 20, 255)


VectorIcons::Download(#ImgDownload, size, green, white)
VectorIcons::New1(#ImgNew1, size, blue, red)
VectorIcons::Open1(#ImgOpen1, size, goldenrod, grey)
VectorIcons::Open2(#ImgOpen2, size, goldenrod, blue, white)
;VectorIcons::Open3(#ImgOpen3, size, goldenrod, goldenrod4)
VectorIcons::Save2(#ImgSave2, size, blue, white)
VectorIcons::SaveAs2(#ImgSaveAs2, size, blue, white)
VectorIcons::Printer1(#ImgPrinter1, size, lightgrey, grey, white)

VectorIcons::Download(#ImgDownload + #IconCount, size, lightgrey, darkwhite)
VectorIcons::New1(#ImgNew1 + #IconCount, size, lightgrey, lightgrey)
VectorIcons::Open1(#ImgOpen1 + #IconCount, size, lightgrey, darkwhite)
VectorIcons::Open2(#ImgOpen2 + #IconCount, size, lightgrey, lightgrey, darkwhite)
;VectorIcons::Open3(#ImgOpen3 + #IconCount, size, lightgrey, lightgrey)
VectorIcons::Save2(#ImgSave2 + #IconCount, size, lightgrey, darkwhite)
VectorIcons::SaveAs2(#ImgSaveAs2 + #IconCount, size, lightgrey, darkwhite)
VectorIcons::Printer1(#ImgPrinter1 + #IconCount, size, lightgrey, lightgrey, darkwhite)

	Procedure.i Download (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
		; [org. by Omi]
		Protected ret.i
		Protected p8.d = size / 8
		Protected p4.d = size / 4
		Protected p2.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)
				
				;panel: round corners
				AddPathBox(p8, p8, size - p4, size - p4)
				FillPath()
				AddPathBox(p8, p8, size - p4, size - p4)
				StrokePath(p4, #PB_Path_RoundCorner)
				;arrow
				VectorSourceColor(color2)
				MovePathCursor(p2, p8)
				AddPathLine   (p2, size - p4)
				StrokePath    (size/5)
				MovePathCursor(p2 - p4, size - p2 + p8)
				AddPathLine   (p2 + p4, size - p2 + p8)
				AddPathLine   (p2, size - p8)
				ClosePath()
				FillPath()
				
				StopVectorDrawing()
			EndIf
		EndIf
		
		ProcedureReturn ret
	EndProcedure
	
	
	Procedure.i New1 (img.i, size.i, color.i, color2.i)
		; 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
		; [org. by Omi]
		Protected ret.i
		Protected p.d = size / 32
		Protected p16 = size / 16
		Protected p8  = size / 8
		Protected p4  = size / 4
		Protected p2  = size / 2
		
		ret = CreateImage(img, size, size, 32, #Background)
		
		If ret
			If img = #PB_Any
				img = ret
			EndIf
			
			If StartVectorDrawing(ImageVectorOutput(img))
				VectorSourceColor(color)
				
				;frame
				MovePathCursor(p8,              p16)
				AddPathLine   (size - p4 - p16, p16)
				AddPathLine   (size - p8,       p4)
				AddPathLine   (size - p8,       size - p16)
				AddPathLine   (p8,              size - p16)
				ClosePath     ()
				StrokePath    (p16)
				;dog-ear
				MovePathCursor(size - p4 - p16, p16)
				AddPathLine   (size - p4 - p16, p4)
				AddPathLine   (size - p8,       p4)
				StrokePath    (p)
				;lines
				MovePathCursor( 7 * p,  9 * p)
				AddPathLine   (19 * p,  9 * p)
				MovePathCursor( 7 * p, 13 * p)
				AddPathLine   (24 * p, 13 * p)
				MovePathCursor( 7 * p, 17 * p)
				AddPathLine   (17 * p, 17 * p)
				MovePathCursor( 7 * p, 21 * p)
				AddPathLine   (19 * p, 21 * p)
				MovePathCursor( 7 * p, 25 * p)
				AddPathLine   (15 * p, 25 * p)
				StrokePath    (p)
				;+
				VectorSourceColor(color2)
				MovePathCursor(size - p4 - p16, size - p8 - p4)
				AddPathLine   (size - p4 - p16, size - p8)
				MovePathCursor(p2 + p16,        size - p4)
				AddPathLine   (size - p8 - p16, size - p4)
				StrokePath    (p16)
				
				StopVectorDrawing()
			Else
				FreeImage(img)
				ret = 0
			EndIf
		EndIf
		
		ProcedureReturn ret
	EndProcedure
	
	
	Procedure.i Open1 (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
		; [org. by Omi]
		Protected ret.i
		Protected p64.d= size / 64
		Protected p.d  = size / 32
		Protected p16.d= size / 16
		Protected p8.f = size / 8
		Protected p4.d = size / 4
		Protected p2.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)
				
				;box: round corners
				AddPathBox    (p16, p4 + p8, size - p8, size - p2 - p)
				StrokePath    (p8, #PB_Path_RoundCorner)
				AddPathBox    (p16, p4 + p8, size - p8, size - p2 - p)
				FillPath      ()
				
				;card
				MovePathCursor(p16,        p2)
				AddPathArc    (p16,        p8,     p4 + p8,    p8,     p16)
				AddPathArc    (p4 + p8,    p8,     p4 + p8,    p4 - p, p16 - p64)
				AddPathArc    (p4 + p8,    p4 - p, size - p16, p4 - p, p16 - p64)
				AddPathArc    (size - p16, p4 - p, size - p16, p2,     p16)
				AddPathLine   (size - p16, p2)
				StrokePath    (p16)
				
				StopVectorDrawing()
			EndIf
		EndIf
		
		ProcedureReturn ret
	EndProcedure
	
	
	Procedure.i Open2 (img.i, size.i, color1.i, color2.i, color3.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
		; [org. by Omi]
		Protected ret.i
		Protected p64.d= size / 64
		Protected p.d  = size / 32
		Protected p16.d= size / 16
		Protected p8.d = size / 8
		Protected p4.d = size / 4
		Protected p2.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)
				
				;card
				MovePathCursor(p16,      p2)
				AddPathArc    (p16,      p4,           p4 + p16,        p4,           p16)
				AddPathArc    (p4 + p16, p4,           p4 + p16,        p4 + p16 + p, p16 - p64)
				AddPathArc    (p4 + p16, p4 + p16 + p, size - p8 - p16, p4 + p16 + p, p16 - p64)
				StrokePath    (p16)
				
				;sheet
				VectorSourceColor(color3)
				MovePathCursor(p4 + p8,   p2 + p4)
				AddPathLine   (p4 + p8,   p)
				AddPathLine   (size - p4, p)
				AddPathLine   (size - p,  p4)
				AddPathLine   (size - p,  p2 + p4)
				ClosePath()
				FillPath()
				;frame
				VectorSourceColor(color2)
				MovePathCursor(p4 + p8,   p2 + p4)
				AddPathLine   (p4 + p8,   p)
				AddPathLine   (size - p4, p)
				AddPathLine   (size - p,  p4)
				AddPathLine   (size - p,  p2 + p4)
				ClosePath()
				;dog-ear
				MovePathCursor(size - p4, p)
				AddPathLine   (size - p4, p4)
				AddPathLine   (size - p,  p4)
				StrokePath    (p)
				;lines
				MovePathCursor(15 * p,  6 * p)
				AddPathLine   (19 * p,  6 * p)
				MovePathCursor(15 * p,  9 * p)
				AddPathLine   (24 * p,  9 * p)
				MovePathCursor(15 * p, 12 * p)
				AddPathLine   (22 * p, 12 * p)
				StrokePath    (p)
				
				;box: round corners
				VectorSourceColor(color1)
				AddPathBox    (p16, p2, size - p4, size - p2 - p16)
				StrokePath    (p8, #PB_Path_RoundCorner)
				AddPathBox    (p16, p2, size - p4, size - p2 - p16)
				FillPath      ()
				
				StopVectorDrawing()
			EndIf
		EndIf
		
		ProcedureReturn ret
	EndProcedure
	
	
; 	Procedure.i Open3 (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
; 		; [org. by Omi]
; 		Protected ret.i
; 		Protected p64.d= size / 64
; 		Protected p.d  = size / 32
; 		Protected p16.d= size / 16
; 		Protected p8.d = size / 8
; 		Protected p4.d = size / 4
; 		Protected p2.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)
; 				
; 				;card
; 				MovePathCursor(p16,       p2)
; 				AddPathArc    (p16,       p4,           p4 + p16,  p4,           p16)
; 				AddPathArc    (p4 + p16,  p4,           p4 + p16,  p4 + p16 + p, p16 - p64)
; 				AddPathArc    (p4 + p16,  p4 + p16 + p, size - p4, p4 + p16 + p, p16 - p64)
; 				AddPathArc    (size - p4, p4 + p16 + p, size - p4, p2,           p16)
; 				AddPathLine   (size - p4, p2)
; 				StrokePath    (p16)
; 				
; 				;box: round corners
; 				VectorSourceColor(color1)
; 				AddPathBox    (p16, p2, size - p4 - p16, size - p2 - p16)
; 				StrokePath    (p8, #PB_Path_RoundCorner)
; 				AddPathBox    (p16, p2, size - p4 - p16, size - p2 - p16)
; 				FillPath      ()
; 				
; 				VectorSourceColor(color2)
; 				MovePathCursor((p + p4) / 2, (size - p16 + p2 + p4) / 2)
; 				AddPathArc    (p4,         p2 + p4,    size - p16,   p2 + p4,                    p)
; 				AddPathArc    (size - p16, p2 + p4,    size - p4 ,   size - p16,                 p)
; 				AddPathArc    (size - p4,  size - p16, p,            size - p16,                 p)
; 				AddPathArc    (p,          size - p16, (p + p4) / 2, (size - p16 + p2 + p4) / 2, p)
; 				ClosePath     ()
; 				StrokePath    (p8)
; 				
; 				MovePathCursor((p + p4) / 2, (size - p16 + p2 + p4) / 2)
; 				AddPathArc    (p4,           p2 + p4,    size - p16,   p2 + p4,                    p)
; 				AddPathArc    (size - p16,   p2 + p4,    size - p4 ,   size - p16,                 p)
; 				AddPathArc    (size - p4,    size - p16, p,            size - p16,                 p)
; 				AddPathArc    (p,            size - p16, (p + p4) / 2, (size - p16 + p2 + p4) / 2, p)
; 				ClosePath     ()
; 				FillPath      ()
; 				
; 				StopVectorDrawing()
; 			EndIf
; 		EndIf
; 		
; 		ProcedureReturn ret
; 	EndProcedure
	
	
	Procedure.i Save2 (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
		; [org. by Omi]
		Protected ret.i
		Protected p16.d= size / 16
		Protected p8.d = size / 8
		Protected p4.d = size / 4
		Protected p2.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)
				
				;box: round corners
				AddPathBox(p8, p16, size - 2 * p8, size - p8)
				StrokePath(p8, #PB_Path_RoundCorner)
				VectorSourceColor(color2)
				AddPathBox(p8, p16, size - 2 * p8, size - p8)
				FillPath()
				;arrow
				VectorSourceColor(color1)
				MovePathCursor(p2, p4)
				AddPathLine   (p2, p2)
				StrokePath    (p4)
				MovePathCursor(p2 - p4, p2)
				AddPathLine   (p2 + p4, p2)
				AddPathLine   (p2, size - p4)
				ClosePath()
				FillPath()
				
				StopVectorDrawing()
			EndIf
		EndIf
		
		ProcedureReturn ret
	EndProcedure
	
	
	Procedure.i SaveAs2 (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
		; [org. by Omi]
		Protected ret.i
		Protected p.d  = size / 32
		Protected p16.d= size / 16
		Protected p8.d = size / 8
		Protected p4.d = size / 4
		Protected p2.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)
				
				;box: round corners
				AddPathBox(p16, p, p2, p4 - p * 2)
				FillPath()
				AddPathBox(p16, p, size - p8, p4 - p * 2)
				StrokePath(p16)
				AddPathBox(p8, p4, size - p4, size - p4 - p16)
				StrokePath(p8, #PB_Path_RoundCorner)
				VectorSourceColor(color2)
				AddPathBox(p8, p4, size - p4, size - p4 - p16)
				FillPath()
				;arrow
				VectorSourceColor(color1)
				MovePathCursor(p2, p2 - p8)
				AddPathLine   (p2, p2 + p8)
				StrokePath    (p4)
				MovePathCursor(p2 - p4, p2 + p8)
				AddPathLine   (p2 + p4, p2 + p8)
				AddPathLine   (p2, size - p8)
				ClosePath()
				FillPath()
				
				StopVectorDrawing()
			EndIf
		EndIf
		
		ProcedureReturn ret
	EndProcedure
	
	
	Procedure.i Printer1 (img.i, size.i, color.i, color2.i, color3.i)
		; 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
		; [org. by Omi]
		Protected ret.i
		Protected p.d   = size / 32
		Protected p16.d = size / 16
		Protected p8.d  = size / 8
		Protected p4.d  = size / 4
		Protected p2.d  = size / 2
		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))
				
				;printer
				VectorSourceColor(color2)
				AddPathBox    (p16, p2, size - p8, p4)
				StrokePath    (p8, #PB_Path_RoundCorner)
				AddPathBox    (p, p2, size - p16, p4 + p8)
				FillPath      ()
				StrokePath    (p)
				
				;sheet top
				VectorSourceColor(color2)
				AddPathBox    (p8 + p16, p, w, p2)
				StrokePath    (2 * p, #PB_Path_RoundCorner)
				VectorSourceColor(color3)
				AddPathBox    (p8 + p16, p, w, p2)
				FillPath      ()
				StrokePath    (p)
				;lines
				VectorSourceColor(color2)
				MovePathCursor( 8 * p,  4 * p)
				AddPathLine   (17 * p,  4 * p)
				MovePathCursor( 8 * p,  7 * p)
				AddPathLine   (19 * p,  7 * p)
				MovePathCursor( 8 * p, 10 * p)
				AddPathLine   (12 * p, 10 * p)
				StrokePath    (p)
				
				;sheet bottom
				VectorSourceColor(color)
				AddPathBox    (p8, size - p4 + p, h, p8 + p16)
				StrokePath    (2 * p, #PB_Path_RoundCorner)
				VectorSourceColor(color3)
				AddPathBox    (p8, size - p4 + p, h, p8 + p16)
				FillPath      ()
				StrokePath    (p)
				
				StopVectorDrawing()
			Else
				FreeImage(img)
				ret = 0
			EndIf
		EndIf
		
		ProcedureReturn ret
	EndProcedure
Best Regards, Charly

PS: edited 2016-03-27 07:00

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

Posted: Sat Mar 26, 2016 8:53 am
by Little John
davido wrote:Hi Little John,
I've had the audacity to transmogrify one your Icons into two others!?
I've taken the 'Search' Icon and made: ZoomIn and ZoomOut.
Hi davido, you are welcome!
That makes much sense. In cases llike these I think there is no need to "reinvent the wheel".
I updated the 1st post and the ZIP archive.

Thanks also for the word "transmogrify". :-)
I'ts one of those English words that we didn't learn at school. Sounds really nice in my ears.

Hi Charly,
thanks for your new icons. I'm very curious to see how they look.
But first I'll have to do some Easter preparations. I'll reply more in detail later.

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

Posted: Sat Mar 26, 2016 4:14 pm
by Little John
Hi again, Charly!
Oma wrote:But first a smarter Update for the Macro UnRedo() (originally i've posted the old, unpolished one)

Code: Select all

Macro UnRedo()
		MovePathCursor(p4 - p, p4 + p)
		AddPathArc    (size - p8, p4+p, size - p8, size - p4 - p, p4 - p)
		AddPathArc    (size - p8, size - p4 - p, p8, size - p4 - p-0.01, p4 - p); workaround for windows
		AddPathLine   (p4, size - p4 - p)
		StrokePath    (p8 * 1.5)
		MovePathCursor(p8, size - p4 - p)
		AddPathLine   (p8 * 3, size - 2 * p4 - p)
		AddPathLine   (p8 * 3, size - p)
		ClosePath()
		FillPath()
	EndMacro
Unfortunately, in this code the AddPathArc() bug was visible again. However, changing p-0.01 to p-0.001 fixed it :-) (at least here with PB 5.42 on Windows 10).

Thanks for the revised and for your new icons.

As alternative to your "Undo" procedure, I added a modified version of it: Since the "Redo" icon shows a clockwise rotation, I personally prefer an "Undo" icon that shows a counter-clockwise rotation.
I changed the name "New1" to "NewDocument", I think that says more precisely what that icon shows (as opposed to "New user", "New internet connection" etc.).
In the demo code, I changed the color of the cross from red to light green, I think this is far more common for a new document, since red is mostly used to signal danger, forbidden, delete etc.
In the procedures Open2() and Printer1(), I introduced a new parameter 'color3' and replaced

Code: Select all

VectorSourceColor(RGBA(255,255,255,255))
with

Code: Select all

VectorSourceColor(color3)
Previously, the hardcoded white color was unwantedly also shown in the "disabled" version of the icons.
I hope you agree with these changes. :-)

Due to the AddPathArc() bug, your icons "Open1", "Open2", and "Open3" do not look correct on Windows 10:

Image
Unfortunately, I was not able to create a workaround for this problem
If and when I'll have some time for it, I'll write a new AddPathArc() procedure in PureBasic, as replacement for the current built-in buggy one.
Oma wrote:With the 'folder'-design i've gotten some color problems and as quick way out, i defined 2 new colors: goldenrod, goldenrod4 (CSS names)
Please convert them in your idea of the color scheme and -set. And again feel free to improve the code or designs.
And: What about using OS indepentent CSS-colors? I have a table here, usable with PB, API (mirrored color ordner), CSS-themes, HTML, ... :?:
That's a great idea!
And we could use those color definitions not only in the demo code that generates the preview window, but include them into the module itself. Then they are better re-usable.

I also added a new icon by me, named "Diskette".

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

Posted: Sat Mar 26, 2016 10:00 pm
by davido
Hi Little John,
I've got a 'handy' little icon to add:
I've called it 'Great' although it might, alternatively, be called 'OK'

Code: Select all

Declare.i Great (img.i, size.i, color.i)

   Procedure.i Great (img.i, size.i, color.i)
     ; 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
     
     p = size / 32
     
     ret = CreateImage(img, size, size, 32, #Background)
     
     If ret
       If img = #PB_Any
         img = ret
       EndIf
       
       If StartVectorDrawing(ImageVectorOutput(img))
         VectorSourceColor(color)
         
         MovePathCursor(p,14*p)
         AddPathLine   (p,30*p)
         AddPathLine(20*p,30*p)
         MovePathCursor(16*p,26*p)
         AddPathLine(22*p,26*p)
         AddPathCircle(20*p,28*p,2*p,270,90)
         MovePathCursor(16*p,22*p)
         AddPathLine(26*p,22*p)
         AddPathCircle(22*p,24*p,2*p,270,90)
         MovePathCursor(16*p,18*p)
         AddPathLine(26*p,18*p)
         AddPathCircle(26*p,20*p,2*p,270,90)
         MovePathCursor(1*p,14*p)
         AddPathLine(22*p,14*p)
         AddPathCircle(22*p,16*p,2*p,270,90)
         AddPathCircle(2*p,p,13*p,10,85)
         MovePathCursor(14.7*p,3*p)
         AddPathLine(13.7*p,3*p)
         AddPathLine(2*p,14*p)
         StrokePath(2*p,#PB_Path_RoundCorner | #PB_Path_RoundEnd)
         
         StopVectorDrawing()
       Else
         FreeImage(img)
         ret = 0
       EndIf
     EndIf
     
     ProcedureReturn ret
   EndProcedure  
   
   #ImgGreat
   
   ; , "Great"
   
   VectorIcons::Great(#ImgGreat, size, blue)
   
   VectorIcons::Great(#ImgGreat + #IconCount, size, lightgrey)

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

Posted: Sun Mar 27, 2016 6:10 am
by Oma
Moinmoin :wink: , Little John. Please excuse the hassle, which i've caused to you.
I didn't expect that the Windows AddPathArc is really so beastly. :twisted:

I also did the (mentioned) correction for the Macro UnRedo() above.
And i've found a solution for Open1 and Open2 on windows by reducing the radius.
Then they are at least usable as basic icons.
Not so with Open3, so i decided to comment out this (anyway) graceless icon.
(It should eke out its existence as bad example to show the Windows-"AddPathArc" bug.)

Nice holidays and best regards, Charly

PS:
A link to a file with X11 and CSS color definitions, usable for PB:http://www.chabba.de/temp/X11+CSS-Colors.pb
My used color goldenrod4 was unfortunately an X11 and no CSS color, but after deactivating the Open3-icon, this is no longer needed.

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

Posted: Sun Mar 27, 2016 7:57 pm
by davido
Hi Little John,
I have another 6 potential Icons to add:
Alternative DownLoad and UpLoad, LineWrapOn and LineWrapOff, Donate and an alternative Donate1
Donate icon has an unfortunate artifact which I cannot remove.

Code: Select all

Declare.i DownLoad1 (img.i, size.i, color.i, color1.i)
Declare.i UpLoad1 (img.i, size.i, color.i, color1.i)
Declare.i LineWrapOn (img.i, size.i, color.i, color1.i)
Declare.i LineWrapOff (img.i, size.i, color.i, color1.i)
Declare.i Donate (img.i, size.i, color.i)
Declare.i Donate1 (img.i, size.i, color.i)


Procedure.i DownLoad1 (img.i, size.i, color.i, color1.i)
  ; 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
  
  p = size / 32
  
  ret = CreateImage(img, size, size, 32, #Background)
  
  If ret
    If img = #PB_Any
      img = ret
    EndIf
    
    If StartVectorDrawing(ImageVectorOutput(img))
      VectorSourceColor(color)
      
      ;Background
      AddPathCircle(16*p,16*p,15*p)
      FillPath()
      ;Tray
      VectorSourceColor(color1)
      MovePathCursor(8*p,16*p)
      AddPathLine(8*p,22*p)
      AddPathLine(24*p,22*p)
      AddPathLine(24*p,16*p)
      ;Shaft
      MovePathCursor(16*p,18*p)
      AddPathLine(16*p,10*p)
      StrokePath(2*p)
      ;Arrowhead
      MovePathCursor(12*p,10*p)
      AddPathLine(20*p,10*p)
      AddPathLine(16*p,6*p)
      ClosePath()
      FillPath()
      
      StopVectorDrawing()
    Else
      FreeImage(img)
      ret = 0
    EndIf
  EndIf
  
  ProcedureReturn ret
EndProcedure  

Procedure.i UpLoad1 (img.i, size.i, color.i, color1.i)
  
  ; 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
  
  p = size / 32
  
  ret = CreateImage(img, size, size, 32, #Background)
  
  If ret
    If img = #PB_Any
      img = ret
    EndIf
    
    If StartVectorDrawing(ImageVectorOutput(img))
      VectorSourceColor(color)
      
      ;Background
      AddPathCircle(16*p,16*p,15*p)
      FillPath()
      ;Tray
      VectorSourceColor(color1)
      MovePathCursor(8*p,16*p)
      AddPathLine(8*p,22*p)
      AddPathLine(24*p,22*p)
      AddPathLine(24*p,16*p)
      ;Shaft
      MovePathCursor(16*p,6*p)
      AddPathLine(16*p,16*p)
      StrokePath(2*p)
      ;Arrowhead
      MovePathCursor(12*p,14*p)
      AddPathLine(20*p,14*p)
      AddPathLine(16*p,18*p)
      ClosePath()
      FillPath()
      
      StopVectorDrawing()
    Else
      FreeImage(img)
      ret = 0
    EndIf
  EndIf
  
  ProcedureReturn ret
EndProcedure  

Procedure.i LineWrapOn (img.i, size.i, color.i, color1.i)
  ; 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, M.i
  
  p = size / 32
  
  ret = CreateImage(img, size, size, 32, #Background)
  
  If ret
    If img = #PB_Any
      img = ret
    EndIf
    
    If StartVectorDrawing(ImageVectorOutput(img))
      VectorSourceColor(color)
      ;Page
      AddPathBox(2*p,2*p,28*p,28*p)
      ;Lines on page
      MovePathCursor(4*p,5*p)
      AddPathLine(28*p,5*p)
      MovePathCursor(4*p,8*p)
      AddPathLine(28*p,8*p)
      For M = 11 To 26 Step 3
        MovePathCursor(4*p,M*p)
        AddPathLine(10*p,M*p)
      Next M
      StrokePath(p,#PB_Path_RoundCorner)
      ;Arrow shaft
      VectorSourceColor(color1)
      MovePathCursor(24*p,10*p)
      AddPathLine(24*p,20*p)
      AddPathLine(16*p,20*p)
      StrokePath(p)
      ;Arrow head
      MovePathCursor(16*p,16*p)
      AddPathLine(16*p,24*p)
      AddPathLine(12*p,20*p)
      ClosePath()
      FillPath()
      
      
      StopVectorDrawing()
    Else
      FreeImage(img)
      ret = 0
    EndIf
  EndIf
  
  ProcedureReturn ret
EndProcedure 

Procedure.i LineWrapOff (img.i, size.i, color.i, color1.i)
  ; 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, M.i
  
  p = size / 32
  
  ret = CreateImage(img, size, size, 32, #Background)
  
  If ret
    If img = #PB_Any
      img = ret
    EndIf
    
    If StartVectorDrawing(ImageVectorOutput(img))
      VectorSourceColor(color)
      ;Page
      AddPathBox(2*p,2*p,28*p,28*p)
      ;Lines on page
      MovePathCursor(4*p,5*p)
      AddPathLine(28*p,5*p)
      MovePathCursor(4*p,8*p)
      AddPathLine(28*p,8*p)
      For M = 11 To 26 Step 3
        MovePathCursor(4*p,M*p)
        AddPathLine(10*p,M*p)
      Next M
      StrokePath(p,#PB_Path_RoundCorner)
      ;Arrow shaft
      VectorSourceColor(color1)
      MovePathCursor(22*p,14*p)
      AddPathLine(22*p,24*p)
      AddPathLine(13*p,24*p)
      StrokePath(p)
      ;Arrow head
      MovePathCursor(18*p,14*p)
      AddPathLine(26*p,14*p)
      AddPathLine(22*p,10*p)
      ClosePath()
      FillPath()
      
      
      StopVectorDrawing()
    Else
      FreeImage(img)
      ret = 0
    EndIf
  EndIf
  
  ProcedureReturn ret
EndProcedure 

Procedure.i Donate (img.i, size.i, color.i)
  ; 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, M.i
  
  p = size / 32
  
  ret = CreateImage(img, size, size, 32, #Background)
  
  If ret
    If img = #PB_Any
      img = ret
    EndIf
    
    If StartVectorDrawing(ImageVectorOutput(img))
      VectorSourceColor(color)
      ;Page
      AddPathCircle(9*p,12*P,7*p,180,0)
      AddPathCircle(23*p,12*P,7*p,180,0)
      
      MovePathCursor(30*p,12*p)
      AddPathLine(16*p,30*p)
      AddPathLine(2*p,12*p)
      ClosePath()
      FillPath()
      AddPathCircle(24*p,12*p,22*p,105,180)
      FillPath()
      AddPathCircle(8*p,12*p,22*p,0,75)
      FillPath()
      
      StopVectorDrawing()
    Else
      FreeImage(img)
      ret = 0
    EndIf
  EndIf
  
  ProcedureReturn ret
EndProcedure  

Procedure.i Donate1 (img.i, size.i, color.i)
  ; 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, M.i
  
  p = size / 32
  
  ret = CreateImage(img, size, size, 32, #Background)
  
  If ret
    If img = #PB_Any
      img = ret
    EndIf
    
    If StartVectorDrawing(ImageVectorOutput(img))
      VectorSourceColor(color)
      ;Page
      AddPathCircle(9*p,12*P,7*p,180,0)
      AddPathCircle(23*p,12*P,7*p,180,0)
      
      MovePathCursor(30*p,12*p)
      AddPathLine(16*p,30*p)
      AddPathLine(2*p,12*p)
      ClosePath()
      FillPath()
      
      StopVectorDrawing()
    Else
      FreeImage(img)
      ret = 0
    EndIf
  EndIf
  
  ProcedureReturn ret
EndProcedure  



#ImgDownload1
#ImgUpload1
#ImgLineWrapOn
#ImgLineWrapOff
#ImgDonate
#ImgDonate1

DownLoad1(#ImgDownload1, size, green,white)
UpLoad1(#ImgUpload1, size, green,white)
LineWrapOn(#ImgLineWrapOn, size, blue, red)
LineWrapOff(#ImgLineWrapOff, size, blue, red)
Donate(#ImgDonate, size, red)
Donate1(#ImgDonate1, size, red)

DownLoad1((#ImgDownload1 + #IconCount, size, darkwhite, lightgrey)
UpLoad1(#ImgUpload1 + #IconCount, size, darkwhite, lightgrey)
LineWrapOn(#ImgLineWrapOn + #IconCount, size, grey, lightgrey)
LineWrapOff(#ImgLineWrapOff + #IconCount, size, grey, lightgrey)
Donate(#ImgDonate + #IconCount, size, lightgrey)
Donate1(#ImgDonate1 + #IconCount, size, lightgrey)
I called my UpDate1 to leave space for a future Update!?
I was hoping to add an Easter themed icon.....

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

Posted: Mon Mar 28, 2016 2:05 pm
by Little John
Little John wrote:If and when I'll have some time for it, I'll write a new AddPathArc() procedure in PureBasic, as replacement for the current built-in buggy one.
Done. :-)
The next version of the module will contain a private procedure for properly drawing arcs.
More later ...

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

Posted: Mon Mar 28, 2016 8:19 pm
by Little John
Current changes:
  • added: CSS color definitions (thanks to Oma);
    Please feel free to add your own colors, if needed/wanted!
  • added: 7 icons by davido
  • added: private procedure AddPathRoundedCorner() and macro AddPathArc() as general workaround for the AddPathArc() bug on Windows.
  • removed: specific workaround for the AddPathArc() bug in Oma's macro UnRedo() (not required anymore)
  • changed: replaced previous self-defined colors with CSS colors
Can everyone please check whether they like the new colors of their icons? If something is not OK, please tell me!
davido wrote:Hi Little John,
I have another 6 potential Icons to add:
Alternative DownLoad and UpLoad, LineWrapOn and LineWrapOff, Donate and an alternative Donate1
Thank you, davido! I added your 7 new icons to the collection. I took the liberty of renaming "Donate" to "Donate1" and "Donate1" to "Donate2".
davido wrote:Donate icon has an unfortunate artifact which I cannot remove.
It seems that I was able to fix that. :-) Please check it. That's a really nice icon! ( and the most important one :mrgreen: )
However, there might still be a little issue: The apex of the heart is not completely visible, while at the top of the picture there is some free space.
in line 250 of the current "vectoricons.pb" file that I just uploaded, replace #Background = #PB_Image_Transparent for instance with #Background = $FFFFFF in order to see exactly what I mean. I'm not sure, but maybe the heart could/should be moved a little upwards?