[effects]docs
fx reference / fx.ui

Interface kit

The kit is what fx was first written for: a film that shows a product. It holds the surfaces a mockup sits on, the chrome around it, the small parts an interface is made of, and the pointer and highlight that lead the eye through it. It has one look (paper surfaces, hairline borders, mono labels, a red bracket) and takes its colors and fonts from fx.theme, so replacing the theme recolors all of it.

The pieces come in two kinds:

  • Immediate ones draw at the stage coordinates you give them: backdrop, vignette, grain, window, phone, cursor, highlight, kinetic, caption.
  • Layout ones are elements of a layout and may only be called inside fx.layout: sidebar, topbar, pill, button, kpi, avatar, bubble, table_head, table_row, bars, meter. Each takes a Box as its last argument, for an id, a size or an animation.

Note: The kit has the pixel sizes of a real interface: labels are 13 to 16 px. That is right when a window fills a 1080p frame, and too small for the players on this page, so most demos here draw inside fx.group({s = 2}) and work on a stage of 960×540. In a film you would do the same to punch in on a detail.

A few pieces carry the original product's German strings as defaults (the top bar's title, the default navigation). They are listed where they occur, with how to pass your own.

Backdrops#

Backdrop :: enum {Night, Paper}

backdrop :: proc(kind: Backdrop, r: Rect = {}, grid := true, offset := Vec2{})

A surface to put things on: a soft elliptical gradient, lighter in the middle, with an engineering-paper grid of fine lines every 48 px and stronger ones every 240 px. .Night is the dark one, .Paper the light one. r is the area to fill (the whole stage when left out), grid = false leaves the lines away, and offset shifts the grid in pixels, so a slowly growing offset makes it drift.

The gradient is rendered once at half resolution and reused by every frame, so a backdrop costs one image draw plus the grid lines. Its colors are fixed and do not follow the theme.

A frame of the ui-backdrop demo
3.72 / 6.00 sui-backdrop
ui_backdrop :: proc(s: fx.Shot) {
    drift := fx.Vec2{40 * s.lt, 0} // 240 px in 6 s is one major square, so the loop closes
    fx.backdrop(.Night, {0, 0, 960, 1080}, offset = drift)
    fx.backdrop(.Paper, {960, 0, 960, 1080}, offset = drift)
    fx.caption(".Night", {480, 540}, 150, fx.theme.nt, {0.5, 0.5})
    fx.caption(".Paper", {1440, 540}, 150, fx.theme.ink, {0.5, 0.5})
}
grid_lines       :: proc(r: Rect, step: f32, c: Color, offset := Vec2{})
ellipse_gradient :: proc(r: Rect, c: Vec2, rx, ry: f32, stops: []Stop)

These are the two things a backdrop is made of, for building your own. grid_lines draws 1 px lines every step px across r, horizontal and vertical, shifted by offset. ellipse_gradient fills r with a radial gradient around the point c that reaches its last stop rx px to the sides and ry px above and below, like CSS radial-gradient(ellipse rx ry at c). A Stop is {color, position} with the position in 0..1.

A frame of the ui-surface demo
3.72 / 6.00 sui-surface
ui_surface :: proc(s: fx.Shot) {
    th := fx.theme
    fx.rect(fx.stage(), th.night)
    // a glow that wanders: your own colors, center and radii
    c := fx.Vec2{960 + 520 * math.sin(s.p * math.TAU), 600 + 140 * math.cos(s.p * math.TAU)}
    glow := [?]fx.Stop{{fx.alpha(th.na, 0.6), 0}, {fx.alpha(th.na, 0.15), 0.5}, {fx.alpha(th.na, 0), 1}}
    fx.ellipse_gradient(fx.stage(), c, knob("rx", 1100, 200, 1900), knob("ry", 520, 100, 1000), glow[:])
    step := knob("step", 96, 24, 240)
    fx.grid_lines(fx.stage(), step, th.nb, {0, 2 * step * s.p}) // two squares down per loop
    fx.caption("a backdrop of your own", {960, 540}, 110, th.nt, {0.5, 0.5})
}

