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.
Color::equal
fn Color::equal(Color, Color) -> BoolColor::hex
fn Color::hex(value : Int) -> ColorAn opaque colour from a hex value, for example 0x020617.
Color::not_equal
fn Color::not_equal(x : Color, y : Color) -> BoolColor::rgba
fn Color::rgba(r : Int, g : Int, b : Int, alpha : Int) -> ColorA colour with the opacity alpha in percent.
Color::tint
fn Color::tint(self : Color) -> ColorAuthor colours have 18 percent opacity, multiplied by any authored alpha.
Color::to_css
fn Color::to_css(self : Color) -> StringCSS text for the colour: #rrggbb when it is opaque, else rgba(...).
Color::to_repr
fn Color::to_repr(Color) -> @moonbitlang/core/debug.ReprFamily
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.
Family::equal
fn Family::equal(Family, Family) -> BoolFamily::name
fn Family::name(self : Family) -> StringThe name of the family, as used in CSS class and variable names.
Family::not_equal
fn Family::not_equal(x : Family, y : Family) -> BoolFamily::to_repr
fn Family::to_repr(Family) -> @moonbitlang/core/debug.ReprFamilyColors
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.
FamilyColors::equal
fn FamilyColors::equal(FamilyColors, FamilyColors) -> BoolFamilyColors::not_equal
fn FamilyColors::not_equal(x : FamilyColors, y : FamilyColors) -> BoolFamilyColors::to_repr
fn FamilyColors::to_repr(FamilyColors) -> @moonbitlang/core/debug.ReprPalette
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.
Palette::equal
fn Palette::equal(Palette, Palette) -> BoolPalette::family
fn Palette::family(self : Palette, f : Family) -> FamilyColorsThe colours of the family f.
Palette::not_equal
fn Palette::not_equal(x : Palette, y : Palette) -> BoolPalette::to_repr
fn Palette::to_repr(Palette) -> @moonbitlang/core/debug.ReprTheme
pub(all) struct Theme {
dark : Palette
light : Palette
} derive(Eq, @moonbitlang/core/debug.Debug)A theme with a dark and a light variant.
Theme::classic
fn Theme::classic() -> ThemeThe 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.
Theme::equal
fn Theme::equal(Theme, Theme) -> BoolTheme::not_equal
fn Theme::not_equal(x : Theme, y : Theme) -> BoolTheme::to_repr
fn Theme::to_repr(Theme) -> @moonbitlang/core/debug.ReprValues
all_families
let all_families : ReadOnlyArray[Family]The families, in the order of the CSS that the renderer writes.
contrast
fn contrast(a : Color, b : Color) -> DoubleThe WCAG 2 contrast ratio of two opaque colours, from 1 to 21.
family_of
fn family_of(kind : @moonrockz/diagrams/sequence.ParticipantKind, cycle_index : Int) -> FamilyThe colour family of a participant kind. A participant with no specific
kind gets the family at cycle_index of a fixed cycle.
luminance
fn luminance(c : Color) -> DoubleThe relative luminance of an opaque colour, as WCAG 2 defines it.
over
fn over(top : Color, bottom : Color) -> ColorThe opaque colour of top painted over the opaque colour bottom.
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.
text_shade
fn text_shade(accent : Color, backgrounds : ArrayView[Color]) -> ColorLower HSL lightness in 0.01 steps, retaining hue and saturation. Both the background and opaque chips must pass. Classic dark accents pass unchanged.