Hidden TFT (and GUI) Colour Names

Code tips and tricks for beginners
Post Reply
User avatar
Electroguard
Posts: 835
Joined: Mon Feb 08, 2021 6:22 pm
Has thanked: 267 times
Been thanked: 317 times

Hidden TFT (and GUI) Colour Names

Post by Electroguard »

I couldn't find it documented anywhere, but it appears that TFT and GUI items can recognise some pre-defined colour names.
For example: TFT.Fill RED (fills the screen red)
Similarly: GUI.Init 20, BLUE (followed by a gui.refresh, fills the screen blue)
They are not simply public variable names though, because eg: Wlog Blue causes a "No such variable " error.

There may be more, but some of the recognised colour names include the primary colours red, green and blue, along with black and white, plus cyan, yellow and magenta.

It is a handy hidden bonus… cos it's pretty much the standard colour names I would usually need to define myself anyway, eg:

Code: [Local Link Removed for Guests]

black=0: white=tft.rgb(255,255,255): red=tft.rgb(255,0,0): green=tft.rgb(0,255,0): blue=tft.rgb(0,0,255)
cyan=green+blue: pink=red+blue: yellow=red+green: orange=tft.rgb(255,165,0)
There are some slight problems with the internal Annex colour names, such as pink being recognised but actually showing as white, and similarly orange being recognised but actually showing as yellow - but that doesn't prevent any of the colour names from being redefined as variables using tft.rgb(R,G,B) as in the snippet above.

I noticed this while using Annex32 1.43.5, so unless a list of available pre-defined colour names is officially added to the Online Help it should just be considered as a nice hidden bonus which might change in future updates.
AndyGadget
Posts: 222
Joined: Mon Feb 15, 2021 1:44 pm
Has thanked: 119 times
Been thanked: 132 times

Re: Hidden TFT (and GUI) Colour Names

Post by AndyGadget »

Hi Electroguard.
I had a fiddle with these named colours a while ago here : [Local Link Removed for Guests] and proposed alternatives to some which could be improved. The full list is at the bottom of the ILI9341 section in the help file.
User avatar
Electroguard
Posts: 835
Joined: Mon Feb 08, 2021 6:22 pm
Has thanked: 267 times
Been thanked: 317 times

Re: Hidden TFT (and GUI) Colour Names

Post by Electroguard »

Yep Andy - it doesn't come up in a topic search, but is hidden away behind a specific display module.
Colornames is very handy, but only if you happen to already know about it... so ideally it would have its own TFT.COLOR(colorname) syntax entry in the Help Doc, and perhaps even its own Colorname subject entry as a searchable topic, so anyone can see the instruction in the ordered Topic list.
Post Reply