A full-screen gradient drawn every frame costs about 5 ms per 1080p frame on one CPU thread. If yours does not move, wrap it in bake as backdrop does.

Vignette and grain#

vignette :: proc(strength: f32 = 0.42, r: Rect = {})
grain    :: proc(amount: f32 = 0.04)

vignette darkens the edges of r (the stage by default): nothing in the middle, black at opacity strength in the corners. It is baked once per strength and reused, which makes it cheap, and also means you should not animate the strength: every new value renders and keeps another image.

grain lays film grain over the whole stage: a 256 px tile of noise in overlay blend that jumps to a new position 24 times a second. amount is its strength; around 0.03 to 0.05 is a fine grain, and above 0.17 the tile is fully opaque.

Both belong on top of everything, so the usual place for them is Video.overlay:

overlay = proc(t: f32) {fx.vignette(0.35); fx.grain(0.035)},
A frame of the ui-grain demo
3.72 / 6.00 sui-grain
ui_grain :: proc(s: fx.Shot) {
    // a still from a film, pushed in slowly; in a project these two calls go in Video.overlay
    fx.image(fx.load_image("assets/frame.jpg"), fx.stage(), zoom = 1.02 + 0.06 * math.sin(s.p * math.PI))
    fx.vignette(0.42)
    fx.grain(knob("grain", 0.04, 0, 0.3))
}

Each is a full-screen pass of about 5 ms on the CPU. Grain is fine detail that video encoders like to smooth away; for dark, grainy films render with --crf 16 --tune grain (see /docs/cli/).

Headlines#

headline :: proc(size: f32, weight: f32 = 600) -> Font
caption  :: proc(s: string, p: Vec2, size: f32 = 84, c: Color = 0, anchor := Vec2{}) -> Rect
eyebrow  :: proc(s: string, p: Vec2, c: Color = 0, anchor := Vec2{}) -> Rect

headline is the kit's display face as a Font: the theme's sans, semibold, set tight (tracking -0.035, line height 0.98). caption draws one line in it, placed like label by p and anchor. eyebrow draws the small line above a headline: 17 px mono capitals, widely spaced.

Left at 0, the color of caption is theme.ink and that of eyebrow is theme.sub. Both are dark, for paper; on a night backdrop pass theme.nt or theme.ns.

Word :: struct {
	w:      string,
	t:      f32,  // when it rises in
	accent: bool,
	br:     bool, // line break after this word
}

kinetic :: proc(words: []Word, x, y: f32, f: Font, c: Color, accent: Color = 0, max_w: f32 = 0, dur: f32 = 0.38) -> Rect

kinetic sets a headline whose words arrive one at a time. Each word has its own time t; starting 0.06 s before it, the word rises 26 px into place, fading in and sharpening, over dur seconds. Words marked accent take the accent color (theme.red when left at 0). The block's top-left corner is at x, y, and a line ends after a word with br, or automatically where the next word would pass max_w (0 means no automatic wrapping).

Every word has its final place from the first frame, so nothing moves sideways as later words arrive. The result is the rect of the whole block.

A frame of the ui-headline demo
3.10 / 5.00 sui-headline
ui_headline :: proc(s: fx.Shot) {
    fx.backdrop(.Night)
    th := fx.theme
    out := fx.ep(s.lt, 4.3, 4.8, fx.ease_in)
    if fx.group({o = 1 - out}) {
        // eyebrow is 17 px, made to be seen 1:1; here it is doubled
        if fx.group({s = 2, origin = {160, 230}}) do fx.eyebrow("Chapter one", {160, 230}, th.ns)
        words := [?]fx.Word {
            {w = "Every", t = 0.4},
            {w = "frame", t = 0.6},
            {w = "is", t = 0.8, br = true},
            {w = "a", t = 1.3},
            {w = "function", t = 1.5, accent = true},
            {w = "of", t = 2.0},
            {w = "time.", t = 2.2, accent = true},
        }
        fx.kinetic(words[:], 160, 310, fx.headline(190), th.nt, th.na, dur = knob("dur", 0.38, 0.1, 1.5))
        o := fx.ep(s.lt, 2.9, 3.4)
        fx.caption("caption draws one line in the same face", {160, 800}, 60, fx.alpha(th.nm, o))
    }
}

