Skip to content

Documentation / @ripl/canvas / canvas2DStateMixin

Function: canvas2DStateMixin() ​

canvas2DStateMixin<TBase>(Base): AbstractConstructor<Canvas2DState> & TBase

Defined in: canvas/src/mixins.ts:152

Mixin applying the shared CanvasRenderingContext2D state plumbing (see Canvas2DState) to a Context base class. Concrete subclasses assign the protected context backing field (declared here, so constructor assignment is not clobbered by class-field initialization) and may override the protected gradientBounds() hook to change which bounding box gradients resolve against; the default is the current render element's local (untransformed) box.

Type Parameters ​

Type Parameter
TBase extends AbstractConstructor<Context<Element, Record<string, unknown>>>

Parameters ​

ParameterTypeDescription
BaseTBaseThe Context base class to extend (e.g. DOMContext<HTMLCanvasElement> or Context3D).

Returns ​

AbstractConstructor<Canvas2DState> & TBase

An abstract class combining Base with the shared canvas 2D state surface.