lmjtfy.git / packages / card / src / README.md

Chapter 11½: inside card/src

lib.rs is a tiny graphics library and three pictures:

  1. The palette: paper, ink, pink and grey, the page's own colours.
  2. Canvas: fill, frame, dither (the page's dot fields, with a 4 by 4 ordered dither), and text in the 8 by 8 face, scaled.
  3. Text layout: cut (shorten with "..."), wrap (break at spaces into lines), fit (the largest scale that fits).
  4. draw: the frame common to every card (dither, pink band, window), then the inside for Home, Question or Code; slider and detail draw an answer's numbers.
  5. png: packs four pixels a byte and writes an indexed PNG.

tests.rs checks the PNG is the size the page declares, that the answer and its numbers change the picture, that nothing runs off the card, and that letters outside ASCII fall back to ?.

Try it. cargo test -p card.

FileWhat
lib.rsThe canvas, the face, the cards, and png.
tests.rsSizes, pictures that change with the answer, and edges.

← Previous: Chapter 11, card/ · Up: card · Next: Chapter 11¾, card/examples/ →