MMOframework
Pourquoi l'IA Playground Bibliothèques Documentation Rechercher Agence
FR EN
Index

Color

MMO.core · 1 symbole · générée le 27 Oct 2026

class

Color

Color.js:155
class MMO.core.Color
Espace de noms
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

Méthodes13

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
retourneObject<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
retourneMMO.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
retourneMMO.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
retourneMMO.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()
retourne
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()
retournestring'#rrggbb', with the alpha appended only when the color is translucent

name()

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

toString()

Color.js:325
toString()
retournestringMMO.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.
retournenumber

textColor()

Color.js:352

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

textColor()
retournestringthe color

toOKLab()

Color.js:359

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

toOKLab()