Color is a class used make it easy to create and modify colors consistently across all aspects of Urchin.
| Color( ): Color | Returns a black, transparent RGBA color with all values equal to 0. |
|---|---|
| Color( color: string ): Color | Returns a RGBA color of one of the 16 basic colors identified in HTML 4.01 specification (Case Insensitive): White, Silver, Gray, Black, Red, Maroon, Yellow, Olive, Lime, Green, Aqua, Teal, Blue, Navy, Fuchsia, and Purple. If the string provided is not in the list, the color Lime is returned. |
| Color( hex: string ): Color | Returns a RGBA color based off of a 3-digit, 4-digit, 6-digit, or 8-digit RGB/RGBA hex value. |
| Color( grayscale: number ): Color | Returns a grayscale, RGBA color based off of the given value. Range: [0, 255] |
| Color( grayscale: number, alpha: number ): Color | Returns a grayscale, RGBA color with an alpha channel based off of the given value. grayscale range: [0-255]. alpha range: [0.0, 1.0] |
| Color( hue: number, saturation: number, lightness: number ): Color | Returns a HSL color with the given values. hue range: [0, 360]. saturation and lightness range: [0, 100]. |
| Color( red: number, green: number, blue: number, alpha: number): Color | Returns a RGBA color from the values specified. red, green, blue range: [0, 255]. alpha range: [0.0, 1.0]. |
| Color.RGBA = 0 | A non-explicit value used to represent the RGBA color type. |
|---|---|
| Color.HSL = 1 | A non-explicit value used to represent the HSL color type. |
| type: number | The type of Color object. Expected values are Color.RGBA or Color.HSL. |
|---|---|
| r: number | The red-channel of a RGBA Color. Expected range: Integer[0, 255]. |
| g: number | The green-channel of a RGBA Color. Expected range: Integer[0, 255]. |
| b: number | The blue-channel of a RGBA Color. Expected range: Integer[0, 255]. |
| a: number | The alpha-channel of a RGBA Color. Expected range: Decimal[0.0, 1.0]. |
| h: number | The hue-channel of a HSL Color. Expected range: Integer[0, 360]. |
| s: number | The saturation-channel of a HSL Color. Expected range: Integer[0, 100]. |
| l: number | The lightness-channel of a HSL Color. Expected range: Integer[0, 100]. |
| add(color: Color): Color | Adds the given color to the current color and constrains the output values to their expected ranges. Returns this. |
|---|---|
| applyLight(color: Color, intensity: number): Color | Modifies the Color object as if a light of given color and intensity is shining directly on it. Returns this. |
| copy(): Color | Returns a copy of the Color object. |
| mult(intensity: number): Color | Multiplies the current color's red, green, and blue channels by the given intensity and constrains the resulting values to their expected ranges. Returns this. |
| toRGB(): Color | Converts the current Color to the RGBA type. Returns this. |
| toString(): string | Returns a CSS-compatible color function as a string. If the Color type is RGBA, the 'rgba()' function is returned. Likewise, if the color type is HSL, the 'hsl()' function is returned. |
| Color.add(c0: Color, c1: Color): Color | Adds the two given colors, constrains the output values to their expected ranges, and returns the resulting RGBA Color. |
|---|---|
| Color.applyLight(c: Color, l: Color, intensity: number): Color | Returns a modified RGBA copy of the first Color object as if a light of given color and intensity is shining directly on it. |
| Color.copy(c: Color): Color | Returns a copy of the Color object or Object with all the required public attributes of either a RGBA or HSL type Color. |
| Color.mult(c: Color, intensity: number): Color | Multiplies a copy of the given color's red, green, and blue channels by the given intensity, constrains the resulting values to their expected ranges, and returns the resulting RGBA Color. |
| Color.toRGB(c: Color): Color | Returns a copy of the given Color to the RGBA type. |
| Color.toString(c: Color): string | Returns a CSS-compatible color function of the given Color as a string. If the Color type is RGBA, the 'rgba()' function is returned. Likewise, if the color type is HSL, the 'hsl()' function is returned. |
Copyright © 2020 Trevor Richard