The times are video times (what fx.now() returns), not times within the scene: in a film, add s.start. In a demo the two are the same.

All words share one font. To mix sizes, call kinetic once per size.

Following a voice-over#

vo_text :: proc(id: string, x, y: f32, f: Font, c: Color, accents: []int = nil, breaks: []int = nil, max_w: f32 = 0) -> Rect

vo_text is kinetic with the words and times taken from the video's voice-over: each word of the line id appears when it is spoken. accents and breaks are word indices (from 0) to color and to break after. It returns an empty rect when the line does not exist.

// if timeline.json has a line with the id "intro" that says "Every frame is a function of time."
fx.vo_text("intro", 160, 310, fx.headline(190), fx.theme.nt, accents = {4, 6}, breaks = {2})

It needs a voice-over timeline (Video.vo, see /docs/voice-over/), which is a file, so there is no demo of it here.

Windows#

window  :: proc(r: Rect, url := "", sheet := "", night := false) -> Rect
corners :: proc(r: Rect, c: Color, size: f32 = 16, off: f32 = 6, width: f32 = 2)
mark    :: proc(p: Vec2, size: f32 = 28, c: Color = 0)

window draws a product window in r: a soft shadow, a paper surface, a 42 px chrome bar with three dots, a hairline border and a red bracket at two corners. url is shown in a field in the middle of the bar and sheet as a small label at its right; either is left out when empty. Set night when the window sits on a dark backdrop: the shadow is made darker so it still reads.

It returns the body, which is r without the bar. That rect is where your content goes, typically as the rect of a layout. The window does not clip: keep to the body, or draw inside a group with clip.

A frame of the ui-window demo
3.10 / 5.00 sui-window
ui_window :: proc(s: fx.Shot) {
    fx.backdrop(.Night)
    k := fx.ep(s.lt, 0.2, 1.1, fx.ease_out5)
    out := fx.ep(s.lt, 4.3, 4.8, fx.ease_in)
    // the kit has the sizes of a real interface, so the demos look at it from twice as close
    if fx.group({s = 2, y = 80 * (1 - k), o = k - out}) {
        body := fx.window({130, 55, 700, 430}, "app.example.com/renders", "Sheet 01", night = true)
        fx.mark({body.x + 44, body.y + 48}, 72)
        fx.caption("The body is yours.", {body.x + 44, body.y + 150}, 56)
        note := "window draws the chrome bar, the border and the red corners, and returns the rect below the bar."
        fx.text(note, body.x + 44, body.y + 236, fx.sans(19), fx.theme.mut, 560)
    }
}

corners draws the two L-shaped brackets on their own, at the top-left and bottom-right of r: off px outside it, with legs size long and width thick. mark draws the brand mark, an open bracket, size px square with its top-left at p, in theme.red unless you pass a color.

App chrome#

Nav :: struct {
	icon, label: string,
	sub:         bool, // child of the previous top-level item
	sep:         bool, // a divider instead of an item
}

Sidebar :: struct {
	active:    string,   // label of the highlighted item
	open:      []string, // top-level items whose children are shown
	items:     []Nav,    // default: LIERMANN_NAV
	workspace: string,
	user:      string,
	role:      string,
	w:         f32,      // default 250
}

sidebar :: proc(sb: Sidebar)
topbar  :: proc(title := "Weber & Kraus GmbH", role := "Inhaber")

Both are layout elements. sidebar is a column as tall as its parent and w wide: the mark and a wordmark at the top, the navigation, and the workspace and user at the bottom. Put it first in a row. topbar is a 52 px bar as wide as its parent, with a panel icon, a title, the role as a pill, and a bell, a language code and a moon icon at the right. Put it first in the column next to the sidebar.

The navigation is a flat list of Nav. An item with sub belongs to the top-level item before it and is only shown while that item's label is in open; a top-level item with children gets a chevron that points down while it is open. sep draws a divider. icon is a name from the icon set. The item whose label equals active is drawn inverted.

Every item gets the id nav/<label>, so fx.rect_of("nav/Renders") finds it for a pointer.

