So I created myself scalable icons with the help of PureBasic's new vector library.
Contributions by other forum members are greatly appreciated.
Please use an existing icon procedure in the most recent version of the module as template for your icons,
or use the included program "newicon.pb" in order to get started.
Your code must be cross-platform, and must comply with the current final PureBasic version.
The main shape of an icon should be visible even at a size as small as 16x16 pixels.
Your code can only be included in this library, if you agree to its license (see below).
vectoricons.pbi wrote:Code: Select all
; PB 5.40+, cross-platform ; Established and maintained by Little John, last updated on 2019-04-10 ; http://www.purebasic.fr/english/viewtopic.php?f=12&t=65091 ; TABLE OF CONTENTS OF THIS FILE ;=============================== ; A) Utility module "VDraw" ; - Procedure Color_Darken(): ; Darken a given RGBA color (the alpha channel is not changed) ; ; - Procedure Color_Transparency(): ; Change the transparency of a given RGBA color ; ; - Procedure StartNewVectorImage(): ; Wrapper for simplifying the usage of StartVectorDrawing() in ; combination with CreateImage() ; ; +----------------------------------------------------------------+ ; | CompilerIf #PB_Compiler_Version <= 542 | ; | Macro AddPathArc(): | ; | Replacement for the built-in command AddPathArc(), which is | ; | buggy at least in PB 5.42 on Windows and Linux. | ; | CompilerEndIf | ; +----------------------------------------------------------------+ ; ; B) Main module "VectorIcons" ; 1) Public part ; - CSS color definitions ; - Own definitions of colors used in this module ; * Declarations of public icon procedures ; ; 2) Private part ; - Private constants ; - Auxiliary procedures ; - Private macros/procedures of basic movable and resizable shapes ; that can be used by any icon procedure. ; * Procedures which generate the icons, sometimes with an optional ; parameter e.g. for flipping or rotating the respective icon.
Most recent changesLicense for 'VectorIcons' wrote:Copyright (c) 2016-2019 Jürgen Lüthje, Oma, davido, Guillaume Saumure,
infratec, and Romerio Medeiros
<viewtopic.php?f=12&t=65091>
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, and/or sublicense the
Software, and to permit persons to whom the Software is furnished to do so,
subject to the following conditions:
1) The above copyright notice and this permission notice shall be included in
all copies or substantial portions of the Software, and in all products that
contain icons in any form which were produced by this software.
2) It is allowed to use the Software and/or icons produced by the Software in
non-commercial and commercial programs. However, commercial programs or
software collections MUST NOT contain the source code of the Software.
3) The restriction imposed by the second sentence of the previous paragraph
does not apply to any code in this project that was created by davido, or
infratec.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
2019-04-10
Changed
- I've added an optional parameter to davido's nice Filter() procedure, which allows to draw only the outline of the filter.
- minor cosmetic changes
- written license!
- small program "newicon.pb", that could/should help creating your own vector icons
Here is the current collection (211+106+35 = 352 icons). Some procedures have optional parameters e.g. for rotating or flipping the generated icons, the following preview does not show all possible results. (The colors can be changed very easily.)
The icons in the first set were created by davido, Oma, StarBootics, infratec and me -- sometimes influenced by ideas of other forum members.
"Transparent", "Add", "Refresh", "SelectAll", "Checked", "Sub", "Delete", "Find",
"FindNext", "Question1", "Question2", "FivePointedStar", "Wizard", "Diskette",
"Alarm1", "Alarm2", "Quit", "HotDrink/Pause", "Watch", "Night", "UpArrow",
"DownArrow", "LeftArrow", "RightArrow", "ReSize", "Stop1", "Stop2", "Warning1",
"Warning2", "On", "Off", "Info1", "Info2", "Collapse", "Expand", "Success", "Home",
"AlignLeft", "AlignCentre", "AlignRight", "AlignJustify", "Compile", "CompileRun",
"Settings", "Options", "Toggle1", "Toggle2", "Save1", "ZoomIn", "ZoomOut",
"Great/OK", "Download1", "Upload1", "LineWrapOn", "LineWrapOff", "Donate1",
"Donate2", "Filter", "Bookmark", "Database", "Tools", "Sort", "Randomise",
"IsProtected", "UnProtected1", "UnProtected2", "Network", "Music", "Microphone",
"Picture", "Bug", "Debug", "Crop", "ReSize2", "Rating", "Orange Fruit",
"Lemon Fruit", "Lime Fruit", "Action", "Move", "Lock" , "Unlock", "Fill", "Message",
"Colours", "Navigation 1", "Navigation 2", "Volume", "Secure", "Book", "Library",
"USB", "Chess_WhitePawn", "Chess_BlackPawn", "Chess_WhiteRook", "Chess_BlackRook",
"Chess_WhiteKnight", "Chess_BlackKnight", "Chess_WhiteBishop", "Chess_BlackBishop",
"Chess_WhiteKing", "Chess_BlackKing", "Chess_WhiteQueen", "Chess_BlackQueen",
"History", "Danger", "The Sun", "Good Luck", "Telephone", "BlueTooth", "Broadcast",
"Speaker", "Mute", "Battery Charging", "Snowflake", "A2M", "N2Z", "Rain Cloud",
"Cloud Storage", "MediaPlay", "MediaStop", "MediaBegin", "MediaEnd", "MediaForward",
"MediaFastForward", "MediaBack", "MediaFastBack", "FirstAid", "NoEntry", "Stop3",
"Download2", "FirstAidSpatial", "NoEntrySpatial", "Stop3Spatial", "Download2Spatial",
"ToClipboard", "FromClipboard", "Copy", "Paste", "Cut", "Undo", "Redo", "Open1",
"Open2", "Open3", "Save2", "SaveAs2", "Printer1", "PrinterError1", "NewDocument",
"EditDocument", "ClearDocument", "ImportDocument", "ExportDocument", "CloseDocument",
"SortAscending", "SortDescending", "SortBlockAsc", "SortBlockDesc", "ChartLine",
"ChartDot", "ChartLineDot", "ChartPrice", "ChartBarVert", "ChartCylVert",
"ChartBarHor", "ChartCylHor", "ChartBarVertStacked", "ChartBarHorStacked",
"ChartCylVertStacked", "ChartCylHorStacked", "ChartArea", "ChartAreaPerc",
"ChartPie", "ChartRing", "Notes", "NotesSpatial", "UnfoldDown", "UnfoldUp/Eject",
"UnfoldLeft", "UnfoldRight", "FoldDown", "FoldUp", "FoldLeft", "FoldRight",
"ArrowBowTop2Right", "ArrowBowRight2Bottom", "ArrowBowBottom2Left",
"ArrowBowLeft2Top", "ArrowBowBottom2Right", "ArrowBowRight2Top", "ArrowBowTop2Left",
"ArrowBowLeft2Bottom", "BracketRoundOpen", "BracketRoundClose", "BracketSquareOpen",
"BracketSquareClose", "BracketAngleOpen", "BracketAngleClose", "BracketCurlyOpen",
"BracketCurlyClose", "BracketHtml", "Site", "Compare", "Attach", "Mail", "Currency",
"CurrencyEuro", "CurrencyDollar", "CurrencyPound", "CurrencyYen"

