Skip to content

Latest commit

 

History

History
74 lines (65 loc) · 2.6 KB

README.md

File metadata and controls

74 lines (65 loc) · 2.6 KB

Node.js CI codecov

symbol2array

symbol2array generates a two-dimensional array from circle, square, diamond and triangle

examples

import { SymbolCreator } from 'symbol2array'

const symbolCreator = new SymbolCreator()

symbolCreator.createSymbol('circle', 10, 1).toArray()
// [
//     [0, 0, 0, 0, 0, 0, 0, 0, 0, 0],
//     [0, 0, 1, 1, 1, 1, 1, 1, 0, 0],
//     [0, 1, 1, 0, 0, 0, 0, 1, 1, 0],
//     [0, 1, 0, 0, 0, 0, 0, 0, 1, 0],
//     [0, 1, 0, 0, 0, 0, 0, 0, 1, 0],
//     [0, 1, 0, 0, 0, 0, 0, 0, 1, 0],
//     [0, 1, 0, 0, 0, 0, 0, 0, 1, 0],
//     [0, 1, 1, 0, 0, 0, 0, 1, 1, 0],
//     [0, 0, 1, 1, 1, 1, 1, 1, 0, 0],
//     [0, 0, 0, 0, 0, 0, 0, 0, 0, 0],
// ]

symbolCreator.createSymbol('square', 10, 1).toArray()
// [
//     [1, 1, 1, 1, 1, 1, 1, 1, 1, 1],
//     [1, 0, 0, 0, 0, 0, 0, 0, 0, 1],
//     [1, 0, 0, 0, 0, 0, 0, 0, 0, 1],
//     [1, 0, 0, 0, 0, 0, 0, 0, 0, 1],
//     [1, 0, 0, 0, 0, 0, 0, 0, 0, 1],
//     [1, 0, 0, 0, 0, 0, 0, 0, 0, 1],
//     [1, 0, 0, 0, 0, 0, 0, 0, 0, 1],
//     [1, 0, 0, 0, 0, 0, 0, 0, 0, 1],
//     [1, 0, 0, 0, 0, 0, 0, 0, 0, 1],
//     [1, 1, 1, 1, 1, 1, 1, 1, 1, 1],
// ]

symbolCreator.createSymbol('diamond', 11, 1).toArray()
// [
//     [0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0],
//     [0, 0, 0, 0, 1, 0, 1, 0, 0, 0, 0],
//     [0, 0, 0, 1, 0, 0, 0, 1, 0, 0, 0],
//     [0, 0, 1, 0, 0, 0, 0, 0, 1, 0, 0],
//     [0, 1, 0, 0, 0, 0, 0, 0, 0, 1, 0],
//     [1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1],
//     [0, 1, 0, 0, 0, 0, 0, 0, 0, 1, 0],
//     [0, 0, 1, 0, 0, 0, 0, 0, 1, 0, 0],
//     [0, 0, 0, 1, 0, 0, 0, 1, 0, 0, 0],
//     [0, 0, 0, 0, 1, 0, 1, 0, 0, 0, 0],
//     [0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0],
// ]

symbolCreator.createSymbol('triangle', 13, 1).toArray()
// [
//     [0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0],
//     [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0],
//     [0, 0, 0, 0, 0, 1, 0, 1, 0, 0, 0, 0, 0],
//     [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0],
//     [0, 0, 0, 0, 1, 0, 0, 0, 1, 0, 0, 0, 0],
//     [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0],
//     [0, 0, 0, 1, 0, 0, 0, 0, 0, 1, 0, 0, 0],
//     [0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0],
//     [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0],
//     [0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0],
//     [0, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0],
//     [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0],
//     [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0],
// ]