Create your own icons for toolbars etc. with PureBasic

Share your advanced PureBasic knowledge/code with the community.
User avatar
Tenaja
Addict
Addict
Posts: 1810
Joined: Tue Nov 09, 2010 10:15 pm

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

Post by Tenaja »

If you are going to do that, perhaps rename the arrows: instead of "UpArrow", "DownArrow", rename to ArrowUp and ArrowDown? Would be an easy way to standardize the naming method.
Little John
Addict
Addict
Posts: 3981
Joined: Thu Jun 07, 2007 3:25 pm
Location: Berlin, Germany

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

Post by Little John »

Tenaja wrote:If you are going to do that, perhaps rename the arrows: instead of "UpArrow", "DownArrow", rename to ArrowUp and ArrowDown? Would be an easy way to standardize the naming method.
For instance, in Unicode there are symbols called "Upwards Arrow" and "Downwards Arrow"; in LaTeX there are symbols called "\uparrow" and "\downarrow"; in a renowned programming language there are mathematical functions called "UpArrow()" and "DownArrow()".
So I think it's OK to leave these arrow names as they are now.
Please excuse my flawed English. My native language is PureBasic.
Search
RSBasic's backups
User avatar
skywalk
Addict
Addict
Posts: 3516
Joined: Wed Dec 23, 2009 10:14 pm
Location: Boston, MA

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

Post by skywalk »

Things are not correct because "everybody" does it.
'Noun - Verb' is more orderly and efficient when searching.
I care not about 'Up Aardvark' when scanning for 'Up Arrow'.
Grouping all Arrow methods is just logical.
Vulcan out :wink:
The nice thing about standards is there are so many to choose from. ~ Andrew Tanenbaum
Little John
Addict
Addict
Posts: 3981
Joined: Thu Jun 07, 2007 3:25 pm
Location: Berlin, Germany

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

Post by Little John »

skywalk wrote:Things are not correct because "everybody" does it.
... and I never wrote that.
BTW: Things are not wrong just because someone says so. :-)
Please excuse my flawed English. My native language is PureBasic.
Search
RSBasic's backups
Little John
Addict
Addict
Posts: 3981
Joined: Thu Jun 07, 2007 3:25 pm
Location: Berlin, Germany

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

Post by Little John »

Current changes (2017-03-17)
  • Since there have been no objections in about 1 week, the names of all chess icons were prefixed by "Chess_".
Please excuse my flawed English. My native language is PureBasic.
Search
RSBasic's backups
User avatar
Blue
Enthusiast
Enthusiast
Posts: 733
Joined: Fri Oct 06, 2006 4:41 am
Location: Canada

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

Post by Blue »

Little John wrote:Current changes (2017-03-17)
Thank you, Little John, for the continuing updates.
Much appreciated.

Is it only my impression, or did the conversation about icon naming quickly turned south ?
If it stopped abruptly, it's too bad, because, independently of how other programming languages name things, Tenaja and skywalk made valid points.

It's indeed easier to follow and recognize how code is structured when the naming scheme used follows the pattern
[main part non-changing] + [qualifying part varying].
Granted, it hurts our normal perception and use of human language, but it makes sense in computer logics.