A frame of the ui-sidebar demo
3.72 / 6.00 sui-sidebar
ui_sidebar :: proc(s: fx.Shot) {
    fx.backdrop(.Night)
    nav := [?]fx.Nav {
        {icon = "dashboard", label = "Overview"},
        {icon = "video", label = "Projects"},
        {icon = "layers", label = "Scenes", sub = true},
        {icon = "volume", label = "Sound", sub = true},
        {icon = "usage", label = "Renders"},
        {sep = true},
        {icon = "settings", label = "Settings"},
    }
    step := int(s.lt / 1.5) % 4 // a click every second and a half
    pages := [?]string{"Overview", "Projects", "Scenes", "Renders"}
    active := pages[step]
    open := [?]string{"Projects"}
    if fx.group({s = 2}) {
        body := fx.window({90, 28, 780, 484}, "app.example.com")
        if fx.layout(body, {dir = .Row}) {
            side := fx.Sidebar{active = active, items = nav[:], workspace = "Studio North", user = "Lena Brandt", role = "Owner", w = 230}
            if step == 1 || step == 2 do side.open = open[:]
            fx.sidebar(side)
            if fx.box({dir = .Col, w = fx.grow(), h = fx.grow()}) {
                fx.topbar("Studio North", "Owner")
                if fx.box({w = fx.grow(), h = fx.grow(), pad = fx.pads(28)}) do fx.txt(active, fx.headline(44), fx.theme.ink)
            }
        }
    }
}

What is yours and what is fixed:

Part Default To change
Navigation LIERMANN_NAV, the product's own rail: Assistent, Übersicht, Kontakte, Outbound, Vertrieb, Content, Aufgaben & Hinweise, Kalender, Telefon, WhatsApp, Flows, Einstellungen, with children under Outbound, Vertrieb and Content Sidebar.items
Workspace "Weber & Kraus GmbH" Sidebar.workspace
User, role "Lisa Brandt", "Inhaber" Sidebar.user, Sidebar.role
Top bar title, role "Weber & Kraus GmbH", "Inhaber" the arguments of topbar
Wordmark "Liermann", the caption "Arbeitsbereich", the avatar "LB", the top bar's "EN" fixed not without your own copy of the procedure

Items are told apart by their label, so two items with the same label are both active together and share an id.

Pills, buttons, tiles#

Tone :: enum {Neutral, Ok, Warn, Red, Ink}

pill   :: proc(s: string, tone := Tone.Neutral, b: Box = {})
button :: proc(s: string, icon := "", primary := false, b: Box = {})
avatar :: proc(initials: string, size: f32 = 26, b: Box = {})
kpi    :: proc(label, value: string, note := "", b: Box = {})

Layout elements, each as big as its content unless b says otherwise.

  • pill is a status label in small capitals. The tone picks its colors: .Neutral is outlined, .Ok green, .Warn amber, .Red red, each on a faint tint of itself, and .Ink is inverted.
  • button is a label with an optional icon in front. primary makes it the dark, filled one.
  • avatar is a square with initials, size px on each side.
  • kpi is a tile with a small label, a large value in tabular figures, and an optional note below.
A frame of the ui-controls demo
2.48 / 4.00 sui-controls
ui_controls :: proc(s: fx.Shot) {
    fx.backdrop(.Paper)
    tones := [?]fx.Tone{.Neutral, .Ok, .Warn, .Red, .Ink}
    frames := fx.count(s.lt, 0.4, 2.4, 0, 3600)
    if fx.group({s = 3}) { // three times as close: the stage is 640×360 in here
        if fx.layout({0, 0, 640, 360}, {dir = .Col, gap = 26, justify = .Center, align = .Center}) {
            if fx.box({dir = .Row, gap = 12, align = .Center}) {
                for tone in tones do fx.pill(fmt.tprint(tone), tone)
            }
            if fx.box({dir = .Row, gap = 12, align = .Center}) {
                fx.avatar("LB", 38)
                fx.button("Cancel")
                fx.button("Export", "upload")
                fx.button("Render", "play", primary = true)
            }
            if fx.box({dir = .Row, gap = 12}) {
                fx.kpi("Frames", fmt.tprintf("%.0f", frames), "at 60 fps", {w = fx.fixed(190)})
                fx.kpi("Render time", "13 min", "on 8 cores", {w = fx.fixed(190)})
                fx.kpi("Per frame", "2 ms", "on one thread", {w = fx.fixed(190)})
            }
        }
    }
}

