Colorconstants for all OS

Got an idea for enhancing PureBasic? New command(s) you'd like to see?
User avatar
ts-soft
Always Here
Always Here
Posts: 5756
Joined: Thu Jun 24, 2004 2:44 pm
Location: Berlin - Germany

Colorconstants for all OS

Post by ts-soft »

like the API constants: #White, #Black, #Gray as
#PB_White or #PB_Color_White
PureBasic 5.73 | SpiderBasic 2.30 | Windows 10 Pro (x64) | Linux Mint 20.1 (x64)
Old bugs good, new bugs bad! Updates are evil: might fix old bugs and introduce no new ones.
Image
AND51
Addict
Addict
Posts: 1040
Joined: Sun Oct 15, 2006 8:56 pm
Location: Germany
Contact:

Post by AND51 »

I would appreciate the most shortest notation.

Furthemore, I would like to see the most/all colors, that also exist in HTML.
For example aqua, lightskyblue, whitesmoke, lime, etc.

To achive this, I could start creating a list in CSV Format for easier copying, if you want!

Example notation:
#PB_Constant;HTML color name;hex notation;RGB() notation
PB 4.30

Code: Select all

onErrorGoto(?Fred)
User avatar
Rescator
Addict
Addict
Posts: 1769
Joined: Sat Feb 19, 2005 5:05 pm
Location: Norway

Post by Rescator »

If you want it as part of PB itself I suggest:

(Note! Intel/LSB (BGR) order which is "wrong" when compared to the proper Motorola/MSB/Network (RGB) order. blame it on intel for being anal and motorola for loosing the PC market to intel)

#PB_Color_White=$FFFFFF
#PB_Color_Grey=$7F7F7F
#PB_Color_Gray=#PB_Color_Grey
#PB_Color_Black=$000000
#PB_Color_Red=$0000FF
#PB_Color_Blue=$FF0000
#PB_Color_Green=$00FF00

And so on, anything else could conflict with user constants.
It also sticks to the constant naming scheme of PB.

I would really hate to get "Constant already declared with a different value"
errors when trying to do
#Red=$2140FE
or for example
#Color_Red=$2140FE
in a game or program I'm making.

And I would not want #PB_White or similar to that
as that would make the auto complete/list in the IDE a pain to scroll through as the colors would be spread ungrouped between all the other constants.

In a ironic twist, I would not mind typing #PB_Color_Red but I also happen to know how to write RGB well enough to know what colors I get when I "mix" the hexes so I do not really need the constants.

But when trying to match "web" colors yeah it might be nice, but there is already some awesome web (and other types) of color charts on the net which is only a copy'n'paste away really.

PS! A nice color table could be added to the PB manual however! With RGB and BGR (LSB) ordered hex values for direct copy'n'paste. :)
PB
PureBasic Expert
PureBasic Expert
Posts: 7581
Joined: Fri Apr 25, 2003 5:24 pm

Re: Colorconstants for all OS

Post by PB »

I only use PureBasic on Windows, but it already has lots of colors defined:

Code: Select all

Debug #Black
Debug #White
Debug #Yellow
Debug #Red
Debug #Green
; etc
Do these not work on Linux or MacOS?
I compile using 5.31 (x86) on Win 7 Ultimate (64-bit).
"PureBasic won't be object oriented, period" - Fred.
User avatar
Rescator
Addict
Addict
Posts: 1769
Joined: Sat Feb 19, 2005 5:05 pm
Location: Norway

Post by Rescator »

Hmm, hey PB! Try defining #Black yourself, seems those are override able?
I certainly never noticed some PureBasic constants could do that. (looks at Fred) This a PB4 feature?
PB
PureBasic Expert
PureBasic Expert
Posts: 7581
Joined: Fri Apr 25, 2003 5:24 pm

Post by PB »

> Try defining #Black yourself, seems those are override able?

Nope, these can't be overridden on the Windows version.
I compile using 5.31 (x86) on Win 7 Ultimate (64-bit).
"PureBasic won't be object oriented, period" - Fred.
Trond
Always Here
Always Here
Posts: 7446
Joined: Mon Sep 22, 2003 6:45 pm
Location: Norway

Re: Colorconstants for all OS

Post by Trond »

PB wrote:I only use PureBasic on Windows, but it already has lots of colors defined:

Code: Select all

Debug #Black
Debug #White
Debug #Yellow
Debug #Red
Debug #Green
; etc
Do these not work on Linux or MacOS?
They will "work" but they aren't defined because they are Windows API constants.

Rescator, the PB manual already has a colour table.
User avatar
Psychophanta
Always Here
Always Here
Posts: 5153
Joined: Wed Jun 11, 2003 9:33 pm
Location: Anare
Contact:

Re: Colorconstants for all OS

Post by Psychophanta »

ts-soft wrote:like the API constants: #White, #Black, #Gray as
#PB_White or #PB_Color_White
Agree.
Or even better, disable those constants.
http://www.zeitgeistmovie.com

while (world==business) world+=mafia;
User avatar
Kaeru Gaman
Addict
Addict
Posts: 4826
Joined: Sun Mar 19, 2006 1:57 pm
Location: Germany

Post by Kaeru Gaman »

i worked Colors.pbi over, works now correctly:
http://www.purebasic.fr/english/viewtopic.php?t=26615
oh... and have a nice day.
User avatar
Andre
PureBasic Team
PureBasic Team
Posts: 2137
Joined: Fri Apr 25, 2003 6:14 pm
Location: Germany (Saxony, Deutscheinsiedel)
Contact:

Re: Colorconstants for all OS

Post by Andre »

I think I've seen several threads about this already, but I want to support at least this topic in the wishlist :mrgreen:

Some simple things like #White, #Black, etc. constants (already defined on Windows) should be pre-defined on all OSes, as now more and more codes are released which are fully cross-platform, but the color constants don't work on MacOS / Linux.

This would avoid such additional codes, which every user on MacOS / Linux need to manually add:

Code: Select all

CompilerIf Not Defined(White, #PB_Constant)
  #White = $EEEEEE
CompilerEndIf
Would be good, if this constants could be added to the next PB version :D
Bye,
...André
(PureBasicTeam::Docs & Support - PureArea.net | Order:: PureBasic | PureVisionXP)
Post Reply