Skip to content
molty.UNO
[ source ↗ ]

Draw on Molty

A skill that draws on Molty is one folder with three things in it:

in the folderwhat it is
SKILL.mdwords for the agent: when to show which screen
display.yamlthe drawing: screens made of shapes
assets/symbols and pictures as plain SVG and PNG files (only if you need them)

Make a folder, say my-skill/, and put this in my-skill/display.yaml:

molty: display/2
package:
id: hello
name: Hello
version: 1.0.0
about: A ring, a pointer and a word.
screens:
hello:
about: A pointer on a ring.
inputs:
angle: { type: angle, about: Where the pointer points., example: 90 }
draw:
- circle: { radius: 0.9, color: ink }
- spoke: { angle: "{{ angle }}", length: 0.7, width: bold }
- label: { text: HELLO, at: { y: -0.4 }, size: 0.14 }

Check it and build it (one command; it tells you the file, the line and the fix when something is wrong):

Terminal window
node packages/tools/molty-display.mjs build my-skill

See it on your computer: node packages/tools/molty-display.mjs preview my-skill, then open the address it prints.

Show it on Molty. The agent sends this through the molty skill (its molty_scene tool, or the script your skill ships). The build writes the call for every screen, in build/display.md:

{"name":"scene.play","args":{"pkg":"hello","layout":"hello","params":{"angle":90},"ttl_s":60}}

Units never change, so learn them once.

whatunit
a distance, a radius, a size, a widtha fraction of the screen’s radius: 1 reaches the rim
an angledegrees, 0 at 3 o’clock, going counter-clockwise (90 is 12 o’clock)
a timeseconds from the moment the screen starts

A place is the centre, an x and y, or an angle and a distance:

at: center # the middle of the glass, the default
at: { x: 0.2, y: -0.4 } # right and up are positive; leave one out and it is 0
at: { angle: 195, distance: 0.825 } # around the centre

Use Molty’s names and a new skill looks like Molty. A color can also be "#rrggbb", a width a number.

nameisuse it for
ink, grid, dim, whitebright to faintmain strokes, scales, background, emphasis (the default)
eraseblackclears what is under it
hairline, thin, bold0.012, 0.03, 0.06crisp one-dot lines, the default, a pointer

Add your own under tokens: tokens: { colors: { coral: "#ff9a7a" }, sizes: { lit_ring: 0.075 } }.

draw is a list. Each entry is one shape: its name, then what it takes. Later shapes paint on top. Every shape except tap_zone also takes color.

shapetakesdraws
circleradius, at, widtha circle outline
arcradius, start, end, at, widthpart of a circle, between two angles
tickscount, radius, length, first_angle, widthevenly spaced marks round the centre
spokeangle, radius (where it starts), length, widthone mark at an angle: a pointer
linefrom and to, or points (2 to 16); smooth; widthstraight segments, or a smooth curve
dotradius, ata filled circle
globeradius, at, map, lit, lit_side, spina shaded ball wearing a map: a moon phase, a planet
symbolasset, size, at, rotateone of your assets
labeltext, size, atup to 40 letters in Molty’s own font
tap_zonesee Tapsnothing: a place to tap
draw:
- ticks: { count: 12, radius: 0.82, length: 0.08, width: hairline, color: grid }
- dot: { radius: 0.05 }

An input is something the agent sends with the screen. Give each a type, an about (one sentence for the agent) and an example. Use it with "{{ name }}", in quotes.

typethe agent sends
number, angle, distance, amount, secondsa number (amount is 0 to 1; min and max narrow it)
text, readingwords: up to 40 for a label, up to 160 for what a tap shows
color"#rrggbb"
assetthe name of one of your assets (of: assets/planets keeps it to one folder)
groupsgroup names with spaces between, for a tap to light
listup to 32 small objects; of names their fields, max says how many at most
inputs:
value: { type: angle, about: Where the pointer points., example: 135 }
draw:
- spoke: { angle: "{{ value }}", length: 0.8 }

A binding fills a whole value. No sums, no text with a gap in it: the skill works those out and sends the result.

for draws its shapes once for each element of a list input. Inside it, "{{ body.angle }}" reads a field.

inputs:
bodies:
type: list
max: 10
about: The planets to place.
of:
angle: { type: angle, about: Where it sits. }
draw:
- for: body in bodies
draw:
- dot: { radius: 0.04, at: { angle: "{{ body.angle }}", distance: 0.64 } }

