Link Search Menu Expand Document

Colors

colors.ts#L43

Class Color

Colour generation and conversion class.

constructor (r: number, g: number, b: number, a: number): Color

Name Type Default Description
r number    
g number    
b number    
a number 1  

Property .a : number

Default value: 1

Property .b : number

Property .g : number

Property .r : number

Accessor .chroma : number

Accessor .hex : string

Converts this colour to a hex string.

Accessor .hsl

Converts this colour to an HSL array.

Accessor .rgb : string

Converts this colour to an rgba string.

Method .copy (): Color

Creates a copy of this colour.

Method .toString (): string

static Method .from (color: string|Color): Color

Name Type Default Description  
color string Color    

static Method .fromHex (hex: string): Color

Creates a Colour instance from a hex string.

Name Type Default Description
hex string    

static Method .fromHsl (h: number, s: number, l: number): Color

Name Type Default Description
h number    
s number    
l number    

static Method .fromRgb (color: string): Color

Name Type Default Description
color string    

static Method .gradient (colors: Array<string|Color>, steps: number): Array<Color>

Generates a rainbow gradient with a given number of steps.

Name Type Default Description  
colors Array<string Color>    
steps number      

static Method .mix (c1: string|Color, c2: string|Color, p: number): Color

Linearly interpolates two colours or hex strings.

Name Type Default Description  
c1 string Color    
c2 string Color    
p number 0.5    

static Method .mixMany (colors: Array<Color>, weights: Array<number>): Color

Name Type Default Description
colors Array<Color>    
weights Array<number>    

static Method .rainbow (steps: number): Array<Color>

Generates a rainbow gradient with a given number of steps.

Name Type Default Description
steps number    

static Method .shades (color: string|Color, steps: number, range: number): Array<Color>

Name Type Default Description  
color string Color    
steps number      
range number 0.5    

Copyright © 2021 Mathigon.org