agentscape
Version:
Agentscape is a library for creating agent-based simulations. It provides a simple API for defining agents and their behavior, and for defining the environment in which the agents interact. Agentscape is designed to be flexible and extensible, allowing
28 lines (27 loc) • 901 B
TypeScript
import RandomGenerator from './RandomGenerator';
export type ColorName = 'red' | 'green' | 'blue' | 'yellow' | 'orange' | 'purple' | 'pink' | 'black' | 'white' | 'gray' | 'brown';
export default class Color {
r: number;
g: number;
b: number;
a: number;
static fromName(name: ColorName): Color;
static fromRGB(r: number, g: number, b: number, a?: number): Color;
static fromHex(hex: string): Color;
static random(rng: RandomGenerator): Color;
toRGB(): string;
toHex(): string;
/**
* Returns a new color that is the result of blending this color with another color.
*/
blend(color: Color, amount: number): Color;
/**
* Lightens a color by a given percentage.
*/
lighten(amount: number): Color;
/**
* Darkens a color by a given percentage.
*/
darken(amount: number): Color;
setOpacity(a: number): Color;
}