-
-
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): migrate brushes #8182
Conversation
Code Coverage Summary
|
Code Coverage Summary
|
Code Coverage Summary
|
Code Coverage Summary
|
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.
See comments for major changes
I propose we add an options object in the constructor passing initial state. I have been wanting this for a while
READY
@@ -93,5 +88,7 @@ import './src/mixins/itext_key_behavior.mixin'; // optional itext | |||
import './src/mixins/itext.svg_export'; // optional itext | |||
import './src/shapes/textbox.class'; // optional textbox | |||
import './src/mixins/default_controls'; // optional interaction | |||
|
|||
import './src/brushes'; // optional freedrawing |
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.
moved to end because brushes depend on shapes
const canvas = this.canvas, | ||
shadow = this.shadow, | ||
ctx = canvas.contextTop, | ||
zoom = canvas.getZoom() * canvas.getRetinaScaling(); |
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.
changed this line
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.
yes but it should be 100% equivalent
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.
It should
src/brushes/base_brush.class.ts
Outdated
*/ | ||
canvas | ||
|
||
constructor(canvas) { |
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.
How about accepting options?
*/ | ||
export type Shadow = any; | ||
export type Canvas = any; | ||
export type Rect = any; |
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.
transient types
* @param {(string|number)[][]} pathData SVG path commands | ||
* @returns {boolean} | ||
*/ | ||
_isEmptySVGPath: function (pathData) { |
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.
extracted to standalone function
* @private | ||
* @param {Object} pointer Actual mouse position related to the canvas. | ||
*/ | ||
_captureDrawingPath: function(pointer) { |
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.
removed
this was a redundant wrapper around _addPoint
Code Coverage Summary
|
I have no issue with adding initial state to a brush ( even if it can probably be done outisde the constructor ). |
I don't mind waiting and returning to it later. |
Code Coverage Summary
|
let's merge this. enough changes for one iteration |
yes this will get merge with no additional changes today. This should let current brushes work as they are working today, but would also allow brushes to work on clicks and collect points like to build a polygon and end when the polygon is closed or end on dblclick. It doesn't change much but offer so much more flexibility. |
sounds great |
I will migrate eraser on a separate PR
It will wait...