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

PencilBrush SHIFT/straight line functionality #7034

Merged
merged 12 commits into from
Sep 9, 2021

Conversation

ShaMan123
Copy link
Contributor

@ShaMan123 ShaMan123 commented Apr 23, 2021

This PR adds the ability to draw a straight line when pressing the shift key or when setting drawStraightLine to true.

// Override `shift` functionality
brush._detach();

// Restore `shift` functionality
brush._attachKeyboardListeners();

// direct setter
brush.drawStraightLine = true;

Logic

When drawStraightLine = true the brush simply pops the last point and adds the new one

Live Example

@@ -246,7 +296,7 @@
var zoom = this.canvas.getZoom(), adjustedDistance = Math.pow(distance / zoom, 2),
i, l = points.length - 1, lastPoint = points[0], newPoints = [lastPoint],
cDistance;
for (i = 1; i < l; i++) {
for (i = 1; i <= l; i++) {
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Needs to be validated against #6966

Copy link
Contributor Author

Choose a reason for hiding this comment

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

It is why there's a merge conflict

Copy link
Member

Choose a reason for hiding this comment

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

so master is at < l -1 to fix a tail issue with decimate.
Why did you add the equal in?
If you explain we can solve the conflict.
But to me is not clear why this has changed.

Copy link
Contributor Author

@ShaMan123 ShaMan123 Aug 4, 2021

Choose a reason for hiding this comment

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

The logic of straight line pops the last point and push the last pointer.
When mouse up fires and drawStraightLine=true it decimated the end and removes the last straight line part.
I don't know/understand what decimate does so I don't want to propose anything but this can be mitigated by pushing another point on mouse up if drawStraightLine=true (I don't like it though)

Copy link
Contributor Author

Choose a reason for hiding this comment

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

@stale
Copy link

stale bot commented May 22, 2021

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.

@stale stale bot added the stale Issue marked as stale by the stale bot label May 22, 2021
@stale stale bot removed the stale Issue marked as stale by the stale bot label May 27, 2021
@stale
Copy link

stale bot commented Jun 10, 2021

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.

@stale stale bot added the stale Issue marked as stale by the stale bot label Jun 10, 2021
@stale stale bot closed this Jun 17, 2021
@ShaMan123
Copy link
Contributor Author

this should be merged

@ShaMan123
Copy link
Contributor Author

@asturur please re open and merge

@asturur asturur added feature and removed stale Issue marked as stale by the stale bot labels Jul 26, 2021
@asturur asturur reopened this Jul 26, 2021
@asturur asturur self-assigned this Jul 26, 2021
@asturur
Copy link
Member

asturur commented Sep 9, 2021

Sorry this PR was good after my conflict resolve, eventually waiting for tests to pass i forgot about it.

@asturur asturur merged commit c5102a1 into fabricjs:master Sep 9, 2021
@asturur asturur mentioned this pull request Jan 26, 2022
@ShaMan123 ShaMan123 deleted the brush-shift branch September 12, 2022 00:00
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants