Index

Color

MMO.core · 1 symbol · generated 30 Sep 2026

class

Color

Color.js:155
class MMO.core.Color
Namespace
MMO.core

Index

constructor(r, g, b, a)
ListMMOColors(node) staticCollect every --mmo-color* custom property resolving on a node.
MMOColor(name, node) staticCreate a color from a sass color variable set in the framework
From(color, node) staticConvert a color to its rgb component
FromStyle(node, style) staticRead a color from a node's computed style, FLATTENING its transparency against the ancestors it would be drawn over, so the result is always opaque.
FromOKLab(L, a, b) staticCreate a Color from OKLab specification
Mix() staticMix colors using Björn Ottosson's OKLab specification and matrices — https://bottosson.github.io/posts/oklab NOTE: You can set the property weight to the color to set a weight in the mix
hex()
name()
toString()
luminance()The WCAG relative luminance: 0 for black, 1 for white.
textColor()Get the text color the has the best contrast with the current color
toOKLab()Return this color to Björn Ottosson's OKLab specification

Methods13

constructor(r, g, b, a)

Color.js:156
constructor(r, g, b, a = 1.0)
r
g
b
a = 1.0

ListMMOColors(node)

staticColor.js:168

Collect every --mmo-color* custom property resolving on a node.

static ListMMOColors(node)
nodeElementthe node whose cascade is read
returnsObject<string, MMO.core.Color>indexed by property name

MMOColor(name, node)

staticColor.js:186

Create a color from a sass color variable set in the framework

static MMOColor(name, node = null)
name
node = null
returnsMMO.core.Color | null

From(color, node)

staticColor.js:199

Convert a color to its rgb component

static From(color, node = null)
colorstring. Supported format : - #XXXXXX, - html color, - var(--xxx) - rgb(xxx,xxx,xxx) | rgb(xxx%,xxx%,xxx%) | rgb(xxx xxx xxx) | rgba(xxx,xxx,xxx,xxx)
node = null
returnsMMO.core.colors.Color | null

FromStyle(node, style)

staticColor.js:237

Read a color from a node's computed style, FLATTENING its transparency against the ancestors it would be drawn over, so the result is always opaque.

static FromStyle(node, style = 'background-color')
nodeElement
style = 'background-color'stringthe css property to read
returnsMMO.core.Color

FromOKLab(L, a, b)

staticColor.js:258

Create a Color from OKLab specification

static FromOKLab(L, a, b)
L
a
b

Mix()

staticColor.js:283

Mix colors using Björn Ottosson's OKLab specification and matrices — https://bottosson.github.io/posts/oklab NOTE: You can set the property weight to the color to set a weight in the mix

static Mix()
returns
MMO.core.Color.Mix("#ff0000", "#00ff00"): a warm olive/brown, not a flat gray if you just mix the RGB

hex()

Color.js:304
hex()
returnsstring'#rrggbb', with the alpha appended only when the color is translucent

name()

Color.js:316
name()
returnsstringthe css keyword for this color, or its hex form when it has no name

toString()

Color.js:325
toString()
returnsstringMMO.core.Color#name

luminance()

Color.js:334

The WCAG relative luminance: 0 for black, 1 for white.

luminance()NOTE: the alpha is IGNORED; flatten the color first if it matters.
returnsnumber

textColor()

Color.js:352

Get the text color the has the best contrast with the current color

textColor()
returnsstringthe color

toOKLab()

Color.js:359

Return this color to Björn Ottosson's OKLab specification

toOKLab()