chroma: Chroma API

Description Methods Note

Description

Manipulate colors with 'chroma.js' library. See https://gka.github.io/chroma.js/.

Methods

Public methods


Method new()

Create a new chroma instance.

Usage
chroma$new(color = NULL)
Arguments
color

Name, hex code or a vector of length 3 (rgb) of a color.

Returns

A new 'chroma' object.


Method chroma.hsl()

Create a new chroma instance with HSL color.

Usage
chroma$chroma.hsl(hue, saturation, lightness)
Arguments
hue

Hue parameter.

saturation

Aaturation parameter.

lightness

Lightness parameter.

Returns

A new 'chroma' object.


Method chroma.hsv()

Create a new chroma instance with HSV color.

Usage
chroma$chroma.hsv(hue, saturation, value)
Arguments
hue

Hue parameter.

saturation

Saturation parameter.

value

Value parameter.

Returns

A new 'chroma' object.


Method chroma.lch()

Create a new chroma instance with LCH color.

Usage
chroma$chroma.lch(Lightness, chroma, hue)
Arguments
Lightness

Lightness parameter.

chroma

Chroma parameter.

hue

Hue parameter.

Returns

A new 'chroma' object.


Method chroma.gl()

Create a new chroma instance with RGB color.

Usage
chroma$chroma.gl(red, green, blue, alpha = NULL)
Arguments
red

Red parameter.

green

Green parameter.

blue

Blue parameter.

alpha

Alpha parameter.

Returns

A new 'chroma' object.


Method mix()

Mixes two colors

Usage
chroma$mix(color2, ratio = 0.5, mode = c("rgb", "hsl", "lab", "lrgb", "lch"))
Arguments
color2

Name of a second color.

ratio

A value between 0 and 1.

mode

Color space used for interpolation.

Returns

A 'chroma' object modified.


Method average()

Average between colors

Usage
chroma$average(colors, mode = c("rgb", "hsl", "lab", "lrgb", "lch"))
Arguments
colors

Color(s).

mode

Color space used for interpolation.

Returns

A 'chroma' object modified.


Method blend()

Blend two colors

Usage
chroma$blend(
  color2,
  type = c("multiply", "darken", "lighten", "screen", "overlay", "burn", "dodge")
)
Arguments
color2

Name of a second color.

blend

Blend mode.

Returns

A 'chroma' object modified.


Method random()

Get a random color

Usage
chroma$random()
Returns

A 'chroma' object modified.


Method contrast()

Contrast between two colors

Usage
chroma$contrast(color1, color2)
Arguments
color1

Name of first color.

color2

Name of second color.

Returns

A 'chroma' object modified.


Method distance()

Distance between two colors

Usage
chroma$distance(color1, color2, mode = c("lab", "rgb", "hsl", "lrgb", "lch"))
Arguments
color1

Name of first color.

color2

Name of second color.

Returns

A 'chroma' object modified.


Method alpha()

Usage
chroma$alpha(value = NA)

Method brighten()

Usage
chroma$brighten(value = 1)

Method darken()

Usage
chroma$darken(value = 1)

Method saturate()

Usage
chroma$saturate(value = 1)

Method desaturate()

Usage
chroma$desaturate(value = 1)

Method set()

Usage
chroma$set(channel, value)

Method get()

Usage
chroma$get(channel)

Method luminance()

Usage
chroma$luminance(lum = NULL, mode = "rgb")

Method hex()

Return color as hexadecimal

Usage
chroma$hex()
Returns

A character.


Method name()

Return color's name

Usage
chroma$name()
Returns

A character.


Method css()

Return color as CSS code

Usage
chroma$css()
Returns

A character.


Method rgb()

Return color as RGB

Usage
chroma$rgb(round = TRUE)
Returns

A character.


Method rgba()

Return color as RGBA

Usage
chroma$rgba(round = TRUE)
Returns

A character.


Method hsl()

Return color as HSL

Usage
chroma$hsl()
Returns

A character.


Method hsv()

Return color as HSV

Usage
chroma$hsv()
Returns

A character.


Method hsi()

Return color as HSI

Usage
chroma$hsi()
Returns

A character.


Method lab()

Return color as LAB

Usage
chroma$lab()
Returns

A character.


Method lch()

Return color as LCH

Usage
chroma$lch()
Returns

A character.


Method hcl()

Return color as HCL

Usage
chroma$hcl()
Returns

A character.


Method gl()

Return color as GL

Usage
chroma$gl()
Returns

A character.


Method print()

Print chroma javascript code

Usage
chroma$print()
Returns

A character.


Method eval()

Evaluate chroma call in javascript

Usage
chroma$eval(type_convert = TRUE, split_char = ",")
Arguments
type_convert

Convert data to appropriate type.

split_char

Character used to split results.

Returns

The result of chroma instructions.


Method clone()

The objects of this class are cloneable with this method.

Usage
chroma$clone(deep = FALSE)
Arguments
deep

Whether to make a deep clone.

Note

Dont initialize chroma instance with a color.

Dont initialize chroma instance with a color.


dreamRs/colorscale documentation built on April 17, 2020, 8:38 a.m.