1234567891011121314151617181920212223242526272829303132333435363738 |
- module.exports = class SpaceImageFormatLayer {
-
- constructor(layerWidth, layerHeight, rawData) {
-
- this.width = layerWidth;
-
- this.height = layerHeight;
-
- this._rawData = rawData;
-
- this.rows = this._parseLayerData(rawData);
- }
-
- _parseLayerData(rawData) {
- const rows = [];
- const rowSplit = new RegExp(`(\\d{${this.width}})`, "g");
- const tempRows = rawData.split(rowSplit).filter((r) => !!r);
- tempRows.forEach((row) => {
- rows.push(row.split("").map((pixel) => Number(pixel)));
- });
- return rows;
- }
- };
|