std/look
shapes, motion, layout (look context only)
# package look
# Opacity over 300ms
define Fade [s: shape] to [o: number]
Tween "opacity" of s to o over 300ms
# Scale to 1.15 and back over 300ms
define Pulse [s: shape]
Tween "scale" of s to 1.15 over 150ms
after 150ms
Tween "scale" of s to 1 over 150ms
std/look/basic is the default look described in spec/09. It is an
ordinary Synod package using the phrases above. Looks and themes beyond the
defaults are in github.com/synodlang/looks, not in std (decision 122).
Phrases
look.Card for [n: node]
The standard node card: a box and a name label, shaped and filled by theme.NodeShape and theme.NodeFill
- Gives
- shape
- Contexts
- look
- Kind
- phrase, written in Synod
- Source
- look/card.synod:6
- Examples
- look/arcs, look/camera, look/effects, look/flight, look/motion, look/shapes
look.Travel [s: shape] from [a: shape] to [b: shape] over [d: time]
Move along a straight path
- Gives
- —
- Contexts
- look
- Kind
- phrase, written in Synod
- Source
- look/card.synod:32
- Examples
- look/motion
look.Remove [s: shape]
Fade out, then delete
- Gives
- —
- Contexts
- look
- Kind
- phrase, written in Synod
- Source
- look/card.synod:39
- Examples
- look/arcs, look/flight, look/motion
look.Frame
A rect of the canvas inset by theme.Margin
- Gives
- shape
- Contexts
- look
- Kind
- phrase, written in Synod
- Source
- look/card.synod:45
- Examples
- look/strokes
look.Reveal [s: shape]
Draw s on: its outline, then its fill; a label writes itself
- Gives
- —
- Contexts
- look
- Kind
- phrase, written in Synod
- Source
- look/enter.synod:3
- Examples
- look/strokes
look.PopIn [s: shape]
Grow from 0 past 1.12 to 1 over 400ms
- Gives
- —
- Contexts
- look
- Kind
- phrase, written in Synod
- Source
- look/enter.synod:8
- Examples
- look/entrance
look.Enter [l: list of shape] every [d: time]
PopIn each shape, d after the one before
- Gives
- —
- Contexts
- look
- Kind
- phrase, written in Synod
- Source
- look/enter.synod:15
- Examples
- look/entrance
look.Circle [r: number]
A circle of radius r points
- Gives
- shape
- Contexts
- look
- Kind
- phrase, native
- Source
- look/look.synod:3
- Examples
- look/arcs, look/effects, look/entrance, look/flight, look/motion, look/shapes, look/strokes
look.Rect [w: number] by [h: number]
A rectangle with the corner radius theme.CornerRadius
- Gives
- shape
- Contexts
- look
- Kind
- phrase, native
- Source
- look/look.synod:6
- Examples
- look/shapes
look.Label [t: text]
Text
- Gives
- shape
- Contexts
- look
- Kind
- phrase, native
- Source
- look/look.synod:9
- Examples
- look/counter, look/flight, look/shapes
look.Line from [a: shape] to [b: shape]
A line that follows both shapes, at opacity theme.LinkOpacity
- Gives
- shape
- Contexts
- look
- Kind
- phrase, native
- Source
- look/look.synod:12
- Examples
- look/shapes
look.Group [l: list of shape]
Shapes moved and faded together
- Gives
- shape
- Contexts
- look
- Kind
- phrase, native
- Source
- look/look.synod:15
- Examples
- look/shapes
look.Fill [s: shape] with [c: color]
Fill color (morphs)
- Gives
- —
- Contexts
- look
- Kind
- phrase, native
- Source
- look/look.synod:18
- Examples
- look/arcs, look/effects, look/entrance, look/flight, look/motion, look/shapes, look/strokes
look.Stroke [s: shape] with [c: color]
Outline color (morphs)
- Gives
- —
- Contexts
- look
- Kind
- phrase, native
- Source
- look/look.synod:21
- Examples
- look/shapes, look/strokes
look.Tween [p: text] of [s: shape] to [v: value] over [d: time]
The only motion primitive (spec/09); of "x" or "y" it also takes a shape: that shape's position
- Gives
- —
- Contexts
- look
- Kind
- phrase, native
- Source
- look/look.synod:24
- Examples
- look/counter, look/icons, look/motion
look.Effect [e: text] on [s: shape]
"glow" (600ms), "indicate" (600ms), "flash" (500ms), "circumscribe" (900ms), "ripple" (700ms) or "sweep" (800ms), scaled by pace
- Gives
- —
- Contexts
- look
- Kind
- phrase, native
- Source
- look/look.synod:27
- Examples
- look/effects, look/motion
look.Layout [kind: text]
"ring", "row" or "grid" for node cards, spaced by theme.Fill
- Gives
- —
- Contexts
- look
- Kind
- phrase, native
- Source
- look/look.synod:30
- Examples
- look/arcs, look/camera, look/effects, look/motion
look.Place [s: shape] above [t: shape]
Position relative to another shape; likewise below, beside
- Gives
- —
- Contexts
- look
- Kind
- phrase, native
- Source
- look/look.synod:33
- Examples
- look/flight, look/shapes
look.Place [s: shape] below [t: shape]
Position relative to another shape: below
- Gives
- —
- Contexts
- look
- Kind
- phrase, native
- Source
- look/look.synod:36
- Examples
- look/counter, look/entrance, look/shapes
look.Place [s: shape] beside [t: shape]
Position relative to another shape: beside, on its right when the box lies inside the canvas there and on its left otherwise
- Gives
- —
- Contexts
- look
- Kind
- phrase, native
- Source
- look/look.synod:39
- Examples
- look/entrance, look/icons, look/shapes
look.Center
An invisible point at the scene centre
- Gives
- shape
- Contexts
- look
- Kind
- phrase, native
- Source
- look/look.synod:42
- Examples
- look/camera, look/shapes
look.Orbit [s: shape] around [c: shape] at [f: number]
Place on a circle of radius 200 around c, at fraction f of a turn (0 is 12 o'clock, clockwise)
- Gives
- —
- Contexts
- look
- Kind
- phrase, native
- Source
- look/look.synod:45
- Examples
- look/motion
look.Flight [s: shape] from [a: shape] to [b: shape] for [m: msg]
Move s from the edge of a to the edge of b, landing when m arrives (halfway when dropped)
- Gives
- —
- Contexts
- look
- Kind
- phrase, native
- Source
- look/look.synod:48
- Examples
- look/arcs, look/flight
look.Icon [name: text]
An icon of the fixed set, 32 units, stroked
- Gives
- shape
- Contexts
- look
- Kind
- phrase, native
- Source
- look/look.synod:54
- Examples
- look/icons
look.Counter [v: number]
A whole number whose digits roll when it changes
- Gives
- shape
- Contexts
- look
- Kind
- phrase, native
- Source
- look/look.synod:57
- Examples
- look/counter
look.Role [s: shape] as [r: text]
Type role of a label or counter: "title", "label", "value" or "caption"
- Gives
- —
- Contexts
- look
- Kind
- phrase, native
- Source
- look/look.synod:60
- Examples
- look/counter
look.Face [s: shape] as [f: text]
Font face of a label or counter: "sans" or "mono"
- Gives
- —
- Contexts
- look
- Kind
- phrase, native
- Source
- look/look.synod:63
- Examples
- look/counter
look.Dash [s: shape] on [a: number] off [b: number]
Dashed outline; on 0 draws solid
- Gives
- —
- Contexts
- look
- Kind
- phrase, native
- Source
- look/look.synod:66
- Examples
- look/strokes
look.Bend [s: shape] by [c: number]
Later moves of s follow an arc bent by c (−1..1) of their length
- Gives
- —
- Contexts
- look
- Kind
- phrase, native
- Source
- look/look.synod:69
- Examples
- look/arcs
look.Trail [s: shape] for [d: time]
Moving s leaves a fading trail d long (0s to 2s)
- Gives
- —
- Contexts
- look
- Kind
- phrase, native
- Source
- look/look.synod:72
- Examples
- look/arcs
look.Focus [s: shape] zoom [z: number] over [d: time]
Move the camera to s at zoom z (0.5..4)
- Gives
- —
- Contexts
- look
- Kind
- phrase, native
- Source
- look/look.synod:75
- Examples
- look/camera
look.MessageColor [m: msg]
One of theme.Message1..4, chosen by the record type of m
- Gives
- color
- Contexts
- look
- Kind
- phrase, native
- Source
- look/look.synod:78
- Examples
- look/effects
look.Fade [s: shape] to [o: number]
Opacity over 300ms
- Gives
- —
- Contexts
- look
- Kind
- phrase, written in Synod
- Source
- look/motion.synod:3
- Examples
- look/motion
look.Pulse [s: shape]
Scale to 1.15 and back over 300ms
- Gives
- —
- Contexts
- look
- Kind
- phrase, written in Synod
- Source
- look/motion.synod:7
- Examples
- look/motion
More looks and themes, with an editable demo each, are on Looks & Themes; the gallery plays every pair.
Examples
arcs
Shows look.Bend and look.Trail: a message ball flies along an arc and leaves a trail
# package main
# Shows look.Bend and look.Trail: a message ball flies along an arc and leaves a trail
use example.com/library/look/arcs
use example.com/library/look/pingpong
use std/sim
define main
set nodes to (sim.Cluster of 2 running pingpong)
deliver (message pingpong.Start with Peer (item 1 of nodes)) to (item 0 of nodes)
sim.StopAt 1s
# package arcs
use std/look
use std/net
use std/sim
use std/theme
when sim.Started
look.Layout "row"
when (sim.Added n)
draw (look.Card for n) as card for n
# The ball bends a quarter of the way and leaves a trail 200ms long
when (net.Sent m from a to b)
draw (look.Circle 6) as ball for (net.Id m)
look.Fill ball with theme.Accent
look.Bend ball by 0.25
look.Trail ball for 200ms
look.Flight ball from (card of a) to (card of b) for m
when (net.Arrived m from a to b)
look.Remove (ball of (net.Id m))
camera
Shows look.Focus: the camera moves to a card and back
# package main
# Shows look.Focus: the camera moves to a card and back
use example.com/library/look/camera
use example.com/library/look/pingpong
use std/sim
define main
set nodes to (sim.Cluster of 2 running pingpong)
deliver (message pingpong.Start with Peer (item 1 of nodes)) to (item 0 of nodes)
sim.StopAt 2s
# package camera
use std/look
use std/sim
when sim.Started
look.Layout "row"
# The camera zooms in on each new card, then returns to the centre
when (sim.Added n)
draw (look.Card for n) as card for n
look.Focus (card of n) zoom 2 over 500ms
after 1s
look.Focus look.Center zoom 1 over 500ms
counter
Shows look.Counter, look.Role and look.Face, and look.Tween of "count": a counter whose digits roll
# package main
# Shows look.Counter, look.Role and look.Face, and look.Tween of "count": a counter whose digits roll
use example.com/library/look/counter
use std/sim
define main
sim.StopAt 2s
# package counter
use std/look
use std/sim
# A counter in the value role and the mono face, counting up to 42
when sim.Started
draw (look.Counter 0) as total
look.Role total as "value"
look.Face total as "mono"
draw (look.Label "messages") as caption
look.Role caption as "caption"
look.Place caption below total
after 300ms
look.Tween "count" of total to 42 over 800ms
effects
Shows every look.Effect name and look.MessageColor: a card per effect, and a dot in the color of a message
# package main
# Shows every look.Effect name and look.MessageColor: a card per effect, and a dot in the color of a message
use example.com/library/look/effects
use example.com/library/look/pingpong
use std/sim
define main
set nodes to (sim.Cluster of 2 running pingpong)
deliver (message pingpong.Start with Peer (item 1 of nodes)) to (item 0 of nodes)
sim.StopAt 1s
# package effects
use std/look
use std/net
use std/sim
when (sim.Added n)
draw (look.Card for n) as card for n
when sim.Started
look.Layout "row"
# A message gets a dot in the color of its record type, and the sender's card plays an effect
when (net.Sent m from a to b)
draw (look.Circle 8) as dot for (net.Id m)
look.Fill dot with (look.MessageColor m)
look.Effect "glow" on (card of a)
look.Effect "indicate" on (card of a)
look.Effect "flash" on (card of a)
look.Effect "circumscribe" on (card of a)
look.Effect "ripple" on (card of b)
look.Effect "sweep" on (card of b)
entrance
Shows look.PopIn and look.Enter: one shape pops in, then a list of shapes enters one after another
# package main
# Shows look.PopIn and look.Enter: one shape pops in, then a list of shapes enters one after another
use example.com/library/look/entrance
use std/sim
define main
sim.StopAt 2s
# package entrance
use std/look
use std/sim
use std/theme
# A big disc pops in alone, then three small ones enter 150ms apart
when sim.Started
draw (look.Circle 40) as big
look.Fill big with theme.Accent
look.PopIn big
draw (look.Circle 12) as a
draw (look.Circle 12) as b
draw (look.Circle 12) as c
look.Place b beside a
look.Place c beside b
look.Place a below big
look.Enter {a, b, c} every 150ms
flight
Shows look.Flight with net.Id and net.Type: balls fly with each message and land on arrival
# package main
# Shows look.Flight with net.Id and net.Type: balls fly with each message and land on arrival
use example.com/library/look/flight
use example.com/library/look/pingpong
use std/sim
define main
set nodes to (sim.Cluster of 2 running pingpong)
deliver (message pingpong.Start with Peer (item 1 of nodes)) to (item 0 of nodes)
sim.StopAt 1s
# package flight
use std/look
use std/net
use std/sim
use std/theme
when (sim.Added n)
draw (look.Card for n) as card for n
# A ball flies from sender to receiver and lands when the message arrives
when (net.Sent m from a to b)
draw (look.Circle 6) as ball for (net.Id m)
look.Fill ball with theme.Accent
draw (look.Label (net.Type m)) as tag for (net.Id m)
look.Place tag above ball
look.Flight ball from (card of a) to (card of b) for m
when (net.Arrived m from a to b)
look.Remove (ball of (net.Id m))
look.Remove (tag of (net.Id m))
icons
Shows look.Icon and look.Tween of "icon": an icon morphs into another of the set
# package main
# Shows look.Icon and look.Tween of "icon": an icon morphs into another of the set
use example.com/library/look/icons
use std/sim
define main
sim.StopAt 2s
# package icons
use std/look
use std/sim
# A server icon and a disk icon; the server becomes a check mark
when sim.Started
draw (look.Icon "server") as server
draw (look.Icon "disk") as disk
look.Place disk beside server
after 500ms
look.Tween "icon" of server to "check" over 400ms
motion
Shows look.Layout, Pulse, Effect, Travel, Tween, Orbit, Fade and Remove: motion reacting to a message
# package main
# Shows look.Layout, Pulse, Effect, Travel, Tween, Orbit, Fade and Remove: motion reacting to a message
use example.com/library/look/motion
use example.com/library/look/pingpong
use std/net
use std/sim
define main
set nodes to (sim.Cluster of 2 running pingpong)
net.Latency between 50ms and 60ms
deliver (message pingpong.Start with Peer (item 1 of nodes)) to (item 0 of nodes)
sim.StopAt 1s
# package motion
use example.com/library/look/pingpong
use std/look
use std/net
use std/sim
use std/theme
when sim.Started
look.Layout "row"
when (sim.Added n)
draw (look.Card for n) as card for n
# Each Ping: the card pulses and glows, a mark travels, then orbits and fades away
when (net.Sent pingpong.Ping from a to b)
look.Pulse (card of a)
look.Effect "glow" on (card of a)
draw (look.Circle 8) as mark
look.Fill mark with theme.Warning
look.Travel mark from (card of a) to (card of b) over 200ms
after 200ms
look.Tween "scale" of mark to 2 over 200ms
look.Orbit mark around (card of b) at 0.25
look.Fade mark to 0
after 300ms
look.Remove mark
shapes
Shows look.Circle, Rect, Label, Line, Group, Fill, Stroke, Center, Place (above, below, beside) and Card in a small look
# package main
# Shows look.Circle, Rect, Label, Line, Group, Fill, Stroke, Center, Place (above, below, beside) and Card in a small look
use example.com/library/look/pingpong
use example.com/library/look/shapes
use std/sim
define main
set nodes to (sim.Cluster of 2 running pingpong)
deliver (message pingpong.Start with Peer (item 1 of nodes)) to (item 0 of nodes)
sim.StopAt 1s
# package shapes
use std/look
use std/sim
use std/theme
# Shapes at rest: circle, rect, label and line, a group, fill and stroke, relative placement
when sim.Started
draw (look.Rect 1032 by 642) as ground
look.Fill ground with theme.Paper
look.Stroke ground with theme.Line
draw (look.Circle 40) as disc
look.Fill disc with theme.Accent
look.Stroke disc with theme.Ink
look.Place disc beside look.Center
draw (look.Label "disc") as caption
look.Place caption below disc
draw (look.Rect 80 by 40) as plate
look.Fill plate with theme.Good
look.Place plate above disc
draw (look.Line from disc to plate) as wire
draw (look.Circle 6) as dot
draw (look.Label "dot") as dotname
look.Place dotname beside dot
draw (look.Group {dot, dotname}) as pair
look.Place pair below caption
when (sim.Added n)
draw (look.Card for n) as card for n
strokes
Shows look.Dash, look.Reveal and look.Frame: a dashed frame, and a circle drawn on
# package main
# Shows look.Dash, look.Reveal and look.Frame: a dashed frame, and a circle drawn on
use example.com/library/look/strokes
use std/sim
define main
sim.StopAt 2s
# package strokes
use std/look
use std/sim
use std/theme
# The frame is dashed, the circle is drawn on with its outline first
when sim.Started
draw look.Frame as frame
look.Stroke frame with theme.Line
look.Dash frame on 8 off 6
draw (look.Circle 60) as disc
look.Fill disc with theme.Accent
look.Stroke disc with theme.Ink
look.Reveal disc