PCanvasHTML constructor
PCanvasHTML(
- int width,
- int height,
- PCanvasPainter painter, {
- PCanvasPixels? initialPixels,
Implementation
PCanvasHTML(int width, int height, this.painter,
{PCanvasPixels? initialPixels})
: super.impl() {
_canvas = CanvasElement(width: width, height: height);
_ctx = (_canvas.getContext('2d', {'willReadFrequently': true})
as CanvasRenderingContext2D?) ??
_canvas.context2D;
// Saves the initial drawing state to allow `_resetCtx`.
_ctx.save();
_initialStateExtra = PCanvasHTMLStateExtra._(_ctx);
_setFont(PFont('Arial', 14));
_setStrokeStyle(PStyle(color: PColor.colorBlack, size: 1));
_setFillStyle(PStyle(color: PColor.colorWhite));
_canvas.onMouseDown.listen(_onMouseDown);
_canvas.onMouseMove.listen(_onMouseMove);
_canvas.onMouseUp.listen(_onMouseUp);
_canvas.onClick.listen(_onClick);
window.onKeyDown.listen(_onKeyDown);
window.onKeyUp.listen(_onKeyUp);
window.onKeyPress.listen(_onKey);
_canvasRelations[_canvas] = this;
_resizeObserver.observe(_canvas);
_setup();
_initialize(initialPixels);
}