A newer version of Max is available. Click here to access the latest version of the documentation

swatch Reference

Choose a color

swatch

Description

Provides 2-dimensional selection and display of colors, representing hue along the horizontal axis and lightness along the vertical axis. A third color dimension, saturation, may be set by means of the saturation message.

Examples

Arguments

None.

Attributes

compatibility [int] (default: 0)

Toggles the number input and output of the swatch object to be in the range of 0.-1.0 floating-point values (0, default) or to old-style 0-255 integer values (1).

parameter_enable [int]

Enables use of this object with Max for Live Parameters and allows for setting initial parameter values in the Max environment.

parameter_mappable [int] (default: 1)

When parameter_mappable is enabled, the object will be available for mapping to keyboard or MIDI input using the Mappings feature.

saturation [float] (default: 255.)

Set the saturation of available swatch colors

Common Box Attributes

Parameter Attributes

Messages

bang

bang message causes output of the RGBA values of the current color at the selected (x,y) position on the 2-dimensional colorspace, taking into account the current saturation value.

int

Arguments

red [int]
In left inlet: Set the red color value (ignores values over 1), and cause output of all values.

Note: Unlike most Max objects, input to any one of the three inlets will re-calculate the current color location on the swatch, and trigger output.

  (inlet1)

Arguments

green [int]
In middle inlet: Set the red color value (ignores values over 1), and cause output of all values.

Note: Unlike most Max objects, input to any one of the three inlets will re-calculate the current color location on the swatch, and trigger output.

  (inlet2)

Arguments

blue [int]
In right inlet: Set the red color value (ignores values over 1), and cause output of all values.

Note: Unlike most Max objects, input to any one of the three inlets will re-calculate the current RGBA color location on the swatch, and trigger output.

float

Arguments

red [float]
Set the red color value (0.-1.), and cause output of all values.

  (inlet1)

Arguments

green [float]
Set the green color value (0.-1.), and cause output of all values.

  (inlet2)

Arguments

blue [float]
Set the red color value (0.-1.), and cause output of all values.

list

Arguments

red [number]
green [number]
blue [number]
alpha [number]
A list of three numbers between 0. and 1. sets the four RGBA color components (red, green, blue, alpha), refreshes the display and causes RGBA output.

alpha

Arguments

opacity [float]
The word alpha, followed by a floating-point number between 0. and 1., will set the RGBA alpha (opacity) value.

hsl

Arguments

hue [int]
saturation [int]
lightness [int]
The word hsl, followed by a list of three numbers between 0. and 1., sets the color based on the given hue (x-axis), saturation, and lightness (y-axis) values. The swatch object converts these values to RGBA color values, refreshes the display, and causes output of the RGBA values.

(mouse)

Clicking and dragging on the swatch object will calculate and output the RGBA color at the selected (x, y) position on the 2-dimensional (hue-lightness) colorspace, taking into account the current saturation value.

set

Arguments

red [number]
green [number]
blue [number]
alpha [number]
The word set, followed by a list of three numbers between 0. and 1. sets the four RGBA color components (red, green, blue, alpha) and refreshes the display without causing RGBA output.

sethsl

Arguments

hue [int]
saturation [int]
lightness [int]
The word sethsl, followed by a list of three numbers between 0. and 1., sets the color based on the given hue (x-axis), saturation, and lightness (y-axis) values and the refreshes the display. Unlike the hsl message the sethsl message does not output the corresponding RGBA values.

Output

int

Out right outlet: the current saturation value (calculated from an RGB list input, or output directly after a saturation message)

list

Out left outlet: a list of four RGBA (red, green, blue, alpha) color values

See Also

Name Description
colorpicker
panel
Max JS Tutorial 3: JavaScript Tasks, Arguments, and Globals Max JS Tutorial 3: JavaScript Tasks, Arguments, and Globals