marrus-sh / jelli

A game engine! Currently being developed.
MIT License
1 stars 0 forks source link

Allow specification of letter widths and offsets via base64-encoded `data-*` attributes #35

Open marrus-sh opened 8 years ago

marrus-sh commented 8 years ago

This should expand to a UInt8Array where each byte provides the pixels wide of that Letter in the corresponding Letters. Drawing should then take this into account by only advancing by the width of the letter. The letter width can be longer than the width of the sprite, which can be used to create space between letters, etc. Letters should be left-aligned.

Characters with zero width may be used to draw over the character which follows them. Characters with negative width are drawn over the previous character by the amount specified, but the final cursor position remains where it was before drawing the character. This is done by:

  1. Increasing the cursor position by the (negative) width
  2. Drawing the character
  3. Increasing the cursor position by -width (now positive).

Thus, negative widths actually function more as offsets for drawing.


Implementing this requires adding attribute support and base64 decoding to the engine, a width attribute (distinct from sprite_width) to Letter(), drawing support to LetterString(), and the assignment of widths to Letters().