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
Nested ClassesModifier and TypeClassDescriptionstatic enumstatic classstatic interfaceNested classes/interfaces inherited from class heronarts.lx.LXComponent
LXComponent.Description, LXComponent.Hidden, LXComponent.Name, LXComponent.Placeholder, LXComponent.PluginRequired, LXComponent.RenamableNested classes/interfaces inherited from interface heronarts.lx.LXSerializable
LXSerializable.Utils -
Field Summary
FieldsModifier and TypeFieldDescriptionfinal DiscreteParameterfinal BooleanParameterAuto-cycle to a random palette, not the next onefinal BoundedParameterTime in seconds after which transition thru the pattern set is automatically initiated.final LXDynamicColorThe primary active color valuefinal BooleanParameterfinal StringParameterfinal StringParameterfinal StringParameterfinal StringParameterfinal StringParameterfinal StringParameter[]final LXSwatchThe active color swatchA read-only list of all the saved color swatchesfinal BooleanParameterfinal BoundedParameterAmount of time taken in seconds to transition into a new snapshot viewfinal TriggerParameterFields inherited from class heronarts.lx.LXComponent
childArrays, 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, presetFileFields inherited from interface heronarts.lx.LXPath
DEFAULT_SEPARATOR, ROOT, ROOT_PREFIX, ROOT_SLASH -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionaddListener(LXPalette.Listener listener) Registers a listener to the paletteaddSwatch(JsonObject swatchObj, int index) Adds a swatch at the given indexvoiddispose()Invoked when a component is being removed from the system and will no longer be used at all.voidexportSwatches(File file) doubledoubleGets the brightness of the primary color in active swatchfloatGets the brightness of the primary color in active swatchintgetColor()Gets the primary color of the currently active swatchdoublegetHue()Gets the hue of the primary color in active swatchfloatgetHuef()Gets the hue of the primary color in active swatchdoubleGets the saturation of the primary color in active swatchfloatGets the saturation of the primary color in active swatchgetSwatchColor(int index) Gets the color in the active swatch at the given index.doublebooleanhandleOscMessage(OscMessage message, String[] parts, int index) Handles an OSC message sent to this component.importSwatches(File file) voidload(LX lx, JsonObject obj) Loads the LX component.voidloop(double deltaMs) moveSwatch(LXSwatch swatch, int index) Moves a saved swatch to a different position in the listvoidSubclasses 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 listvoidsave(LX lx, JsonObject obj) Serializes the LX component.Saves the current swatch to the list of saved swatchesbooleanSet the palette to a saved swatchMethods inherited from class heronarts.lx.LXComponent
addArray, addChild, addInternalParameter, addLegacyInternalParameter, addLegacyParameter, addParameter, addParameter, addParameters, assertDisposed, contains, copyParameters, getCategory, getChild, getComponentDescription, 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, toStringMethods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, waitMethods inherited from interface heronarts.lx.osc.LXOscComponent
getOscAddressMethods inherited from interface heronarts.lx.LXPath
getCanonicalLabel, getCanonicalLabel, getCanonicalLabel, 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:LXComponentSubclasses are free to override this if desired. It will automatically fire for any listenable parameter that is registered with this component.- Specified by:
onParameterChangedin interfaceLXParameterListener- Overrides:
onParameterChangedin 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:
loopin 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:LXComponentHandles 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:
handleOscMessagein interfaceLXOscComponent- Overrides:
handleOscMessagein 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:
trueif the OSC message was handled and should be considered consumed,falseotherwise
-
dispose
public void dispose()Description copied from class:LXComponentInvoked 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:
disposein classLXComponent
-
save
Description copied from class:LXComponentSerializes 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:
savein interfaceLXSerializable- Overrides:
savein classLXComponent- Parameters:
lx- LX instanceobj- Object to serialize into
-
load
Description copied from class:LXComponentLoads 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:
loadin interfaceLXSerializable- Overrides:
loadin classLXComponent- Parameters:
lx- LX instanceobj- Object to deserialize
-
exportSwatches
-
importSwatches
-