UNPKG

pixel-eight

Version:

A library inspired by the pico-8 API for writing games for the Kano Pixel

688 lines (621 loc) 7.35 kB
// prettier-ignore const space = [ ' ', ' ', ' ', ' ', ' ', ]; // prettier-ignore const exclamation = [ ' * ', ' * ', ' * ', ' ', ' * ', ]; // prettier-ignore const doubleQuote = [ '* *', '* *', ' ', ' ', ' ', ]; // prettier-ignore const singleQuote = [ ' * ', ' * ', ' ', ' ', ' ', ]; // prettier-ignore const openParen = [ ' * ', '* ', '* ', '* ', ' * ', ]; // prettier-ignore const closeParen = [ ' * ', ' *', ' *', ' *', ' * ', ]; // prettier-ignore const plus = [ ' ', ' * ', '***', ' * ', ' ', ]; // prettier-ignore const comma = [ ' ', ' ', ' ', ' * ', '* ', ]; // prettier-ignore const minus = [ ' ', ' ', '***', ' ', ' ', ]; // prettier-ignore const period = [ ' ', ' ', ' ', '** ', '** ', ]; // prettier-ignore const forwardSlash = [ ' *', ' *', ' * ', '* ', '* ', ]; // prettier-ignore const _0 = [ '***', '* *', '* *', '* *', '***', ]; // prettier-ignore const _1 = [ ' * ', '** ', ' * ', ' * ', '***', ]; // prettier-ignore const _2 = [ '***', ' *', '***', '* ', '***', ]; // prettier-ignore const _3 = [ '***', ' *', '***', ' *', '***', ]; // prettier-ignore const _4 = [ '* *', '* *', '***', ' *', ' *', ]; // prettier-ignore const _5 = [ '***', '* ', '***', ' *', '***', ]; // prettier-ignore const _6 = [ '***', '* ', '***', '* *', '***', ]; // prettier-ignore const _7 = [ '***', ' *', ' *', ' *', ' *', ]; // prettier-ignore const _8 = [ '***', '* *', '***', '* *', '***', ]; // prettier-ignore const _9 = [ '***', '* *', '***', ' *', '***', ]; // prettier-ignore const colon = [ '** ', '** ', ' ', '** ', '** ', ]; // prettier-ignore const semiColon = [ '** ', '** ', ' ', ' * ', '* ', ]; // prettier-ignore const lessThan = [ ' *', ' * ', '* ', ' * ', ' *', ]; // prettier-ignore const equals = [ ' ', '***', ' ', '***', ' ', ]; // prettier-ignore const greaterThan = [ '* ', ' * ', ' *', ' * ', '* ', ]; // prettier-ignore const questionMark = [ '***', ' *', ' * ', ' ', ' * ', ]; // prettier-ignore const at = [ '***', '* *', '* *', '* ', ' **', ]; // prettier-ignore const a = [ '***', '* *', '***', '* *', '* *', ]; // prettier-ignore const b = [ '***', '* *', '** ', '* *', '***', ]; // prettier-ignore const c = [ ' **', '* ', '* ', '* ', ' **', ]; // prettier-ignore const d = [ '** ', '* *', '* *', '* *', '***', ]; // prettier-ignore const e = [ '***', '* ', '** ', '* ', '***', ]; // prettier-ignore const f = [ '***', '* ', '** ', '* ', '* ', ]; // prettier-ignore const g = [ ' **', '* ', '* ', '* *', '***', ]; // prettier-ignore const h = [ '* *', '* *', '***', '* *', '* *', ]; // prettier-ignore const i = [ '***', ' * ', ' * ', ' * ', '***', ]; // prettier-ignore const j = [ '***', ' * ', ' * ', ' * ', '** ', ]; // prettier-ignore const k = [ '* *', '* *', '** ', '* *', '* *', ]; // prettier-ignore const l = [ '* ', '* ', '* ', '* ', '***', ]; // prettier-ignore const m = [ '***', '***', '* *', '* *', '* *', ]; // prettier-ignore const n = [ '** ', '* *', '* *', '* *', '* *', ]; // prettier-ignore const o = [ ' **', '* *', '* *', '* *', '** ', ]; // prettier-ignore const p = [ '***', '* *', '***', '* ', '* ', ]; // prettier-ignore const q = [ ' * ', '* *', '* *', '** ', ' **', ]; // prettier-ignore const r = [ '***', '* *', '** ', '* *', '* *', ]; // prettier-ignore const s = [ ' **', '* ', '***', ' *', '** ', ]; // prettier-ignore const t = [ '***', ' * ', ' * ', ' * ', ' * ', ]; // prettier-ignore const u = [ '* *', '* *', '* *', '* *', ' **', ]; // prettier-ignore const v = [ '* *', '* *', '* *', '***', ' * ', ]; // prettier-ignore const w = [ '* *', '* *', '* *', '***', '***', ]; // prettier-ignore const x = [ '* *', '* *', ' * ', '* *', '* *', ]; // prettier-ignore const y = [ '* *', '* *', '***', ' *', '***', ]; // prettier-ignore const z = [ '** ', ' *', '***', '* ', ' **', ]; // prettier-ignore const openBracket = [ '***', '* ', '* ', '* ', '***', ]; // prettier-ignore const backSlash = [ '* ', '* ', ' * ', ' *', ' *', ]; // prettier-ignore const closeBracket = [ '***', ' *', ' *', ' *', '***', ]; // prettier-ignore const hat = [ ' * ', '* *', ' ', ' ', ' ', ]; // prettier-ignore const underscore = [ ' ', ' ', ' ', ' ', '***', ]; // prettier-ignore const tick = [ ' * ', ' *', ' ', ' ', ' ', ]; // prettier-ignore const openCurl = [ ' *', ' * ', '** ', ' * ', ' *', ]; // prettier-ignore const pipe = [ ' * ', ' * ', ' * ', ' * ', ' * ', ]; // prettier-ignore const closeCurl = [ '* ', ' * ', ' **', ' * ', '* ', ]; var hash = space; var dollar = space; var percent = space; var ampersand = space; var star = space; var tilde = space; var charactersByCode = [ space, exclamation, doubleQuote, hash, dollar, percent, ampersand, singleQuote, openParen, closeParen, star, plus, comma, minus, period, forwardSlash, _0, _1, _2, _3, _4, _5, _6, _7, _8, _9, colon, semiColon, lessThan, equals, greaterThan, questionMark, at, a, b, c, d, e, f, g, h, i, j, k, l, m, n, o, p, q, r, s, t, u, v, w, x, y, z, openBracket, backSlash, closeBracket, hat, underscore, tick, a, b, c, d, e, f, g, h, i, j, k, l, m, n, o, p, q, r, s, t, u, v, w, x, y, z, openCurl, pipe, closeCurl, tilde ]; const characters = text => { var result = []; for (var index = 0; index < text.length; ++index) { var code = text.charCodeAt(index) - 32; if (code >= 0 && code < charactersByCode.length) { var character = charactersByCode[code]; result.push(character); } else { result.push(space); } } return result; }; module.exports = { characters };