CanvasGraphic Class
Canvas implementation of the Graphic class.
CanvasGraphic is not intended to be used directly. Instead, use the Graphic class.
If the browser lacks SVG capabilities but has
Canvas capabilities, the Graphic
class will point to the CanvasGraphic class.
Item Index
Methods
Properties
Attributes
Methods
_appendShape
    
        - 
                    
                        
shape 
Adds a shape instance to the graphic instance.
Parameters:
- 
                    
                        
shapeShapeThe shape instance to be added to the graphic.
 
_calculateTranslate
    
        - 
                    
                        
position - 
                    
                        
contentSize - 
                    
                        
boundsSize 
Determines the value for either an x or y value to be used for the translate of the Graphic.
Parameters:
Returns:
Number
_getDocFrag
    
        ()
    
    
        
            
        
    
    
    
        private
    
    
    
    
    
    
    Returns a document fragment to for attaching shapes.
Returns:
DocumentFragment
_getShapeClass
    
        - 
                    
                        
val 
Returns a shape class. Used by addShape.
Returns:
Function
_getUpdatedContentBounds
    
        ()
    
    
        
            Object
        
    
    
    
        private
    
    
    
    
    
    
    Recalculates and returns the contentBounds for the Graphic instance.
Returns:
_redraw
    
        ()
    
    
    
    
        private
    
    
    
    
    
    
    Redraws all shapes.
_toBack
    
        - 
                    
                        
Shape 
Inserts shape as the first child of the content node.
Parameters:
- 
                    
                        
ShapeCanvasShapeto add.
 
_toFront
    
        - 
                    
                        
Shape 
Inserts shape on the top of the tree.
Parameters:
- 
                    
                        
ShapeCanvasShapeto add.
 
addShape
    
        - 
                    
                        
cfg 
Generates a shape instance by type.
Parameters:
- 
                    
                        
cfgObjectattributes for the shape
 
Returns:
Shape
addToRedrawQueue
    
        - 
                    
                        
Shape 
Adds a shape to the redraw queue and calculates the contentBounds. Used internally
by Shape instances.
Parameters:
- 
                    
                        
ShapeObjectshape The shape instance to add to the queue
 
batch
    
        - 
                    
                        
method 
Allows for creating multiple shapes in order to batch appending and redraw operations.
Parameters:
- 
                    
                        
methodFunctionMethod to execute.
 
clear
    
        ()
    
    
    
    
    
    
    
    
    
    Clears the graphics object.
destroy
    
        ()
    
    
    
    
    
    
    
    
    
    Removes all nodes.
getShapeById
    
        - 
                    
                        
id 
Returns a shape based on the id of its dom node.
Parameters:
- 
                    
                        
idStringDom id of the shape's node attribute.
 
Returns:
Shape
getXY
    
        ()
    
    
        
            
        
    
    
    
    
    
    
    
    
    Gets the current position of the graphic instance in page coordinates.
Returns:
Array The XY position of the shape.
removeAllShapes
    
        ()
    
    
    
    
    
    
    
    
    
    Removes all shape instances from the dom.
removeShape
    
        - 
                    
                        
shape 
Removes a shape instance from from the graphic instance.
render
    
        - 
                    
                        
parentNode 
Adds the graphics node to the dom.
Parameters:
- 
                    
                        
parentNodeHTMLElementnode in which to render the graphics node into.
 
set
    
        - 
                    
                        
name - 
                    
                        
value 
Sets the value of an attribute.
Properties
_shapeClass
    Object
    
    
        private
    
    
    
    
    Look up for shape classes. Used by addShape to retrieve a class for instantiation.
Attributes
autoDraw
    Boolean
    
    
        private
    
    
    
    
    
    
    
    Indicates whether or not the instance will automatically redraw after a change is made to a shape. This property will get set to false when batching operations.
Default: true
autoSize
    Boolean | String
    
    
    
    
    
    
    
    
    Determines the sizing of the Graphic.
- sizeContentToGraphic
 - The Graphic's width and height attributes are, either explicitly set through the
    
widthandheightattributes or are determined by the dimensions of the parent element. The content contained in the Graphic will be sized to fit with in the Graphic instance's dimensions. When using this setting, thepreserveAspectRatioattribute will determine how the contents are sized. - sizeGraphicToContent
 - (Also accepts a value of true) The Graphic's width and height are determined by the size and positioning of the content.
 - false
 - The Graphic's width and height attributes are, either explicitly set through the 
widthandheightattributes or are determined by the dimensions of the parent element. The contents of the Graphic instance are not affected by this setting. 
Default: false
contentBounds
    Object
    
    
    
    
    
    
    
        readonly
    
    
    Object containing size and coordinate data for the content of a Graphic in relation to the graphic instance's position.
preserveAspectRatio
    String
    
    
    
    
    
    
    
    
    Determines how content is sized when autoSize is set to sizeContentToGraphic.
- none
 - Do not force uniform scaling. Scale the graphic content of the given element non-uniformly if necessary such that the element's bounding box exactly matches the viewport rectangle.
 - xMinYMin
 - Force uniform scaling position along the top left of the Graphic's node.
 - xMidYMin
 - Force uniform scaling horizontally centered and positioned at the top of the Graphic's node.
 - xMaxYMin
 - Force uniform scaling positioned horizontally from the right and vertically from the top.
 - xMinYMid Force uniform scaling positioned horizontally from the left and vertically centered.
 - xMidYMid (the default)
 - Force uniform scaling with the content centered.
 - xMaxYMid
 - Force uniform scaling positioned horizontally from the right and vertically centered.
 - xMinYMax
 - Force uniform scaling positioned horizontally from the left and vertically from the bottom.
 - xMidYMax
 - Force uniform scaling horizontally centered and position vertically from the bottom.
 - xMaxYMax
 - Force uniform scaling positioned horizontally from the right and vertically from the bottom.
 
Default: xMidYMid
render
    Node | String
    
    
    
    
    
    
    
    
    Whether or not to render the Graphic automatically after to a specified parent node after init. This can be a Node
instance or a CSS selector string.
resizeDown
    Boolean
    
    
    
    
    
    
    
    
    The contentBounds will resize to greater values but not smaller values. (for performance) When resizing the contentBounds down is desirable, set the resizeDown value to true.
