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

refactor(): Pattern Gradient transform #8263

Open
wants to merge 119 commits into
base: master
Choose a base branch
from
Open

Conversation

ShaMan123
Copy link
Contributor

@ShaMan123 ShaMan123 commented Sep 8, 2022

First merge #8255, update from master
This PR refactors how fabric transforms patterns and gradients by using the native Pattern#setTransform and refactoring logic to allow a simpler solution for Gradient than what was before.

We can consider enhancing perf by keeping a ref to the live pattern/gradient and invalidating it when one of the values change. This PR makes it possible to keep the ref even if the patternTransform changes.

fixes #5506 (added 2 visual tests)

ts-pattern...gradient-transform

Changes

  • .browserslistrc: bump chrome version, see MDN
  • HEADER.js: expose DOMMatrix from node-canvas for Pattern#setTransform
  • bump node-canvas for Pattern#SetTransform
  • src/Filler.ts: create base class Filler, a delegate that is in charge of preparing ctx for gradient/pattern fill/stroke
  • stops using pattern to achieve gradient transform
  • removed _setStrokeStyles
  • removed _setFillStyles
  • removed _applyPatternForTransformedGradient
  • removed _applyPatternGradientTransform
  • tests: added sinon for stubbing etc.
  • Point: removed type for usage as a spread object { ...point } (type is a sensitive word in fabric)
  • BREAKING: canvas gradient now aligned to new behavior (it seems that someone with superb linear algebra skills can tell us the representing matrix of the diff, not me unfortunately. However it seems that the new transform makes sense - a gradient defined by a vector in the x axis direction can be affected only by scaleX, skewY - see tests)

Follow Up

Copy link
Contributor Author

@ShaMan123 ShaMan123 left a comment

Choose a reason for hiding this comment

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

I have made major progress but I am stuck in the transform matrix calculation.
Help is needed

@stale
Copy link

stale bot commented Oct 15, 2022

This pull request 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.

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.

Problems with pattern fill on fabric.Text using patternTransform
2 participants