moonrockz/diagrams-svg/theme

Types

Color

pub struct Color {
  r : Int
  g : Int
  b : Int
  alpha : Int
} derive(Eq, @moonbitlang/core/debug.Debug)

An sRGB colour. alpha is the opacity in percent, from 0 to 100.

Source

Color::equal

fn Color::equal(Color, Color) -> Bool

Source

Color::hex

fn Color::hex(value : Int) -> Color

An opaque colour from a hex value, for example 0x020617.

Source

Color::not_equal

fn Color::not_equal(x : Color, y : Color) -> Bool

Source

Color::rgba

fn Color::rgba(r : Int, g : Int, b : Int, alpha : Int) -> Color

A colour with the opacity alpha in percent.

Source

Color::tint

fn Color::tint(self : Color) -> Color

Author colours have 18 percent opacity, multiplied by any authored alpha.

Source

Color::to_css

fn Color::to_css(self : Color) -> String

CSS text for the colour: #rrggbb when it is opaque, else rgba(...).

Source

Color::to_repr

fn Color::to_repr(Color) -> @moonbitlang/core/debug.Repr

Source

Family

pub(all) enum Family {
  Frontend
  Backend
  Database
  Cloud
  Security
  MessageBus
  External
} derive(Eq, @moonbitlang/core/debug.Debug)

A colour family of the archify classic preset.

Source

Family::equal

fn Family::equal(Family, Family) -> Bool

Source

Family::name

fn Family::name(self : Family) -> String

The name of the family, as used in CSS class and variable names.

Source

Family::not_equal

fn Family::not_equal(x : Family, y : Family) -> Bool

Source

Family::to_repr

fn Family::to_repr(Family) -> @moonbitlang/core/debug.Repr

Source

FamilyColors

pub(all) struct FamilyColors {
  fill : Color
  stroke : Color
  ink : Color
} derive(Eq, @moonbitlang/core/debug.Debug)

The colours of one family. fill and stroke are archify's values. ink is the colour of text in this family, with at least 4.5:1 contrast.

Source

FamilyColors::equal

fn FamilyColors::equal(FamilyColors, FamilyColors) -> Bool

Source

FamilyColors::not_equal

fn FamilyColors::not_equal(x : FamilyColors, y : FamilyColors) -> Bool

Source

FamilyColors::to_repr

fn FamilyColors::to_repr(FamilyColors) -> @moonbitlang/core/debug.Repr

Source

Palette

pub(all) struct Palette {
  bg : Color
  text : Color
  muted : Color
  mask : Color
  arrow : Color
  frontend : FamilyColors
  backend : FamilyColors
  database : FamilyColors
  cloud : FamilyColors
  security : FamilyColors
  messagebus : FamilyColors
  external : FamilyColors
} derive(Eq, @moonbitlang/core/debug.Debug)

The colours of one theme variant, dark or light.

Source

Palette::equal

fn Palette::equal(Palette, Palette) -> Bool

Source

Palette::family

fn Palette::family(self : Palette, f : Family) -> FamilyColors

The colours of the family f.

Source

Palette::not_equal

fn Palette::not_equal(x : Palette, y : Palette) -> Bool

Source

Palette::to_repr

fn Palette::to_repr(Palette) -> @moonbitlang/core/debug.Repr

Source

Theme

pub(all) struct Theme {
  dark : Palette
  light : Palette
} derive(Eq, @moonbitlang/core/debug.Debug)

A theme with a dark and a light variant.

Source

Theme::classic

fn Theme::classic() -> Theme

The classic preset of archify (MIT), in dark and light. In the light variant, the ink of six families is a darker shade of the same hue, because archify's colour has less than 4.5:1 contrast as text.

Source

Theme::equal

fn Theme::equal(Theme, Theme) -> Bool

Source

Theme::not_equal

fn Theme::not_equal(x : Theme, y : Theme) -> Bool

Source

Theme::to_repr

fn Theme::to_repr(Theme) -> @moonbitlang/core/debug.Repr

Source

Values

all_families

let all_families : ReadOnlyArray[Family]

The families, in the order of the CSS that the renderer writes.

Source

contrast

fn contrast(a : Color, b : Color) -> Double

The WCAG 2 contrast ratio of two opaque colours, from 1 to 21.

Source

family_of

fn family_of(kind : @moonrockz/diagrams/sequence.ParticipantKind, cycle_index : Int) -> Family

The colour family of a participant kind. A participant with no specific kind gets the family at cycle_index of a fixed cycle.

Source

luminance

fn luminance(c : Color) -> Double

The relative luminance of an opaque colour, as WCAG 2 defines it.

Source

over

fn over(top : Color, bottom : Color) -> Color

The opaque colour of top painted over the opaque colour bottom.

Source

parse_color

fn parse_color(source : String) -> Color?

Read CSS named colours, #rgb[a], #rrggbb[aa], rgb() and rgba(). Values that need a viewer context, such as currentColor, are deliberately unresolved.

Source

text_shade

fn text_shade(accent : Color, backgrounds : ArrayView[Color]) -> Color

Lower HSL lightness in 0.01 steps, retaining hue and saturation. Both the background and opaque chips must pass. Classic dark accents pass unchanged.

Source