Color
MMO.core · 1 symbol · generated 5 Oct 2026
Color
Color.js:155- Namespace
MMO.core
Index
| constructor(r, g, b, a) | ||
| ListMMOColors(node) static | Collect every --mmo-color* custom property resolving on a node. | |
| MMOColor(name, node) static | Create a color from a sass color variable set in the framework | |
| From(color, node) static | Convert a color to its rgb component | |
| FromStyle(node, style) static | 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. | |
| FromOKLab(L, a, b) static | Create a Color from OKLab specification | |
| Mix() static | 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 | |
| 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| r | ||
| g | ||
| b | ||
| a = 1.0 |
ListMMOColors(node)
staticColor.js:168Collect every --mmo-color* custom property resolving on a node.
| node | Element | the node whose cascade is read |
| returns | Object<string, MMO.core.Color> | indexed by property name |
MMOColor(name, node)
staticColor.js:186Create a color from a sass color variable set in the framework
| name | ||
| node = null | ||
| returns | MMO.core.Color | null |
From(color, node)
staticColor.js:199Convert a color to its rgb component
| color | string | . 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 | ||
| returns | MMO.core.colors.Color | null |
FromStyle(node, style)
staticColor.js:237Read 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.
| node | Element | |
| style = 'background-color' | string | the css property to read |
| returns | MMO.core.Color |
FromOKLab(L, a, b)
staticColor.js:258Create a Color from OKLab specification
| L | ||
| a | ||
| b |
Mix()
staticColor.js:283Mix 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
| returns |
hex()
Color.js:304| returns | string | '#rrggbb', with the alpha appended only when the color is translucent |
name()
Color.js:316| returns | string | the css keyword for this color, or its hex form when it has no name |
toString()
Color.js:325| returns | string | MMO.core.Color#name |
luminance()
Color.js:334The WCAG relative luminance: 0 for black, 1 for white.
| returns | number |
textColor()
Color.js:352Get the text color the has the best contrast with the current color
| returns | string | the color |
toOKLab()
Color.js:359Return this color to Björn Ottosson's OKLab specification