API Docs for: 1.7.0
Show:

photonui.Color Class

Extends photonui.Base
Module: NonVisual
Parent Module: PhotonUI

Handle colors.

wEvents:

  • value-changed:
    • description: the selected color changed.
    • callback: function(photonui.Color)

Constructor

photonui.Color

(
)

Parameters:

  • Object multiple

    An object that can contain any property of the Color class (optional).

Methods

_bindEvent

(
  • id
  • element
  • evName
  • callback
)
private

Inherited from photonui.Base: src/base.js:229

Javascript event binding (for internal use).

Parameters:

  • id String
    An unique id for the event.
  • element DOMElement
    The element on which the event will be bind.
  • evName String
    The event name (e.g. "mousemove", "click",...).
  • callback Function
    The function that will be called when the event occured.

_callCallbacks

(
  • wEvent
  • params
)
private

Inherited from photonui.Base: src/base.js:288

Call all callbacks for the given wEvent. NOTE: the first argument passed to the callback is the current widget. NOTEĀ²: if the thisArg of the callback is null, this will be binded to the current widget.

Parameters:

  • wEvent String
    The widget event.
  • params Array
    Parametters that will be sent to the callbacks.

_registerWEvents

(
  • wEvents
)
private

Inherited from photonui.Base: src/base.js:272

Register available wEvent.

Parameters:

_unbindEvent

(
  • id
)
private

Inherited from photonui.Base: src/base.js:253

Unbind javascript event.

Parameters:

  • id String
    The id of the event.

_updateHSB

() private

Update HSB from RGB.

_updateProperties

(
  • properties
)
deprecated private

Inherited from photonui.Base: src/base.js:209

Force the update of the given properties. This method is deprecated. One should use '@photonui-update' abitbol's annotation on concerned properties.

Parameters:

  • properties Array
    The properties to update.

_updateRGB

() private

Update RGB from HSB.

destroy

()

Inherited from photonui.Base: src/base.js:157

Destroy the class.

FormatToCssRgbaString

(
  • red
  • green
  • blue
  • alpha
)
String static

Format an RGBA color to CSS RGBA string (e.g. rgba(255, 0, 0, 1.00)).

Parameters:

  • red Number

    The red component

  • green Number

    The green component

  • blue Number

    The blue component

  • alpha Number

    The opacity of the color

Returns:

String:

The formatted color string.

FormatToCssRgbString

(
  • red
  • green
  • blue
)
String static

Format an RGB color to CSS RGB string (e.g. rgb(255, 0, 0)).

Parameters:

  • red Number

    The red component

  • green Number

    The green component

  • blue Number

    The blue component

Returns:

String:

The formatted color string.

FormatToRgbaHexString

(
  • red
  • green
  • blue
  • alpha
)
String static