b passes through anything the piece does not set itself: an id, a width, o, dy, s and the other animation fields. kpi and avatar also accept your own bg and border; pill and button always use their own.

tone_colors :: proc(tone: Tone) -> (fg, bg, line: Color)

tone_colors returns the text, fill and border color of a tone, for elements of your own that should match the pills.

Chat#

bubble :: proc(s: string, mine := false, max_w: f32 = 420, b: Box = {})
phone  :: proc(r: Rect) -> Rect

bubble is a chat message: wrapped text in a padded box, dark when mine, light with a hairline otherwise. Which side it sits on is up to the row you put it in (justify = .End for your own messages).

Note: Give a bubble a width in b. Its text wraps, and wrapped text has no width of its own, so with the default size (as wide as its content, at most max_w) the box shrinks to its padding and the text runs out of it. {w = fx.fixed(260)} works, and so does measuring the text first, as the demo does.

phone draws a phone in r: a dark bezel, a notch, and a status bar with the time "9:41", signal bars and a battery. It returns the screen, which is r inset by 14 px. The status bar covers about the top 50 px of the screen, so start your content below it. The bezel's 54 px corner radius and the 110 px notch do not scale with r: draw the phone 300 to 400 px wide and zoom the group to make it bigger.

A frame of the ui-phone demo
4.34 / 7.00 sui-phone
ui_phone :: proc(s: fx.Shot) {
    fx.backdrop(.Night)
    chat := [?]struct {
        text: string,
        mine: bool,
    } {
        {"Is the render done?", false},
        {"3,600 frames in thirteen minutes.", true},
        {"And if I change the title?", false},
        {"Save the file. It reloads.", true},
    }
    out := fx.ep(s.lt, 6.3, 6.8, fx.ease_in)
    if fx.group({s = 2, o = 1 - out}) {
        screen := fx.phone({310, 26, 340, 660}) // taller than the frame: it runs out at the bottom
        if fx.layout(fx.inset4(screen, 66, 16, 0, 16), {dir = .Col, gap = 12}) {
            for m, i in chat {
                k := fx.stagger(s.lt, i, 0.6, 1.2, 0.45)
                row := fx.Box{dir = .Row, w = fx.grow(), gap = 8, align = .End, justify = m.mine ? .End : .Start, o = k, dy = 16 * (1 - k)}
                if fx.box(row) {
                    if !m.mine do fx.avatar("LB", 28)
                    // a bubble needs a width: here as wide as its text, 210 at most
                    w := min(fx.measure(m.text, fx.sans(15)).x + 28, 210)
                    fx.bubble(m.text, m.mine, b = {w = fx.fixed(w)})
                }
            }
        }
    }
}

Tables#

Col :: struct {
	title: string,
	w:     Size,       // default grow()
	align: Text_Align,
	mono:  bool,
}

table_head :: proc(cols: []Col, b: Box = {})
table_row  :: proc(cols: []Col, cells: []string, b: Box = {})

A table is a column of rows that share one list of Col. table_head draws the titles in small capitals over a hairline; table_row draws one row of cells, in order, each in its column's width and alignment. A column with mono sets its cells in the mono font with tabular figures, for numbers. Missing cells are left empty.

Put the head and the rows into the same column box, so they all have the same width.

