mirror of
https://github.com/lospec/pixel-editor.git
synced 2023-08-10 21:12:51 +03:00
Started tool tutorials
This commit is contained in:
@ -19,7 +19,7 @@ class MagicWandTool extends SelectionTool {
|
||||
getSelection() {
|
||||
let coords = [Math.floor(this.endMousePos[0]), Math.floor(this.endMousePos[1])];
|
||||
let data = currFile.currentLayer.context.getImageData(0, 0, currFile.canvasSize[0], currFile.canvasSize[1]).data;
|
||||
let index = (coords[1] * currFile.canvasSize[1] + coords[0]) * 4;
|
||||
let index = (coords[1] * currFile.canvasSize[0] + coords[0]) * 4;
|
||||
let color = [data[index], data[index+1], data[index+2], data[index+3]];
|
||||
let selectedData = new ImageData(currFile.canvasSize[0], currFile.canvasSize[1]);
|
||||
|
||||
@ -28,7 +28,7 @@ class MagicWandTool extends SelectionTool {
|
||||
|
||||
for (const pixel in this.currSelection) {
|
||||
let coords = [parseInt(pixel.split(",")[0]), parseInt(pixel.split(",")[1])];
|
||||
let index = (currFile.canvasSize[1] * coords[1] + coords[0]) * 4;
|
||||
let index = (currFile.canvasSize[0] * coords[1] + coords[0]) * 4;
|
||||
|
||||
selectedData[index] = color[0];
|
||||
selectedData[index+1] = color[1];
|
||||
|
@ -94,7 +94,7 @@ class SelectionTool extends Tool {
|
||||
for (const key in this.currSelection) {
|
||||
let x = parseInt(key.split(",")[0]);
|
||||
let y = parseInt(key.split(",")[1]);
|
||||
let index = (y * currFile.canvasSize[1] + x) * 4;
|
||||
let index = (y * currFile.canvasSize[0] + x) * 4;
|
||||
|
||||
for (let i=0; i<4; i++) {
|
||||
// Save the pixel
|
||||
|
Reference in New Issue
Block a user