Humanities Home page   Office of Digital Humanities
Back     BYU LiveCode Lessons Gateway

DigHT 310
Colors in LiveCode
Activity

Two types of color mixing: subtractive and additive

Subtractive (pigment) mixtures Additive (light) mixtures
  • colors on opaque surfaces
  • What we learned in elementary school: Red, Yellow, Blue primary colors; Green, Purple, Orange secondary.
  • Mixed colors are more intense
  • colors produced by mixing colored light, including computer monitors
  • Light primaries are red, green, and blue
  • Secondary colors are paler.

Nice overview of these concepts (YouTube)

In LiveCode, colors are defined in one of three ways:

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 value

Objects have up to 8 color properties that can be set:

These can be set manually in the Colors & Patterns pane of the property inspector, or by script, as we have seen here.

Quick Color Stack activity

(To be turned in by next class period.)

  1. Create a new stack
  2. Create graphic named "tester"
  3. Create button "setColor"
  4. Create field "colorDef"

    Button script:
    on mouseUp
      set the backgroundColor of graphic "tester" to fld "colorDef"
    end mouseUp
    

    Try 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:

  1. Drag a Scrolling list field from the Tools palette and name it "colorList"
  2. Message box: put the colornames into field "colorList"
  3. Script of list field:
    on mouseup
      set the backgroundColor of graphic "tester" to the selectedText of me
    end mouseup
    

How to display a standard system color picker:

  1. 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
    

Back     BYU LiveCode Lessons Gateway
Maintained by Devin Asay.
Copyright © 2005 Brigham Young University.
This page last updated on January 15, 2020 17:31:59.