Colours
Colour values can be specified in SetColours() and ButtonEvent2() and may be in either:
- RGB format, or
- ARGB format
Each of A (Alpha), R (Red), G (Green) and B (Blue) values may range from 0 thru 255. While a colour specifier may be written as a decimal number, it’s far easier to write is as a 2 digit hexadecimal format, so would range from 00 thru FF.
(Note in SPLat a hexadecimal number is prefixed with an apostrophe, ‘.)
As an example, say you wanted to use this particular shade of blue:
The RGB hexadecimal code for this is ‘1E5AA0, meaning:
- Red = ‘1E
- Green = ‘5A
- Blue = A0
Thus in hexadecimal format it’s easy to see the value of each colour, but ‘1E5AA0 in decimal is 1989280, we’ve no idea what colour this would be.
Alpha
Alpha defines how “solid” the colour is. All “RGB” colours are assumed to be totally solid. However, SimpleHMI allow this to be changed, so button background, or text can be “ghostly” and allow some of the background to show through. A good use case would be drawing a disabled button as a faded button. But normal everyday text can be transparent too.
Using the blue above, if we wanted to print a message with 50% transparency, we’d do this:
;--core colour names
HUEkWhite #EQU 'FFFFFF
HUEkBlack #EQU '000000
HUEkTransparent #EQU '00000000
;--application colours
HUEkTitleText #EQU HUEkWhite
HUEkTitleBackground #EQU '801E5AA0 ;our favourite blue, 50% transparent
#HMI SetColours( f:HUEkTitleText, b:HUEkTitleBackground )
#HMI SetBounds( x:0, y:0, w:100%, h:1.2 )
#HMI Cls()
#HMI Print( "Hello World" )
#HMI SetBounds()
In this example we’ve used good programming practice and given the colours names. As its name implies, HUEkTransparent is completely see through which makes sense as its alpha value is zero. This example will draw a title bar at the top of the screen, making its background 50% transparent, allowing some of a background image to leak through. We’ve also made sure we clear the bounds once we’ve finished.
Finding Colour Values
SPLat/PC contains a colour picker under the Window menu, which returns the RGB-Hex value on the clipboard, i.e. the hex number without Alpha. You can pre-pend you own Alpha. Here are some representative Alpha values:
| Hex | Opacity |
|---|---|
| ‘FF | 100% (it’s solid) |
| ‘C0 | 75% |
| ’80 | 50% |
| ’40 | 25% |
| ’20 | 12.5% |
| ’00 | 0% (it’s transparent) |
The Nothing Colour
There’s a special colour number which is useful when you want to print text without refreshing the background. It means “do absolutely nothing with the background just print on top of whatever is there now. This differs to “Transparent” which actually means “redraw the area under the text”. The nothing colour is:
HUEkNothing #EQU '00010101
We have commonly used this to print a value in a HBar().