Two types of color mixing: subtractive and additive
Subtractive (pigment) mixtures | Additive (light) mixtures |
|
|
Nice overview of these concepts (YouTube)
In LiveCode, colors are defined in one of three ways:
- name - See
the colorNames
property (predefined colors)
In the message box try this:put the colorNames- RGB values - 3 integers, separated by commas in the range 0-255
- Hexidecimal values - A string preceded by # followed by three hex values
To change colors use the set command, followed by a valid color reference:
set the backgroundcolor of graphic 1 to "Gray100" --color name set the backgroundColor of graphic 1 to 120,120,220 --RGB triplet set the backgroundColor of graphic 1 to "#1050AF" -- hex valueObjects have up to 8 color properties that can be set:
the foregroundColor
(synonym: the textColor)the backgroundColor
the hiliteColor
(the background color of highlighted text)the borderColor
(only whenthe threeD
property is false)the topColor
(only whenthe threeD
property is true)the bottomColor
(only whenthe threeD
property is true)the shadowColor
(only whenthe shadow
property is true)the focusColor
(for focus border)These can be set manually in the Colors & Patterns pane of the property inspector, or by script, as we have seen here.
(To be turned in by next class period.)
- Create a new stack
- Create graphic named "tester"
- Create button "setColor"
- Create field "colorDef"
Button script:on mouseUp set the backgroundColor of graphic "tester" to fld "colorDef" end mouseUpTry entering some valid color references in the field and test the result
Now create a list-style field that shows the named colors recognized by the system:
- Drag a Scrolling list field from the Tools palette and name it "colorList"
- Message box:
put the colornames into field "colorList"
- Script of list field:
on mouseup set the backgroundColor of graphic "tester" to the selectedText of me end mouseupHow to display a standard system color picker:
- Create button "chooseColor"
Use the answer color command in the button script:
on mouseUp answer color set the backgroundcolor of graphic "tester" to it end mouseUp