Unique color palettes for data visualization and generative art
A continuous color palette created by overlaying curves onto surfaces in the HSL color space.
A ColorPalette has exactly two curves. The "hs" curve maps to hue and saturation values and lies in a unit circle in the HS space. The "l" curve maps it's y-coordinate to lightness, and lies in a unit square in the L space.
Void
Creates a new Color Palette.
Name | Type | Description | |
---|---|---|---|
hsCurve | object string |
The curve object or curve type of the "hs" curve | Optional |
lCurve | object string |
The curve object or curve type of the "l" curve | Optional |
options | object |
= {}] Optional properties of the color palette | Optional |
options.start | number |
Starts the palette at a certain point along the curve | Optional |
options.end | number |
Ends the palette at a certain point along the curve | Optional |
Void
Sets a name for this palette
Name | Type | Description | |
---|---|---|---|
name | string |
A name for this palette | Optional |
Void
Sets a name for this palette
Name | Type | Description | |
---|---|---|---|
author | string |
A name for this palette | Optional |
Void
Sets the "hs" (hue-saturation) curve for this palette.
Name | Type | Description | |
---|---|---|---|
hsCurve | object string |
An object or string describing the "hs" curve. See {@link Curve} | Optional |
Void
Sets the "l" (lightness) curve for this palette.
Name | Type | Description | |
---|---|---|---|
lCurve | object string |
An object or string describing the "hs" curve. See {@link Curve} | Optional |
Void
Returns a JSON representation of this palette, including representations for each of its curves and the palette itself. The returned string consists of three comma-separated JSON objects which map to hsCurve, lCurve, and paletteParams in the ColorPalette constructor.
Name | Type | Description | |
---|---|---|---|
precision | number |
The number of decimals to include in numerical parameters. | Optional |
string
The JSON representation of this palette.
Sets the start point for the palette's curves
Name | Type | Description | |
---|---|---|---|
start | number |
A number in the range [0, 1]. Not to exceed the palette's end point. | Optional |
Void
Sets the end point for the palette's curves
Name | Type | Description | |
---|---|---|---|
end | number |
A number in the range [0, 1]. Not to be exceeded by the palette's start point. | Optional |
Void
Draws a representation of the palette using evenly spaced stops.
Name | Type | Description | |
---|---|---|---|
canvas | object |
An HTML canvas on which to draw the palette. | |
numStops | number |
The number of distinct colors to use in the drawing. |
Void
Draws a representation of the palette using a continuous gradient.
Name | Type | Description | |
---|---|---|---|
canvas | object |
An HTML canvas on which to draw the palette. | |
resolution | number |
= 32] The number of sub-gradients to use. | Optional |
Void
Helper function that builds a curve from a specified string.
Name | Type | Description | |
---|---|---|---|
curveType | string |
A string that maps to one of the supported curve types. | |
options | object |
Options for the curve. See {@link Curve}. | Optional |
Void
Helper function to set the clamp bounds for both curves in the palette. This method should be run before after changing the parameters - but before getting a color value - for palette that use curves of overflow type 'clamp'
Void
Samples the HS and L curves, and converts their cartesian coordinates to hue, saturation, and lightness values
Name | Type | Description | |
---|---|---|---|
n | number |
A number in the range [0, 1] that represents the proportion of each curve to traverse before sampling |
object
The hue, saturation, and lightness values of the palette at the point n
Gets the HSL values at the given point in the palette's range.
Name | Type | Description | |
---|---|---|---|
n | number |
A number in the range [0, 1] that represents the proportion of each curve to traverse before sampling |
string
The HSL string of the color at the point n
Gets the RGB values at the given point in the palette's range.
Name | Type | Description | |
---|---|---|---|
n | number |
A number in the range [0, 1] that represents the proportion of each curve to traverse before sampling |
string
The RGB string of the color at the point n
Gets the hex values at the given point in the palette's range.
Name | Type | Description | |
---|---|---|---|
n | number |
A number in the range [0, 1] that represents the proportion of each curve to traverse before sampling |
string
The hex string of the color at the point n
Represents a relationship between a 1-dimensional input bounded by [0, 1] and a 2-dimensional output bounded by the perimeter of the surface on which the curve lies.
The surface must be either a unit circle (to represent the Hue-Saturation space) or a unit square (to represent the lightness space).
Curves are not instantiated directly.
Void
Creates a new Curve.
Name | Type | Description | |
---|---|---|---|
options | object |
Optional properties of the curve | Optional |
options.overflow | object |
Defines how to adjust output that extends past the surface perimeter | Optional |
options.reverse | boolean |
Whether to reverse the direction of the curve | Optional |
options.rotation | number |
Z-axis rotation of the curve in radians | Optional |
options.scale | object |
2-dimensional scale of the curve | Optional |
options.scale.x | number |
Translation along the local X axis | Optional |
options.scale.y | number |
Translation along the local Y axis | Optional |
options.surface | string |
The surface on which to draw the curve | Optional |
options.translation | object |
2-dimensional translation of the curve | Optional |
options.translation.x | number |
Translation along the local X axis | Optional |
options.translation.y | number |
Translation along the local Y axis | Optional |
Void
Set the curve's surface.
Name | Type | Description | |
---|---|---|---|
surface | object string |
The surface on which to draw the curve |
Void
Samples the curve and sets clampStart and clampEnd to the input values where the curve intersects the perimeter. If the outputs at 0 or 1 are inside of the surface then the clampStart and clampEnd are set to 0 and 1, respectively.
Name | Type | Description | |
---|---|---|---|
resolution | number |
= 128] Number of samples used to determine the clamp bounds | Optional |
Void
Sets the overflow behavior.
Name | Type | Description | |
---|---|---|---|
overflow | string |
= 'clamp'] Method for adjusting output that extends past the surface perimeter | Optional |
Void
Sets the reverse flag.
Name | Type | Description | |
---|---|---|---|
reverse | boolean |
= false] Whether to reverse the direction of the curve | Optional |
Void
Sets the rotation of the curve
Name | Type | Description | |
---|---|---|---|
rotation | boolean |
= 0] Z-Axis rotation of the curve in radians | Optional |
Void
Sets the scale of the curve
Name | Type | Description | |
---|---|---|---|
options.scale | object |
2-dimensional scale of the curve | Optional |
options.scale.x | number |
Scale along the local X axis | Optional |
options.scale.y | number |
Scale along the local Y axis | Optional |
Void
Sets the X scale of the curve. Default depends on the surface type.
Name | Type | Description | |
---|---|---|---|
x | number |
Scale along the local X axis | Optional |
Void
Sets the Y scale of the curve. Default depends on the surface type.
Name | Type | Description | |
---|---|---|---|
y | number |
Scale along the local Y axis | Optional |
Void
Sets the translation of the curve
Name | Type | Description | |
---|---|---|---|
options.translation | object |
2-dimensional translation of the curve | Optional |
options.translation.x | number |
Translation along the local X axis | Optional |
options.translation.y | number |
Translation along the local Y axis | Optional |
Void
Sets the translation of the curve along the local X axis. The default values depends on the surface type.
Name | Type | Description | |
---|---|---|---|
x | number |
Translation along the local X axis | Optional |
Void
Sets the translation of the curve along the local Y axis. The default values depends on the surface type.
Name | Type | Description | |
---|---|---|---|
y | number |
Translation along the local Y axis | Optional |
Void
Returns the x and y coordinates associated with a number n in the range [0, 1].
Name | Type | Description | |
---|---|---|---|
n | object |
A number between 0 and 1 representing the proportion of the curve to traverse |
object.<string, number>
The x and y coordinates of the function at a point n
Applies transformation to the coordinates of the underlying function for the curve. Returns an object containing the new x and y coordinates and well as a 'clamped' flag that is true for coordinates outside of the surface perimeter.
Name | Type | Description | |
---|---|---|---|
n | object |
A number between 0 and 1 representing the proportion of the curve to traverse |
object.<string, number|boolean>
The x and y coordinates of the curve at a point n
Creates an "ease back" function.
Name | Type | Description | |
---|---|---|---|
options | object |
Optional properties of the function | Optional |
options.variation | string |
The contour of the function (see https://easings.net) | Optional |
options.overshoot | number |
The degree to which the function "overshoots" | Optional |
Void
Sets the easing variation. See https://easings.net/
Name | Type | Description | |
---|---|---|---|
variation | string |
The curve variation ('in', 'out', or 'in-out') |
Void
Assigns a function to this class that maps input to output
Void
Creates an ease "bounce" curve.
Name | Type | Description | |
---|---|---|---|
options | object |
Optional properties of the function | Optional |
options.variation | string |
The contour of the function (see https://easings.net) | Optional |
Void
Sets the easing variation. See https://easings.net/
Name | Type | Description | |
---|---|---|---|
variation | string |
The curve variation ('in', 'out', or 'in-out') |
Void
Assigns a function to this class that maps input to output
Void
Creates an "elastic" function.
Name | Type | Description | |
---|---|---|---|
options | object |
Optional properties of the function | Optional |
options.amplitude | string |
The amplitude of the function | Optional |
options.period | number |
The period of the function | Optional |
Void
Sets the easing variation. See https://easings.net/
Name | Type | Description | |
---|---|---|---|
variation | string |
The curve variation ('in', 'out', or 'in-out') |
Void
Assigns a function to this class that maps input to output
Void
Represents a generic function that can be further extended by a child class that specified a 1:1 relationship between a single input and single output
Name | Type | Description | |
---|---|---|---|
options | object |
Optional properties of the function | Optional |
Void
Creates a linear curve.
Name | Type | Description | |
---|---|---|---|
options | object |
Optional properties of the function | Optional |
Void
Creates an ease "elastic" curve.
Name | Type | Description | |
---|---|---|---|
options | object |
Optional properties of the function | Optional |
options.exponent | string |
The exponent of the function | Optional |
Void
Sets the easing variation. See https://easings.net/
Name | Type | Description | |
---|---|---|---|
variation | string |
The curve variation ('in', 'out', or 'in-out') |
Void
Assigns a function to this class that maps input to output
Void
Creates an ease "exponential" curve.
Name | Type | Description | |
---|---|---|---|
options | object |
Optional properties of the function | Optional |
options.variation | string |
The contour of the function (see https://easings.net) | Optional |
Void
Sets the easing variation. See https://easings.net/
Name | Type | Description | |
---|---|---|---|
variation | string |
The curve variation ('in', 'out', or 'in-out') |
Void
Assigns a function to this class that maps input to output
Void
Creates an ease "sinusoidal" curve.
Name | Type | Description | |
---|---|---|---|
options | object |
Optional properties of the function | Optional |
options.variation | string |
The contour of the function (see https://easings.net) | Optional |
Void
Sets the easing variation. See https://easings.net/
Name | Type | Description | |
---|---|---|---|
variation | string |
The curve variation ('in', 'out', or 'in-out') |
Void
Assigns a function to this class that maps input to output
Void
Represents a segment of a circle
Void
Creates a new Arc.
Name | Type | Description | |
---|---|---|---|
options | object |
Optional properties of the arc | Optional |
options.radius | number |
Radius of the arc | Optional |
options.angleStart | number |
= 0] The angle in radians of the segment start | Optional |
options.angleEnd | number |
= 2PI] The angle in radians of the segment end | Optional |
options.angleOffset | number |
= 0] The degrees in radians by which the angleStart and angleEnd are offset | Optional |
curveOptions | See {@link Curve} | Optional |
Void
Sets the radius of the arc. If no value is passed a default is set based on the surface type.
Name | Type | Description | |
---|---|---|---|
radius | object |
Radius of the arc | Optional |
Void
Sets the angle in radians of the ending point of the segment.
Name | Type | Description | |
---|---|---|---|
angleStart | object |
= 0] The angle in radians | Optional |
Void
Sets the angle in radians of the starting point of the segment.
Name | Type | Description | |
---|---|---|---|
angleEnd | object |
= 0] The angle in radians | Optional |
Void
Sets the degrees in radians by which the angleStart and angleEnd are offset
Name | Type | Description | |
---|---|---|---|
angleOffset | object |
= 0] The degrees in radians | Optional |
Void
A circle with a radius of 1 and a center point at (0, 0)
Void
Converts an HSL color value to RGB. Returns r, g, and b values in the set [0, 255].
Name | Type | Description | |
---|---|---|---|
h | number |
The hue value as a degree | |
s | number |
The saturation value in the range [0, 1] | |
l | number |
The lightness color value in the range [0, 1] |
Object
The RGB representation
Converts a hexadecimal string to an RGB color value. Returns r, g, and b values in the set [0, 255]. See: https://stackoverflow.com/a/5624139/3064334
Name | Type | Description | |
---|---|---|---|
hex | String |
The hex value in the range [#000000, #FFFFFF] |
Object
The rgb representation
A square with sides of length 1 and a center point at (0.5, 0.5)
Void
Documentation generated with doxdox.