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,
23 dragonblocks.PixelManipulator = class{
27 for(let y = 0; y < arr.length; y++){
28 for(let x = 0; x < arr[y].length; x++){
29 if(arr[y][x][0] == "ยง"){
31 arr[y][x] = arr[y][x].slice(1, arr[y][x].length);
44 for(let pixel of this.content){
45 pixel.x = pixel.x - pos.x;
46 pixel.y = pixel.y - pos.y;
52 for(let pixel of this.content){
53 if(! dragonblocks.getNode(pixel.x + x, pixel.y + y))
56 for(let func of this.functions)
57 if(func(dragonblocks.getNode(pixel.x + x, pixel.y + y).toNode(), pixel.x + x, pixel.y + y, pixel.node) == false)
60 dragonblocks.setNode(pixel.x + x, pixel.y + y, pixel.node);
63 replace(toReplace, replaceWith){
64 for(let pixel of this.content){
65 if(pixel.node == toReplace)
66 pixel.node = replaceWith;
70 this.functions.push(func);
73 dragonblocks.getPixelManipulator = function(arr){
74 return new dragonblocks.PixelManipulator(arr);