-
-
Notifications
You must be signed in to change notification settings - Fork 3.6k
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
Changes from all commits
Commits
Show all changes
8 commits
Select commit
Hold shift + click to select a range
b5b5126
abstract methods + tidyup
ShaMan123 c536ecb
Update base_brush.class.ts
ShaMan123 faf374e
Update CHANGELOG.md
ShaMan123 2558035
Update base_brush.class.ts
ShaMan123 e6d81f3
Merge branch 'master' into brushes-patch
asturur a43e7aa
fix merge
asturur f9bc28b
Merge branch 'master' into brushes-patch
asturur 515ea18
Merge branch 'master' into brushes-patch
asturur File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,9 +1,12 @@ | ||
import { fabric } from '../../HEADER'; | ||
import { Color } from '../color'; | ||
import { Point } from '../point.class'; | ||
import type { Point } from '../point.class'; | ||
import { TEvent } from '../EventTypeDefs'; | ||
import type { Shadow } from '../shadow.class'; | ||
import { Canvas } from '../__types__'; | ||
|
||
type TBrushEventData = TEvent & { pointer: Point }; | ||
|
||
/** | ||
* @see {@link http://fabricjs.com/freedrawing|Freedrawing demo} | ||
*/ | ||
|
@@ -76,6 +79,14 @@ export abstract class BaseBrush { | |
this.canvas = canvas; | ||
} | ||
|
||
abstract _render(): void; | ||
abstract onMouseDown(pointer: Point, ev: TBrushEventData): void; | ||
abstract onMouseMove(pointer: Point, ev: TBrushEventData): void; | ||
/** | ||
* @returns true if brush should continue blocking interaction | ||
*/ | ||
abstract onMouseUp(ev: TBrushEventData): boolean | void; | ||
|
||
/** | ||
* Sets brush styles | ||
* @private | ||
|
@@ -101,6 +112,11 @@ export abstract class BaseBrush { | |
ctx.transform(v[0], v[1], v[2], v[3], v[4], v[5]); | ||
} | ||
|
||
protected needsFullRender() { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe 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 | ||
|
@@ -121,11 +137,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 | ||
|
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I want to make all signature the same
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Let's plan the new api directly.