The usual UpArrow and DownArrow are very clear, and they come naturally, since they are descriptive and follow natural speech patterns.
But ArrowUp and ArrowDown (or Aardvark_slow and Aardvark_fast) :shock: (you'll have to ask skywalk...) present the advantages of better documenting the built-in logics of the code, and being easier to sort.

Same with DrawBox_rounded and DrawBox_square rather than DrawRoundedBox and DrawSquareBox .
The latter are crystal clear about their purpose in life, but the former emphasize better the internal structure of the code and the logical relationship of things, whether they be icon names, functions, procedures or code sections. And, again, they're easier to search and sort.

In fact, this is exactly the same debate as with the numeric representation of dates. Every nation is attached to its date representation format, but in the end, from a computing perspective, the only format that makes sense is the ISO format [yyyy-mm-dd] because it's the only one that can be sorted without any confusion, using either alphabetical or numerical sorting algorithms. Try it within a Windows Explorer folder, and you'll see.

In the end, it's a matter of preference.
But some preferences have intrinsic advantages that may be interesting to adopt.
Just think of the metric system...
"That's not a bug..." said the programmer. "it's a feature! "
"Oh! I see..." replied the blind man.
Little John
Addict
Addict
Posts: 3981
Joined: Thu Jun 07, 2007 3:25 pm
Location: Berlin, Germany

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

Post by Little John »

Hello Blue.
Blue wrote:In the end, it's a matter of preference.
Yes, it is. :-)
Blue wrote:But some preferences have intrinsic advantages that may be interesting to adopt.
Just think of the metric system...
I absolutely agree with what you wrote about dates, and guess why I'm always using the ISO date format in my posts and in the comments of my source code. :-)
However, choosing names is different from choosing a date format. And I'm sorry, I don't understand what the meaning of the metric system is in this context.

As you know, I have not been active here on the forum for several months. I did not plan to "come back" to the forum by now. I only did do so because of your recent feature requests for this project. Unfortunately, my spare time is still very limited, and I'll have to limit my activities on this forum to things which I really consider important. Sorry, discussing about naming preferences at length is not among them.

(Of course, I'll rename any icon if this is explicitly requested by its creator.)
Please excuse my flawed English. My native language is PureBasic.
Search
RSBasic's backups
Little John
Addict
Addict
Posts: 3981
Joined: Thu Jun 07, 2007 3:25 pm
Location: Berlin, Germany

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

Post by Little John »

Current changes (2017-04-23)
Just some small changes in the file "vectoriconbrowser.pb".
  • One step of zooming does not mean multiplying/dividing the length of the icon edges by 2 anymore, but now it means adding/subtracting 8 pixels to/from the length of each edge.
  • The default icon size was reduced from 32x32 to 24x24, so that it's now a bit more convenient to generate PNG icon files for PureBasic's toolbars when using the new #PB_ToolBar_Large flag.
  • some other minor changes
Please excuse my flawed English. My native language is PureBasic.
Search
RSBasic's backups
Klonk
Enthusiast
Enthusiast
Posts: 173
Joined: Tue Jul 13, 2004 2:17 pm

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

Post by Klonk »

Wow, cool work. Thanks for that...
Bye Karl
davido
Addict
Addict
Posts: 1841
Joined: Fri Nov 09, 2012 11:04 pm
Location: Uttoxeter, UK

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

Post by davido »

Hi Little John,
Thank you for keeping the hinges oiled, and, of course, the enhancements.

I have a few more icons in the works which I will post in the next few weeks.
DE AA EB
Little John
Addict
Addict
Posts: 3981
Joined: Thu Jun 07, 2007 3:25 pm
Location: Berlin, Germany

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

Post by Little John »

Hi davido,

very cool. 8)
Many thanks in advance!
Please excuse my flawed English. My native language is PureBasic.
Search
RSBasic's backups
Little John
Addict
Addict
Posts: 3981
Joined: Thu Jun 07, 2007 3:25 pm
Location: Berlin, Germany

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

Post by Little John »

Most recent changes:

2017-08-27
New great stuff from Oma (1st icon set):
  • 30 flags
  • 7 other icons
  • several new color definitions
Thank you very much!
Please excuse my flawed English. My native language is PureBasic.
Search
RSBasic's backups
Justin
Enthusiast
Enthusiast
Posts: 714
Joined: Sat Apr 26, 2003 2:49 pm

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

Post by Justin »

Really great work, thanks.

How can i make the icon image smaller within the given size?
For example in the MediaFastBack() icon if i change the line:

Code: Select all

w = size / 8.0
to:

Code: Select all

w = size / 16.0
The arrows are half of the side, that is what i need, but they are not centered in the icon.
I need this because i want to draw a circle around the arrows so they have to be smaller.

So it would be great some option or zoom factor for the image inside the icon.
Or an example of how to center the smaller image inside the icon, i played a bit but i have no idea where all those magic numbers come, here is the code:

Code: Select all

  Procedure.i MediaFastBack (file$, img.i, size.i, color.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)
      ;      color: foreground color
      ; out: return value: if img = #Pb_Any --> number of the created image,
      ;                    on error --> 0
      ; [by infratec]
      Protected ret.i, w.d
      
      ;Changed size here from 8.0 to 16.0
      w = size / 16.0 ;8.0
      
      ret = StartVectorIconOutput(file$, img, size)
      
      If ret
         VectorSourceColor(color)
         
         MovePathCursor(4*w, w)
         AddPathLine(w, 4*w)
         AddPathLine(4*w, 7*w)
         StrokePath(1.5*w, #PB_Path_RoundCorner)
         
         MovePathCursor(7*w, w)
         AddPathLine(4*w, 4*w)
         AddPathLine(7*w, 7*w)
         StrokePath(1.5*w, #PB_Path_RoundCorner)
         
         StopVectorDrawing()
      EndIf
      
      ProcedureReturn ret
   EndProcedure
Little John
Addict
Addict
Posts: 3981
Joined: Thu Jun 07, 2007 3:25 pm
Location: Berlin, Germany

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

Post by Little John »

Justin wrote:I need this because i want to draw a circle around the arrows so they have to be smaller.

So it would be great some option or zoom factor for the image inside the icon.
Or an example of how to center the smaller image inside the icon
The format of the icon procedures in this library does not support the concept of freely adjustable margins.

However, you can easily reach your goal like this:
Load or create a background image, that has the desired size of your picture. The image can contain anything you want (e.g. just a monochrome or transparent background).
Then draw an icon from this library on the background image (see example program "icon on picture.pb" in the VectorIcons ZIP archive). Pass a value as 'size' parameter to the icon procedure (e.g. MediaFastBack()) which is small enough, so that there is sufficient space on the backgrond image for your circle.
Please excuse my flawed English. My native language is PureBasic.
Search
RSBasic's backups
Justin
Enthusiast
Enthusiast
Posts: 714
Joined: Sat Apr 26, 2003 2:49 pm

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

Post by Justin »

That would be a way, thanks.
I added a zoom param to the procedure to do it in one shot, i only use it to make it smaller, zoom < 1.
Needs more checks but works and centers the image. Passing 0.5 reduces the image half of the size.

Code: Select all

   Procedure.i MediaFastForward (file$, img.i, size.i, color.i, zoom.d)
		; 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)
		;      color: foreground color
		; out: return value: if img = #Pb_Any --> number of the created image,
		;                    on error --> 0
		; [by infratec]
		Protected ret.i, w.d, newsize, offsetX, offsetY
		
		w = size / 8.0
		
		ret = StartVectorIconOutput(file$, img, size)
		
		If ret
			newsize = size * zoom
			If newsize < size
				offsetX = (size - newsize) / 2
				offsetY = offsetX
				
		  	TranslateCoordinates(offsetX, offsetY)
		  	ScaleCoordinates(zoom, zoom)
			EndIf 
			
			VectorSourceColor(color)
			
			MovePathCursor(w, w)
			AddPathLine(4*w, 4*w)
			AddPathLine(w, 7*w)
			StrokePath(1.5*w, #PB_Path_RoundCorner)
			
			MovePathCursor(4*w, w)
			AddPathLine(7*w, 4*w)
			AddPathLine(4*w, 7*w)
			StrokePath(1.5*w, #PB_Path_RoundCorner)
			
			StopVectorDrawing()
		EndIf
		
		ProcedureReturn ret
   EndProcedure
Post Reply