All icons in the second set were created by Oma:
"FindAndReplace", "Open1Spatial", "Open2Spatial", "Open3Spatial", "FindFileSpatial",
"FindFile", "RotateDownSpatial", "RotateUpSpatial", "RotateVerticalSpatial",
"RotateLeftSpatial", "RotateRightSpatial", "RotateHorizontalSpatial",
"RotateCounterClockwiseSpatial", "RotateClockwiseSpatial", "WritingPad",
"WritingPadSpatial", "CalculateSpatial", "CalendarSpatial", "RulerSpatial",
"RulerTriangleSpatial", "CartonSpatial", "BookKeepingSpatial", "PenSpatial",
"PenFlat", "BrushSpatial", "BrushFlat", "PipetteSpatial", "PipetteFlat",
"FillSpatial", "FillFlat", "SpraySpatial", "SprayFlat", "EraserSpatial",
"EraserFlat", "ColorPaletteSpatial", "ColorPaletteFlat", "PaintSpatial", "PaintFlat",
"DrawVText", "DrawVLine", "DrawVBox", "DrawVRoundedBox", "DrawVPolygonBox",
"DrawVCircle", "DrawVCircleSegment", "DrawVEllipse", "DrawVEllipseSegment",
"DrawVCurve(Spline)", "DrawVArc", "DrawVLinePath", "SetVSelectRange",
"SetVLineStyle", "SetVLineWidth", "SetVLineCap", "SetVLineJoin", "SetVColorSelect",
"SetVColorBoardSelect", "SetVFlipX", "SetVFlipY", "SetVRotate", "SetVMove",
"SetVCopy", "SetVScale", "SetVTrimSegment", "SetVExtendSegment", "SetVCatchGrid",
"SetVLinearGradient", "SetVCircularGradient", "SetVChangeCoord", "SetVDelete",
"SetVFill", "SetVLayer", "ToClipboardSpatial", "FromClipboardSpatial", "CopySpatial",
"PasteSpatial", "CutSpatial", "FindSpatial", "FindNextSpatial",
"FindAndReplaceSpatial", "ZoomInSpatial", "ZoomOutSpatial", "NewDocument1Spatial",
"EditDocument1Spatial", "ClearDocument1Spatial", "ImportDocument1Spatial",
"ExportDocument1Spatial", "SaveDocument1Spatial", "CloseDocument1Spatial",
"SortAscending1Spatial", "SortDescending1Spatial", "SortBlockAscending1Spatial",
"SortBlockDescending1Spatial", "NewDocument2Spatial", "EditDocument2Spatial",
"ClearDocument2Spatial", "ImportDocument2Spatial", "ExportDocument2Spatial",
"SaveDocument2Spatial", "CloseDocument2Spatial", "SortAscending2Spatial",
"SortDescending2Spatial", "SortBlockAscending2Spatial",
"SortBlockDescending2Spatial", "SiteSpatial", "CompareSpatial"

