CanvasForm(ctx) methods error.
cdaein opened this issue · 3 comments
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!
Thank you so much, @cdaein - good catch! I'll make a patch for this.
Patched in v0.10.12. Give it a try :)
Thank you for the quick fixes! It's working fine now. 🙏