Rebus.Deck
- Package
- purescript-rebus
- Repository
- afcondon/purescript-rebus
Rebus.Deck — the icon deck and the colour palette: the two tables a rebus
is drawn from.
The deck is a value, not a constant, because some consumer will one day
want a deck of its own — animals only, a house icon set, a deck sized to what
a small display can render. But read the warning on defaultDeck before
reaching for one: swapping decks is a versioning decision, not a preference.
#Deck Source
newtype DeckAn ordered list of icon NAMES. Rebus never draws anything; a name is whatever the consumer's renderer can look up — a FontAwesome class, an SVG id, a key into a sprite sheet.
The deck must hold at least as many entries as the widest rebus drawn from
it, since a run is bumped apart so no icon repeats. Size is the whole of the
collision story: 64 entries give 64 identities at width one, 64x63 = 4032 at
two and 249984 at three, so how wide a consumer draws follows from how many
things it must tell apart (see Rebus.Width).
Constructors
Instances
#defaultDeck Source
defaultDeck :: DeckThe deck Rebus ships with: sixty-four concrete, drawable nouns, each of which happens to be a FontAwesome free-solid name so the common case needs no mapping table at all.
ORDER IS THE IDENTITY. An index into this array is what a content hash actually produces, so reordering an entry, removing one, or inserting in the middle silently re-identifies every rebus ever minted: the alias someone wrote down stops matching the picture they remember. The array is therefore FIXED and APPEND-ONLY — and even appending changes identities, because the hash is reduced modulo the deck size.
The same goes for rebusOfWith and a deck of your own. A different deck is a
different identity space; two programs that must agree have to agree on the
deck first, and a program that changes its deck has performed a data
migration whether or not it migrated anything.
#without Source
without :: Array String -> Deck -> DeckThe deck with the named icons WITHDRAWN, the rest left in their order.
This is for icons that mean something to your subject. A reader reads a
flame as heat and a skull as danger whether or not anyone meant it, so a
pure hash will sooner or later say something false: a flame on the thing
that is cold. Withdraw every icon that carries meaning for the subject, deal
names from what is left, and place the withdrawn ones only by declaration
(Rebus.Choice).
The library ships no list of "loaded" icons, on purpose: what is loaded depends on the subject (a bolt means nothing in a build and electricity in a house), so the list belongs with the subject's vocabulary.
The warning on defaultDeck applies with full force. A restricted deck is a
different identity space: the same text deals to a different glyph, and an
icon withdrawn LATER re-deals everything dealt before. Decide what is
withdrawn once, per identity space.
#Theme Source
data ThemeA named part of defaultDeck. The six themes PARTITION it: every one of
the sixty-four icons is in exactly one theme.
A theme is how a picture can say which subject it belongs to before any
word is read: deal one subject's names from Animals and another's from
Travel and the two cannot share an icon, so they look like two families
rather than one. (Rebus.Assign.assignThemes hands themes out to subjects.)
They are unequal in size, and the size is the limit on what a theme can
name without two things sharing an icon: Nature 14, Animals 13,
Travel and Emblems 12, Tools 9, Music 4. Join themes with
themesDeck when one is too small.
A closed set, like Width: the themes are a fact about defaultDeck, not
a vocabulary a caller extends. A subset of your own is only.
Constructors
Instances
#themeFromName Source
themeFromName :: String -> Maybe ThemeThe theme a stored name spells, if it spells one.
#themeIcons Source
themeIcons :: Theme -> Array StringThe icons of a theme. Membership is the fact; the order a theme's deck
deals in is always defaultDeck's (see themeDeck).
#themeOfIcon Source
themeOfIcon :: String -> Maybe ThemeWhich theme an icon of defaultDeck belongs to; Nothing for a name that
is not in the default deck.
#themesDeck Source
themesDeck :: Array Theme -> DeckThe deck of several themes together, in defaultDeck's order whatever
order the themes are named in. themesDeck allThemes == defaultDeck.
#defaultPalette Source
defaultPalette :: PaletteEight hues spaced around the wheel, all mid-dark so a small icon still reads against a light ground.
Unlike the deck, the palette is NOT part of the identity: a rebus is
identified by its icons, which is what the alias records, and colour is a
memorability accent laid on top ("red cow, blue star" is easier to hold than
"cow, star"). Recolouring is therefore a visual change and not a migration —
which is why rebusOfWith takes a deck and no palette.
Eight is also why colour de-duplication is only ever pairwise. A run of five icons cannot be given five well-separated hues out of eight, and should not try: all that is needed is that two icons standing side by side are not mistaken for one shape drawn twice.
#paletteSize Source
paletteSize :: Palette -> Int