Package heronarts.lx.color
Class LXPalette
java.lang.Object
heronarts.lx.LXComponent
heronarts.lx.color.LXPalette
- All Implemented Interfaces:
LXLoopTask
,LXPath
,LXSerializable
,LXOscComponent
,LXParameterListener
A palette is an object that is used to keep track of top-level color values and
set modes of color computation. Though its use is not required, it is very useful for
creating coherent color schemes across patterns.
-
Nested Class Summary
Modifier and TypeClassDescriptionstatic enum
static class
static interface
Nested classes/interfaces inherited from class heronarts.lx.LXComponent
LXComponent.Hidden, LXComponent.Placeholder, LXComponent.Renamable
Nested classes/interfaces inherited from interface heronarts.lx.LXSerializable
LXSerializable.Utils
-
Field Summary
Modifier and TypeFieldDescriptionfinal DiscreteParameter
final BooleanParameter
Auto-cycle to a random palette, not the next onefinal BoundedParameter
Time in seconds after which transition thru the pattern set is automatically initiated.final LXDynamicColor
The primary active color valuefinal BooleanParameter
final StringParameter
final StringParameter
final StringParameter
final StringParameter
final StringParameter
final StringParameter[]
final LXSwatch
The active color swatchA read-only list of all the saved color swatchesfinal BooleanParameter
final BoundedParameter
Amount of time taken in seconds to transition into a new snapshot viewfinal TriggerParameter
Fields inherited from class heronarts.lx.LXComponent
children, internalParameters, KEY_CHILDREN, KEY_CLASS, KEY_COMPONENT_ID, KEY_ID, KEY_INTERNAL, KEY_PARAMETER_PATH, KEY_PARAMETERS, KEY_PATH, KEY_RESET, label, legacyInternalParameters, legacyParameters, lx, modulationColor, modulationControlsExpanded, modulationsExpanded, parameters, presetFile
Fields inherited from interface heronarts.lx.LXPath
ROOT, ROOT_PREFIX, ROOT_SLASH
-
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptionaddListener
(LXPalette.Listener listener) Registers a listener to the paletteaddSwatch
(JsonObject swatchObj, int index) Adds a swatch at the given indexvoid
dispose()
Invoked when a component is being removed from the system and will no longer be used at all.void
exportSwatches
(File file) double
double
Gets the brightness of the primary color in active swatchfloat
Gets the brightness of the primary color in active swatchint
getColor()
Gets the primary color of the currently active swatchdouble
getHue()
Gets the hue of the primary color in active swatchfloat
getHuef()
Gets the hue of the primary color in active swatchdouble
Gets the saturation of the primary color in active swatchfloat
Gets the saturation of the primary color in active swatchgetSwatchColor
(int index) Gets the color in the active swatch at the given index.double
boolean
handleOscMessage
(OscMessage message, String[] parts, int index) Handles an OSC message sent to this component.importSwatches
(File file) void
load
(LX lx, JsonObject obj) Loads the LX component.void
loop
(double deltaMs) moveSwatch
(LXSwatch swatch, int index) Moves a saved swatch to a different position in the listvoid
Subclasses are free to override this if desired.removeListener
(LXPalette.Listener listener) Unregisters a listener to the paletteremoveSwatch
(LXSwatch swatch) Removes a swatch from the color palette's saved swatch listvoid
save
(LX lx, JsonObject obj) Serializes the LX component.Saves the current swatch to the list of saved swatchesboolean
Set the palette to a saved swatchMethods inherited from class heronarts.lx.LXComponent
addArray, addChild, addInternalParameter, addLegacyInternalParameter, addLegacyParameter, addParameter, addParameter, addParameters, contains, copyParameters, getCategory, getChild, getComponentName, getComponentName, getComponentName, getDescription, getId, getLabel, getLX, getOscAddress, getOscLabel, getOscPath, getParameter, getParameters, getParent, getPath, hasParameter, isValidOscParameter, loadParameters, loadPreset, removeParameter, removeParameter, removeParameter, removeParameter, savePreset, setDescription, setParent, toOscQuery, toOscQuery, toOscQuery, toString, toString
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
Methods inherited from interface heronarts.lx.osc.LXOscComponent
getOscAddress
Methods inherited from interface heronarts.lx.LXPath
getCanonicalLabel, getCanonicalLabel, getCanonicalPath, getCanonicalPath, isDescendant
-
Field Details
-
swatches
A read-only list of all the saved color swatches -
swatch
The active color swatch -
color
The primary active color value -
autoCycleEnabled
-
autoCycleMode
Auto-cycle to a random palette, not the next one -
autoCycleTimeSecs
Time in seconds after which transition thru the pattern set is automatically initiated. -
autoCycleCursor
-
triggerSwatchCycle
-
transitionTimeSecs
Amount of time taken in seconds to transition into a new snapshot view -
transitionEnabled
-
transitionMode
-
expandedPerformance
-
label1
-
label2
-
label3
-
label4
-
label5
-
labels
-
-
Constructor Details
-
LXPalette
-
-
Method Details
-
onParameterChanged
Description copied from class:LXComponent
Subclasses are free to override this if desired. It will automatically fire for any listenable parameter that is registered with this component.- Specified by:
onParameterChanged
in interfaceLXParameterListener
- Overrides:
onParameterChanged
in classLXComponent
- Parameters:
p
- Parameter that has a value change
-
getColor
public int getColor()Gets the primary color of the currently active swatch- Returns:
- Primary color of active swatch
-
getSwatchColor
Gets the color in the active swatch at the given index. If the swatch doesn't have that many colors, the last available color is returned.- Parameters:
index
- Index in swatch- Returns:
- Color
-
getHuef
public float getHuef()Gets the hue of the primary color in active swatch- Returns:
- Hue of primary color
-
getHue
public double getHue()Gets the hue of the primary color in active swatch- Returns:
- Hue of primary color
-
getSaturationf
public float getSaturationf()Gets the saturation of the primary color in active swatch- Returns:
- Saturation of primary color
-
getSaturation
public double getSaturation()Gets the saturation of the primary color in active swatch- Returns:
- Saturation of primary color
-
getBrightnessf
public float getBrightnessf()Gets the brightness of the primary color in active swatch- Returns:
- Brightness of primary color
-
getBrightness
public double getBrightness()Gets the brightness of the primary color in active swatch- Returns:
- Brightness of primary color
-
saveSwatch
Saves the current swatch to the list of saved swatches- Returns:
- Saved swatch, added to swatch list
-
addSwatch
Adds a swatch at the given index- Parameters:
swatchObj
- Saved swatch objectindex
- Index to save at- Returns:
- Swatch object
-
removeSwatch
Removes a swatch from the color palette's saved swatch list- Parameters:
swatch
- Swatch to remove- Returns:
- this
-
setSwatch
Set the palette to a saved swatch- Parameters:
swatch
- Swatch to transition to- Returns:
- Whether swatch was set, or false if already in transition
-
getTransitionProgress
public double getTransitionProgress() -
getAutoCycleProgress
public double getAutoCycleProgress() -
loop
public void loop(double deltaMs) - Specified by:
loop
in interfaceLXLoopTask
-
moveSwatch
Moves a saved swatch to a different position in the list- Parameters:
swatch
- Saved swatchindex
- New index for that swatch- Returns:
- this
-
addListener
Registers a listener to the palette- Parameters:
listener
- Palette listener- Returns:
- this
-
removeListener
Unregisters a listener to the palette- Parameters:
listener
- Palette listener- Returns:
- this
-
handleOscMessage
Description copied from class:LXComponent
Handles an OSC message sent to this component. By default this method handles registered components and parameters, but subclasses may override this method to handle different types of OSC messages.- Specified by:
handleOscMessage
in interfaceLXOscComponent
- Overrides:
handleOscMessage
in classLXComponent
- Parameters:
message
- Full OSC message objectparts
- The OSC address pattern, broken into an array of partsindex
- Which index into the parts array corresponds to this component's children- Returns:
true
if the OSC message was handled and should be considered consumed,false
otherwise
-
dispose
public void dispose()Description copied from class:LXComponent
Invoked when a component is being removed from the system and will no longer be used at all. This unregisters the component and should free up any resources and parameter listeners. Ideally after this method is called the object should be eligible for garbage collection. Subclasses are generally expected to override this method to handle their particular cleanup work. They should also generally callsuper.dispose()
at the appropriate time to perform the basic cleanup, which may need to happen either before or after cleaning up other objects.- Overrides:
dispose
in classLXComponent
-
save
Description copied from class:LXComponent
Serializes the LX component. By default, all internal and user-facing parameters are serialized, as well as any explicitly registered child components. Note that child arrays are not serialized, or any other dynamic components. Subclasses may override to perform more saving, and are expected to callsuper.save(lx, obj)
at the appropriate time.- Specified by:
save
in interfaceLXSerializable
- Overrides:
save
in classLXComponent
- Parameters:
lx
- LX instanceobj
- Object to serialize into
-
load
Description copied from class:LXComponent
Loads the LX component. Restores the ID of the component, as well as its internal and user-facing parameters. Any explicitly registered children will be automatically loaded, so long as they are direct descendants. Dynamic arrays will not be automatically loaded, this is left to subclasses to implement.- Specified by:
load
in interfaceLXSerializable
- Overrides:
load
in classLXComponent
- Parameters:
lx
- LX instanceobj
- Object to deserialize
-
exportSwatches
-
importSwatches
-