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

CanvasForm(ctx) methods error. #186

Closed
cdaein opened this issue Jun 13, 2022 · 3 comments
Closed

CanvasForm(ctx) methods error. #186

cdaein opened this issue Jun 13, 2022 · 3 comments

Comments

@cdaein
Copy link

cdaein commented Jun 13, 2022

Hi,

I've been recreating the official demo sketches with an existing canvas (my repo) with CanvasForm(ctx) without using CanvasSpace and ran into some issues with methods.

Upon looking at the Canvas.ts source code, I noticed the 3 methods below make use of this.ctx, not this._ctx that are used by all the other methods.

  • form.composite()
  • form.gradient()
  • form.clip()

this.ctx comes from Canvas.ts line:499:

get ctx():PtsCanvasRenderingContext2D { return this._space.ctx; }

but CanavsForm(ctx) created with an existing context does not have this._space initialized. (Canvas.ts line 478)

I think the quick fix might be just updating this.ctx to this._ctx or add a check inside get ctx() although I am not familiar enough with the library yet to know what other issues might be down the line. When I subclass CanvasForm and overwrite gradient() it worked for me.

Thank you!

@williamngan
Copy link
Owner

Thank you so much, @cdaein - good catch! I'll make a patch for this.

@williamngan
Copy link
Owner

Patched in v0.10.12. Give it a try :)

@cdaein
Copy link
Author

cdaein commented Jun 14, 2022

Thank you for the quick fixes! It's working fine now. 🙏

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants