mirror of
https://github.com/lospec/pixel-editor.git
synced 2023-08-10 21:12:51 +03:00
Added back eraser tool
This commit is contained in:
@ -1,16 +1,14 @@
|
||||
class BrushTool extends Tool {
|
||||
constructor(name, options) {
|
||||
constructor(name, options, switchFunction) {
|
||||
super(name, options);
|
||||
|
||||
// Selection button, brush size buttons
|
||||
Events.on('click',"pencil-button", this.onSelect);
|
||||
Events.on('click',"pencil-bigger-button", this.increaseSize.bind(this));
|
||||
Events.on('click',"pencil-smaller-button", this.decreaseSize.bind(this));
|
||||
Events.on('click', this.mainButton, switchFunction, this);
|
||||
Events.on('click', this.biggerButton, this.increaseSize.bind(this));
|
||||
Events.on('click', this.smallerButton, this.decreaseSize.bind(this));
|
||||
}
|
||||
|
||||
onStart(mousePos) {
|
||||
super.onStart(mousePos);
|
||||
this.startMousePos = mousePos;
|
||||
}
|
||||
|
||||
onDrag(mousePos, cursorTarget) {
|
||||
@ -35,4 +33,12 @@ class BrushTool extends Tool {
|
||||
super.onEnd(mousePos);
|
||||
this.endMousePos = mousePos;
|
||||
}
|
||||
|
||||
onSelect() {
|
||||
super.onSelect();
|
||||
}
|
||||
|
||||
onDeselect() {
|
||||
super.onDeselect();
|
||||
}
|
||||
}
|
@ -0,0 +1,44 @@
|
||||
class EraserTool extends Tool {
|
||||
constructor(name, options, switchFunction) {
|
||||
super(name, options);
|
||||
|
||||
Events.on('click', this.mainButton, switchFunction, this);
|
||||
Events.on('click', this.biggerButton, this.increaseSize.bind(this));
|
||||
Events.on('click', this.smallerButton, this.decreaseSize.bind(this));
|
||||
}
|
||||
|
||||
onStart(mousePos) {
|
||||
super.onStart(mousePos);
|
||||
}
|
||||
|
||||
onDrag(mousePos, cursorTarget) {
|
||||
super.onDrag(mousePos);
|
||||
|
||||
if (cursorTarget === undefined)
|
||||
return;
|
||||
//draw line to current pixel
|
||||
if (cursorTarget.className == 'drawingCanvas' || cursorTarget.className == 'drawingCanvas') {
|
||||
line(Math.floor(this.prevMousePos[0]/zoom),
|
||||
Math.floor(this.prevMousePos[1]/zoom),
|
||||
Math.floor(this.currMousePos[0]/zoom),
|
||||
Math.floor(this.currMousePos[1]/zoom),
|
||||
this.currSize
|
||||
);
|
||||
}
|
||||
|
||||
currentLayer.updateLayerPreview();
|
||||
}
|
||||
|
||||
onEnd(mousePos) {
|
||||
super.onEnd(mousePos);
|
||||
this.endMousePos = mousePos;
|
||||
}
|
||||
|
||||
onSelect() {
|
||||
super.onSelect();
|
||||
}
|
||||
|
||||
onDeselect() {
|
||||
super.onDeselect();
|
||||
}
|
||||
}
|
@ -1,11 +1,3 @@
|
||||
new Tool('eraser', {
|
||||
cursor: 'none',
|
||||
brushPreview: true,
|
||||
});
|
||||
new Tool('resizeeraser', {
|
||||
cursor: 'default',
|
||||
});
|
||||
|
||||
new Tool('eyedropper', {
|
||||
imageCursor: 'eyedropper',
|
||||
});
|
||||
@ -29,13 +21,6 @@ new Tool('pan', {
|
||||
},
|
||||
});
|
||||
|
||||
new Tool('pencil', {
|
||||
cursor: 'none',
|
||||
brushPreview: true,
|
||||
});
|
||||
new Tool('resizebrush', {
|
||||
cursor: 'default',
|
||||
});
|
||||
|
||||
new Tool('rectangle', {
|
||||
cursor: 'none',
|
||||
@ -61,9 +46,4 @@ new Tool('moveselection', {
|
||||
|
||||
new Tool('zoom', {
|
||||
imageCursor: 'zoom-in',
|
||||
});
|
||||
|
||||
//set a default tool
|
||||
// REFACTOR: move to FileManager
|
||||
var currentTool = tool.pencil;
|
||||
var currentToolTemp = tool.pencil;
|
||||
});
|
Reference in New Issue
Block a user