Skip to main content

Module onebit

Module onebit 

Source
Expand description

One-bit output by role (ADR-0008 §4): a fixed set of 8 × 8 Patterns, and the pattern map (palette@onebit.ron, beside the palette) that gives each of a skin’s palette roles a foreground and a background pattern, with the groups of roles that tell things apart and must stay distinct. As a format (ADR-0007): PatternMapRon. check is what shuyi check --target checks of a one-bit target; the renderer that draws with the map is shuyi_ui::frame::onebit.

(
    roles: {
        "text": (fg: Black, bg: White),
        "team.player": (fg: White),
        "team.enemy": (fg: Dither50),
        "team.ally": (fg: Inverted(DiagonalUp)),
    },
    distinct: [["team.player", "team.enemy", "team.ally"]],
    text: ["text"],
)

Structs§

Pattern
A pattern of 8 × 8 pixels: one of the Base patterns, or one of them inverted. A pattern map spells it Dither50 or Inverted(Dither50).
PatternMapDef
A pattern map: each palette role’s patterns on a one-bit target, the groups of roles that must stay distinct, and the roles text is drawn in.
PatternMapRon
A pattern map file (pattern-map, .ron), read as PatternMapDef::from_source says.
Problem
What check found wrong with a pattern map.
RolePatterns
A role’s two patterns: fg for what is drawn in its colour (a glyph, a rectangle, a sprite painted in it), bg for a cell’s background in it (fg again, if the map doesn’t say).

Enums§

Base
One of the fixed patterns, before any inversion: black and white solids, three ordered dithers, and four kinds of line.
Rule
Which rule a Problem breaks.
Severity
How bad a Problem is.

Constants§

BAYER
The Bayer 8 × 8 order, by row then column: the dithers’ thresholds. A dither with k black pixels is black where the order is below k.

Functions§

check
What is wrong with map as the one-bit look of palette (ADR-0008 §4), in this order:
dither
Bayer ordered dither of a grey darkness from 0 (white) to 255 (black): black where 4 × order + 2 < darkness, so 64 is Base::Dither25, 128 Base::Dither50 and 192 Base::Dither75 exactly, and the levels between fall evenly.
map_path
Where a palette’s pattern map is: beside it, its name with @onebit (skin/palette.ron → skin/palette@onebit.ron).

Type Aliases§

Rows
The eight rows of a pattern: a row’s highest bit is its left pixel, a set bit white, as in the Playdate’s frame buffer.