Page 10 of 18

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

Posted: Tue Apr 26, 2016 4:00 pm
by davido
Hi Little John,

Apologies for 'bumping' the reply to [blendman]. I must have penned it whilst you where posting and didn't notice the error until some time later.

Thank you for all the recent changes.
Lucky I didn't upload any more icons in the meantime!
Apart from including file$ in the Procedure parameters, will you want a comment on file$ including?

It is a shame that SVG files only work on Linux.

For interest all the icons in the latest version appear the same on my PCs and on my MacBook Pro.
I'll post a few more this evening.

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

Posted: Tue Apr 26, 2016 4:36 pm
by Little John
davido wrote:Apologies for 'bumping' the reply to [blendman]. I must have penned it whilst you where posting and didn't notice the error until some time later.
Hi davido,

that's not a problem at all ! :-)
davido wrote:Apart from including file$ in the Procedure parameters, will you want a comment on file$ including?
Ooops. I knew that I forgot something ... Thanks for asking! Maybe something like

Code: Select all

; file$: name of SVG file which is to be created (only supported on Linux),
;        or "" for creating an image in memory

What do you think?
By the way: I am always thankful for corrections or improvements by native English speakers. :-)
davido wrote:For interest all the icons in the latest version appear the same on my PCs an MacBook Pro.
I'll post a few more this evening.
a) Cool. 8)
b) Cool. :-)

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

Posted: Tue Apr 26, 2016 9:37 pm
by davido
HI Little John,

Thank you.

I have added the comments you suggested to the Procedures of the three icons below.
Those comments look fine to me.

