Skip to content

VectorToColor

A plugin to convert a vector to a color string.

Usage

example
import { vecToRGB } from 'animare/plugins';
const red: Vec3Array = [255, 0, 0];
const rgb = vecToRGB(red); // 'rgb(255 0 0)'
const blue: Vec4Array = [0, 0, 255, 0.5]; // with alpha
const rgba = vecToRGB(blue); // 'rgb(0 0 255 / 50%)'

vecToRGB()

vecToRGB(vec: Vec3Array | Vec4Array | Vec3Object | Vec4Object): string

Converts vector (3D or 4D) to RGB string

3D Vector [number, number, number] | { x: number, y: number, z: number }
4D Vector [number, number, number, number] | { x: number, y: number, z: number, w: number }

vecToHSL()

vecToHSL(vec: Vec3Array | Vec4Array | Vec3Object | Vec4Object): string

Converts vector (3D or 4D) to HSL string

3D Vector [number, number, number] | { x: number, y: number, z: number }
4D Vector [number, number, number, number] | { x: number, y: number, z: number, w: number }

vecToHWB()

vecToHWB(vec: Vec3Array | Vec4Array | Vec3Object | Vec4Object): string

Converts vector (3D or 4D) to HWB string

3D Vector [number, number, number] | { x: number, y: number, z: number }
4D Vector [number, number, number, number] | { x: number, y: number, z: number, w: number }