Class: ColorUtils

ColorUtils()

new ColorUtils()

ColorUtils provides several method to abstract color manipulation for canvas

This class doesn't need to be instantiated, as all its methods are static in order to make those utils methods available without constraints. Refer to each method for their associated documentation.
Since:
  • 2020
Author:
  • Arthur Beaulieu
Source:

Members

(static) defaultAntiPrimaryColor :string

The default anti primary color, #FF6B67

Type:
  • string
Source:

(static) defaultAudioGradient :Array.<string>

The default color array to be used in gradient, ['#56D45B', '#AFF2B3', '#FFAD67', '#FF6B67', '#FFBAB8']

Type:
  • Array.<string>
Source:

(static) defaultBackgroundColor :string

The default background color, #1D1E25

Type:
  • string
Source:

(static) defaultDarkPrimaryColor :string

The default dark primary color, #12B31D

Type:
  • string
Source:

(static) defaultLoopAlphaColor :string

The default dark primary color, #FFAD67

Type:
  • string
Source:

(static) defaultLoopColor :string

The default dark primary color, #FFAD67

Type:
  • string
Source:

(static) defaultPrimaryColor :string

The default primary color, #56D45B

Type:
  • string
Source:

(static) defaultTextColor :string

The default text color, #E7E9E7

Type:
  • string
Source:

Methods

(static) alphaColor(color, alpha) → {string}

Add transparency on an existing color.
Parameters:
Name Type Description
color string

The color to make transparent in Hex

alpha number

The amount of transparency applied on color in Float[0,1]

Since:
  • 2020
Author:
  • Arthur Beaulieu
Source:
Returns:

The transparent color in rgba

Type
string

(static) drawRadialGradient(canvas, options)

Fill context with radial gradient according to options object.
Parameters:
Name Type Description
canvas object

The canvas to draw radial gradient in

options object

Radial gradient options

Properties
Name Type Description
x0 number

The x origin in canvas dimension

y0 number

The y origin in canvas dimension

r0 number

The radius of the start circle in Float[0,2PI]

x1 number

The x endpoint in canvas dimension

y1 number

The y endpoint in canvas dimension

r1 number

The radius of the end circle in Float[0,2PI]

colors Array.<object>

The color gradient, must be objects with color (in Hex/RGB/HSL) and index (in Float[0,1]) properties

Since:
  • 2020
Author:
  • Arthur Beaulieu
Source:

(static) lightenDarkenColor(color, amount) → {string}

Lighten or darken a given color from an amount. Inspired from https://jsfiddle.net/gabrieleromanato/hrJ4X/
Parameters:
Name Type Description
color string

The color to alter in Hex

amount number

The percentage amount to lighten or darken in Float[-100,100]

Since:
  • 2020
Author:
  • Arthur Beaulieu
Source:
Returns:

The altered color in Hex

Type
string

(static) linearGradient(canvas, options) → {object}

Returns a linear gradient according to options object.
Parameters:
Name Type Description
canvas object

The canvas to draw radial glowing gradient in

options object

Linear gradient options

Properties
Name Type Attributes Description
vertical boolean <optional>

Draw the gradient vertically

colors Array.<object>

The color gradient, must be objects with color (in Hex or css colors) and index (in Float[0,1]) properties

Since:
  • 2021
Author:
  • Arthur Beaulieu
Source:
Returns:

The linear gradient to apply

Type
object

(static) radialGlowGradient(canvas, options) → {object}

Returns a radial glowing gradient according to options object.
Parameters:
Name Type Description
canvas object

The canvas to draw radial glowing gradient in

options object

Radial glowing gradient options

Properties
Name Type Description
centerX number

The center x origin in canvas dimension

centerY number

The center y origin in canvas dimension

radius number

The circle radius in canvas dimension

colors Array.<object>

The color gradient, must be objects with color (in Hex/RGB/HSL) and index (in Float[0,1]) properties

Since:
  • 2020
Author:
  • Arthur Beaulieu
Source:
Returns:

The radial glowing gradient to apply

Type
object

(static) rainbowLinearGradient(canvas, verticalopt) → {object}

Returns a vertical or horizontal rainbow gradient.
Parameters:
Name Type Attributes Default Description
canvas object

The canvas to create gradient from

vertical boolean <optional>
false

The gradient orientation, default to horizontal

Since:
  • 2020
Author:
  • Arthur Beaulieu
Source:
Returns:

The rainbow gradient to apply

Type
object