Two more tools, both worked out when you build, so they cost nothing to send:

  • data: a fixed table in display.yaml (the twelve signs and their angles). for: sign in zodiac repeats over it.
  • parts: a group of shapes with a name. Place it with - use: wheel, pass values with with: { sign_size: 0.1 }.

skills/molty-astro/display.yaml uses both.

A tap_zone draws nothing. Tap it and Molty shows its reads at once, word by word.

- tap_zone:
at: { angle: "{{ body.angle }}", distance: 0.64 }
radius: 0.08
reads: "{{ body.reading }}" # what Molty shows
id: "{{ body.id }}" # names the zone in the tap event the agent gets
keymeaning
at + radiusa round zone
along: { from, to } + radiusa band along a line, for tapping a line
sector: { from, to, inner, outer }a wedge of a ring: from one angle to another, between two distances
opensa tap opens another screen on Molty; it comes back when that ends, or at a tap beside it
highlightsgroup names to light. Left out: whatever is drawn inside the zone
growhow much the lit shapes grow, 1 to 3 (1.25 if you say nothing)
- tap_zone:
sector: { from: 180, to: 210, inner: 0.75, outer: 0.9 } # this wedge
reads: Aries, bold and quick.
id: aries
opens: { screen: sign-closeup, seconds: 12 } # opens that screen, for 12 s

The opened screen finds its inputs by name: in the tapped element of the list, else among this screen’s inputs. A list passes on only the elements whose of is the zone’s id. For a wedge around a zone an input places, say sector: { width: 30, inner: 0.75, outer: 0.9 }: so many degrees wide, around at. A tap right on a zone’s own circle or line beats one that only falls in a wedge.

Any shape can join a group with group: "{{ body.id }}". A lit shape grows and brightens while the reading plays. A shape with only_when: highlighted shows only then.

Put files in assets/ and list them. An asset’s name is its file name without the ending.

assets:
- { files: "assets/signs/*.svg", as: symbol, pixels: 64 }
- { file: assets/moon.png, as: map }
asfromon screen
symbolan SVG made of lines, or a PNG (its solid pixels)one color: the color of the shape that draws it
picturea PNGits own colors, up to 15, and see-through
mapa PNG twice as wide as tallwrapped round a globe

An SVG needs pixels (its width on Molty, 128 at most). A PNG is used at its own size. smooth: true rounds an SVG’s lines into curves. "assets/{sun,moon}.png" lists files in the order you want.

duration: 6 # seconds; or hold (stays until replaced)
subtitles: middle # where readings show: bottom, middle, or a y
draw:
- dot: { radius: 0.1, show: { from: 0.4, until: 2 } }

show says when a shape is on screen: without from it is there from the start, without until it stays to the end. Both take bindings, so a list can carry each step’s times.

In SKILL.md, link each screen where you say when to use it: [hello](https://github.com/apresmoi/molty.uno/blob/main/docs/display.yaml#hello). The build writes build/display.md (every screen, its inputs and a call that works: link that too) and build/inputs/<screen>.schema.json, which lets a skill check what it is about to send.

commanddoes
molty-display check <folder>finds mistakes: spelling and types, then what Molty cannot take, then links in SKILL.md
molty-display build <folder>check, then the package, its cost, and build/
molty-display preview <folder>a page on your computer: pick a screen, edit inputs, scrub time, click tap zones

molty-display is node packages/tools/molty-display.mjs. A skill in skills/ builds into packages/<id>/, where Molty fetches it once merged: commit the folder and the built package, then run node tools/scripts/check-packages.mjs --write-index. Any other folder builds into its own build/. Editors complete display.yaml when it starts with # yaml-language-server: $schema=<path to>/schema/display-2.json.

whatlimit
screens in a package32
shapes written out in a screen (a part or a data table counts every shape)64
shapes on screen once every list is at its max128
inputs to a screen8
elements in a list, fields in an element32, 12
letters in a label, and in all labels on screen; characters in a reading40; 160
groups a screen can light; names in one highlights32; 4
assets; pixels a side64; 128
the built package256 KB
textplain ASCII; cannot start with $ or @
namesscreens, inputs and fields: lower case, digits and _ (a screen may use -), 24 at most
every inputmust be sent, and must be used by some shape
sent_as on an input or a fieldthe name the agent sends, when you want a clearer one in the drawing
read from inputsa point of a line or along must be { x, y }; lit_side is a number, 1 right, -1 left
move, default, type: pathneed new firmware: check refuses them and says what to write instead
SVGline, polyline and polygon only; anything else goes in as a PNG