Draw on Molty
A skill that draws on Molty is one folder with three things in it:
| in the folder | what it is |
|---|---|
SKILL.md | words for the agent: when to show which screen |
display.yaml | the drawing: screens made of shapes |
assets/ | symbols and pictures as plain SVG and PNG files (only if you need them) |
Your first screen
Section titled “Your first screen”Make a folder, say my-skill/, and put this in my-skill/display.yaml:
molty: display/2package: 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):
node packages/tools/molty-display.mjs build my-skillSee 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}}Places and units
Section titled “Places and units”Units never change, so learn them once.
| what | unit |
|---|---|
| a distance, a radius, a size, a width | a fraction of the screen’s radius: 1 reaches the rim |
| an angle | degrees, 0 at 3 o’clock, going counter-clockwise (90 is 12 o’clock) |
| a time | seconds 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 defaultat: { x: 0.2, y: -0.4 } # right and up are positive; leave one out and it is 0at: { angle: 195, distance: 0.825 } # around the centreColors and line widths
Section titled “Colors and line widths”Use Molty’s names and a new skill looks like Molty. A color can also be "#rrggbb", a width a number.
| name | is | use it for |
|---|---|---|
ink, grid, dim, white | bright to faint | main strokes, scales, background, emphasis (the default) |
erase | black | clears what is under it |
hairline, thin, bold | 0.012, 0.03, 0.06 | crisp one-dot lines, the default, a pointer |
Add your own under tokens: tokens: { colors: { coral: "#ff9a7a" }, sizes: { lit_ring: 0.075 } }.
Shapes
Section titled “Shapes”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.
| shape | takes | draws |
|---|---|---|
circle | radius, at, width | a circle outline |
arc | radius, start, end, at, width | part of a circle, between two angles |
ticks | count, radius, length, first_angle, width | evenly spaced marks round the centre |
spoke | angle, radius (where it starts), length, width | one mark at an angle: a pointer |
line | from and to, or points (2 to 16); smooth; width | straight segments, or a smooth curve |
dot | radius, at | a filled circle |
globe | radius, at, map, lit, lit_side, spin | a shaded ball wearing a map: a moon phase, a planet |
symbol | asset, size, at, rotate | one of your assets |
label | text, size, at | up to 40 letters in Molty’s own font |
tap_zone | see Taps | nothing: a place to tap |
draw: - ticks: { count: 12, radius: 0.82, length: 0.08, width: hairline, color: grid } - dot: { radius: 0.05 }Inputs and binding
Section titled “Inputs and binding”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.
| type | the agent sends |
|---|---|
number, angle, distance, amount, seconds | a number (amount is 0 to 1; min and max narrow it) |
text, reading | words: up to 40 for a label, up to 160 for what a tap shows |
color | "#rrggbb" |
asset | the name of one of your assets (of: assets/planets keeps it to one folder) |
groups | group names with spaces between, for a tap to light |
list | up 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.
Repeat and reuse
Section titled “Repeat and reuse”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 indisplay.yaml(the twelve signs and their angles).for: sign in zodiacrepeats over it.parts: a group of shapes with a name. Place it with- use: wheel, pass values withwith: { 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| key | meaning |
|---|---|
at + radius | a round zone |
along: { from, to } + radius | a 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 |
opens | a tap opens another screen on Molty; it comes back when that ends, or at a tap beside it |
highlights | group names to light. Left out: whatever is drawn inside the zone |
grow | how 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 sThe 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.
Assets
Section titled “Assets”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 }as | from | on screen |
|---|---|---|
symbol | an SVG made of lines, or a PNG (its solid pixels) | one color: the color of the shape that draws it |
picture | a PNG | its own colors, up to 15, and see-through |
map | a PNG twice as wide as tall | wrapped 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.
Timing
Section titled “Timing”duration: 6 # seconds; or hold (stays until replaced)subtitles: middle # where readings show: bottom, middle, or a ydraw: - 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.
SKILL.md and the docs you get
Section titled “SKILL.md and the docs you get”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.
| command | does |
|---|---|
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.
Limits and edge cases
Section titled “Limits and edge cases”| what | limit |
|---|---|
| screens in a package | 32 |
| 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 max | 128 |
| inputs to a screen | 8 |
| elements in a list, fields in an element | 32, 12 |
| letters in a label, and in all labels on screen; characters in a reading | 40; 160 |
groups a screen can light; names in one highlights | 32; 4 |
| assets; pixels a side | 64; 128 |
| the built package | 256 KB |
| text | plain ASCII; cannot start with $ or @ |
| names | screens, inputs and fields: lower case, digits and _ (a screen may use -), 24 at most |
| every input | must be sent, and must be used by some shape |
sent_as on an input or a field | the name the agent sends, when you want a clearer one in the drawing |
| read from inputs | a point of a line or along must be { x, y }; lit_side is a number, 1 right, -1 left |
move, default, type: path | need new firmware: check refuses them and says what to write instead |
| SVG | line, polyline and polygon only; anything else goes in as a PNG |