Working with Color
Cues that assign color to lights are designed to leverage the jolby/colors library. In addition to creating colors by name, as in the Usage examples, you can create them by hex string, RGB values, and, most usefully when thinking about how to mix and fade them, HSL (Hue, Saturation, and Lightness). So, if you wanted a cue that shifts back and forth around yellow, and don’t remember the hue value of yellow, you could do something like this:
(use 'com.evocomputing.colors)
(def yellow (create-color "yellow"))
(def hue-param (oscillators/build-oscillated-param
(oscillators/sine) :min (hue (adjust-hue yellow -5))
:max (hue (adjust-hue yellow 5))))
(show/add-effect! :color (global-color-effect
(params/build-color-param :s 100 :l 50 :h hue-param)))
You can add lighten it up by changing to something like :l 70
in the
build-color-param
call, darken it a bunch with :l 20
or desaturate
it a touch with :s 80
… For more options and ideas, delve into the
colors library API documentation,
and the various oscillators that Afterglow
makes available to you.
Since working with colors is so fundamental to creating light shows, the mechanism for creating dynamic color parameters is very well developed, and worth getting familiar with. You can often avoid having to write your own function entirely by clever combinations of oscillated parameters for creating dynamic color parameters.
Thinking in Hue, Saturation, and Lightness
If you are not accustomed to working with colors in the HSL space, it is definitely worth spending a little time becoming familiar with it, because it is a powerful way of expressing relationships between colors in ways that are visually sensible and pleasing. The Wikipedia article is a nice reference, with diagrams. Please spend a little time reading it. This is the way that Afterglow works with colors when it is fading (blending) between them, and many of the sample cues and effects use HSL relationships to achieve pretty and interesting results.
In a nutshell, a color in HSL is represented by three numbers:
- Hue
-
Identifies a specific pure color, as an angle in degrees around the color wheel. Red is at 0, green is at 120, and blue at 240; values in between these are a linear mixture between the colors, and as the value increases towards 360 it returns to red.
- Saturation
-
Specifies how pure the color is. A saturation of 100 means it is fully pure, while a saturation of 0 is completely achromatic (gray).
- Lightness
-
Specifies how white the color is. A lightness value of 100 is pure white, while 0 is pure black. At these extremes the saturation can’t affect the color, it is always achromatic anyway. A lightness of 50 lets the color "be itself" when fully saturated. Lightnesses above fifty start to whiten it, while those below fifty blacken it.
Modifying Colors
You can also create a variety of layered looks by building effects that work with each other, rather than having to create a separate effect for each combination. The discussion on layering effects explains how to do this and points at a sample implementation that ships with Afterglow.
Colors and Cues
When you create a cue that assigns a color to a group of lights, you can take advantage of Afterglow’s rich user interfaces for picking colors to let the operator tweak that color during the show, simply by making the color a cue variable.
Even if you are creating a cue to simply assign a fixed color to a
group of lights, it is worth setting that color up as a cue variable,
because it will allow the show operator to adjust the color in a very
convenient way when running the show. The
global-color-effect
function in the examples
namespace provides an example of how to do
this (click the view source link below the description to see
how it is done).
You may also want to have a group of cues which share a same basic
color, like the strobe cues do in the sample show. In that case,
rather than having a color variable that exists only within the cue,
you will want to set up a show variable to contain the color, and have
each cue share the same show variable as a cue variable. The
make-strobe-cue
function in the examples
namespace shows how to do this (again click
the view source link below the description to see how it is
done). All of the strobe cues in the sample show use the same color,
and if you adjust that color while one is running, the cue cells
within the web interface and on the Ableton Push and Novation
Launchpad Pro will update to show the new color you have chosen, and
it will be used when you press any of them.
In order to let you adjust the strobe color even when no strobe cue is
running, the sample show also sets up a “Strobe Color”
cue. All it does is run a
blank
effect, while
binding a cue variable to the show variable that is being used to set
strobe colors, so that you can run the cue to adjust the color without
firing any strobes:
(let [color-var {:key :strobe-color :type :color :name "Strobe Color"}]
(ct/set-cue! (:cue-grid *show*) 7 6
(cues/cue :strobe-color (fn [_] (fx/blank "Strobe Color"))
:color :purple
:color-fn (cues/color-fn-from-cue-var color-var)
:variables [color-var])))
This example also shows how to use the cue :color-fn
key to
configure the cue grid to display the cue using the current value of
the color variable associated with it, as an additional aid to the
show operator.