You can set colors in Small Basic in 3 ways:
- Using pre-defined color names (e.g. GraphicsWindow.BrushColor = "Red")
- Using a Hex value code (e.g. GraphicsWindows.BrushColor = "#FF0000")
- Setting the Red, Green, Blue components (RGB) (e.g. GraphicsWindows.BrushColor = GraphicsWindow.GetColorFromRGB(255,0,0))
All 3 above are equivalent (Red). See that the Hex example has 3 hexadecimal values corresponding to the Red, Green and Blue components: FF(R), 00(G) and 00(B), which in decimal are 255(R), 0(G) and 0(B). The # symbol is required and is a standard symbol that shows that the following characters are hex values.
The 'Introducing Small Basic' guide lists all the available named colors, and their corresponding hex values, here are the Red hue colors.
You can also add transparency using the hex method by adding an extra hex value for the opacity (00 fully transparent and FF fully opaque), using ARGB in place of RGB.
For example "#80FF0000" is 50% (80) transparent Red.
Another way to describe a color is by HSL, which stands for Hue, Saturation, Lightness.
- Hue is the color (from 0 to 360) which corresponds to degrees of a circle since Hue 0 is Hue 360 (Red).
- Saturation is the color intensity (0 to 1) which is gray to bright
- Lightness is the lightness (0 to 1) which is black to white
The following code converts HSL to RGB, and displays the available Hues (0 to 360) at maximum Saturation (1) and medium Lightness (0.5).