Colors
Colors in Pix are specified as hexadecimal literals or as references to
named colors defined in a color block.
Hex colors
A hex color starts with # followed by 3, 6, or 8 hexadecimal
digits. The digits are case-insensitive.
3-digit format
Each digit is expanded by repeating it. #E40 becomes
#EE4400. Alpha defaults to fully opaque.
#E40 // orange
#FFF // white
#000 // black 6-digit format
Standard RGB hex: #RRGGBB. Each pair represents red, green, or
blue in the range 0 to 255. Alpha defaults to fully opaque.
#e84a00 // accent orange
#e8ddd0 // warm beige
#2a1208 // dark brown
#b0a090 // muted tan 8-digit format
RGB with alpha: #RRGGBBAA. The last two digits set opacity.
FF is fully opaque, 00 is fully transparent.
#e84a0080 // orange at 50% opacity
#e8ddd040 // beige at 25% opacity
#FFFFFF00 // fully transparent white Color block
A color block defines named colors that can be reused
throughout the program. Each entry maps a name to a hex color.
color {
warm: #e84a00
light: #e8ddd0
dark: #2a1208
} Referencing named colors
Use color <name> wherever a color value is expected.
draw x = 3 and y = 5 with color warm
pixel (10, 10) with color dark
circle (8, 8) radius 4 with color light Validation
- Referencing an undefined color name produces an error.
- Color names are case-sensitive.
- An empty
colorblock is allowed.