The icons in the third set were created by Oma, holzhacker, and me:
"Flag_Australia", "Flag_Austria", "Flag_Bangladesh", "Flag_Belgium", "Flag_Brazil",
"Flag_Bulgaria", "Flag_Canada", "Flag_China", "Flag_Czech", "Flag_Denmark",
"Flag_Estonia", "Flag_Europe", "Flag_Finland", "Flag_France", "Flag_Germany",
"Flag_GreatBritain", "Flag_Greece", "Flag_Hungary", "Flag_Ireland", "Flag_Island",
"Flag_Italy", "Flag_Japan", "Flag_SouthKorea", "Flag_Luxembourg", "Flag_Netherlands",
"Flag_NewZealand", "Flag_Norway", "Flag_Poland", "Flag_Romania", "Flag_Russia",
"Flag_Spain", "Flag_Sweden", "Flag_Switzerland", "Flag_Ukraine", "Flag_USA"

Using the icons
On principle, there are 2 ways to use the icons:
a) Launch the included program "vectoriconbrowser.pb", and save icons as individual PNG files. Then use these files as shown in the example code "ToolBar.pb" that ships with PureBasic.
b) If you don't want to generate any icon files, you can also create the vector icons dynamically like so (this example is also included in the ZIP archive):
Code: Select all
; ------------------------------------------------------------
;
; modified after
; ToolBar example that ships with PureBasic;
; tested with PB 5.44 LTS
;
; ------------------------------------------------------------
EnableExplicit
XIncludeFile "../vectoricons.pbi"
Enumeration
#New
#Open
#Save
#Find
EndEnumeration
Dim name$(#PB_Compiler_EnumerationValue-1)
name$(#New) = "New"
name$(#Open) = "Open"
name$(#Save) = "Save"
name$(#Find) = "Find"
Define.i event, tbIconSize=16
If OpenWindow(0, 100, 200, 300, 250, "Vectoricons toolbar example", #PB_Window_SystemMenu | #PB_Window_SizeGadget) = 0
MessageRequester("Fatal error", "Can't open main window.")
End
EndIf
If CreateToolBar(0, WindowID(0))
ToolBarImageButton(#New, ImageID(VectorIcons::NewDocument("", #PB_Any, tbIconSize,
VectorIcons::#CSS_White, VectorIcons::#CSS_Navy, VectorIcons::#CSS_Black)))
ToolBarToolTip(0, #New, name$(#New))
ToolBarImageButton(#Open, ImageID(VectorIcons::Open2("", #PB_Any, tbIconSize,
VectorIcons::#CSS_GoldenRod, VectorIcons::#CSS_Navy, VectorIcons::#CSS_White)))
ToolBarToolTip(0, #Open, name$(#Open))
ToolBarImageButton(#Save, ImageID(VectorIcons::Diskette("", #PB_Any, tbIconSize,
VectorIcons::#CSS_Navy, VectorIcons::#VI_GuardsmanRed, VectorIcons::#CSS_White)))
ToolBarToolTip(0, #Save, name$(#Save))
ToolBarSeparator()
ToolBarImageButton(#Find, ImageID(VectorIcons::Find("", #PB_Any, tbIconSize,
VectorIcons::#CSS_Black)))
ToolBarToolTip(0, #Find, name$(#Find))
EndIf
If CreateMenu(0, WindowID(0))
MenuTitle("Project")
MenuItem(#New, name$(#New))
MenuItem(#Open, name$(#Open))
MenuItem(#Save, name$(#Save))
MenuBar()
MenuItem(#Find, name$(#Find))
EndIf
Repeat
event = WaitWindowEvent()
Select event
Case #PB_Event_Menu
MessageRequester("Information", "ToolBar or Menu ID: " + Str(EventMenu()))
EndSelect
Until event = #PB_Event_CloseWindow ; If the user has clicked on the close button