Diorama

Made for a big screen.

This site is one 3D scene, built for a computer: a wide window and a mouse. Open dioramajs.dev on a desktop or a laptop to see it.This site is one 3D scene, built for a wide window. Make this one wider, or open dioramajs.dev on a larger screen.

GitHub

DioramaDocs

cssColor function

Any CSS colour as '#rrggbb', which three's `Color.setStyle` parses.

View as Markdown
import { cssColor } from '@dioramajs/diorama/render'

Alpha is dropped. Hex, rgb() and hsl() in both syntaxes and colour names are parsed here; other colour spaces go through a canvas, so they need a browser. Undefined for what is not a colour.

With element, var(--brand) (its fallback when unset, nested custom properties followed) and currentColor are read from the element's computed style, anywhere in the value, as in color-mix(in oklab, var(--brand), white). The value is read at the call: call again to see a changed variable.

function cssColor(value: string, element?: Element): string | undefined

Parameters

NameTypeDescription
valuestring
element?Element

Also exported from @dioramajs/render.

Defined in packages/render/src/color.ts.