Important changes to Tiny Cloud pricing > Find out more

tinymce.util.Color

This class lets you parse/serialize colors and convert rgb/hsb.

Examples

var white = new tinymce.util.Color({r: 255, g: 255, b: 255});
var red = new tinymce.util.Color('#FF0000');

console.log(white.toHex(), red.toHsv());

Constructors

name summary defined by
Color() Constructs a new color instance. tinymce.util.Color

Methods

name summary defined by
parse() Parses the specified value and populates the color instance. Supported format examples: * rbg(255,0,0) * #ff0000 * #fff * {r: 255, g: 0, b: 0} * {h: 360, s: 100, v: 100} tinymce.util.Color
toHex() Returns the hex string of the current color. For example: #ff00ff tinymce.util.Color
toHsv() Returns the h, s, v values of the color. Ranges: h=0-360, s=0-100, v=0-100. tinymce.util.Color
toRgb() Returns the r, g, b values of the color. Each channel has a range from 0-255. tinymce.util.Color

Constructors

Color

public constructor function Color(value:String)

Constructs a new color instance.

Parameters
  • value (String) - Optional initial value to parse.

Methods

parse

parse(value:Object):tinymce.util.Color

Parses the specified value and populates the color instance. Supported format examples: * rbg(255,0,0) * #ff0000 * #fff * {r: 255, g: 0, b: 0} * {h: 360, s: 100, v: 100}

Parameters
  • value (Object) - Color value to parse.
Return value

toHex

toHex():String

Returns the hex string of the current color. For example: #ff00ff

Return value
  • String - Hex string of current color.

toHsv

toHsv():Object

Returns the h, s, v values of the color. Ranges: h=0-360, s=0-100, v=0-100.

Return value
  • Object - Object with h, s, v fields.

toRgb

toRgb():Object

Returns the r, g, b values of the color. Each channel has a range from 0-255.

Return value
  • Object - Object with r, g, b fields.

Can't find what you're looking for? Let us know.

Except as otherwise noted, the content of this page is licensed under the Creative Commons BY-NC-SA 3.0 License, and code samples are licensed under the Apache 2.0 License.