Drawing.CanvasDevice

Static Type
Location: igium / Igium.Web / Drawing / Drawing.CanvasDevice

A primitive buffered drawing device that uses html canvas to draw raster and vector graphics.

Instance Constructor

Constructor Description
CanvasDevice(canvasElement: HTMLElement, width: Number, height: Number) initializes a new instance of the device; width and height set the size of the canvasElement in pixels

Methods

Method Description
this.lockVectorGraphics(): {} sets the device in a state that allows for vector graphics drawing; use the methods of the object returned to perform drawing; see the VectorGraphics object below
this.releaseVectorGraphics() sets the device in a no-drawing state
this.lockRasterGraphics(): {} sets the device in a state that allows for raster graphics drawing; use the methods of the object returned to perform drawing; see the RasterGraphics object below
this.releaseRasterGraphics() flushes the drawn image to the internal buffer and sets the device in a no-drawing state
this.flush() flushes the internal buffer to the screen

Properties

Method Description
this.setScale(value: Number) sets the scaling factor for the device; affects the drawing of both the vector and raster graphics
this.getScale(): Number gets the scaling factor for the device
this.setOrigin(offsetX: Number, offsetY: Number) sets the unscaled translation of the drawn image in pixels; affects the drawing of both the vector and raster graphics
this.getScaledOriginX(): Number gets the scaled translation X-delta
this.getScaledOriginY(): Number gets the scaled translation Y-delta

Objects

VectorGraphics

Methods

Method Description
vg.clear(fillStyle: String) clears the canvas; uses fillStype (HTML canvas fillStyle Property) to fill the empty canvas
vg.drawRect(x: Number, y: Number, width: Number, height: Number, strokeStyle: String) draws a rectangle; uses strokeStyle (HTML canvas strokeStyle Property) to fill the empty canvas; the coordinates and sizes are given in unscaled pixels

RasterGraphics

Methods

Method Description
rgsetPixel(x: Number, y: Number, r: Number, g: Number, b: Number, a: Number) sets the color of a single pixel; the coordiantes are given in unscaled pixels

Remarks

All drawing is done on the internal buffer. To make any drawing visible, use the flush method.

Unit tests: n/a