Skip to main content
Using Deno in production at your company? Earn free Deno merch.
Give us feedback
Module

x/threejs_4_deno/src/math/Color.d.ts>Color

A simple transformation of three.js for use within a Deno workflow
Go to Latest
class Color
import { Color } from "https://deno.land/x/threejs_4_deno@v121/src/math/Color.d.ts";

Represents a color. See also ColorUtils.

Examples

const color = new THREE.Color( 0xff0000 );

Constructors

new
Color(color?: Color | string | number)
new
Color(
r: number,
g: number,
b: number,
)

Properties

b: number

Blue channel value between 0 and 1. Default is 1.

g: number

Green channel value between 0 and 1. Default is 1.

readonly
isColor: true
r: number

Red channel value between 0 and 1. Default is 1.

Methods

add(color: Color): this
addColors(color1: Color, color2: Color): this
addScalar(s: number): this
clone(): this

Clones this color.

convertGammaToLinear(gammaFactor?: number): Color

Converts this color from gamma to linear space.

convertLinearToGamma(gammaFactor?: number): Color

Converts this color from linear to gamma space.

Converts this color from linear to sRGB space.

Converts this color from sRGB to linear space.

copy(color: Color): this

Copies given color.

copyGammaToLinear(color: Color, gammaFactor?: number): Color

Copies given color making conversion from gamma to linear space.

copyLinearToGamma(color: Color, gammaFactor?: number): Color

Copies given color making conversion from linear to gamma space.

Copies given color making conversion from linear to sRGB space.

Copies given color making conversion from sRGB to linear space.

equals(color: Color): boolean
fromArray(array: number[], offset?: number): this

Sets this color's red, green and blue value from the provided array.

fromArray(array: ArrayLike<number>, offset?: number): this

Sets this color's red, green and blue value from the provided array-like.

fromBufferAttribute(attribute: BufferAttribute, index: number): this
getHex(): number

Returns the hexadecimal value of this color.

getHexString(): string

Returns the string formated hexadecimal value of this color.

getHSL(target: HSL): HSL
getStyle(): string

Returns the value of this color in CSS context style. Example: rgb(r, g, b)

lerp(color: Color, alpha: number): this
lerpHSL(color: Color, alpha: number): this
multiply(color: Color): this
multiplyScalar(s: number): this
offsetHSL(
h: number,
s: number,
l: number,
): this
set(color: Color | string | number): Color
setColorName(style: string): Color

Sets this color from a color name. Faster than Color#setStyle | .setStyle() method if you don't need the other CSS-style formats.

setHex(hex: number): Color
setHSL(
h: number,
s: number,
l: number,
): Color

Sets this color from HSL values. Based on MochiKit implementation by Bob Ippolito.

setRGB(
r: number,
g: number,
b: number,
): Color

Sets this color from RGB values.

setScalar(scalar: number): Color
setStyle(style: string): Color

Sets this color from a CSS context style string.

sub(color: Color): this
toArray(array?: number[], offset?: number): number[]

Returns an array [red, green, blue], or copies red, green and blue into the provided array.

toArray(xyz: ArrayLike<number>, offset?: number): ArrayLike<number>

Copies red, green and blue into the provided array-like.

Static Properties

NAMES: Record<string, number>

List of X11 color names.