class BBS::Art

A drawing kept as readable, diffable text: a YAML file of a character grid and a colour grid, for either face of a board. The modern face draws it in 256-colour ANSI (ansi_lines, draw on a BBS::FrameBuffer, BBS::Widgets::Scene), the C64 face as raw PETSCII on a BBS::Petscii::Canvas (draw_canvas, petscii).

The format (art/house.yml):

size: [40, 6]           # columns, rows
charset: petscii-upper  # or cp437
palette:                # letter => colour
  y: yellow             #   a C64 colour name (BBS::Petscii::Canvas::COLOR_NAMES)
  o: 208                #   an xterm 256-colour index
  s: '#3050a0'          #   or #rrggbb
chars: |2               # the picture, a line a row, every row size[0] wide
  ...
colors: |2              # a palette letter a cell; '.' or space: no colour
  ...
reverse: |2             # optional: 'R' reverses the cell
  ...
background: |2          # optional, cp437 only: a palette letter a cell
  ...
hotspots:               # optional: cells the board fills from its data
  window_1: [12, 3]     #   [col, row], 0-based
  sign: [2, 1, 10, 1]   #   [col, row, width, height]
layers: [snow, pumpkin] # optional: layer files beside this one
grids

chars, colors, reverse and background are YAML literal blocks, every row exactly as wide as the art (the trailing spaces too), as many rows as it is high. Write them |2: without the indentation indicator YAML takes the indentation from the first row, and a row starting with spaces breaks the block.

chars

In petscii-upper every character must be one the uppercase/graphics set shows (BBS::Petscii::Canvas.glyph?): letters, digits, signs and the graphics of Canvas::GLYPHS and Canvas::GLYPHS_REVERSED. In cp437 every character must be in code page 437.

reverse

A reversed cell swaps its colours: a reversed space in yellow is a yellow block. The reversed glyphs of the Canvas (█ ▀ ▐ ◢ ◣) are drawn as they look; reversing them inverts them again.

background

The colour behind a cp437 cell, the second colour of a half block. A C64 has one background for the whole screen, so a petscii-upper art draws with reversed cells instead.

layers

A layer is a file of the same format, <name>.yml in the same folder. size defaults to the art’s, at ([col, row]) places it, charset must match, its palette adds to (and overrides) the art’s, its hotspots add to the art’s. A layer cell that is a plain space (not reversed, no background) is transparent. with stacks the layers chosen, in the order given.

Every mistake raises Art::Error naming the file, the grid, the row and the column.

art = BBS::Art.load('art/house.yml').with(*BBS::Season.now.layers)
session.write(art.ansi)                     # modern face
session.write_raw(art.petscii)              # C64 face: a whole frame
art.hotspot(:window_1)                      # => #<struct col=12, row=3 …>