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.
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.
Hi,
I've been recreating the official demo sketches with an existing canvas (my repo) with
CanvasForm(ctx)
without usingCanvasSpace
and ran into some issues with methods.Upon looking at the
Canvas.ts
source code, I noticed the 3 methods below make use ofthis.ctx
, notthis._ctx
that are used by all the other methods.form.composite()
form.gradient()
form.clip()
this.ctx
comes from Canvas.ts line:499:but
CanavsForm(ctx)
created with an existing context does not havethis._space
initialized. (Canvas.ts line 478)I think the quick fix might be just updating
this.ctx
tothis._ctx
or add a check insideget ctx()
although I am not familiar enough with the library yet to know what other issues might be down the line. When I subclassCanvasForm
and overwritegradient()
it worked for me.Thank you!