A frame of the ui-table demo
3.10 / 5.00 sui-table
ui_table :: proc(s: fx.Shot) {
    fx.backdrop(.Paper)
    th := fx.theme
    cols := [?]fx.Col {
        {title = "Project"},
        {title = "Status", w = fx.fixed(120)},
        {title = "Frames", w = fx.fixed(90), align = .Right, mono = true},
        {title = "Time", w = fx.fixed(90), align = .Right, mono = true},
    }
    rows := [?][4]string {
        {"fable", "Done", "3,600", "13:02"},
        {"showreel", "Done", "1,836", "0:50"},
        {"spot", "Rendering", "744", "0:20"},
        {"teaser", "Queued", "480", ""},
    }
    if fx.group({s = 2.4}) {
        if fx.layout({0, 0, 800, 450}, {justify = .Center, align = .Center}) {
            if fx.box({dir = .Col, w = fx.fixed(700), pad = fx.padxy(24, 14), bg = th.sf, border = th.bds}) {
                fx.table_head(cols[:])
                for &r, i in rows {
                    k := fx.stagger(s.lt, i, 0.4, 0.15, 0.5)
                    picked := i == 2 ? fx.win(s.lt, 2.2, 4.4, 0.3, 0.3) : 0
                    // any Box field passes through: animation, an id, a background
                    fx.table_row(cols[:], r[:], {o = k, dy = 12 * (1 - k), bg = fx.alpha(th.sf3, picked)})
                }
            }
        }
    }
}

b lets a row carry an id (for a highlight), an animation or a background. The row's bottom hairline is replaced if you set border, and its padding (8 px above and below) if you set pad.

Note: Give every column but one a fixed or pct width. Rows are laid out independently, and a growing cell starts from the width of its own text, so two growing columns end up with different widths in every row and do not line up.

Charts#

bars  :: proc(values: []f32, max_v: f32 = 0, accent := -1, p: f32 = 1, b: Box = {})
meter :: proc(v: f32, p: f32 = 1, c: Color = 0, b: Box = {})

bars is a column chart: one column per value, 8 px apart, over a baseline. Heights are relative to max_v, or to the largest value when it is 0. The column at index accent is drawn in theme.red, the others in theme.ink. By default the chart is as wide as its parent and 150 px high; set b.w and b.h to change that.

meter is a horizontal bar: a track with a fill of v (0..1) of its width, in c or theme.ink. By default it is as wide as its parent and 10 px high.

Both grow in with p, a progress from 0 to 1. bars eases each column itself and lets them rise one after the other from left to right, so pass it a linear progress (prog, not ep).

A frame of the ui-charts demo
3.10 / 5.00 sui-charts
ui_charts :: proc(s: fx.Shot) {
    fx.backdrop(.Paper)
    th := fx.theme
    ms := [?]f32{31, 28, 34, 30, 52, 33, 29, 27, 30, 32, 28, 31}
    p := fx.prog(s.lt, 0.4, 1.9) // linear: bars eases and staggers its columns itself
    if fx.group({s = 2.4}) {
        if fx.layout({120, 35, 560, 380}, {dir = .Col, gap = 14, pad = fx.pads(24), bg = th.sf, border = th.bds}) {
            fx.txt("Milliseconds per frame", fx.sans(17, 600), th.ink)
            fx.bars(ms[:], accent = int(knob("accent", 4, 0, 11)), p = p, b = {h = fx.grow()})
            for cores, i in ([?]f32{0.25, 0.5, 1}) {
                if fx.box({dir = .Row, w = fx.grow(), gap = 14, align = .Center}) {
                    fx.txt(fmt.tprintf("%d cores", int(cores * 16)), fx.mono(13), th.mut, {w = fx.fixed(72)})
                    fx.meter(cores, p, i == 2 ? th.red : 0)
                }
            }
        }
    }
}

Pointer and highlight#

Cursor_Key :: struct {
	t:     f32,
	p:     Vec2, // where the pointer's tip is
	click: bool,
}

cursor :: proc(ks: []Cursor_Key, from, to: f32, size: f32 = 34)

cursor draws a mouse pointer that travels through a list of keys. At each key's time t its tip is at p; between two keys it moves with an ease in and out, so two keys at the same place make it wait there. It is visible from from to to, fading in and out, and rests at the first key before that key's time and at the last key after it. A key with click presses at its time: the arrow dips for 0.2 s and a red ring spreads from the tip. size scales the arrow; at the default 34 it is about 20 px wide.

Hl_Key :: struct {
	t:   f32,
	r:   Rect,
	off: bool, // hide from here on
}

