pixel-mouth
A mouth for pixel-art characters, as data and one pure function. A host describes where a character's
mouth sits and how it is drawn (a MouthSpec) and asks for the rectangles of one of four
openness levels (Closed, Small, Wide, Round); it draws them in its own grid. Nothing here knows
what a character is, what a grid is drawn on, or which host asked.
| Item | What it is |
|---|---|
MouthSpec | The anchor in the host's grid, the size, the style and the colours the mouth draws with. |
Style | The animal's kind of mouth: Cat (a nose line and two steps when shut), Flat (a plain line when shut), Muzzle (cells under a nose, growing across or down), BeakSide (a lower beak that drops, on a character in profile), BeakFront (the opening under a beak seen from the front). |
rects(spec, level) | The rectangles to draw, in the host's grid units, in paint order. A level whose style adds nothing (a muzzle shut) is empty: the host's own picture is the closed mouth. |
Level | The four openness levels, how open each is (open), and the level nearest an openness (level_for_open). |
level_for_vowel, level_in_syllable, OPEN_UNTIL | The timing that steps the openness over a syllable: the vowel of the syllable being said chooses the level, and it shuts in the last of the gap before the next. |
flap_open, flap_level | The beat a mouth follows when nothing says which syllable it is on. |
The levels are not drawn by a host: a character is a MouthSpec and nothing else, so a new character
adds data and no code.
mise run test