Code: Select all

   Declare.i Fill (file$, img.i, size.i, color1.i, color2.i)
   Declare.i Message (file$, img.i, size.i, color1.i, color2.i)
   Declare.i Colours (file$, img.i, size.i, color1.i, color2.i, color3.i, color4.i, color5.i, color6.i)
   
   Procedure.i Fill (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(img, size)
      p = size / 32
      If ret
        ;Drips
        VectorSourceColor(color2)
;         AddPathCircle(26.5*p,20.5*p,0.2*p)
         AddPathCircle(26.5*p,26*p,2.5*p,0,180)
         FillPath()
         AddPathCircle(26.5*p,23*p,0.99*p,180,0)
         FillPath()

         MovePathCursor(25.5*p,23*p)
         AddPathLine(24*p,26*p)
         AddPathLine(29*p,26*p)
         AddPathLine(27.5*p,23*p)
         ClosePath()
         FillPath()
         AddPathCircle(25.5*p,19.5*p,1.5*p,330,60)
         StrokePath(p)
        VectorSourceColor(color1)
        SaveVectorState()
        RotateCoordinates(16*p,16*p,45)
        AddPathRoundBox(8*p,10*p,16*p,15*p,2*p)
        FillPath()
        MovePathCursor(20*p,11.5*p)
        AddPathLine(25*p,11.5*p)
        AddPathLine(20*p,15*p)
        ClosePath()
        StrokePath(3*p,#PB_Path_RoundCorner)
        RestoreVectorState()
        AddPathEllipse(12*p,8*p,3*p,6*p)
        StrokePath(p)

         StopVectorDrawing()
      EndIf
      
      ProcedureReturn ret
   EndProcedure


   Procedure.i Message (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(img, size)
      p = size / 32
      If ret
         VectorSourceColor(color1)
         AddPathRoundBox(2*p,2*p,28*p,28*p,5*p)
         FillPath()
         VectorSourceColor(color2)
         AddPathEllipse(16*p,16*p,11*p,9*p)
         FillPath()
         MovePathCursor(13*p,24*p)
         AddPathLine(7*p,27*p)
         AddPathLine(10*p,22*p)
         ClosePath()
         FillPath()
         StrokePath(P)
         StopVectorDrawing()
      EndIf
      
      ProcedureReturn ret
   EndProcedure
   
   Macro ColourSegments()
     AddPathCircle(16*p,9*p,3.9*p,180,0)
     MovePathCursor(12.1*p,9*p)
     AddPathLine(16*p,15.8*p)
     AddPathLine(19.9*p,9*p)
     ClosePath()
     FillPath() 
   EndMacro 
   
   Procedure.i Colours (file$, img.i, size.i, color1.i, color2.i, color3.i, color4.i, color5.i, color6.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
     ;      color5: foreground color #5
     ;      color6: foreground color #6
     ; out: return value: if img = #Pb_Any => number of the created image,
     ;                    error => 0
     ; [by davido]
     Protected ret.i, p.d
  
      ret = StartVectorIconOutput(img, size)
      p = size / 32
      If ret
         VectorSourceColor(color1)
         ColourSegments()
         VectorSourceColor(color2)
         RotateCoordinates(16*p,16*p,60)
         ColourSegments()
         VectorSourceColor(color3)
         RotateCoordinates(16*p,16*p,60)
         ColourSegments()
         VectorSourceColor(color4)
         RotateCoordinates(16*p,16*p,60)
         ColourSegments()
         VectorSourceColor(color5)
         RotateCoordinates(16*p,16*p,60)
         ColourSegments()
         VectorSourceColor(color6)
         RotateCoordinates(16*p,16*p,60)
         ColourSegments()
         
         StopVectorDrawing()
      EndIf
      
      ProcedureReturn ret
    EndProcedure
    
    
      #ImgFill
      #ImgMessage
      #ImgColours
      
      
      , "Fill" , "Message" , "Colours"
      
      Fill(file$, #ImgFill, size.i, #CSS_Black, #CSS_OrangeRed)
      Message(file$, #ImgMessage, size.i, #CSS_RoyalBlue, #CSS_WhiteSmoke)
      Colours(file$, #ImgColours, size.i, #CSS_Red, #CSS_Green, #CSS_Blue, #CSS_Magenta, #CSS_Yellow, #CSS_Cyan)
      
      Fill(file$, #ImgFill + #IconCount, size.i, #CSS_Silver, #CSS_Silver)
      Message(file$, #ImgMessage + #IconCount, size.i, #CSS_Silver, #CSS_WhiteSmoke)
      Colours(file$, #ImgColours + #IconCount, size.i, #CSS_DarkGrey, #CSS_Grey, #CSS_Silver, #CSS_DarkGrey, #CSS_Grey, #CSS_Silver)
      
      

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

Posted: Wed Apr 27, 2016 1:54 am
by Little John
Thanks, davido!

Current changes
  • Added icons "Fill", "Message", and "Colours" by davido
  • Added missing comments for the new 'file$' parameter in the icon procedures.

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

Posted: Wed Apr 27, 2016 8:59 pm
by davido
Hi Little John,

I would like to add the 3 more icons: Navigation1, Navigation2 and Volume.

Code: Select all

   Declare.i Navigation1 (file$, img.i, size.i, color1.i, color2.i)
   Declare.i Navigation2 (file$, img.i, size.i, color1.i, color2.i, color3.i, color4.i)
   Declare.i Volume (file$, img.i, size.i, color1.i, color2.i)
   
    Procedure.i Navigation1 (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(img, size)
      p = size / 32
      If ret
         VectorSourceColor(color1)
         AddPathCircle(16*p,16*p,13*p)
         StrokePath(2*p)
         RotateCoordinates(16*p,16*p,45)
         MovePathCursor(16*p,5*p)
         AddPathLine(12*p,16*p)
         AddPathLine(16*p,26*p)
         AddPathLine(20*p,16*p)
         ClosePath()
         FillPath()
         VectorSourceColor(color2)
         AddPathCircle(16*p,16*p,2*p)
         FillPath()
         StopVectorDrawing()
      EndIf
      
      ProcedureReturn ret
   EndProcedure

   Procedure.i Navigation2 (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(img, size)
      p = size / 32
      If ret
        ;Outer circle
         VectorSourceColor(color1)
         AddPathCircle(16*p,16*p,8*p)
         StrokePath(3.5*p)
         AddPathCircle(16*p,16*p,3*p)
         StrokePath(2*p)
         ;NESW
         VectorSourceColor(color2)
         MovePathCursor(14*p,13*p)
         AddPathLine(16*p,1*p)
         AddPathLine(18*p,13*p)
         RotateCoordinates(16*p,16*p,90)
         MovePathCursor(14*p,13*p)
         AddPathLine(16*p,1*p)
         AddPathLine(18*p,13*p)
         RotateCoordinates(16*p,16*p,90)
         MovePathCursor(14*p,13*p)
         AddPathLine(16*p,1*p)
         AddPathLine(18*p,13*p)
         RotateCoordinates(16*p,16*p,90)
         MovePathCursor(14*p,13*p)
         AddPathLine(16*p,1*p)
         AddPathLine(18*p,13*p)
         ClosePath()
         FillPath()
         ;NwSwSeNe
         VectorSourceColor(color3)
         RotateCoordinates(16*p,16*p,45)
         MovePathCursor(14.5*p,13*p)
         AddPathLine(16*p,4*p)
         AddPathLine(17.5*p,13*p)
         RotateCoordinates(16*p,16*p,90)
         MovePathCursor(14.5*p,13*p)
         AddPathLine(16*p,4*p)
         AddPathLine(17.5*p,13*p)
         RotateCoordinates(16*p,16*p,90)
         MovePathCursor(14.5*p,13*p)
         AddPathLine(16*p,4*p)
         AddPathLine(17.5*p,13*p)
         RotateCoordinates(16*p,16*p,90)
         MovePathCursor(14.5*p,13*p)
         AddPathLine(16*p,4*p)
         AddPathLine(17.5*p,13*p)
         ClosePath()
         FillPath()
         
         ;Inner circle
         VectorSourceColor(color1)
         AddPathCircle(16*p,16*p,3*p)
         StrokePath(2*p)
         StopVectorDrawing()
      EndIf
      
      ProcedureReturn ret
   EndProcedure

   Procedure.i Volume (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(img, size)
      p = size / 32
      If ret
        VectorSourceColor(color2)
        AddPathRoundBox(5*p,0,22*p,size,5*p)
        FillPath()
         VectorSourceColor(color1)
         DrawPlus(16*p,5*p,4*p,1.5*p)
         MovePathCursor(8*p,20*p)
         AddPathLine(24*p,20*p)
         AddPathLine(24*p,12*p)
         ClosePath()
         FillPath()
         DrawMinus(16*p,27*p,4*p,1.5*p)
         StopVectorDrawing()
      EndIf
      
      ProcedureReturn ret
    EndProcedure
    
      #ImgNavigation1
      #ImgNavigation2
      #ImgVolume
      
      
      , "Navigation 1", "Navigation 2", "Volume"
      
      
      Navigation1(file$, #ImgNavigation1, size.i, #CSS_Black, #CSS_WhiteSmoke)
      Navigation2(file$, #ImgNavigation2, size.i, #CSS_Black, #CSS_RoyalBlue, #CSS_Gold, #CSS_WhiteSmoke)
      Volume(file$, #ImgVolume, size.i, #CSS_Black, #CSS_LightSteelBlue)
      
      Navigation1(file$, #ImgNavigation1 + #IconCount, size.i, #CSS_Silver, #CSS_WhiteSmoke)
      Navigation2(file$, #ImgNavigation2 + #IconCount, size.i, #CSS_DarkGrey, #CSS_Grey, #CSS_Silver, #CSS_WhiteSmoke)
      Volume(file$, #ImgVolume + #IconCount, size.i, #CSS_Grey, #CSS_Silver)
      
      
    
    

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

Posted: Wed Apr 27, 2016 10:07 pm
by Little John
Current changes
  • Added icons "Navigation 1", "Navigation 2", and "Volume" by davido
  • Added a procedure that creates one PNG file with all icons (e.g. for uploading on the PureBasic forum).
    So I don't always have to take a screenshot. :-)

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

Posted: Thu Apr 28, 2016 8:10 pm
by Oma
Hi everyone!
So, as announced ...
(what an effort in the meanwhile - and for John in particular i think - so thank you again for your efforts.)
Because of the amount of data, for this time the code is stored for download (till it's obiously downloaded).
http://www.chabba.de/temp/VectorIcon_up ... 6-04-28.pb


To make it short, this icons are new

- FirstAid_Convex
- NoEntry_Convex
- Stop3_Convex
- Download2_Convex


which are derivates from the existing eponymous (w/o "_Convex") flat icons, with a convex appearing background.
For that this Macro is required: Convex_Area(_colorbright_, _darken_)
(a general macro to create a convex & round, rectangular or rounded corners background area)
It's also applicable on icons like "Donate1", "Question2", "On", "Off", "Info2", printer, open, ...

@John: I think your assessment is needed first, whether you want this style in the collection.

Also new ...
- ChartLineDot
- ChartBarHor
- ChartBarVertStacked
- ChartBarHorStacked
- ChartCylHor
- ChartCylVertStacked
- ChartCylHorStacked
- ChartArea
- ChartAreaPerc
- ChartPrice

(- ChartRing; just realized that it's double-buggy again on windows :evil: )
This time with white backgrounds (with the exception of ChartArea() icon as it would leave a false (percentage) impression, and ChartAreaPerc(), which has no place for a background)
If the old, transparent style is prefered, please delete the last parameter in the calls (", #CSS_White")

Furthermore all xxxDocument-style icons are changed to an outsourced "sheet" within a Macro.
- NewDocument
- CloseDocument
- EditDocument
- ClearDocument
- ImportDocument
- ExportDocument
- SortAscending
- SortDescending
- SortBlockAsc
- SortBlockDesc

and the following icons got smart improvements (for my taste)
- FirstAid
- NoEntry
- Stop3

- ChartLine
- ChartDot
- ChartBarVert
- ChartCylVert
- ChartPie
- Open3

Therefore the following macros were created ...
- DocuSheet()
- ChartScale()
- ChartBars(_angle_)
- ChartBarsStacked(_angle_)
- ChartCylBars(_angle_)
- ChartCylBarsStacked(_angle_)

Best Regards, Charly

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

Posted: Fri Apr 29, 2016 1:50 pm
by Little John
Oma wrote:Because of the amount of data, for this time the code is stored for download (till it's obiously downloaded).
http://www.chabba.de/temp/VectorIcon_up ... 6-04-28.pb
Hi Charly ... wow :!:
Very impressive! What else could I say? ;-)

This is what I did in the current collection with your input:
Changed 2016-04-29, 2:00 p.m.
15 procedures modified
(some of these icons have got new colors, too):
  • NewDocument()
  • EditDocument()
  • ClearDocument()
  • ImportDocument()
  • ExportDocument()
  • CloseDocument()
  • SortAscending()
  • SortDescending()
  • SortBlockAscending()
  • SortBlockDescending()
  • ChartLine()
  • ChartDot()
  • ChartBarVert()
  • ChartCylVert()
  • ChartPie()
11 procedures added:
  • ChartLineDot()
  • ChartBarHor()
  • ChartCylHor()
  • ChartBarVertStacked()
  • ChartBarHorStacked()
  • ChartCylVertStacked()
  • ChartCylHorStacked()
  • ChartArea()
  • ChartAreaPerc()
  • ChartPrice()
  • ChartRing()
I have also rearranged the order of some of your icons, e.g. "NewDocument" is now directly before "EditDocument", so that all xxxDocument icons are next to each other. I hope you like it. If not I'll change it, of course.
Oma wrote:To make it short, this icons are new

- FirstAid_Convex
- NoEntry_Convex
- Stop3_Convex
- Download2_Convex


which are derivates from the existing eponymous (w/o "_Convex") flat icons, with a convex appearing background.
For that this Macro is required: Convex_Area(_colorbright_, _darken_)
(a general macro to create a convex & round, rectangular or rounded corners background area)
It's also applicable on icons like "Donate1", "Question2", "On", "Off", "Info2", printer, open, ...

@John: I think your assessment is needed first, whether you want this style in the collection.
In your file "VectorIcon_updt_omi_2016-04-28.pb", I didn't find the above mentioned procedures or macro.
So I don't know exactly how these icons look.
However, I personally don't want to exclude any icons from the collection.
If these icons look very different than the others, then maybe we could put the existing icons and those new ones in different "categories".
"Categories" could mean in this context, separate tabs in the overview window, and separate subfolders when saving the icons as files. What do you think?
Oma wrote:(- ChartRing; just realized that it's double-buggy again on windows :evil: )
It seems to be this bug.

I already encountered it in the previous version of your "ChartPie" icon ... and wrote a Windows-bugfix for it.
Now in the new version of the "ChartPie" icon, on Wondows the bug is again there.

In the new ChartRing icon, you used CompilerIf ... CompilerEndIf for Windows, probably because of the bug.
But when the CompilerIf ... CompilerEndIf is active, IMHO it looks even worse. :-)
So I disabled these Compiler directives for the moment. Please tell me what to do with this.
Oma wrote:and the following icons got smart improvements (for my taste)
- FirstAid
- NoEntry
- Stop3
- Open3
In your uploaded PB source file, I couldn't find code which changes these icons. :?
(There is only code for calling Open3(), which uses the same colors as before.)

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

Posted: Fri Apr 29, 2016 7:25 pm
by Oma
Hello John!
I'm very sorry that this went so wrong. :oops:
Please do not be too angry. Yesterday I was really too tired for this work.
Now i've got the declaration for this fault. After the whole copying, testing, converting it to your new programm and creating the uploaded filed, i've got two Upload-Folders on USB-Stick and have uploaded an old file.

Since you have already integrated a part of my intended post, i've tried to figure out what is still missing.

As an excuse, i tried to make a workaround for the ChartRing()-icon for Windows. Like the icon itself, the workaround has no calculated CAD-precision.
(if you look at the parts you see, the angles are a little 'faked') but it should be enough for an icon.
What surprises me is, that the angles of AddPathEllipse() are not the same on Windows and Linux (in addition to your mentioned bug with #PB_Path_Connected).

Also included is the ChartPie()-Icon with your Windows-workaround (which should be in the download-file). The only difference against the original version is only a small (lazy) correction of the position.

The Open3()-Icon got only an attempt to find a better color for the flap in the call for the color-version.

I finally tried to re-integrate the missing parts in your new edition with the (again) new procedure-format but got a "Zeile 7243: With 'EnableExplicit', variables have to be declared: iconCount." and have no idea why?
So i let it in the previous format and hope, that not too much is missing' ...

Code: Select all

;-declares ...
; Declare.i ChartRing(img.i, size.i, color1.i, color2.i, color3.i, color4.i, color5.i= 0)
Declare.i FirstAid_Convex (img.i, size.i, color1.i, color2.i=0)
Declare.i NoEntry_Convex (img.i, size.i, color1.i, color2.i=0)
Declare.i Stop3_Convex (img.i, size.i, color1.i, color2.i=0)
Declare.i Download2_Convex (img.i, size.i, color.i, color2.i=0)

;-
;-macros new ...
;general macro to create a convex & round / rectangular / rounded corner background area
Macro Convex_Area(_colorbright_, _darken_); for 'x_Convex()'-icons
	;The brighter the _colorbright_ & lower the _darken_-factor (0.0 ... 1.0), the stronger is the effect.
	VectorSourceLinearGradient(0, 0, size, size)
	VectorSourceGradientColor(_colorbright_, 0.0)
	VectorSourceGradientColor(Color_Darken(_colorbright_, _darken_), 1.0)
EndMacro

;-
;-procedures mod ...
Procedure.i FirstAid (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.0
	Protected p2.d = size / 2.0
	
	ret = StartVectorIconOutput(img, size)
	
	If ret
		VectorSourceColor(color2)
		; panel: round corners
		AddPathBox    (p8, p8, size - 2 * p8, size - 2 * p8)
		FillPath      ()
		AddPathBox    (p8, p8, size - 2 * p8, size - 2 * p8)
		StrokePath    (p8 * 2, #PB_Path_RoundCorner)
		
		VectorSourceColor(color1)
		; hor. bar
		MovePathCursor(p8, p2)
		AddPathLine   (size - 2 * p8, 0, #PB_Path_Relative)
		; vert. bar
		MovePathCursor(p2, p8)
		AddPathLine   (0, size - 2 * p8, #PB_Path_Relative)
		StrokePath    (size / 5)
		
		StopVectorDrawing()
	EndIf
	
	ProcedureReturn ret
EndProcedure


Procedure.i NoEntry (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.0
	Protected p2.d = size / 2.0
	
	ret = StartVectorIconOutput(img, size)
	
	If ret
		; panel
		VectorSourceColor(color2)
		
		AddPathCircle    (p2, p2, p2)
		FillPath()
		
		; bar
		VectorSourceColor(color1)
		MovePathCursor   (p8, p2)
		AddPathLine      (size - 2 * p8, 0, #PB_Path_Relative)
		StrokePath       (size/5)
		
		StopVectorDrawing()
	EndIf
	
	ProcedureReturn ret
EndProcedure


Procedure.i Stop3 (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 hw.d = size / 3.5
	Protected half.d = size / 2.0
	
	ret = StartVectorIconOutput(img, size)
	
	If ret
		VectorSourceColor(color2)
		; panel
		AddPathCircle    (half, half, half)
		FillPath()
		
		VectorSourceColor(color1)
		; cross
		MovePathCursor   (hw, hw)
		AddPathLine      (size - hw, size - hw)
		MovePathCursor   (hw, size - hw)
		AddPathLine      (size - hw, hw)
		StrokePath       (size / 10)
		
		StopVectorDrawing()
	EndIf
	
	ProcedureReturn ret
EndProcedure

;- only pos-correction (your fixed version) ...
Procedure.i ChartPie (img.i, size.i, color1.i, color2.i, color3.i, color4.i, color5.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
	;      color3: foreground color #3
	;      color4: foreground color #4
	;      color5: foreground color #5
	; out: return value: if img = #Pb_Any => number of the created image,
	;                    error => 0
	; [org. by Omi, 10.04.2016]
	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 = StartVectorIconOutput(img, size)
	
	If ret
		; border
		If color5
			VectorSourceColor(color5)
			AddPathBox(0, 0, size, size)
			FillPath()
		EndIf
		
		TranslateCoordinates(0, -p16)
		; bottom right
		MovePathCursor   (size - p16, p2)
		AddPathEllipse   (p2, p2 + p8, p2 - p16, p2 - p4, 0, 90, #PB_Path_Connected)
		AddPathLine      (p2, p2 + p4)
		ClosePath()
		VectorSourceColor(Color_Darken(color3, 0.8))
		FillPath(#PB_Path_Preserve)
		VectorSourceColor(color1)
		StrokePath       (p)
		
		; bottom left
		MovePathCursor   (p2,  p2 + p4)
		AddPathEllipse   (p2,  p2 + p8, p2 - p16, p2 - p4, 90, 180, #PB_Path_Connected)
		AddPathLine      (p16, p2)
		ClosePath()
		VectorSourceColor(Color_Darken(color4, 0.8))
		FillPath(#PB_Path_Preserve)
		VectorSourceColor(color1)
		StrokePath       (p)
		
		; pieces
		MovePathCursor   (p2, p2)
		AddPathEllipse   (p2, p2, p2 - p16, p2 - p4, 210, 330, #PB_Path_Connected)
		VectorSourceColor(color2)
		ClosePath        ()
		FillPath(#PB_Path_Preserve)
		VectorSourceColor(color1)
		StrokePath       (p)
		
		CompilerIf #PB_Compiler_OS = #PB_OS_Windows
			; Workaround for bug in PB 5.42 on Windows, see
			; <http://www.purebasic.fr/english/viewtopic.php?f=4&t=65540>
			Protected.d x1, y1, x2, y2
			
			x1 = p2 + 0.69*p2 * Cos(Radian(330))
			y1 = p2 + 0.69*p2 * Sin(Radian(330))
			x2 = p2 + 0.53*p2 * Cos(Radian( 90))
			y2 = p2 + 0.53*p2 * Sin(Radian( 90))
			
			MovePathCursor(x1, y1)
			AddPathLine(x2, y2-0.03*p2)
			VectorSourceColor(color3)
			StrokePath       (p)
			
			AddPathEllipse   (p2, p2, p2 - p16, p2 - p4, 330, 90)
			MovePathCursor   (x1, y1)
			AddPathLine      (p2, p2)
			AddPathLine      (x2, y2)
			FillPath(#PB_Path_Preserve)
			VectorSourceColor(color1)
			StrokePath       (p)
			
		CompilerElse
			MovePathCursor   (p2, p2)
			AddPathEllipse   (p2, p2, p2 - p16, p2 - p4, 330, 90, #PB_Path_Connected)
			VectorSourceColor(color3)
			ClosePath        ()
			FillPath(#PB_Path_Preserve)
			VectorSourceColor(color1)
			StrokePath       (p)
		CompilerEndIf
		
		MovePathCursor   (p2, p2)
		AddPathEllipse   (p2, p2, p2 - p16, p2 - p4, 90, 210, #PB_Path_Connected)
		VectorSourceColor(color4)
		ClosePath        ()
		FillPath         (#PB_Path_Preserve)
		VectorSourceColor(color1)
		StrokePath       (p)
		
		StopVectorDrawing()
	EndIf
	
	ProcedureReturn ret
EndProcedure


;-
;- procedures new ...
Procedure.i ChartRing(img.i, size.i, color1.i, color2.i, color3.i, color4.i, color5.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
	;      color3: foreground color #1
	;      color4: foreground color #2
	;      color5: foreground color #1
	; 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 angle1.d, angle2.d, angle3.d
	
	CompilerIf #PB_Compiler_OS = #PB_OS_Windows
		angle1= 196
		angle2= 344
		angle3= 90
	CompilerElse
		angle1= 210
		angle2= 330
		angle3= 90
	CompilerEndIf
	
	ret = StartVectorIconOutput(img, size)
	
	If ret
		;border
		If color5
			VectorSourceColor(color5)
			AddPathBox(0, 0, size, size)
			FillPath()
		EndIf
		
		TranslateCoordinates(0, -p)
		;rand
		MovePathCursor   (size - p16 + p / 3, p2 + p)
		AddPathEllipse   (p2,                 p2 + p8, p2 - p16, p2 - p4 + p, 0, 90, #PB_Path_Connected)
		AddPathLine      (p2,                 p2 + p4)
		ClosePath()
		VectorSourceColor(Color_Darken(color3, 0.6))
		FillPath(#PB_Path_Preserve)
		StrokePath       (p)
		
		CompilerIf #PB_Compiler_OS = #PB_OS_Windows
			MovePathCursor   (p2 - p / 2, p2 + p8)
			AddPathLine      (p2 - p / 2, p2 + p4)
			AddPathEllipse   (p2,         p2 + p8, p2 - p16, p2 - p4 + p, 92, 180)
			AddPathLine      (p * 1.5,    p2 )
			AddPathLine      (p2 - p / 2, p2 + p8)
			ClosePath()
			VectorSourceColor(Color_Darken(color4, 0.6))
			FillPath(#PB_Path_Preserve)
			StrokePath       (p)
		CompilerElse
			MovePathCursor   (p2 - p / 2, p2 + p4)
			AddPathEllipse   (p2,         p2 + p8, p2 - p16, p2 - p4 + p, 92, 180, #PB_Path_Connected)
			AddPathLine      (p16 - p/3,  p2 + p)
			ClosePath()
			VectorSourceColor(Color_Darken(color4, 0.6))
			FillPath(#PB_Path_Preserve)
			StrokePath       (p)
		CompilerEndIf
		
		MovePathCursor   (p2 - p * 9, p2 - p4)
		AddPathEllipse   (p2,         p2 + p4 - p, p2 - p16, p2 - p4 + p, 230, 310, #PB_Path_Connected)
		AddPathLine      (p2 + p * 9, p2 - p4)
		ClosePath()
		VectorSourceColor(Color_Darken(color2, 0.6))
		FillPath(#PB_Path_Preserve)
		StrokePath       (p)
		;
		;pieces
		AddPathEllipse   (p2, p2 - p, p2 - p8, p4 - p, angle1, angle2)
		VectorSourceColor(color2)
		StrokePath       (p8+p16)
		
		AddPathEllipse   (p2, p2 - p, p2 - p8, p4 - p, angle2, angle3)
		VectorSourceColor(color3)
		StrokePath       (p8+p16)
		
		AddPathEllipse   (p2, p2 - p, p2 - p8, p4 - p, angle3, angle1)
		VectorSourceColor(color4)
		StrokePath       (p8+p16)
		;lines
		VectorSourceColor(Color_Darken(color1, 0.6))
		MovePathCursor   (size - p * 3, p2 - p * 6)
		AddPathLine      (size - p * 8, p2 - p * 3)
		AddPathLine      (0,            p * 3,      #PB_Path_Relative)
		StrokePath       (p)
		
		MovePathCursor   (p * 3,        p2 - p * 6)
		AddPathLine      (p * 8,        p2 - p * 3)
		AddPathLine      (0,            p * 3,      #PB_Path_Relative)
		StrokePath       (p)
		
		MovePathCursor   (p2,           p2 + p * 3 )
		AddPathLine      (p2,           p2 + p / 2 * 26)
		StrokePath       (p)
		
		StopVectorDrawing()
	EndIf
	
	ProcedureReturn ret
EndProcedure

;- +
;-(Johns assessment needed ...)
Procedure.i FirstAid_Convex (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.0
	Protected p2.d = size / 2.0
	
	ret = StartVectorIconOutput(img, size)
	
	If ret
		; panel: round corners
		Convex_Area(color2, 0.4)
		AddPathBox    (p8, p8, size - 2 * p8, size - 2 * p8)
		FillPath      ()
		AddPathBox    (p8, p8, size - 2 * p8, size - 2 * p8)
		StrokePath    (p8 * 2, #PB_Path_RoundCorner)
		
		VectorSourceColor(color1)
		; hor. bar
		MovePathCursor(p8, p2)
		AddPathLine   (size - 2 * p8, 0, #PB_Path_Relative)
		; vert. bar
		MovePathCursor(p2, p8)
		AddPathLine   (0, size - 2 * p8, #PB_Path_Relative)
		StrokePath    (size / 5)
		
		StopVectorDrawing()
	EndIf
	
	ProcedureReturn ret
EndProcedure


Procedure.i NoEntry_Convex (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.0
	Protected p2.d = size / 2.0
	
	ret = StartVectorIconOutput(img, size)
	
	If ret
		; panel
		Convex_Area(color2, 0.4)
		AddPathCircle    (p2, p2, p2)
		FillPath()
		
		; bar
		VectorSourceColor(color1)
		MovePathCursor   (p8, p2)
		AddPathLine      (size - 2 * p8, 0, #PB_Path_Relative)
		StrokePath       (size/5)
		
		StopVectorDrawing()
	EndIf
	
	ProcedureReturn ret
EndProcedure

Procedure.i Stop3_Convex (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 hw.d = size / 3.5
	Protected half.d = size / 2.0
	
	ret = StartVectorIconOutput(img, size)
	
	If ret
		; panel
		Convex_Area(color2, 0.4)
		AddPathCircle    (half, half, half)
		FillPath()
		
		VectorSourceColor(color1)
		; cross
		MovePathCursor   (hw, hw)
		AddPathLine      (size - hw, size - hw)
		MovePathCursor   (hw, size - hw)
		AddPathLine      (size - hw, hw)
		StrokePath       (size / 10)
		
		StopVectorDrawing()
	EndIf
	
	ProcedureReturn ret
EndProcedure

Procedure.i Download2_Convex (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 = StartVectorIconOutput(img, size)
	
	If ret
		Convex_Area(color2, 0.4)
		; 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(color1)
		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
	
	ProcedureReturn ret
EndProcedure

Data.s  "FirstAidConvex", "NoEntryConvex", "Stop3Convex", "Download2Convex"



;-
;- calls new, color ...
NewElement(imgEnabled(), FirstAid_Convex(#PB_Any, size, #CSS_White, #CSS_OrangeRed))
NewElement(imgEnabled(), NoEntry_Convex(#PB_Any, size, #CSS_White, #CSS_OrangeRed))
NewElement(imgEnabled(), Stop3_Convex(#PB_Any, size, #CSS_White, #CSS_OrangeRed))
NewElement(imgEnabled(), Download2_Convex(#PB_Any, size, #CSS_White, #CSS_LimeGreen))
NewElement(imgEnabled(), ChartRing (#PB_Any, size, #CSS_DarkGray, #CSS_DarkOrange, #CSS_Yellow, #CSS_CornflowerBlue, #CSS_White))
;- calls mod. (smart color change)
NewElement(imgEnabled(), Open3(#PB_Any, size, #CSS_GoldenRod, #CSS_Chocolate))
;- calls mod. color
NewElement(imgEnabled(), ChartPie (#PB_Any, size, #CSS_Black, #CSS_DarkOrange, #CSS_Yellow, #CSS_CornflowerBlue, #CSS_White))

;- calls new, greyed ...
NewElement(imgDisabled(), FirstAid_Convex(#PB_Any, size, #CSS_WhiteSmoke, #CSS_Silver))
NewElement(imgDisabled(), NoEntry_Convex(#PB_Any, size, #CSS_WhiteSmoke, #CSS_Silver))
NewElement(imgDisabled(), Stop3_Convex(#PB_Any, size, #CSS_WhiteSmoke, #CSS_Silver))
NewElement(imgDisabled(), Download2_Convex(#PB_Any, size, #CSS_WhiteSmoke, #CSS_Silver))
NewElement(imgDisabled(), ChartRing (#PB_Any, size, #CSS_DimGrey, #CSS_Silver, #CSS_Silver, #CSS_Silver))
;- calls mod. 
;NewElement(imgDisabled(), Open3(#PB_Any, size, #CSS_Silver, #CSS_Silver)); w/o change
;- calls mod. grey
NewElement(imgDisabled(), ChartPie (#PB_Any, size, #CSS_DimGrey, #CSS_Silver, #CSS_Silver, #CSS_Silver, #CSS_White))
I guess that the current snapshot was taken on Linux. I've just noticed that the visual differences are greater than thought between the systems.

@davido:
Just had the idea of an 'Volume'-icon and be happy to be too slow. Your version is look much better than my 'idea'.

Best regards, Charly

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

Posted: Fri Apr 29, 2016 7:59 pm
by davido
@oma,
Regarding the 'Volume' Icon, I had a similar experience when you posted your first group of 'Chart' Icons. I had just started a simple bar chart. It looked rather shabby compared with your excellent bar chart icons, though.
I've just looked at your latest batch of 'Chart' Icons, they look really great.

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

Posted: Fri Apr 29, 2016 10:49 pm
by Andre
Very impressive, and thank you very much for adding the new Chart icons! :mrgreen:

More suggestions/wishes will come for sure, as soon I'm able to use/integrate the icons... :wink:

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

Posted: Sat Apr 30, 2016 2:56 pm
by Little John
Oma wrote:Hello John!
I'm very sorry that this went so wrong. :oops:
Please do not be too angry. Yesterday I was really too tired for this work.
Now i've got the declaration for this fault. After the whole copying, testing, converting it to your new programm and creating the uploaded filed, i've got two Upload-Folders on USB-Stick and have uploaded an old file.
Hi Charly,

please don't worry, I am not angry at all. Things like that just happen.
Actually, I am very pleased about all your ideas and contributions.
Oma wrote:Like the icon itself, the workaround has no calculated CAD-precision.
(if you look at the parts you see, the angles are a little 'faked') but it should be enough for an icon.
I agree that for our icons here no calculated CAD-precision is required. :-)
Oma wrote:What surprises me is, that the angles of AddPathEllipse() are not the same on Windows and Linux (in addition to your mentioned bug with #PB_Path_Connected).
That seems to be the same bug which davido already encountered on Mac OSX. You can use this code for checking the angles. The tests by davido and me disclosed a bug on Mac OSX, while on Windows the angles were correct. So maybe this bug is in the Linux version of PB, too?
Oma wrote:I finally tried to re-integrate the missing parts in your new edition with the (again) new procedure-format [...]
I am sorry for the hassle that I caused by so often changing the procedure format!
The main reason was that I really wanted to implement proper support for saving the icons to SVG files, because we are drawing vector graphics here. It would be a shame to only save the results in a pixel graphics format such as PNG. Unfortunately, it took some time until I had the right ideas for proper SVG file creation support.

Here is the summary of the current changes:
New changes by Oma, included in this collection by me on 2016-04-30, 2:50 p.m.
5 procedures modified
(some of these icons have got new colors, too):
  • FirstAid()
  • NoEntry()
  • Stop3()
  • ChartPie()
  • ChartRing()
4 procedures added:
  • FirstAid_Convex()
  • NoEntry_Convex()
  • Stop3_Convex()
  • Download2_Convex()
Additionally I have rearranged the order of some icons, and your macros DocuSheet(), Chartxxx() and Convex_Area() are now at the beginnung of your code.

I like your xxx_Convex() icons, I don't want to miss them in the collection. :-)
The style of the icons in the collection is heterogeneous anyway, because they are created by several different people. So in this project we have to live with this circumstance.
Oma wrote:

Code: Select all

;- calls mod. grey
NewElement(imgDisabled(), ChartPie (#PB_Any, size, #CSS_DimGrey, #CSS_Silver, #CSS_Silver, #CSS_Silver, #CSS_White))
The new thing here is #CSS_White as last parameter. I did not implement this change :oops: because I think in the "disabled" versions, there shouldn't be white (or black), but only shades of grey.
Another small modification by me: For generating the "disabled" version of Open3(), I changed the value of the last parameter to #CSS_DarkGrey. Previously, both parameter values were identical, which did not produce a proper representation of that icon.
I guess that the current snapshot was taken on Linux.
Yes, it was. I did it deliberately on Linux because of the bugs in the Windows version.

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

Posted: Sat Apr 30, 2016 4:17 pm
by Oma
Got a new one with a derivate - so it stays simple ;-)
- Notes
- Notes_Curved (w. gradient)

Hi John, you're always some minutes too fast - thats's my destiny :cry: .

Code: Select all

;- declares ...
Declare.i Notes (file$, img.i, size.i, color1.i, color2.i, color3.i, color4.i, color5.i)
Declare.i Notes_Curved (file$, img.i, size.i, color1.i, color2.i, color3.i, color4.i, color5.i)


;- macros ...
Macro GradientFullsize_AxisVhi(_colorbright_, _darken_); vertical, axis w. high color value
	;The brighter the _colorbright_ & lower the _darken_-factor (0.0 ... 1.0), the stronger is the effect.
	VectorSourceLinearGradient(0, 0, size, 0)
	VectorSourceGradientColor(Color_Darken(_colorbright_, _darken_), 0.0)
	VectorSourceGradientColor(_colorbright_, 0.55)
	VectorSourceGradientColor(Color_Darken(_colorbright_, _darken_), 1.0)
EndMacro


;- icons ...
Procedure.i Notes (file$, img.i, size.i, color1.i, color2.i, color3.i, color4.i, color5.i)
	; in : file$: name of SVG file which is to be created (only supported on Linux),
	;             or "" for creating an image in memory
	;      img   : number of the image which is to be created, or #PB_Any
	;      size  : width and height (number of pixels)
	;      color1: foreground color #1
	;      colorn: foreground color #n
	; 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 = StartVectorIconOutput(file$, img, size)
	
	If ret
		;border
		VectorSourceColor(color2)
		MovePathCursor(p16,        p4)
		AddPathLine   (size - p4,  p)
		AddPathLine   (size - p16, size - p4)
		AddPathLine   (p4,         size - p)
		ClosePath     ()
		FillPath      ()
		
		TranslateCoordinates(-p, -p)
		VectorSourceColor(color1)
		MovePathCursor   (p16,        p4)
		AddPathLine      (size - p4,  p)
		AddPathLine      (size - p16, size - p4)
		AddPathLine      (p4,         size - p)
		ClosePath        ()
		FillPath         ()
		
		; pen
		VectorSourceColor(color3)
		MovePathCursor(size - p,      7 * p)
		AddPathLine   (size - 5 * p, 11 * p)
		StrokePath    (p8)
		
		VectorSourceColor(color5)
		MovePathCursor(size - 5 * p, 11 * p)
		AddPathLine   (size - 6 * p, 12 * p)
		StrokePath    (p8)
		
		VectorSourceColor(color3)
		MovePathCursor(size - 6 * p, 12 * p)
		AddPathLine   (p2 - p,       23 * p)
		StrokePath    (p8)
		; added wooden tip-part w. extra color ...
		VectorSourceColor(color4)
		MovePathCursor(27 * p / 2,  43 * p / 2)
		AddPathLine   (12 * p,      26 * p)
		AddPathLine   (33 * p / 2,  49 * p / 2)
		ClosePath     ()
		FillPath      ()
		
		VectorSourceColor(color3)
		MovePathCursor(13 * p,      23 * p)
		AddPathLine   (12 * p,      26 * p)
		AddPathLine   (15 * p,      25 * p)
		ClosePath     ()
		FillPath      ()
		
		StopVectorDrawing()
	EndIf
	
	ProcedureReturn ret
EndProcedure

Procedure.i Notes_Curved (file$, img.i, size.i, color1.i, color2.i, color3.i, color4.i, color5.i)
	; in : file$: name of SVG file which is to be created (only supported on Linux),
	;             or "" for creating an image in memory
	;      img   : number of the image which is to be created, or #PB_Any
	;      size  : width and height (number of pixels)
	;      color1: foreground color #1
	;      colorn: foreground color #n
	; 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 = StartVectorIconOutput(file$, img, size)
	
	If ret
		; note ...
		VectorSourceColor(color2)
		MovePathCursor(p16,        p4)
		AddPathLine   (size - p4,  p)
		AddPathLine   (size - p16, size - p4)
		AddPathLine   (p4,         size - p)
		ClosePath     ()
		FillPath      ()
		
		TranslateCoordinates(-p, -p)
		GradientFullsize_AxisVhi(color1, 0.75)
		MovePathCursor(p16,        p4)
		AddPathLine   (size - p4,  p)
		AddPathLine   (size - p16, size - p4)
		AddPathLine   (p4,         size - p)
		ClosePath     ()
		FillPath      ()
		
		; pen ...
		VectorSourceColor(color3)
		MovePathCursor(size - p,      7 * p)
		AddPathLine   (size - 5 * p, 11 * p)
		StrokePath    (p8)
		
		VectorSourceColor(color5)
		MovePathCursor(size - 5 * p, 11 * p)
		AddPathLine   (size - 6 * p, 12 * p)
		StrokePath    (p8)
		
		VectorSourceColor(color3)
		MovePathCursor(size - 6 * p, 12 * p)
		AddPathLine   (p2 - p,       23 * p)
		StrokePath    (p8)
		; added wooden tip-part w. extra color ...
		VectorSourceColor(color4)
		MovePathCursor(27 * p / 2,  43 * p / 2)
		AddPathLine   (12 * p,      26 * p)
		AddPathLine   (33 * p / 2,  49 * p / 2)
		ClosePath     ()
		FillPath      ()
		
		VectorSourceColor(color3)
		MovePathCursor(13 * p,      23 * p)
		AddPathLine   (12 * p,      26 * p)
		AddPathLine   (15 * p,      25 * p)
		ClosePath     ()
		FillPath      ()
		
		StopVectorDrawing()
	EndIf
	
	ProcedureReturn ret
EndProcedure


;- data ...
Data.s "Notes", "NotesCurved"


;- add colored ...
NewIcon(Notes(file$, img, size, #CSS_Gold, #CSS_DarkGray, #CSS_Black, #CSS_White, #CSS_White))
NewIcon(Notes_Curved(file$, img, size, #CSS_Yellow, #CSS_DarkGray, #CSS_Black, #CSS_Wheat, #CSS_White))

;- add greyed ...
NewIcon(Notes(file$, img, size, #CSS_Silver, #CSS_DimGrey, #CSS_DimGrey, #CSS_Silver, #CSS_Silver))
NewIcon(Notes_Curved(file$, img, size, #CSS_Silver, #CSS_DimGrey, #CSS_DimGrey, #CSS_Silver, #CSS_Silver))
Concerning the angles: So maybe this bug is in the Linux version of PB, too?
Visually it seems, that the bug is in the windows version but i haven't checked it.
Thanks for the link - i hope i do not forget and give (if need be) a hint to the bugreport ...
I am sorry for the hassle that I caused by so often changing the procedure format!
It costs me much time but now i see the benefit. You got a good solution and it's much more easier to do new postings in the future. :D
I like your xxx_Convex() icons, I don't want to miss them in the collection.
Thank you, and Andre, and davido ... :D
The new thing here is #CSS_White as last parameter. I did not implement this change
Sorry! again :cry: , i totally agree, this was an accident.
... Open3(), I changed the value of the last parameter to #CSS_DarkGrey
Every improvement is okay 8)


I did some trials on existing flat icons to demonstrate the effect of the new GradientFullsize_xxx()-Macros.
Here's a snapshot of some icons AND the effect of the new macros, which create the varying fullsize-gradients ...Image

I think, i should post them the next day with a few demo backgrounds.

Until then, best regards, Charly

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

Posted: Sun May 01, 2016 8:03 pm
by Little John
Current changes
Added a macro and icons "Notes" and "NotesCurved" by Oma.

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

Posted: Sun May 01, 2016 9:59 pm
by davido
Hi Little John,

I would like to add a new icon which I have called: Secure

Code: Select all

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

   Procedure.i Secure (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(16*p,18*p,11*p,0,180)
       StrokePath(4*p)
       AddPathCircle(16*p,4.5*p,2.5*p)
       StrokePath(2*p)
       MovePathCursor(14.5*p,7.5*p)
       AddPathLine(13*p,27*p)
       AddPathLine(19*p,27*p)
       AddPathLine(17.5*p,7.5*p)
       ClosePath()
       FillPath()
       MovePathCursor(0.75*p,20*p)
       AddPathLine(5*p,16*p)
       AddPathLine(9.5*p,20*p)
       ClosePath()
       FillPath()
       MovePathCursor(22.75*p,20*p)
       AddPathLine(27*p,16*p)
       AddPathLine(31*p,20*p)
       ClosePath()
       FillPath()
       MovePathCursor(11*p,13*p)
       AddPathLine(21*p,13*p)
       StrokePath(3*p,#PB_Path_RoundEnd)
       StopVectorDrawing()
     EndIf
     
     ProcedureReturn ret
   EndProcedure
   
   , "Secure"
   
   NewIcon( Secure (file$, img.i, size.i, #CSS_Black))
   
   NewIcon( Secure (file$, img.i, size.i, #CSS_Silver))