highlight :: proc(ks: []Hl_Key, dur: f32 = 0.35, pad: f32 = 6, c: Color = 0)

highlight draws a thin frame with corner brackets around a rect, pad px outside it, in c or theme.red. At the first key it fades in around that key's rect. At every later key it glides from the previous rect to the new one within dur seconds. A key with off fades the frame out where it stands (its rect is ignored), and the key after that fades it in again at a new place.

Like kinetic, both read video time, so key times in a film are s.start + ….

Neither needs to know where things are in advance: give the targets an id and ask rect_of after the layout. rect_of answers in stage pixels. The demo draws the pointer and the frame inside the same zoomed group as the interface, so that they scale with it, and therefore divides the rects by the zoom; outside any group the rects can be used as they are.

A frame of the ui-pointer demo
3.72 / 6.00 sui-pointer
ui_pointer :: proc(s: fx.Shot) {
    fx.backdrop(.Paper)
    press := fx.hit(s.lt, 4.2, 0.25)
    if fx.group({s = 3}) {
        if fx.layout({0, 0, 640, 360}, {dir = .Row, gap = 18, justify = .Center, align = .Center}) {
            fx.kpi("Frames", "3,600", "at 60 fps", {id = "frames", w = fx.fixed(170)})
            fx.kpi("Render time", "13 min", "on 8 cores", {id = "time", w = fx.fixed(170)})
            fx.button("Render again", "refresh", true, {id = "again", s = 1 - 0.06 * press})
        }
        // rect_of answers in stage pixels; this group is zoomed 3x, so divide to draw inside it
        at :: proc(id: string) -> fx.Rect {
            r, _ := fx.rect_of(id)
            return {r.x / 3, r.y / 3, r.w / 3, r.h / 3}
        }
        fx.highlight({{0.8, at("frames"), false}, {2.0, at("time"), false}, {3.4, at("again"), false}, {5.0, {}, true}})
        a, b, c := fx.center(at("frames")) + {40, 16}, fx.center(at("time")) + {40, 16}, fx.center(at("again")) + {36, 6}
        path := [?]fx.Cursor_Key{{0.6, {560, 330}, false}, {1.4, a, false}, {2.0, a, false}, {2.8, b, false}, {3.3, b, false}, {4.2, c, true}}
        fx.cursor(path[:], 0.3, 5.5)
    }
}

A whole screen#

Everything together: a window on a night backdrop, a layout in its body with the sidebar and top bar, a page with tiles and a table, and on top of the layout a highlight and a pointer that find their targets by id.

