Skip to content

Commit

Permalink
toggle SharpenFilter
Browse files Browse the repository at this point in the history
  • Loading branch information
adamcanray committed Mar 28, 2024
1 parent 513b041 commit 055b280
Showing 1 changed file with 25 additions and 4 deletions.
29 changes: 25 additions & 4 deletions src/tools/filter.js
Original file line number Diff line number Diff line change
Expand Up @@ -342,6 +342,20 @@ export class Sharpen {
this.#app = app;
}

/**
* Associated filter.
*
* @type {object}
*/
#filter = new SharpenFilter();

/**
* Flag to know wether to reset the image or not.
*
* @type {boolean}
*/
#resetImage = true;

/**
* Listener handler.
*
Expand Down Expand Up @@ -371,12 +385,19 @@ export class Sharpen {
* @param {*} _args The filter arguments.
*/
run(_args) {
const filter = new SharpenFilter();
filter.setOriginalImage(this.#app.getLastImage());
const command = new RunFilterCommand(filter, this.#app);
const command = new RunFilterCommand(this.#filter, this.#app);
command.onExecute = this.#fireEvent;
command.onUndo = this.#fireEvent;
command.execute();

// reset the image if asked
if (this.#resetImage) {
this.#filter.setOriginalImage(this.#app.getLastImage());
this.#resetImage = false;
command.execute();
} else {
command.undo();
}

// save command in undo stack
this.#app.addToUndoStack(command);
}
Expand Down

0 comments on commit 055b280

Please sign in to comment.