lmjtfy.git / packages / card / src / README.md
1# Chapter 11½: inside card/src
2
3`lib.rs` is a tiny graphics library and three pictures:
4
51. **The palette**: paper, ink, pink and grey, the page's own colours.
62. **`Canvas`**: `fill`, `frame`, `dither` (the page's dot fields, with a 4
7   by 4 ordered dither), and `text` in the 8 by 8 face, scaled.
83. **Text layout**: `cut` (shorten with "..."), `wrap` (break at spaces into
9   lines), `fit` (the largest scale that fits).
104. **`draw`**: the frame common to every card (dither, pink band, window),
11   then the inside for `Home`, `Question` or `Code`; `slider` and `detail`
12   draw an answer's numbers.
135. **`png`**: packs four pixels a byte and writes an indexed PNG.
14
15`tests.rs` checks the PNG is the size the page declares, that the answer
16and its numbers change the picture, that nothing runs off the card, and that
17letters outside ASCII fall back to `?`.
18
19> **Try it.** `cargo test -p card`.
20
21| File | What |
22| --- | --- |
23| [lib.rs](lib.rs) | The canvas, the face, the cards, and `png`. |
24| [tests.rs](tests.rs) | Sizes, pictures that change with the answer, and edges. |
25
26← Previous: [Chapter 11, card/](../) · Up: [card](../) · Next: [Chapter 11¾, card/examples/](../examples/) →