-
-
Notifications
You must be signed in to change notification settings - Fork 56
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
[RFC]: Add Testing Feature ctx.__getClipRegion() #54
Comments
Right. So implementing this feature isn't exactly a couple hours of work, but it should be doable. The problem is definitely that save and restore make this implementation quite complicated. I am happy to help add this feature, but I'd rather mentor someone to learn how to help maintain this software through pair programming. Is this something that interests you? |
The problem with the
|
I'm still trying to think how this should be accomplished, becuase it's not exactly obvious what instructions should be copied over into a The clip function essentially "closes" the path. So I think the Also, if more instructions are added to the path and it is clipped before it's reset with ctx.beginPath();
ctx.arc(1, 2, 3, 4, 5);
ctx.clip(); // copy the previous instructions
ctx.rect(1, 2, 3, 4);
ctx.clip(); // only copy the rect and the current clip It seems that this might require keeping track of a written index inside the path buffer for the clipping region. |
I will probably start development on this next week, and do a minor version bump. |
Hello,
According to...
https://developer.mozilla.org/en-US/docs/Web/API/CanvasRenderingContext2D/save
... the clipping region is also involved in
ctx.save()
andctx.restore()
operations, but that seems not to be implemented injest-canvas-mock
.A very easy solution to this would be to create a
_clipStack
object on the main class to keep the saved clips. Not sure though which should be the initial clip (on the bottom of the stack).PS: sorry to open so many issues lately, but this library is a fine piece of work even more incredible after solving those small issues 👌. Thank you!
The text was updated successfully, but these errors were encountered: