PureBasic Forum
http://forums.purebasic.com/english/

Create your own icons for toolbars etc. with PureBasic
http://forums.purebasic.com/english/viewtopic.php?f=12&t=65091
Page 16 of 18

Author:  Tenaja [ Sat Mar 11, 2017 4:32 pm ]
Post subject:  Re: Create your own icons for toolbars etc. with PureBasic

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.

Author:  Little John [ Mon Mar 13, 2017 6:16 am ]
Post subject:  Re: Create your own icons for toolbars etc. with PureBasic

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.

Author:  skywalk [ Mon Mar 13, 2017 6:25 am ]
Post subject:  Re: Create your own icons for toolbars etc. with PureBasic

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:

Author:  Little John [ Mon Mar 13, 2017 6:33 am ]
Post subject:  Re: Create your own icons for toolbars etc. with PureBasic

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. :-)

Author:  Little John [ Fri Mar 17, 2017 7:55 am ]
Post subject:  Re: Create your own icons for toolbars etc. with PureBasic

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_".

Author:  Blue [ Sat Mar 18, 2017 6:40 am ]
Post subject:  Re: Create your own icons for toolbars etc. with PureBasic

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...

Author:  Little John [ Sat Mar 18, 2017 7:44 am ]
Post subject:  Re: Create your own icons for toolbars etc. with PureBasic

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.)

Author:  Little John [ Sun Apr 23, 2017 6:16 pm ]
Post subject:  Re: Create your own icons for toolbars etc. with PureBasic

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

Author:  Klonk [ Thu Jul 20, 2017 12:31 pm ]
Post subject:  Re: Create your own icons for toolbars etc. with PureBasic

Wow, cool work. Thanks for that...

Author:  davido [ Thu Jul 20, 2017 4:23 pm ]
Post subject:  Re: Create your own icons for toolbars etc. with PureBasic

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.

Author:  Little John [ Thu Jul 20, 2017 4:58 pm ]
Post subject:  Re: Create your own icons for toolbars etc. with PureBasic

Hi davido,

very cool. 8)
Many thanks in advance!

Author:  Little John [ Sun Aug 27, 2017 12:34 pm ]
Post subject:  Re: Create your own icons for toolbars etc. with PureBasic

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!

Author:  Justin [ Thu Nov 02, 2017 12:12 pm ]
Post subject:  Re: Create your own icons for toolbars etc. with PureBasic

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:
w = size / 8.0

to:
Code:
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:
  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

Author:  Little John [ Thu Nov 02, 2017 5:58 pm ]
Post subject:  Re: Create your own icons for toolbars etc. with PureBasic

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.

Author:  Justin [ Fri Nov 03, 2017 8:15 pm ]
Post subject:  Re: Create your own icons for toolbars etc. with PureBasic

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:
   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

Page 16 of 18 All times are UTC + 1 hour
Powered by phpBB © 2000, 2002, 2005, 2007 phpBB Group
http://www.phpbb.com/