ColorPickerHSLuvGradientView
A color picker gradient view using the HSLuv color space for perceptually uniform color selection. HSLuv is a human-friendly alternative to HSL that maintains perceptual uniformity across hue and saturation changes, making color selection more intuitive.
The gradient displays:
- Hue along the horizontal axis (0-360 degrees)
- Saturation along the vertical axis (100% at top, 0% at bottom)
- Lightness controlled externally and applied uniformly
Users can select colors by clicking/dragging on the gradient, with a visual pointer indicating the current selection. The pointer automatically adjusts its color for visibility based on the lightness value.
@event updateColorFromPointer Emitted when the color is updated via pointer interaction
Instance Members
The currently selected color value. Setting this updates the gradient and pointer position.
The lightness value (0-1) applied uniformly across the gradient. This is typically controlled by an external spectrum/slider.
Updates the gradient mesh colors based on the current lightness value. Regenerates all vertex colors to reflect the HSLuv color space.
Name | Type | Default | Description |
---|---|---|---|
lightness |
Float | (optional) | Optional new lightness value (0-1) |
Saves the current pointer position for later restoration. Useful when temporarily moving the pointer during spectrum adjustments.
Restores the pointer to its previously saved position.
Calculates the saturation value based on the pointer's vertical position.
Returns | Description |
---|---|
Float | Saturation value (0-1), where 1 is at the top |
Calculates the hue value based on the pointer's horizontal position.
Returns | Description |
---|---|
Float | Hue value in degrees (0-360) |
Creates a new HSLuv gradient color picker view. Initializes the gradient mesh and selection pointer.
Private Members
Number of horizontal segments in the gradient mesh for hue precision
Number of vertical segments in the gradient mesh for saturation precision
Internal flag indicating the spectrum (lightness) is being adjusted
The mesh that renders the HSLuv gradient
Visual pointer indicating the current color selection
Target color for pointer border animation
Active tween for animating pointer color changes
Flag indicating the pointer is being dragged
Saved X position of the pointer for restoration
Saved Y position of the pointer for restoration
Filter container for the gradient content
updateColorFromPointer event
Creates a color with the specified hue and saturation using the current lightness.
Name | Type | Description |
---|---|---|
hue |
Float | Hue value in degrees (0-360) |
saturation |
Float | Saturation value (0-1) |
Returns | Description |
---|---|
ceramic.AlphaColor | The resulting color with full opacity |
Updates the pointer position based on the current color value. Also adjusts the pointer border color for visibility.
Handles layout updates when the view is resized. Scales the gradient mesh and updates pointer position accordingly.
Handles pointer down events to begin color selection.
Name | Type | Description |
---|---|---|
info |
ceramic.TouchInfo | Touch/mouse information |
Handles pointer move events during color selection.
Name | Type | Description |
---|---|---|
info |
ceramic.TouchInfo | Touch/mouse information |
Handles pointer up events to end color selection.
Name | Type | Description |
---|---|---|
info |
ceramic.TouchInfo | Touch/mouse information |
Updates the selected color based on touch/mouse position. Converts screen coordinates to hue/saturation values and updates the color.
Name | Type | Description |
---|---|---|
info |
ceramic.TouchInfo | Touch/mouse information containing screen coordinates |
Metadata
Name | Parameters |
---|---|
:build |
ceramic.macros.EntityMacro.buildForCompletion() |
:autoBuild |
ceramic.macros.EntityMacro.buildForCompletion() |
:build |
tracker.macros.EventsMacro.build() |
:autoBuild |
tracker.macros.EventsMacro.build() |