A frame of the ui-screen demo
4.96 / 8.00 sui-screen
ui_screen :: proc(s: fx.Shot) {
    fx.backdrop(.Night)
    th := fx.theme
    nav := [?]fx.Nav {
        {icon = "dashboard", label = "Overview"},
        {icon = "video", label = "Projects"},
        {icon = "usage", label = "Renders"},
        {sep = true},
        {icon = "settings", label = "Settings"},
    }
    num := fx.Col{w = fx.fixed(80), align = .Right, mono = true}
    cols := [?]fx.Col{{title = "Project"}, num, num}
    cols[1].title, cols[2].title = "Frames", "Time"
    rows := [?][3]string{{"fable", "3,600", "13:02"}, {"showreel", "1,836", "0:50"}, {"spot", "744", "0:20"}}
    at :: proc(id: string) -> fx.Rect { // rect_of is in stage pixels; the group below is zoomed 2x
        r, _ := fx.rect_of(id)
        return {r.x / 2, r.y / 2, r.w / 2, r.h / 2}
    }
    if fx.group({s = 2, o = fx.fade(s)}) {
        body := fx.window({60, 26, 840, 488}, "app.example.com/renders")
        if fx.layout(body, {dir = .Row}) {
            fx.sidebar({active = "Renders", items = nav[:], workspace = "Studio North", user = "Lena Brandt", role = "Owner", w = 220})
            if fx.box({dir = .Col, w = fx.grow(), h = fx.grow()}) {
                fx.topbar("Studio North", "Owner")
                if fx.box({dir = .Col, w = fx.grow(), h = fx.grow(), pad = fx.pads(24), gap = 16}) {
                    if fx.box({dir = .Row, w = fx.grow(), align = .Center}) {
                        fx.txt("Renders", fx.headline(28), th.ink)
                        fx.spacer()
                        fx.button("Render all", "play", true, {id = "go", s = 1 - 0.06 * fx.hit(s.lt, 5.4, 0.25)})
                    }
                    if fx.box({dir = .Row, w = fx.grow(), gap = 12}) {
                        fx.kpi("Frames", "6,180", b = {w = fx.grow()})
                        fx.kpi("Render time", "14 min", b = {w = fx.grow()})
                        fx.kpi("Queue", "empty", b = {w = fx.grow()})
                    }
                    if fx.box({dir = .Col, w = fx.grow()}) {
                        fx.table_head(cols[:])
                        for &r, i in rows {
                            k := fx.stagger(s.lt, i, 0.8, 0.15, 0.5)
                            fx.table_row(cols[:], r[:], {id = r[0], o = k, dy = 10 * (1 - k)})
                        }
                    }
                }
            }
        }
        // on top of the layout: a frame and a pointer that find their targets by id
        fx.highlight({{2.6, at("fable"), false}, {3.6, at("spot"), false}, {4.6, at("go"), false}, {6.4, {}, true}})
        a, b, c := fx.center(at("fable")), fx.center(at("spot")), fx.center(at("go")) + {30, 8}
        path := [?]fx.Cursor_Key{{2.2, {700, 520}, false}, {3.0, a, false}, {3.6, a, false}, {4.2, b, false}, {4.6, b, false}, {5.4, c, true}}
        fx.cursor(path[:], 2.0, 7.0)
    }
}

This is as much as the kit does. Anything it has no piece for (a form field, a tab bar, a calendar) is a few boxes of the layout in the same colors: theme.sf and theme.sf2 for surfaces, theme.bd and theme.bds for hairlines, theme.ink, theme.mut and theme.sub for text.

Reference#

Name Kind What it is
backdrop(kind, r, grid, offset) immediate Gradient surface with a grid, .Night or .Paper.
grid_lines(r, step, c, offset) immediate A grid of 1 px lines.
ellipse_gradient(r, c, rx, ry, stops) immediate Elliptical radial gradient filling r.
vignette(strength, r) immediate Darkened edges; baked per strength.
grain(amount) immediate Film grain over the stage.
NOISE_SIZE constant Side of the grain's noise tile, 256.
headline(size, weight) font The display face.
caption(s, p, size, c, anchor) immediate One line in the display face.
eyebrow(s, p, c, anchor) immediate Small capitals above a headline.
Word, kinetic(words, x, y, f, c, accent, max_w, dur) immediate A headline whose words rise in at their own times.
vo_text(id, x, y, f, c, accents, breaks, max_w) immediate kinetic timed by a voice-over line.
window(r, url, sheet, night) immediate Product window; returns its body.
corners(r, c, size, off, width) immediate Brackets at two corners of a rect.
mark(p, size, c) immediate The brand mark.
phone(r) immediate A phone; returns its screen.
Nav, Sidebar, sidebar(sb) layout App sidebar; items have ids nav/<label>.
LIERMANN_NAV data The default navigation.
topbar(title, role) layout The bar above a page.
Tone, tone_colors(tone) Status colors: text, fill, border.
pill(s, tone, b) layout Status label.
button(s, icon, primary, b) layout Button.
avatar(initials, size, b) layout Square with initials.
kpi(label, value, note, b) layout Tile with a big number.
bubble(s, mine, max_w, b) layout Chat message.
Col, table_head(cols, b), table_row(cols, cells, b) layout Table rows.
bars(values, max_v, accent, p, b) layout Column chart.
meter(v, p, c, b) layout Horizontal meter.
Cursor_Key, cursor(ks, from, to, size) immediate Mouse pointer moving between keys.
CURSOR_SVG constant The pointer's outline as SVG path data.
Hl_Key, highlight(ks, dur, pad, c) immediate Frame moving between rects.

Edit this page · Plain Markdown · All docs in one file