Class: ColorPalette

ColorPalette()

Allows the user to select what colors they wish to paint with, choose new colors to paint with, and select the color that they are currently painting with.

Constructor

new ColorPalette()

Source:

Extends

  • React.Component

Members

getAddColorCell

Creates the JSX for the add color cell. If the internal ColorPalette's colors array is full, returns null instead.

Source:

getColorCells

Creates the JSX for all of the color select buttons.

Source:

handlePickerChange

Handles color picker change.

Source:

onAddCellClick

Handles when the add cell button is clicked.

Source:

onColorCellClick

Updates the currently selected color cell to the given id

Source:

updateColorData

Checks for changes in color data from the onGetColorData() prop. If there are any, updates the state.

Source:

Methods

addColor(ropt, gopt, bopt)

Adds a new color to the end of the colors array. Red by default.

Parameters:
Name Type Attributes Default Description
r number <optional>
1
g number <optional>
0
b number <optional>
0
Source:

getColorAtIndex(index) → {Color}

Returns the color at the given index.

Parameters:
Name Type Description
index number
Source:
Returns:

The color at the index. Null if not found

Type
Color

getColorsArray() → {Array.Color}

Returns the array of colors currently in the palette.

Source:
Returns:
Type
Array.Color

getSelectedColor() → {Color}

Returns the currently selected color.

Source:
Returns:
Type
Color

getSelectedColorIndex() → {number}

Returns the index of the selected color.

Source:
Returns:
Type
number

isColorsFull() → {boolean}

Checks if the colors array is full. True if it is. False otherwise.

Source:
Returns:
Type
boolean

restoreDefaults()

Sets the color palette to its default settings.

Source:

setColorAtIndex(index, r, g, b)

Sets the color at the given index to the given r, g, b values.

Parameters:
Name Type Description
index number
r number
g number
b number
Source:

setNewColorsArray(newColors)

Creates a new color array from the new one.

Parameters:
Name Type Description
newColors Array
Source:

setSelectedColor(index)

Changes the currently selected color to another within the colors array.

Parameters:
Name Type Description
index number
Source:

ColorPalette(colorsopt, selectedColoropt)

Internal representation of the ColorPalette React component. Used to track each color of the voxels within the scene.

Constructor

new ColorPalette(colorsopt, selectedColoropt)

Creates a new ColorPalette.

Parameters:
Name Type Attributes Default Description
colors Array <optional>
null

Array of colors to create the color palette with

selectedColor number <optional>
0

The initial selected color

Properties:
Name Type Description
colors Array.<Color>

Array containing all of the colors in the color palette

selectedColor number

The currently selected color from the colors array

maxColors number

The maximum number of colors that the colors array can hold

Source:

Members

getAddColorCell

Creates the JSX for the add color cell. If the internal ColorPalette's colors array is full, returns null instead.

Source:

getColorCells

Creates the JSX for all of the color select buttons.

Source:

handlePickerChange

Handles color picker change.

Source:

onAddCellClick

Handles when the add cell button is clicked.

Source:

onColorCellClick

Updates the currently selected color cell to the given id

Source:

updateColorData

Checks for changes in color data from the onGetColorData() prop. If there are any, updates the state.

Source:

Methods

addColor(ropt, gopt, bopt)

Adds a new color to the end of the colors array. Red by default.

Parameters:
Name Type Attributes Default Description
r number <optional>
1
g number <optional>
0
b number <optional>
0
Source:

getColorAtIndex(index) → {Color}

Returns the color at the given index.

Parameters:
Name Type Description
index number
Source:
Returns:

The color at the index. Null if not found

Type
Color

getColorsArray() → {Array.Color}

Returns the array of colors currently in the palette.

Source:
Returns:
Type
Array.Color

getSelectedColor() → {Color}

Returns the currently selected color.

Source:
Returns:
Type
Color

getSelectedColorIndex() → {number}

Returns the index of the selected color.

Source:
Returns:
Type
number

isColorsFull() → {boolean}

Checks if the colors array is full. True if it is. False otherwise.

Source:
Returns:
Type
boolean

restoreDefaults()

Sets the color palette to its default settings.

Source:

setColorAtIndex(index, r, g, b)

Sets the color at the given index to the given r, g, b values.

Parameters:
Name Type Description
index number
r number
g number
b number
Source:

setNewColorsArray(newColors)

Creates a new color array from the new one.

Parameters:
Name Type Description
newColors Array
Source:

setSelectedColor(index)

Changes the currently selected color to another within the colors array.

Parameters:
Name Type Description
index number
Source: