Skip to content
react-cards-opening

PixelGlyph

PixelGlyph is how a card gets a picture without an image file. A glyph is nine strings of nine characters: x for a lit pixel, o for a half-lit one, a dot for nothing. It is drawn in one colour, the card's tier, so the same glyph reads as common or legendary by colour alone.

  • mountain
  • bolt
  • flame
  • globe
  • check
  • tree
  • palm
  • eye
  • lock
  • rocket
  • calendar
  • moon
  • duck
  • plant
  • mug
  • cat
  • owl
  • hedgehog
  • octopus
  • fox
  • dragon
  • phoenix
  • crown
  • trophy
  • question

The twenty five that ship, by name.

Usage

tsx
import { GLYPHS, PixelGlyph } from "@react-cards-opening/ui";

<PixelGlyph art={GLYPHS.dragon} colour="#f2cc60" cell={14} />

Props

PropTypeWhat it does
artPixelArtNine strings of nine characters.
colourstringLit pixels wear it. Half-lit ones wear half of it.
cell?numberThe size of one pixel. 11 by default: 14 on a card, 3 in a badge.

Draw your own

ts
import type { PixelArt } from "@react-cards-opening/ui";

export const heart: PixelArt = [
  ".........",
  ".xx...xx.",
  "xxxx.xxxx",
  "xxxxxxxxx",
  "xxxxxxxxx",
  ".xxxxxxx.",
  "..xxxxx..",
  "...xxx...",
  "....x....",
];

Use o for shading: the inside of a shape, a shadow under it. Nine by nine is small enough that every pixel is a decision, which is the charm of it.

Or use a picture

Nothing requires glyphs. A card's face is a slot: put an image, an SVG or a 3D canvas in it with renderFace. See Custom card face.

Last updated . Read this page as Markdown.