Format an RGBA color to hexadecimal RGBA string (e.g. #FF0000FF).

Parameters:

  • red Number

    The red component

  • green Number

    The green component

  • blue Number

    The blue component

  • alpha Number

    The opacity of the color

Returns:

String:

The formatted color string.

FormatToRgbHexString

(
  • red
  • green
  • blue
)
String static

Format an RGB color to hexadecimal RGB string (e.g. #FF0000).

Parameters:

  • red Number

    The red component

  • green Number

    The green component

  • blue Number

    The blue component

Returns:

String:

The formatted color string.

fromString

(
  • color
)

Defines the color from any supported string format.

Parameters:

getRGB

() Array

Get RGB.

Returns:

Array:

[red(0-255), green(0-255), blue(0-255)]

getRGBA

() Array

Get RGBA.

Returns:

Array:

[red(0-255), green(0-255), blue(0-255), alpha(0-255)]

NormalizeRgbaColor

(
  • red
  • green
  • blue
  • alpha
)
Array static

Normalize an RGBA color.

Parameters:

  • red Number

    The red component

  • green Number

    The green component

  • blue Number

    The blue component

  • alpha Number

    The opacity of the color

Returns:

Array:

The normalized array [r, g, b, a] where each component is an integer between 0-255.

NormalizeRgbColor

(
  • red
  • green
  • blue
)
Array static

Normalize an RGB color.

Parameters:

  • red Number

    The red component

  • green Number

    The green component

  • blue Number

    The blue component

Returns:

Array:

The normalized array [r, g, b] where each component is an integer between 0-255.

ParseCssRgbaString

(
  • color
)
Array static

Converts a CSS RGBA color (e.g. rgba(255, 0, 0, 0.3)) to an [r, g, b, a] array.

Parameters:

  • color String

    The CSS RGBA color

Returns:

Array:

[r, g, b, a] where each component is an integer between 0-255

ParseCssRgbString

(
  • color
)
Array static

Converts a CSS RGB color (e.g. rgb(255, 0, 0)) to an [r, g, b] array.

Parameters:

  • color String

    The CSS RGB color

Returns:

Array:

[r, g, b] where each component is an integer between 0-255

ParseNamedColor

(
  • color
)
Array static

Converts a named color (e.g. "red") to an [r, g, b] array.

Parameters:

  • color String

    The named color

Returns:

Array:

[r, g, b] where each component is an integer between 0-255

ParseRgbaHexString

(
  • color
)
Array static

Converts an hexadecimal RGBA color (e.g. #FF0000FF, #F00F) to an [r, g, b, a] array.

Parameters:

  • color String

    The hexadecimal RGBA color

Returns:

Array:

[r, g, b, a] where each component is an integer between 0-255

ParseRgbHexString

(
  • color
)
Array static

Converts an hexadecimal RGB color (e.g. #FF0000, #F00) to an [r, g, b] array.

Parameters:

  • color String

    The hexadecimal RGB color

Returns:

Array:

[r, g, b] where each component is an integer between 0-255

ParseString

(
  • color
)
Array static

Converts any supported color format to an [r, g, b, a] array.

Parameters:

Returns:

Array:

[r, g, b, a] where each components is an integer between 0-255

registerCallback

(
  • id
  • wEvent
  • callback
  • thisArg
)

Inherited from photonui.Base: src/base.js:169

Register a callback for any PhotonUI/Widget event (called wEvent). Callback signature: function (Object(Base/Widget) [, arg1 [, arg2 [, ...]]])

Parameters:

  • id String
    An unique id for the callback.
  • wEvent String
    the PhotonUI/Widget event name.
  • callback Function
    The callback function.
  • thisArg Object
    The value of this (optionnal, default = current widget).

removeCallback

(
  • id
)

Inherited from photonui.Base: src/base.js:193

Remove a registered callback.

Parameters:

  • id String
    The id of the callback.

setHSB

(
  • hue
  • saturation
  • brightness
)

Set HSB color

The params can also be replaced by an array.

Parameters:

setRGB

(
  • red
  • green
  • blue
)

Set RGB(A) color (alias for setRGBA).

The params can also be replaced by an array.

Parameters:

setRGBA

(
  • red
  • green
  • blue
  • alpha
)

Set RGBA color.

The params can also be replaced by an array.

Parameters:

Properties

__callbacks

Object private

Inherited from photonui.Base: src/base.js:142

Object containing references to registered callbacks.

__events

Object private

Inherited from photonui.Base: src/base.js:132

Object containing references javascript events binding (for widget internal use).

alpha

Number

Alpha channel (0-255)

blue

Number

Blue (0-255).

brightness

Number

Brightness (0-100).

cssRgbaString

String

The color in CSS RGBA format (e.g. "rgb(255, 0, 0, 1.0)").

cssRgbString

String

The color in CSS RGB format (e.g. "rgb(255, 0, 0)").

data

Object

Inherited from photonui.Base: src/base.js:113

Arbitrary data

Default: {}

green

Number

Green (0-255).

hexString

String deprecated

The color in RGB hexadecimal format (e.g. "#FF0000").

hue

Number

Hue (0-360).

NAMED_COLORS

Object static

Object containing all known named colors (colorName: [r, g, b]).

red

Number

Red (0-255).

rgbaHexString

String

The color in RGBA hexadecimal format (e.g. "#FF0000FF").

rgbaString

String deprecated

The color in CSS RGBA format (e.g. "rgba(255, 0, 0, 1.0)").

rgbHexString

String

The color in RGB hexadecimal format (e.g. "#FF0000").

rgbString

String deprecated

The color in CSS RGB format (e.g. "rgb(255, 0, 0)").

saturation

Number

Saturation (0-100).