Home

# Class goog.graphics.CanvasGraphics

A Graphics implementation for drawing using canvas.

extends goog.graphics.AbstractGraphics

Instance Method Summary
| `append(?goog.graphics.Element element, (goog.graphics.CanvasGroupElement|null|undefined) group)` Append an element.
| `append_(?goog.graphics.Element element, (goog.graphics.CanvasGroupElement|null|undefined) group)` Append an element.
| `clear()` Remove all drawing elements from the graphics.
| `clearContext_()` Clears the drawing context object in response to actions that make the old context invalid - namely resize of the canvas element.
| `createDom()` Creates the DOM representation of the graphics area.
| `createGroup(?goog.graphics.CanvasGroupElement= opt_group) ⇒ ?goog.graphics.CanvasGroupElement` Create an empty group of drawing elements.
| `disposeInternal()` Disposes of the component by removing event handlers, detacing DOM nodes from the document body, and removing references to them.
| `drawElement(?goog.graphics.Element element)` Draw an element, including any stroke or fill.
| `drawEllipse(number cx, number cy, number rx, number ry, ?goog.graphics.Stroke stroke, ?goog.graphics.Fill fill, ?goog.graphics.CanvasGroupElement= opt_group) ⇒ ?goog.graphics.EllipseElement` Draw an ellipse.
| `drawImage(number x, number y, number width, number height, string src, ?goog.graphics.CanvasGroupElement= opt_group) ⇒ ?goog.graphics.ImageElement` Draw an image.
| `drawPath(!goog.graphics.Path path, ?goog.graphics.Stroke stroke, ?goog.graphics.Fill fill, ?goog.graphics.CanvasGroupElement= opt_group) ⇒ ?goog.graphics.PathElement` Draw a path.
| `drawRect(number x, number y, number width, number height, ?goog.graphics.Stroke stroke, ?goog.graphics.Fill fill, ?goog.graphics.CanvasGroupElement= opt_group) ⇒ ?goog.graphics.RectElement` Draw a rectangle.
| `drawTextOnLine(string text, number x1, number y1, number x2, number y2, ?string align, !goog.graphics.Font font, ?goog.graphics.Stroke stroke, ?goog.graphics.Fill fill, ?goog.graphics.CanvasGroupElement= opt_group) ⇒ ?goog.graphics.TextElement` Draw a text string vertically centered on a given line.
| `enterDocument()` Called when the component's element is known to be in the document. Anything using document.getElementById etc. should be done at this stage. If the component contains child components, this call is propagated to its children.
| `getContext() ⇒ ?Object` Returns the drawing context.
| `getPixelSize() ⇒ ?goog.math.Size`
| `getTextWidth(string text, ?goog.graphics.Font font)` Measure and return the width (in pixels) of a given text string. Text measurement is needed to make sure a text can fit in the allocated area. The way text length is measured is by writing it into a div that is after the visible area, measure the div width, and immediatly erase the written value.
| `isDrawable(?goog.graphics.CanvasGroupElement group) ⇒ boolean`
| `isRedrawRequired(?goog.graphics.CanvasGroupElement group) ⇒ boolean` Returns true if drawing to the given group means a redraw is required.
| `popElementTransform()` Pop an element transform off of the transform stack.
| `pushElementTransform(?goog.graphics.Element element)` Push an element transform on to the transform stack.
| `redraw()` Redraw the entire canvas.
| `reset()` Reset the canvas.
| `resume()` Stop preventing redraws. If any redraws had been prevented, a redraw will be done now.
| `setCoordOrigin(number left, number top)` Changes the coordinate system position.
| `setCoordSize(number coordWidth, number coordHeight)` Changes the coordinate size.
| `setElementFill(?goog.graphics.StrokeAndFillElement element, ?goog.graphics.Fill fill)` Sets the fill for the given element.
| `setElementStroke(?goog.graphics.StrokeAndFillElement element, ?goog.graphics.Stroke stroke)` Sets the stroke for the given element.
| `setElementTransform(?goog.graphics.Element element, number x, number y, number angle, number centerX, number centerY)` Set the transformation of an element.
| `setSize(number pixelWidth, number pixelHeight)` Change the size of the canvas.
| `suspend()` Start preventing redraws - useful for chaining large numbers of changes together. Not guaranteed to do anything - i.e. only use this for optimization of a single code path.
| `updateSize()` Update the size of the canvas.