Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

chore(TS): BaseBrush abstract methods #8428

Merged
merged 8 commits into from
Nov 27, 2022
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
19 changes: 12 additions & 7 deletions src/brushes/base_brush.class.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { fabric } from '../../HEADER';
import { Color } from '../color';
import { Point } from '../point.class';
import { Canvas, Shadow } from '../__types__';
import type { Point } from '../point.class';
import type { Canvas, Shadow } from '../__types__';

/**
* @see {@link http://fabricjs.com/freedrawing|Freedrawing demo}
Expand Down Expand Up @@ -75,6 +75,11 @@ export abstract class BaseBrush {
this.canvas = canvas;
}

abstract _render(): void;
abstract onMouseDown(pointer: Point): void;
abstract onMouseMove(pointer: Point): void;
abstract onMouseUp(pointer: Point): void;

/**
* Sets brush styles
* @private
Expand All @@ -100,6 +105,11 @@ export abstract class BaseBrush {
ctx.transform(v[0], v[1], v[2], v[3], v[4], v[5]);
}

protected needsFullRender() {
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

moved it because it was in between shadow methods

const color = new Color(this.color);
return color.getAlpha() < 1 || !!this.shadow;
}

/**
* Sets brush shadow styles
* @private
Expand All @@ -120,11 +130,6 @@ export abstract class BaseBrush {
ctx.shadowOffsetY = shadow.offsetY * zoom;
}

protected needsFullRender() {
const color = new Color(this.color);
return color.getAlpha() < 1 || !!this.shadow;
}

/**
* Removes brush shadow styles
* @private
Expand Down