4 * Copyright 2020 Elias Fleckenstein <eliasfleckenstein@web.de>
6 * This program is free software; you can redistribute it and/or modify
7 * it under the terms of the GNU General Public License as published by
8 * the Free Software Foundation; either version 2 of the License, or
9 * (at your option) any later version.
11 * This program is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 * GNU General Public License for more details.
16 * You should have received a copy of the GNU General Public License
17 * along with this program; if not, write to the Free Software
18 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
24 dragonblocks.Schematic = class
33 for (let y = 0; y < arr.length; y++) {
34 for (let x = 0; x < arr[y].length; x++) {
37 if (node[0] == "ยง") {
38 anchor = {x: x, y: y};
39 node = node.slice(1, node.length);
54 anchor = {x: 0, y: 0};
56 for (let pixel of this.data) {
57 pixel.x = pixel.x - anchor.x;
58 pixel.y = pixel.y - anchor.y;
64 for (let pixel of this.data) {
69 let node = dragonblocks.getNode(mx, my);
73 let nodeDef = node.toNode();
77 for (let func of this.functions) {
78 if (func(nodeDef, mx, my, pixel.node) == false) {
85 dragonblocks.setNode(mx, my, pixel.node);
91 replace(toReplace, replaceWith)
93 for (let pixel of this.data)
94 if (pixel.node == toReplace)
95 pixel.node = replaceWith;
102 this.functions.push(func);