happstack-yui-7371.5.0: bundle/graphics-canvas/graphics-canvas-coverage.js
/*
YUI 3.7.1 (build 5627)
Copyright 2012 Yahoo! Inc. All rights reserved.
Licensed under the BSD License.
http://yuilibrary.com/license/
*/
if (typeof _yuitest_coverage == "undefined"){
_yuitest_coverage = {};
_yuitest_coverline = function(src, line){
var coverage = _yuitest_coverage[src];
if (!coverage.lines[line]){
coverage.calledLines++;
}
coverage.lines[line]++;
};
_yuitest_coverfunc = function(src, name, line){
var coverage = _yuitest_coverage[src],
funcId = name + ":" + line;
if (!coverage.functions[funcId]){
coverage.calledFunctions++;
}
coverage.functions[funcId]++;
};
}
_yuitest_coverage["build/graphics-canvas/graphics-canvas.js"] = {
lines: {},
functions: {},
coveredLines: 0,
calledLines: 0,
coveredFunctions: 0,
calledFunctions: 0,
path: "build/graphics-canvas/graphics-canvas.js",
code: []
};
_yuitest_coverage["build/graphics-canvas/graphics-canvas.js"].code=["YUI.add('graphics-canvas', function (Y, NAME) {","","var IMPLEMENTATION = \"canvas\","," SHAPE = \"shape\","," SPLITPATHPATTERN = /[a-z][^a-z]*/ig,"," SPLITARGSPATTERN = /[-]?[0-9]*[0-9|\\.][0-9]*/g,"," DOCUMENT = Y.config.doc,"," Y_LANG = Y.Lang,"," AttributeLite = Y.AttributeLite,"," CanvasShape,"," CanvasPath,"," CanvasRect,"," CanvasEllipse,"," CanvasCircle,"," CanvasPieSlice,"," Y_DOM = Y.DOM,"," Y_Color = Y.Color,"," PARSE_INT = parseInt,"," PARSE_FLOAT = parseFloat,"," IS_NUMBER = Y_LANG.isNumber,"," RE = RegExp,"," TORGB = Y_Color.toRGB,"," TOHEX = Y_Color.toHex,"," _getClassName = Y.ClassNameManager.getClassName;","","/**"," * <a href=\"http://www.w3.org/TR/html5/the-canvas-element.html\">Canvas</a> implementation of the <a href=\"Drawing.html\">`Drawing`</a> class. "," * `CanvasDrawing` is not intended to be used directly. Instead, use the <a href=\"Drawing.html\">`Drawing`</a> class. "," * If the browser lacks <a href=\"http://www.w3.org/TR/SVG/\">SVG</a> capabilities but has "," * <a href=\"http://www.w3.org/TR/html5/the-canvas-element.html\">Canvas</a> capabilities, the <a href=\"Drawing.html\">`Drawing`</a> "," * class will point to the `CanvasDrawing` class."," *"," * @module graphics"," * @class CanvasDrawing"," * @constructor"," */","function CanvasDrawing()","{","}","","CanvasDrawing.prototype = {"," /**"," * Maps path to methods"," *"," * @property _pathSymbolToMethod"," * @type Object"," * @private"," */"," _pathSymbolToMethod: {"," M: \"moveTo\","," m: \"relativeMoveTo\","," L: \"lineTo\","," l: \"relativeLineTo\","," C: \"curveTo\","," c: \"relativeCurveTo\","," Q: \"quadraticCurveTo\","," q: \"relativeQuadraticCurveTo\","," z: \"closePath\","," Z: \"closePath\""," },",""," /**"," * Current x position of the drawing."," *"," * @property _currentX"," * @type Number"," * @private"," */"," _currentX: 0,",""," /**"," * Current y position of the drqwing."," *"," * @property _currentY"," * @type Number"," * @private"," */"," _currentY: 0,"," "," /**"," * Parses hex color string and alpha value to rgba"," *"," * @method _toRGBA"," * @param {Object} val Color value to parse. Can be hex string, rgb or name."," * @param {Number} alpha Numeric value between 0 and 1 representing the alpha level."," * @private"," */"," _toRGBA: function(val, alpha) {"," alpha = (alpha !== undefined) ? alpha : 1;"," if (!Y_Color.re_RGB.test(val)) {"," val = TOHEX(val);"," }",""," if(Y_Color.re_hex.exec(val)) {"," val = 'rgba(' + ["," PARSE_INT(RE.$1, 16),"," PARSE_INT(RE.$2, 16),"," PARSE_INT(RE.$3, 16)"," ].join(',') + ',' + alpha + ')';"," }"," return val;"," },",""," /**"," * Converts color to rgb format"," *"," * @method _toRGB"," * @param val Color value to convert."," * @private "," */"," _toRGB: function(val) {"," return TORGB(val);"," },",""," /**"," * Sets the size of the graphics object."," * "," * @method setSize"," * @param w {Number} width to set for the instance."," * @param h {Number} height to set for the instance."," * @private"," */"," setSize: function(w, h) {"," if(this.get(\"autoSize\"))"," {"," if(w > this.node.getAttribute(\"width\"))"," {"," this.node.style.width = w + \"px\";"," this.node.setAttribute(\"width\", w);"," }"," if(h > this.node.getAttribute(\"height\"))"," {"," this.node.style.height = h + \"px\";"," this.node.setAttribute(\"height\", h);"," }"," }"," },"," "," /**"," * Tracks coordinates. Used to calculate the start point of dashed lines. "," *"," * @method _updateCoords"," * @param {Number} x x-coordinate"," * @param {Number} y y-coordinate"," * @private"," */"," _updateCoords: function(x, y)"," {"," this._xcoords.push(x);"," this._ycoords.push(y);"," this._currentX = x;"," this._currentY = y;"," },",""," /**"," * Clears the coordinate arrays. Called at the end of a drawing operation. "," * "," * @method _clearAndUpdateCoords"," * @private"," */"," _clearAndUpdateCoords: function()"," {"," var x = this._xcoords.pop() || 0,"," y = this._ycoords.pop() || 0;"," this._updateCoords(x, y);"," },",""," /**"," * Moves the shape's dom node."," *"," * @method _updateNodePosition"," * @private"," */"," _updateNodePosition: function()"," {"," var node = this.get(\"node\"),"," x = this.get(\"x\"),"," y = this.get(\"y\"); "," node.style.position = \"absolute\";"," node.style.left = (x + this._left) + \"px\";"," node.style.top = (y + this._top) + \"px\";"," },"," "," /**"," * Queues up a method to be executed when a shape redraws."," *"," * @method _updateDrawingQueue"," * @param {Array} val An array containing data that can be parsed into a method and arguments. The value at zero-index of the array is a string reference of"," * the drawing method that will be called. All subsequent indices are argument for that method. For example, `lineTo(10, 100)` would be structured as:"," * `[\"lineTo\", 10, 100]`."," * @private"," */"," _updateDrawingQueue: function(val)"," {"," this._methods.push(val);"," },"," "," /**"," * Draws a line segment from the current drawing position to the specified x and y coordinates."," * "," * @method lineTo"," * @param {Number} point1 x-coordinate for the end point."," * @param {Number} point2 y-coordinate for the end point."," */"," lineTo: function()"," {"," this._lineTo.apply(this, [Y.Array(arguments), false]);"," },",""," /**"," * Draws a line segment from the current drawing position to the relative x and y coordinates."," * "," * @method lineTo"," * @param {Number} point1 x-coordinate for the end point."," * @param {Number} point2 y-coordinate for the end point."," */"," relativeLineTo: function()"," {"," this._lineTo.apply(this, [Y.Array(arguments), true]);"," },",""," /**"," * Implements lineTo methods."," *"," * @method _lineTo"," * @param {Array} args The arguments to be used."," * @param {Boolean} relative Indicates whether or not to use relative coordinates."," * @private"," */"," _lineTo: function(args, relative) "," {"," var point1 = args[0], "," i, "," len,"," x,"," y,"," wt = this._stroke && this._strokeWeight ? this._strokeWeight : 0,"," relativeX = relative ? parseFloat(this._currentX) : 0,"," relativeY = relative ? parseFloat(this._currentY) : 0;"," if(!this._lineToMethods)"," {"," this._lineToMethods = [];"," }"," len = args.length - 1;"," if (typeof point1 === 'string' || typeof point1 === 'number') {"," for (i = 0; i < len; i = i + 2) {"," x = parseFloat(args[i]);"," y = parseFloat(args[i + 1]);"," x = x + relativeX;"," y = y + relativeY;"," this._updateDrawingQueue([\"lineTo\", x, y]);"," this._trackSize(x - wt, y - wt);"," this._trackSize(x + wt, y + wt);"," this._updateCoords(x, y);"," }"," }"," else"," {"," for (i = 0; i < len; i = i + 1) "," {"," x = parseFloat(args[i][0]);"," y = parseFloat(args[i][1]);"," this._updateDrawingQueue([\"lineTo\", x, y]);"," this._lineToMethods[this._lineToMethods.length] = this._methods[this._methods.length - 1];"," this._trackSize(x - wt, y - wt);"," this._trackSize(x + wt, y + wt);"," this._updateCoords(x, y);"," }"," }"," this._drawingComplete = false;"," return this;"," },",""," /**"," * Moves the current drawing position to specified x and y coordinates."," *"," * @method moveTo"," * @param {Number} x x-coordinate for the end point."," * @param {Number} y y-coordinate for the end point."," */"," moveTo: function()"," {"," this._moveTo.apply(this, [Y.Array(arguments), false]);"," },",""," /**"," * Moves the current drawing position relative to specified x and y coordinates."," *"," * @method relativeMoveTo"," * @param {Number} x x-coordinate for the end point."," * @param {Number} y y-coordinate for the end point."," */"," relativeMoveTo: function()"," {"," this._moveTo.apply(this, [Y.Array(arguments), true]);"," },",""," /**"," * Implements moveTo methods."," *"," * @method _moveTo"," * @param {Array} args The arguments to be used."," * @param {Boolean} relative Indicates whether or not to use relative coordinates."," * @private"," */"," _moveTo: function(args, relative) {"," var wt = this._stroke && this._strokeWeight ? this._strokeWeight : 0,"," relativeX = relative ? parseFloat(this._currentX) : 0,"," relativeY = relative ? parseFloat(this._currentY) : 0,"," x = parseFloat(args[0]) + relativeX,"," y = parseFloat(args[1]) + relativeY;"," this._updateDrawingQueue([\"moveTo\", x, y]);"," this._trackSize(x - wt, y - wt);"," this._trackSize(x + wt, y + wt);"," this._updateCoords(x, y);"," this._drawingComplete = false;"," return this;"," },"," "," /**"," * Draws a bezier curve."," *"," * @method curveTo"," * @param {Number} cp1x x-coordinate for the first control point."," * @param {Number} cp1y y-coordinate for the first control point."," * @param {Number} cp2x x-coordinate for the second control point."," * @param {Number} cp2y y-coordinate for the second control point."," * @param {Number} x x-coordinate for the end point."," * @param {Number} y y-coordinate for the end point."," */"," curveTo: function() {"," this._curveTo.apply(this, [Y.Array(arguments), false]);"," },",""," /**"," * Draws a bezier curve relative to the current coordinates."," *"," * @method curveTo"," * @param {Number} cp1x x-coordinate for the first control point."," * @param {Number} cp1y y-coordinate for the first control point."," * @param {Number} cp2x x-coordinate for the second control point."," * @param {Number} cp2y y-coordinate for the second control point."," * @param {Number} x x-coordinate for the end point."," * @param {Number} y y-coordinate for the end point."," */"," relativeCurveTo: function() {"," this._curveTo.apply(this, [Y.Array(arguments), true]);"," },"," "," /**"," * Implements curveTo methods."," *"," * @method _curveTo"," * @param {Array} args The arguments to be used."," * @param {Boolean} relative Indicates whether or not to use relative coordinates."," * @private"," */"," _curveTo: function(args, relative) {"," var w,"," h,"," cp1x,"," cp1y,"," cp2x,"," cp2y,"," x,"," y,"," pts,"," right,"," left,"," bottom,"," top,"," i,"," len,"," relativeX = relative ? parseFloat(this._currentX) : 0,"," relativeY = relative ? parseFloat(this._currentY) : 0;"," len = args.length - 5;"," for(i = 0; i < len; i = i + 6)"," {"," cp1x = parseFloat(args[i]) + relativeX;"," cp1y = parseFloat(args[i + 1]) + relativeY;"," cp2x = parseFloat(args[i + 2]) + relativeX;"," cp2y = parseFloat(args[i + 3]) + relativeY;"," x = parseFloat(args[i + 4]) + relativeX;"," y = parseFloat(args[i + 5]) + relativeY;"," this._updateDrawingQueue([\"bezierCurveTo\", cp1x, cp1y, cp2x, cp2y, x, y]);"," this._drawingComplete = false;"," right = Math.max(x, Math.max(cp1x, cp2x));"," bottom = Math.max(y, Math.max(cp1y, cp2y));"," left = Math.min(x, Math.min(cp1x, cp2x));"," top = Math.min(y, Math.min(cp1y, cp2y));"," w = Math.abs(right - left);"," h = Math.abs(bottom - top);"," pts = [[this._currentX, this._currentY] , [cp1x, cp1y], [cp2x, cp2y], [x, y]]; "," this._setCurveBoundingBox(pts, w, h);"," this._currentX = x;"," this._currentY = y;"," }"," },",""," /**"," * Draws a quadratic bezier curve."," *"," * @method quadraticCurveTo"," * @param {Number} cpx x-coordinate for the control point."," * @param {Number} cpy y-coordinate for the control point."," * @param {Number} x x-coordinate for the end point."," * @param {Number} y y-coordinate for the end point."," */"," quadraticCurveTo: function() {"," this._quadraticCurveTo.apply(this, [Y.Array(arguments), false]);"," },",""," /**"," * Draws a quadratic bezier curve relative to the current position."," *"," * @method relativeQuadraticCurveTo"," * @param {Number} cpx x-coordinate for the control point."," * @param {Number} cpy y-coordinate for the control point."," * @param {Number} x x-coordinate for the end point."," * @param {Number} y y-coordinate for the end point."," */"," relativeQuadraticCurveTo: function() {"," this._quadraticCurveTo.apply(this, [Y.Array(arguments), true]);"," },",""," /**"," * Implements quadraticCurveTo methods."," *"," * @method _quadraticCurveTo"," * @param {Array} args The arguments to be used."," * @param {Boolean} relative Indicates whether or not to use relative coordinates."," * @private"," */"," _quadraticCurveTo: function(args, relative) {"," var cpx, "," cpy, "," x, "," y,"," w,"," h,"," pts,"," right,"," left,"," bottom,"," top,"," i,"," len = args.length - 3,"," wt = this._stroke && this._strokeWeight ? this._strokeWeight : 0,"," relativeX = relative ? parseFloat(this._currentX) : 0,"," relativeY = relative ? parseFloat(this._currentY) : 0;"," for(i = 0; i < len; i = i + 4)"," {"," cpx = parseFloat(args[i]) + relativeX;"," cpy = parseFloat(args[i + 1]) + relativeY;"," x = parseFloat(args[i + 2]) + relativeX;"," y = parseFloat(args[i + 3]) + relativeY;"," this._drawingComplete = false;"," right = Math.max(x, cpx);"," bottom = Math.max(y, cpy);"," left = Math.min(x, cpx);"," top = Math.min(y, cpy);"," w = Math.abs(right - left);"," h = Math.abs(bottom - top);"," pts = [[this._currentX, this._currentY] , [cpx, cpy], [x, y]]; "," this._setCurveBoundingBox(pts, w, h);"," this._updateDrawingQueue([\"quadraticCurveTo\", cpx, cpy, x, y]);"," this._updateCoords(x, y);"," }"," return this;"," },",""," /**"," * Draws a circle. Used internally by `CanvasCircle` class."," *"," * @method drawCircle"," * @param {Number} x y-coordinate"," * @param {Number} y x-coordinate"," * @param {Number} r radius"," * @protected"," */"," drawCircle: function(x, y, radius) {"," var startAngle = 0,"," endAngle = 2 * Math.PI,"," wt = this._stroke && this._strokeWeight ? this._strokeWeight : 0,"," circum = radius * 2;"," circum += wt;"," this._drawingComplete = false;"," this._trackSize(x + circum, y + circum);"," this._trackSize(x - wt, y - wt);"," this._updateCoords(x, y);"," this._updateDrawingQueue([\"arc\", x + radius, y + radius, radius, startAngle, endAngle, false]);"," return this;"," },",""," /**"," * Draws a diamond. "," * "," * @method drawDiamond"," * @param {Number} x y-coordinate"," * @param {Number} y x-coordinate"," * @param {Number} width width"," * @param {Number} height height"," * @protected"," */"," drawDiamond: function(x, y, width, height)"," {"," var midWidth = width * 0.5,"," midHeight = height * 0.5;"," this.moveTo(x + midWidth, y);"," this.lineTo(x + width, y + midHeight);"," this.lineTo(x + midWidth, y + height);"," this.lineTo(x, y + midHeight);"," this.lineTo(x + midWidth, y);"," return this;"," },",""," /**"," * Draws an ellipse. Used internally by `CanvasEllipse` class."," *"," * @method drawEllipse"," * @param {Number} x x-coordinate"," * @param {Number} y y-coordinate"," * @param {Number} w width"," * @param {Number} h height"," * @protected"," */"," drawEllipse: function(x, y, w, h) {"," var l = 8,"," theta = -(45/180) * Math.PI,"," angle = 0,"," angleMid,"," radius = w/2,"," yRadius = h/2,"," i,"," centerX = x + radius,"," centerY = y + yRadius,"," ax, ay, bx, by, cx, cy,"," wt = this._stroke && this._strokeWeight ? this._strokeWeight : 0;",""," ax = centerX + Math.cos(0) * radius;"," ay = centerY + Math.sin(0) * yRadius;"," this.moveTo(ax, ay);"," for(i = 0; i < l; i++)"," {"," angle += theta;"," angleMid = angle - (theta / 2);"," bx = centerX + Math.cos(angle) * radius;"," by = centerY + Math.sin(angle) * yRadius;"," cx = centerX + Math.cos(angleMid) * (radius / Math.cos(theta / 2));"," cy = centerY + Math.sin(angleMid) * (yRadius / Math.cos(theta / 2));"," this._updateDrawingQueue([\"quadraticCurveTo\", cx, cy, bx, by]);"," }"," this._trackSize(x + w + wt, y + h + wt);"," this._trackSize(x - wt, y - wt);"," this._updateCoords(x, y);"," return this;"," },",""," /**"," * Draws a rectangle."," *"," * @method drawRect"," * @param {Number} x x-coordinate"," * @param {Number} y y-coordinate"," * @param {Number} w width"," * @param {Number} h height"," */"," drawRect: function(x, y, w, h) {"," var wt = this._stroke && this._strokeWeight ? this._strokeWeight : 0;"," this._drawingComplete = false;"," this.moveTo(x, y);"," this.lineTo(x + w, y);"," this.lineTo(x + w, y + h);"," this.lineTo(x, y + h);"," this.lineTo(x, y);"," return this;"," },",""," /**"," * Draws a rectangle with rounded corners."," * "," * @method drawRect"," * @param {Number} x x-coordinate"," * @param {Number} y y-coordinate"," * @param {Number} w width"," * @param {Number} h height"," * @param {Number} ew width of the ellipse used to draw the rounded corners"," * @param {Number} eh height of the ellipse used to draw the rounded corners"," */"," drawRoundRect: function(x, y, w, h, ew, eh) {"," var wt = this._stroke && this._strokeWeight ? this._strokeWeight : 0;"," this._drawingComplete = false;"," this.moveTo( x, y + eh);"," this.lineTo(x, y + h - eh);"," this.quadraticCurveTo(x, y + h, x + ew, y + h);"," this.lineTo(x + w - ew, y + h);"," this.quadraticCurveTo(x + w, y + h, x + w, y + h - eh);"," this.lineTo(x + w, y + eh);"," this.quadraticCurveTo(x + w, y, x + w - ew, y);"," this.lineTo(x + ew, y);"," this.quadraticCurveTo(x, y, x, y + eh);"," return this;"," },"," "," /**"," * Draws a wedge."," *"," * @method drawWedge"," * @param {Number} x x-coordinate of the wedge's center point"," * @param {Number} y y-coordinate of the wedge's center point"," * @param {Number} startAngle starting angle in degrees"," * @param {Number} arc sweep of the wedge. Negative values draw clockwise."," * @param {Number} radius radius of wedge. If [optional] yRadius is defined, then radius is the x radius."," * @param {Number} yRadius [optional] y radius for wedge."," * @private"," */"," drawWedge: function(x, y, startAngle, arc, radius, yRadius)"," {"," var wt = this._stroke && this._strokeWeight ? this._strokeWeight : 0,"," segs,"," segAngle,"," theta,"," angle,"," angleMid,"," ax,"," ay,"," bx,"," by,"," cx,"," cy,"," i = 0;"," yRadius = yRadius || radius;",""," this._drawingComplete = false;"," // move to x,y position"," this._updateDrawingQueue([\"moveTo\", x, y]);"," "," yRadius = yRadius || radius;"," "," // limit sweep to reasonable numbers"," if(Math.abs(arc) > 360)"," {"," arc = 360;"," }"," "," // First we calculate how many segments are needed"," // for a smooth arc."," segs = Math.ceil(Math.abs(arc) / 45);"," "," // Now calculate the sweep of each segment."," segAngle = arc / segs;"," "," // The math requires radians rather than degrees. To convert from degrees"," // use the formula (degrees/180)*Math.PI to get radians."," theta = -(segAngle / 180) * Math.PI;"," "," // convert angle startAngle to radians"," angle = (startAngle / 180) * Math.PI;"," "," // draw the curve in segments no larger than 45 degrees."," if(segs > 0)"," {"," // draw a line from the center to the start of the curve"," ax = x + Math.cos(startAngle / 180 * Math.PI) * radius;"," ay = y + Math.sin(startAngle / 180 * Math.PI) * yRadius;"," this.lineTo(ax, ay);"," // Loop for drawing curve segments"," for(i = 0; i < segs; ++i)"," {"," angle += theta;"," angleMid = angle - (theta / 2);"," bx = x + Math.cos(angle) * radius;"," by = y + Math.sin(angle) * yRadius;"," cx = x + Math.cos(angleMid) * (radius / Math.cos(theta / 2));"," cy = y + Math.sin(angleMid) * (yRadius / Math.cos(theta / 2));"," this._updateDrawingQueue([\"quadraticCurveTo\", cx, cy, bx, by]);"," }"," // close the wedge by drawing a line to the center"," this._updateDrawingQueue([\"lineTo\", x, y]);"," }"," this._trackSize(-wt , -wt);"," this._trackSize((radius * 2) + wt, (radius * 2) + wt);"," return this;"," },"," "," /**"," * Completes a drawing operation. "," *"," * @method end"," */"," end: function() {"," this._closePath();"," return this;"," },",""," /**"," * Ends a fill and stroke"," *"," * @method closePath"," */"," closePath: function()"," {"," this._updateDrawingQueue([\"closePath\"]);"," this._updateDrawingQueue([\"beginPath\"]);"," },",""," /**"," * Clears the graphics object."," *"," * @method clear"," */"," "," /**"," * Returns a linear gradient fill"," *"," * @method _getLinearGradient"," * @return CanvasGradient"," * @private"," */"," _getLinearGradient: function() {"," var isNumber = Y.Lang.isNumber,"," fill = this.get(\"fill\"),"," stops = fill.stops,"," opacity,"," color,"," stop,"," i,"," len = stops.length,"," gradient,"," x = 0,"," y = 0,"," w = this.get(\"width\"),"," h = this.get(\"height\"),"," r = fill.rotation || 0,"," x1, x2, y1, y2,"," cx = x + w/2,"," cy = y + h/2,"," offset,"," radCon = Math.PI/180,"," tanRadians = parseFloat(parseFloat(Math.tan(r * radCon)).toFixed(8));"," if(Math.abs(tanRadians) * w/2 >= h/2)"," {"," if(r < 180)"," {"," y1 = y;"," y2 = y + h;"," }"," else"," {"," y1 = y + h;"," y2 = y;"," }"," x1 = cx - ((cy - y1)/tanRadians);"," x2 = cx - ((cy - y2)/tanRadians); "," }"," else"," {"," if(r > 90 && r < 270)"," {"," x1 = x + w;"," x2 = x;"," }"," else"," {"," x1 = x;"," x2 = x + w;"," }"," y1 = ((tanRadians * (cx - x1)) - cy) * -1;"," y2 = ((tanRadians * (cx - x2)) - cy) * -1;"," }"," gradient = this._context.createLinearGradient(x1, y1, x2, y2);"," for(i = 0; i < len; ++i)"," {"," stop = stops[i];"," opacity = stop.opacity;"," color = stop.color;"," offset = stop.offset;"," if(isNumber(opacity))"," {"," opacity = Math.max(0, Math.min(1, opacity));"," color = this._toRGBA(color, opacity);"," }"," else"," {"," color = TORGB(color);"," }"," offset = stop.offset || i/(len - 1);"," gradient.addColorStop(offset, color);"," }"," return gradient;"," },",""," /**"," * Returns a radial gradient fill"," *"," * @method _getRadialGradient"," * @return CanvasGradient"," * @private"," */"," _getRadialGradient: function() {"," var isNumber = Y.Lang.isNumber,"," fill = this.get(\"fill\"),"," r = fill.r,"," fx = fill.fx,"," fy = fill.fy,"," stops = fill.stops,"," opacity,"," color,"," stop,"," i,"," len = stops.length,"," gradient,"," x = 0,"," y = 0,"," w = this.get(\"width\"),"," h = this.get(\"height\"),"," x1, x2, y1, y2, r2, "," xc, yc, xn, yn, d, "," offset,"," ratio,"," stopMultiplier;"," xc = x + w/2;"," yc = y + h/2;"," x1 = w * fx;"," y1 = h * fy;"," x2 = x + w/2;"," y2 = y + h/2;"," r2 = w * r;"," d = Math.sqrt( Math.pow(Math.abs(xc - x1), 2) + Math.pow(Math.abs(yc - y1), 2) );"," if(d >= r2)"," {"," ratio = d/r2;"," //hack. gradient won't show if it is exactly on the edge of the arc"," if(ratio === 1)"," {"," ratio = 1.01;"," }"," xn = (x1 - xc)/ratio;"," yn = (y1 - yc)/ratio;"," xn = xn > 0 ? Math.floor(xn) : Math.ceil(xn);"," yn = yn > 0 ? Math.floor(yn) : Math.ceil(yn);"," x1 = xc + xn;"," y1 = yc + yn;"," }"," "," //If the gradient radius is greater than the circle's, adjusting the radius stretches the gradient properly."," //If the gradient radius is less than the circle's, adjusting the radius of the gradient will not work. "," //Instead, adjust the color stops to reflect the smaller radius."," if(r >= 0.5)"," {"," gradient = this._context.createRadialGradient(x1, y1, r, x2, y2, r * w);"," stopMultiplier = 1;"," }"," else"," {"," gradient = this._context.createRadialGradient(x1, y1, r, x2, y2, w/2);"," stopMultiplier = r * 2;"," }"," for(i = 0; i < len; ++i)"," {"," stop = stops[i];"," opacity = stop.opacity;"," color = stop.color;"," offset = stop.offset;"," if(isNumber(opacity))"," {"," opacity = Math.max(0, Math.min(1, opacity));"," color = this._toRGBA(color, opacity);"," }"," else"," {"," color = TORGB(color);"," }"," offset = stop.offset || i/(len - 1);"," offset *= stopMultiplier;"," if(offset <= 1)"," {"," gradient.addColorStop(offset, color);"," }"," }"," return gradient;"," },","",""," /**"," * Clears all values"," *"," * @method _initProps"," * @private"," */"," _initProps: function() {"," this._methods = [];"," this._lineToMethods = [];"," this._xcoords = [0];"," this._ycoords = [0];"," this._width = 0;"," this._height = 0;"," this._left = 0;"," this._top = 0;"," this._right = 0;"," this._bottom = 0;"," this._currentX = 0;"," this._currentY = 0;"," },"," "," /**"," * Indicates a drawing has completed."," *"," * @property _drawingComplete"," * @type Boolean"," * @private"," */"," _drawingComplete: false,",""," /**"," * Creates canvas element"," *"," * @method _createGraphic"," * @return HTMLCanvasElement"," * @private"," */"," _createGraphic: function(config) {"," var graphic = Y.config.doc.createElement('canvas');"," return graphic;"," },"," "," /**"," * Returns the points on a curve"," *"," * @method getBezierData"," * @param Array points Array containing the begin, end and control points of a curve."," * @param Number t The value for incrementing the next set of points."," * @return Array"," * @private"," */"," getBezierData: function(points, t) { "," var n = points.length,"," tmp = [],"," i,"," j;",""," for (i = 0; i < n; ++i){"," tmp[i] = [points[i][0], points[i][1]]; // save input"," }"," "," for (j = 1; j < n; ++j) {"," for (i = 0; i < n - j; ++i) {"," tmp[i][0] = (1 - t) * tmp[i][0] + t * tmp[parseInt(i + 1, 10)][0];"," tmp[i][1] = (1 - t) * tmp[i][1] + t * tmp[parseInt(i + 1, 10)][1]; "," }"," }"," return [ tmp[0][0], tmp[0][1] ]; "," },"," "," /**"," * Calculates the bounding box for a curve"," *"," * @method _setCurveBoundingBox"," * @param Array pts Array containing points for start, end and control points of a curve."," * @param Number w Width used to calculate the number of points to describe the curve."," * @param Number h Height used to calculate the number of points to describe the curve."," * @private"," */"," _setCurveBoundingBox: function(pts, w, h)"," {"," var i = 0,"," left = this._currentX,"," right = left,"," top = this._currentY,"," bottom = top,"," len = Math.round(Math.sqrt((w * w) + (h * h))),"," t = 1/len,"," wt = this._stroke && this._strokeWeight ? this._strokeWeight : 0,"," xy;"," for(i = 0; i < len; ++i)"," {"," xy = this.getBezierData(pts, t * i);"," left = isNaN(left) ? xy[0] : Math.min(xy[0], left);"," right = isNaN(right) ? xy[0] : Math.max(xy[0], right);"," top = isNaN(top) ? xy[1] : Math.min(xy[1], top);"," bottom = isNaN(bottom) ? xy[1] : Math.max(xy[1], bottom);"," }"," left = Math.round(left * 10)/10;"," right = Math.round(right * 10)/10;"," top = Math.round(top * 10)/10;"," bottom = Math.round(bottom * 10)/10;"," this._trackSize(right + wt, bottom + wt);"," this._trackSize(left - wt, top - wt);"," },",""," /**"," * Updates the size of the graphics object"," *"," * @method _trackSize"," * @param {Number} w width"," * @param {Number} h height"," * @private"," */"," _trackSize: function(w, h) {"," if (w > this._right) {"," this._right = w;"," }"," if(w < this._left)"," {"," this._left = w; "," }"," if (h < this._top)"," {"," this._top = h;"," }"," if (h > this._bottom) "," {"," this._bottom = h;"," }"," this._width = this._right - this._left;"," this._height = this._bottom - this._top;"," }","};","Y.CanvasDrawing = CanvasDrawing;","/**"," * <a href=\"http://www.w3.org/TR/html5/the-canvas-element.html\">Canvas</a> implementation of the <a href=\"Shape.html\">`Shape`</a> class. "," * `CanvasShape` is not intended to be used directly. Instead, use the <a href=\"Shape.html\">`Shape`</a> class. "," * If the browser lacks <a href=\"http://www.w3.org/TR/SVG/\">SVG</a> capabilities but has "," * <a href=\"http://www.w3.org/TR/html5/the-canvas-element.html\">Canvas</a> capabilities, the <a href=\"Shape.html\">`Shape`</a> "," * class will point to the `CanvasShape` class."," *"," * @module graphics"," * @class CanvasShape"," * @constructor"," */","CanvasShape = function(cfg)","{"," this._transforms = [];"," this.matrix = new Y.Matrix();"," CanvasShape.superclass.constructor.apply(this, arguments);","};","","CanvasShape.NAME = \"shape\";","","Y.extend(CanvasShape, Y.GraphicBase, Y.mix({"," /**"," * Init method, invoked during construction."," * Calls `initializer` method."," *"," * @method init"," * @protected"," */"," init: function()"," {"," this.initializer.apply(this, arguments);"," },",""," /**"," * Initializes the shape"," *"," * @private"," * @method _initialize"," */"," initializer: function(cfg)"," {"," var host = this,"," graphic = cfg.graphic,"," data = this.get(\"data\");"," host._initProps();"," host.createNode(); "," host._xcoords = [0];"," host._ycoords = [0];"," if(graphic)"," {"," this._setGraphic(graphic);"," }"," if(data)"," {"," host._parsePathData(data);"," }"," host._updateHandler();"," },"," "," /**"," * Set the Graphic instance for the shape."," *"," * @method _setGraphic"," * @param {Graphic | Node | HTMLElement | String} render This param is used to determine the graphic instance. If it is a `Graphic` instance, it will be assigned"," * to the `graphic` attribute. Otherwise, a new Graphic instance will be created and rendered into the dom element that the render represents."," * @private"," */"," _setGraphic: function(render)"," {"," var graphic;"," if(render instanceof Y.CanvasGraphic)"," {"," this._graphic = render;"," }"," else"," {"," render = Y.one(render);"," graphic = new Y.CanvasGraphic({"," render: render"," });"," graphic._appendShape(this);"," this._graphic = graphic;"," }"," },"," "," /**"," * Add a class name to each node."," *"," * @method addClass"," * @param {String} className the class name to add to the node's class attribute "," */"," addClass: function(className)"," {"," var node = Y.one(this.get(\"node\"));"," node.addClass(className);"," },"," "," /**"," * Removes a class name from each node."," *"," * @method removeClass"," * @param {String} className the class name to remove from the node's class attribute"," */"," removeClass: function(className)"," {"," var node = Y.one(this.get(\"node\"));"," node.removeClass(className);"," },",""," /**"," * Gets the current position of the node in page coordinates."," *"," * @method getXY"," * @return Array The XY position of the shape."," */"," getXY: function()"," {"," var graphic = this.get(\"graphic\"),"," parentXY = graphic.getXY(),"," x = this.get(\"x\"),"," y = this.get(\"y\");"," return [parentXY[0] + x, parentXY[1] + y];"," },",""," /**"," * Set the position of the shape in page coordinates, regardless of how the node is positioned."," *"," * @method setXY"," * @param {Array} Contains X & Y values for new position (coordinates are page-based)"," */"," setXY: function(xy)"," {"," var graphic = this.get(\"graphic\"),"," parentXY = graphic.getXY(),"," x = xy[0] - parentXY[0],"," y = xy[1] - parentXY[1];"," this._set(\"x\", x);"," this._set(\"y\", y);"," this._updateNodePosition(x, y);"," },",""," /**"," * Determines whether the node is an ancestor of another HTML element in the DOM hierarchy. "," *"," * @method contains"," * @param {CanvasShape | HTMLElement} needle The possible node or descendent"," * @return Boolean Whether or not this shape is the needle or its ancestor."," */"," contains: function(needle)"," {"," return needle === Y.one(this.node);"," },",""," /**"," * Test if the supplied node matches the supplied selector."," *"," * @method test"," * @param {String} selector The CSS selector to test against."," * @return Boolean Wheter or not the shape matches the selector."," */"," test: function(selector)"," {"," return Y.one(this.get(\"node\")).test(selector);"," //return Y.Selector.test(this.node, selector);"," },",""," /**"," * Compares nodes to determine if they match."," * Node instances can be compared to each other and/or HTMLElements."," * @method compareTo"," * @param {HTMLElement | Node} refNode The reference node to compare to the node."," * @return {Boolean} True if the nodes match, false if they do not."," */"," compareTo: function(refNode) {"," var node = this.node;"," return node === refNode;"," },",""," /**"," * Value function for fill attribute"," *"," * @method _getDefaultFill"," * @return Object"," * @private"," */"," _getDefaultFill: function() {"," return {"," type: \"solid\","," opacity: 1,"," cx: 0.5,"," cy: 0.5,"," fx: 0.5,"," fy: 0.5,"," r: 0.5"," };"," },",""," /**"," * Value function for stroke attribute"," *"," * @method _getDefaultStroke"," * @return Object"," * @private"," */"," _getDefaultStroke: function() "," {"," return {"," weight: 1,"," dashstyle: \"none\","," color: \"#000\","," opacity: 1.0"," };"," },",""," /**"," * Left edge of the path"," *"," * @property _left"," * @type Number"," * @private"," */"," _left: 0,",""," /**"," * Right edge of the path"," *"," * @property _right"," * @type Number"," * @private"," */"," _right: 0,"," "," /**"," * Top edge of the path"," *"," * @property _top"," * @type Number"," * @private"," */"," _top: 0, "," "," /**"," * Bottom edge of the path"," *"," * @property _bottom"," * @type Number"," * @private"," */"," _bottom: 0,",""," /**"," * Creates the dom node for the shape."," *"," * @method createNode"," * @return HTMLElement"," * @private"," */"," createNode: function()"," {"," var host = this,"," node = Y.config.doc.createElement('canvas'),"," id = host.get(\"id\"),"," concat = host._camelCaseConcat,"," name = host.name;"," host._context = node.getContext('2d');"," node.setAttribute(\"overflow\", \"visible\");"," node.style.overflow = \"visible\";"," if(!host.get(\"visible\"))"," {"," node.style.visibility = \"hidden\";"," }"," node.setAttribute(\"id\", id);"," id = \"#\" + id;"," host.node = node;"," host.addClass(_getClassName(SHAPE) + \" \" + _getClassName(concat(IMPLEMENTATION, SHAPE)) + \" \" + _getClassName(name) + \" \" + _getClassName(concat(IMPLEMENTATION, name))); "," },"," "," /**"," * Overrides default `on` method. Checks to see if its a dom interaction event. If so, "," * return an event attached to the `node` element. If not, return the normal functionality."," *"," * @method on"," * @param {String} type event type"," * @param {Object} callback function"," * @private"," */"," on: function(type, fn)"," {"," if(Y.Node.DOM_EVENTS[type])"," {"," return Y.one(\"#\" + this.get(\"id\")).on(type, fn);"," }"," return Y.on.apply(this, arguments);"," },"," "," /**"," * Adds a stroke to the shape node."," *"," * @method _strokeChangeHandler"," * @param {Object} stroke Properties of the `stroke` attribute."," * @private"," */"," _setStrokeProps: function(stroke)"," {"," var color,"," weight,"," opacity,"," linejoin,"," linecap,"," dashstyle;"," if(stroke)"," {"," color = stroke.color;"," weight = PARSE_FLOAT(stroke.weight);"," opacity = PARSE_FLOAT(stroke.opacity);"," linejoin = stroke.linejoin || \"round\";"," linecap = stroke.linecap || \"butt\";"," dashstyle = stroke.dashstyle;"," this._miterlimit = null;"," this._dashstyle = (dashstyle && Y.Lang.isArray(dashstyle) && dashstyle.length > 1) ? dashstyle : null;"," this._strokeWeight = weight;",""," if (IS_NUMBER(weight) && weight > 0) "," {"," this._stroke = 1;"," } "," else "," {"," this._stroke = 0;"," }"," if (IS_NUMBER(opacity)) {"," this._strokeStyle = this._toRGBA(color, opacity);"," }"," else"," {"," this._strokeStyle = color;"," }"," this._linecap = linecap;"," if(linejoin == \"round\" || linejoin == \"bevel\")"," {"," this._linejoin = linejoin;"," }"," else"," {"," linejoin = parseInt(linejoin, 10);"," if(IS_NUMBER(linejoin))"," {"," this._miterlimit = Math.max(linejoin, 1);"," this._linejoin = \"miter\";"," }"," }"," }"," else"," {"," this._stroke = 0;"," }"," },",""," /**"," * Sets the value of an attribute."," *"," * @method set"," * @param {String|Object} name The name of the attribute. Alternatively, an object of key value pairs can "," * be passed in to set multiple attributes at once."," * @param {Any} value The value to set the attribute to. This value is ignored if an object is received as "," * the name param."," */"," set: function() "," {"," var host = this,"," val = arguments[0];"," AttributeLite.prototype.set.apply(host, arguments);"," if(host.initialized)"," {"," host._updateHandler();"," }"," },"," "," /**"," * Adds a fill to the shape node."," *"," * @method _setFillProps "," * @param {Object} fill Properties of the `fill` attribute."," * @private"," */"," _setFillProps: function(fill)"," {"," var isNumber = IS_NUMBER,"," color,"," opacity,"," type;"," if(fill)"," {"," color = fill.color;"," type = fill.type;"," if(type == \"linear\" || type == \"radial\")"," {"," this._fillType = type;"," }"," else if(color)"," {"," opacity = fill.opacity;"," if (isNumber(opacity)) "," {"," opacity = Math.max(0, Math.min(1, opacity));"," color = this._toRGBA(color, opacity);"," } "," else "," {"," color = TORGB(color);"," }",""," this._fillColor = color;"," this._fillType = 'solid';"," }"," else"," {"," this._fillColor = null;"," }"," }"," else"," {"," this._fillType = null;"," this._fillColor = null;"," }"," },",""," /**"," * Specifies a 2d translation."," *"," * @method translate"," * @param {Number} x The value to transate on the x-axis."," * @param {Number} y The value to translate on the y-axis."," */"," translate: function(x, y)"," {"," this._translateX += x;"," this._translateY += y;"," this._addTransform(\"translate\", arguments);"," },",""," /**"," * Translates the shape along the x-axis. When translating x and y coordinates,"," * use the `translate` method."," *"," * @method translateX"," * @param {Number} x The value to translate."," */"," translateX: function(x)"," {"," this._translateX += x;"," this._addTransform(\"translateX\", arguments);"," },",""," /**"," * Performs a translate on the y-coordinate. When translating x and y coordinates,"," * use the `translate` method."," *"," * @method translateY"," * @param {Number} y The value to translate."," */"," translateY: function(y)"," {"," this._translateY += y;"," this._addTransform(\"translateY\", arguments);"," },",""," /**"," * Skews the shape around the x-axis and y-axis."," *"," * @method skew"," * @param {Number} x The value to skew on the x-axis."," * @param {Number} y The value to skew on the y-axis."," */"," skew: function(x, y)"," {"," this._addTransform(\"skew\", arguments);"," },",""," /**"," * Skews the shape around the x-axis."," *"," * @method skewX"," * @param {Number} x x-coordinate"," */"," skewX: function(x)"," {"," this._addTransform(\"skewX\", arguments);"," },",""," /**"," * Skews the shape around the y-axis."," *"," * @method skewY"," * @param {Number} y y-coordinate"," */"," skewY: function(y)"," {"," this._addTransform(\"skewY\", arguments);"," },",""," /**"," * Rotates the shape clockwise around it transformOrigin."," *"," * @method rotate"," * @param {Number} deg The degree of the rotation."," */"," rotate: function(deg)"," {"," this._rotation = deg;"," this._addTransform(\"rotate\", arguments);"," },",""," /**"," * Specifies a 2d scaling operation."," *"," * @method scale"," * @param {Number} val"," */"," scale: function(x, y)"," {"," this._addTransform(\"scale\", arguments);"," },"," "," /**"," * Storage for `rotation` atribute."," *"," * @property _rotation"," * @type Number"," * @private"," */"," _rotation: 0,"," "," /**"," * Storage for the transform attribute."," *"," * @property _transform"," * @type String"," * @private"," */"," _transform: \"\",",""," /**"," * Adds a transform to the shape."," *"," * @method _addTransform"," * @param {String} type The transform being applied."," * @param {Array} args The arguments for the transform."," * @private"," */"," _addTransform: function(type, args)"," {"," args = Y.Array(args);"," this._transform = Y_LANG.trim(this._transform + \" \" + type + \"(\" + args.join(\", \") + \")\");"," args.unshift(type);"," this._transforms.push(args);"," if(this.initialized)"," {"," this._updateTransform();"," }"," },",""," /**"," * Applies all transforms."," *"," * @method _updateTransform"," * @private"," */"," _updateTransform: function()"," {"," var node = this.node,"," key,"," transform,"," transformOrigin = this.get(\"transformOrigin\"),"," matrix = this.matrix,"," i,"," len = this._transforms.length;"," "," if(this._transforms && this._transforms.length > 0)"," {"," for(i = 0; i < len; ++i)"," {"," key = this._transforms[i].shift();"," if(key)"," {"," matrix[key].apply(matrix, this._transforms[i]); "," }"," }"," transform = matrix.toCSSText();"," }"," "," this._graphic.addToRedrawQueue(this); "," transformOrigin = (100 * transformOrigin[0]) + \"% \" + (100 * transformOrigin[1]) + \"%\";"," Y_DOM.setStyle(node, \"transformOrigin\", transformOrigin);"," if(transform)"," {"," Y_DOM.setStyle(node, \"transform\", transform);"," }"," this._transforms = [];"," },",""," /**"," * Updates `Shape` based on attribute changes."," *"," * @method _updateHandler"," * @private"," */"," _updateHandler: function()"," {"," this._draw();"," this._updateTransform();"," },"," "," /**"," * Updates the shape."," *"," * @method _draw"," * @private"," */"," _draw: function()"," {"," var node = this.node;"," this.clear();"," this._closePath();"," node.style.left = this.get(\"x\") + \"px\";"," node.style.top = this.get(\"y\") + \"px\";"," },",""," /**"," * Completes a shape or drawing"," *"," * @method _closePath"," * @private"," */"," _closePath: function()"," {"," if(!this._methods)"," {"," return;"," }"," var node = this.get(\"node\"),"," w = this._right - this._left,"," h = this._bottom - this._top,"," context = this._context,"," methods = [],"," cachedMethods = this._methods.concat(),"," i,"," j,"," method,"," args,"," argsLen,"," len = 0;"," this._context.clearRect(0, 0, node.width, node.height);"," if(this._methods)"," {"," len = cachedMethods.length;"," if(!len || len < 1)"," {"," return;"," }"," for(i = 0; i < len; ++i)"," {"," methods[i] = cachedMethods[i].concat();"," args = methods[i];"," argsLen = (args[0] == \"quadraticCurveTo\" || args[0] == \"bezierCurveTo\") ? args.length : 3;"," for(j = 1; j < argsLen; ++j)"," {"," if(j % 2 === 0)"," {"," args[j] = args[j] - this._top;"," }"," else"," {"," args[j] = args[j] - this._left;"," }"," }"," }"," node.setAttribute(\"width\", Math.min(w, 2000));"," node.setAttribute(\"height\", Math.min(2000, h));"," context.beginPath();"," for(i = 0; i < len; ++i)"," {"," args = methods[i].concat();"," if(args && args.length > 0)"," {"," method = args.shift();"," if(method)"," {"," if(method == \"closePath\")"," {"," context.closePath();"," this._strokeAndFill(context);"," }"," else if(method && method == \"lineTo\" && this._dashstyle)"," {"," args.unshift(this._xcoords[i] - this._left, this._ycoords[i] - this._top);"," this._drawDashedLine.apply(this, args);"," }"," else"," {"," context[method].apply(context, args); "," }"," }"," }"," }",""," this._strokeAndFill(context);"," this._drawingComplete = true;"," this._clearAndUpdateCoords();"," this._updateNodePosition();"," this._methods = cachedMethods;"," }"," },",""," /**"," * Completes a stroke and/or fill operation on the context."," *"," * @method _strokeAndFill"," * @param {Context} Reference to the context element of the canvas instance."," * @private"," */"," _strokeAndFill: function(context)"," {"," if (this._fillType) "," {"," if(this._fillType == \"linear\")"," {"," context.fillStyle = this._getLinearGradient();"," }"," else if(this._fillType == \"radial\")"," {"," context.fillStyle = this._getRadialGradient();"," }"," else"," {"," context.fillStyle = this._fillColor;"," }"," context.closePath();"," context.fill();"," }",""," if (this._stroke) {"," if(this._strokeWeight)"," {"," context.lineWidth = this._strokeWeight;"," }"," context.lineCap = this._linecap;"," context.lineJoin = this._linejoin;"," if(this._miterlimit)"," {"," context.miterLimit = this._miterlimit;"," }"," context.strokeStyle = this._strokeStyle;"," context.stroke();"," }"," },",""," /**"," * Draws a dashed line between two points."," * "," * @method _drawDashedLine"," * @param {Number} xStart The x position of the start of the line"," * @param {Number} yStart The y position of the start of the line"," * @param {Number} xEnd The x position of the end of the line"," * @param {Number} yEnd The y position of the end of the line"," * @private"," */"," _drawDashedLine: function(xStart, yStart, xEnd, yEnd)"," {"," var context = this._context,"," dashsize = this._dashstyle[0],"," gapsize = this._dashstyle[1],"," segmentLength = dashsize + gapsize,"," xDelta = xEnd - xStart,"," yDelta = yEnd - yStart,"," delta = Math.sqrt(Math.pow(xDelta, 2) + Math.pow(yDelta, 2)),"," segmentCount = Math.floor(Math.abs(delta / segmentLength)),"," radians = Math.atan2(yDelta, xDelta),"," xCurrent = xStart,"," yCurrent = yStart,"," i;"," xDelta = Math.cos(radians) * segmentLength;"," yDelta = Math.sin(radians) * segmentLength;"," "," for(i = 0; i < segmentCount; ++i)"," {"," context.moveTo(xCurrent, yCurrent);"," context.lineTo(xCurrent + Math.cos(radians) * dashsize, yCurrent + Math.sin(radians) * dashsize);"," xCurrent += xDelta;"," yCurrent += yDelta;"," }"," "," context.moveTo(xCurrent, yCurrent);"," delta = Math.sqrt((xEnd - xCurrent) * (xEnd - xCurrent) + (yEnd - yCurrent) * (yEnd - yCurrent));"," "," if(delta > dashsize)"," {"," context.lineTo(xCurrent + Math.cos(radians) * dashsize, yCurrent + Math.sin(radians) * dashsize);"," }"," else if(delta > 0)"," {"," context.lineTo(xCurrent + Math.cos(radians) * delta, yCurrent + Math.sin(radians) * delta);"," }"," "," context.moveTo(xEnd, yEnd);"," },",""," //This should move to CanvasDrawing class. "," //Currently docmented in CanvasDrawing class."," clear: function() {"," this._initProps();"," if(this.node) "," {"," this._context.clearRect(0, 0, this.node.width, this.node.height);"," }"," return this;"," },"," "," /**"," * Returns the bounds for a shape."," *"," * Calculates the a new bounding box from the original corner coordinates (base on size and position) and the transform matrix."," * The calculated bounding box is used by the graphic instance to calculate its viewBox. "," *"," * @method getBounds"," * @return Object"," */"," getBounds: function()"," {"," var type = this._type,"," w = this.get(\"width\"),"," h = this.get(\"height\"),"," x = this.get(\"x\"),"," y = this.get(\"y\");"," if(type == \"path\")"," {"," x = x + this._left;"," y = y + this._top;"," w = this._right - this._left;"," h = this._bottom - this._top;"," }"," return this._getContentRect(w, h, x, y);"," },",""," /**"," * Calculates the bounding box for the shape."," *"," * @method _getContentRect"," * @param {Number} w width of the shape"," * @param {Number} h height of the shape"," * @param {Number} x x-coordinate of the shape"," * @param {Number} y y-coordinate of the shape"," * @private"," */"," _getContentRect: function(w, h, x, y)"," {"," var transformOrigin = this.get(\"transformOrigin\"),"," transformX = transformOrigin[0] * w,"," transformY = transformOrigin[1] * h,"," transforms = this.matrix.getTransformArray(this.get(\"transform\")),"," matrix = new Y.Matrix(),"," i,"," len = transforms.length,"," transform,"," key,"," contentRect;"," if(this._type == \"path\")"," {"," transformX = transformX + x;"," transformY = transformY + y;"," }"," transformX = !isNaN(transformX) ? transformX : 0;"," transformY = !isNaN(transformY) ? transformY : 0;"," matrix.translate(transformX, transformY);"," for(i = 0; i < len; i = i + 1)"," {"," transform = transforms[i];"," key = transform.shift();"," if(key)"," {"," matrix[key].apply(matrix, transform); "," }"," }"," matrix.translate(-transformX, -transformY);"," contentRect = matrix.getContentRect(w, h, x, y);"," return contentRect;"," },",""," /**"," * Places the shape above all other shapes."," *"," * @method toFront"," */"," toFront: function()"," {"," var graphic = this.get(\"graphic\");"," if(graphic)"," {"," graphic._toFront(this);"," }"," },",""," /**"," * Places the shape underneath all other shapes."," *"," * @method toFront"," */"," toBack: function()"," {"," var graphic = this.get(\"graphic\");"," if(graphic)"," {"," graphic._toBack(this);"," }"," },",""," /**"," * Parses path data string and call mapped methods."," *"," * @method _parsePathData"," * @param {String} val The path data"," * @private"," */"," _parsePathData: function(val)"," {"," var method,"," methodSymbol,"," args,"," commandArray = Y.Lang.trim(val.match(SPLITPATHPATTERN)),"," i,"," len, "," str,"," symbolToMethod = this._pathSymbolToMethod;"," if(commandArray)"," {"," this.clear();"," len = commandArray.length || 0;"," for(i = 0; i < len; i = i + 1)"," {"," str = commandArray[i];"," methodSymbol = str.substr(0, 1);"," args = str.substr(1).match(SPLITARGSPATTERN);"," method = symbolToMethod[methodSymbol];"," if(method)"," {"," if(args)"," {"," this[method].apply(this, args);"," }"," else"," {"," this[method].apply(this);"," }"," }"," }"," this.end();"," }"," },"," "," /**"," * Destroys the shape instance."," *"," * @method destroy"," */"," destroy: function()"," {"," var graphic = this.get(\"graphic\");"," if(graphic)"," {"," graphic.removeShape(this);"," }"," else"," {"," this._destroy();"," }"," },",""," /**"," * Implementation for shape destruction"," *"," * @method destroy"," * @protected"," */"," _destroy: function()"," {"," if(this.node)"," {"," Y.one(this.node).remove(true);"," this._context = null;"," this.node = null;"," }"," }","}, Y.CanvasDrawing.prototype));","","CanvasShape.ATTRS = {"," /**"," * An array of x, y values which indicates the transformOrigin in which to rotate the shape. Valid values range between 0 and 1 representing a "," * fraction of the shape's corresponding bounding box dimension. The default value is [0.5, 0.5]."," *"," * @config transformOrigin"," * @type Array"," */"," transformOrigin: {"," valueFn: function()"," {"," return [0.5, 0.5];"," }"," },"," "," /**"," * <p>A string containing, in order, transform operations applied to the shape instance. The `transform` string can contain the following values:"," * "," * <dl>"," * <dt>rotate</dt><dd>Rotates the shape clockwise around it transformOrigin.</dd>"," * <dt>translate</dt><dd>Specifies a 2d translation.</dd>"," * <dt>skew</dt><dd>Skews the shape around the x-axis and y-axis.</dd>"," * <dt>scale</dt><dd>Specifies a 2d scaling operation.</dd>"," * <dt>translateX</dt><dd>Translates the shape along the x-axis.</dd>"," * <dt>translateY</dt><dd>Translates the shape along the y-axis.</dd>"," * <dt>skewX</dt><dd>Skews the shape around the x-axis.</dd>"," * <dt>skewY</dt><dd>Skews the shape around the y-axis.</dd>"," * <dt>matrix</dt><dd>Specifies a 2D transformation matrix comprised of the specified six values.</dd> "," * </dl>"," * </p>"," * <p>Applying transforms through the transform attribute will reset the transform matrix and apply a new transform. The shape class also contains corresponding methods for each transform"," * that will apply the transform to the current matrix. The below code illustrates how you might use the `transform` attribute to instantiate a recangle with a rotation of 45 degrees.</p>"," var myRect = new Y.Rect({"," type:\"rect\","," width: 50,"," height: 40,"," transform: \"rotate(45)\""," };"," * <p>The code below would apply `translate` and `rotate` to an existing shape.</p>"," "," myRect.set(\"transform\", \"translate(40, 50) rotate(45)\");"," * @config transform"," * @type String "," */"," transform: {"," setter: function(val)"," {"," this.matrix.init(); "," this._transforms = this.matrix.getTransformArray(val);"," this._transform = val;"," return val;"," },",""," getter: function()"," {"," return this._transform;"," }"," },",""," /**"," * Dom node for the shape"," *"," * @config node"," * @type HTMLElement"," * @readOnly"," */"," node: {"," readOnly: true,",""," getter: function()"," {"," return this.node;"," }"," },",""," /**"," * Unique id for class instance."," *"," * @config id"," * @type String"," */"," id: {"," valueFn: function()"," {"," return Y.guid();"," },",""," setter: function(val)"," {"," var node = this.node;"," if(node)"," {"," node.setAttribute(\"id\", val);"," }"," return val;"," }"," },",""," /**"," * Indicates the width of the shape"," *"," * @config width"," * @type Number"," */"," width: {"," value: 0"," },",""," /**"," * Indicates the height of the shape"," *"," * @config height"," * @type Number"," */"," height: {"," value: 0"," },",""," /**"," * Indicates the x position of shape."," *"," * @config x"," * @type Number"," */"," x: {"," value: 0"," },",""," /**"," * Indicates the y position of shape."," *"," * @config y"," * @type Number"," */"," y: {"," value: 0"," },",""," /**"," * Indicates whether the shape is visible."," *"," * @config visible"," * @type Boolean"," */"," visible: {"," value: true,",""," setter: function(val){"," var node = this.get(\"node\"),"," visibility = val ? \"visible\" : \"hidden\";"," if(node)"," {"," node.style.visibility = visibility;"," }"," return val;"," }"," },",""," /**"," * Contains information about the fill of the shape. "," * <dl>"," * <dt>color</dt><dd>The color of the fill.</dd>"," * <dt>opacity</dt><dd>Number between 0 and 1 that indicates the opacity of the fill. The default value is 1.</dd>"," * <dt>type</dt><dd>Type of fill."," * <dl>"," * <dt>solid</dt><dd>Solid single color fill. (default)</dd>"," * <dt>linear</dt><dd>Linear gradient fill.</dd>"," * <dt>radial</dt><dd>Radial gradient fill.</dd>"," * </dl>"," * </dd>"," * </dl>"," * <p>If a `linear` or `radial` is specified as the fill type. The following additional property is used:"," * <dl>"," * <dt>stops</dt><dd>An array of objects containing the following properties:"," * <dl>"," * <dt>color</dt><dd>The color of the stop.</dd>"," * <dt>opacity</dt><dd>Number between 0 and 1 that indicates the opacity of the stop. The default value is 1. Note: No effect for IE 6 - 8</dd>"," * <dt>offset</dt><dd>Number between 0 and 1 indicating where the color stop is positioned.</dd> "," * </dl>"," * </dd>"," * <p>Linear gradients also have the following property:</p>"," * <dt>rotation</dt><dd>Linear gradients flow left to right by default. The rotation property allows you to change the flow by rotation. (e.g. A rotation of 180 would make the gradient pain from right to left.)</dd>"," * <p>Radial gradients have the following additional properties:</p>"," * <dt>r</dt><dd>Radius of the gradient circle.</dd>"," * <dt>fx</dt><dd>Focal point x-coordinate of the gradient.</dd>"," * <dt>fy</dt><dd>Focal point y-coordinate of the gradient.</dd>"," * </dl>"," * <p>The corresponding `SVGShape` class implements the following additional properties.</p>"," * <dl>"," * <dt>cx</dt><dd>"," * <p>The x-coordinate of the center of the gradient circle. Determines where the color stop begins. The default value 0.5.</p>"," * </dd>"," * <dt>cy</dt><dd>"," * <p>The y-coordinate of the center of the gradient circle. Determines where the color stop begins. The default value 0.5.</p>"," * </dd>"," * </dl>"," * <p>These properties are not currently implemented in `CanvasShape` or `VMLShape`.</p> "," *"," * @config fill"," * @type Object "," */"," fill: {"," valueFn: \"_getDefaultFill\","," "," setter: function(val)"," {"," var fill,"," tmpl = this.get(\"fill\") || this._getDefaultFill();"," fill = (val) ? Y.merge(tmpl, val) : null;"," if(fill && fill.color)"," {"," if(fill.color === undefined || fill.color == \"none\")"," {"," fill.color = null;"," }"," }"," this._setFillProps(fill);"," return fill;"," }"," },",""," /**"," * Contains information about the stroke of the shape."," * <dl>"," * <dt>color</dt><dd>The color of the stroke.</dd>"," * <dt>weight</dt><dd>Number that indicates the width of the stroke.</dd>"," * <dt>opacity</dt><dd>Number between 0 and 1 that indicates the opacity of the stroke. The default value is 1.</dd>"," * <dt>dashstyle</dt>Indicates whether to draw a dashed stroke. When set to \"none\", a solid stroke is drawn. When set to an array, the first index indicates the"," * length of the dash. The second index indicates the length of gap."," * <dt>linecap</dt><dd>Specifies the linecap for the stroke. The following values can be specified:"," * <dl>"," * <dt>butt (default)</dt><dd>Specifies a butt linecap.</dd>"," * <dt>square</dt><dd>Specifies a sqare linecap.</dd>"," * <dt>round</dt><dd>Specifies a round linecap.</dd>"," * </dl>"," * </dd>"," * <dt>linejoin</dt><dd>Specifies a linejoin for the stroke. The following values can be specified:"," * <dl>"," * <dt>round (default)</dt><dd>Specifies that the linejoin will be round.</dd>"," * <dt>bevel</dt><dd>Specifies a bevel for the linejoin.</dd>"," * <dt>miter limit</dt><dd>An integer specifying the miter limit of a miter linejoin. If you want to specify a linejoin of miter, you simply specify the limit as opposed to having"," * separate miter and miter limit values.</dd>"," * </dl>"," * </dd>"," * </dl>"," *"," * @config stroke"," * @type Object"," */"," stroke: {"," valueFn: \"_getDefaultStroke\",",""," setter: function(val)"," {"," var tmpl = this.get(\"stroke\") || this._getDefaultStroke(),"," wt;"," if(val && val.hasOwnProperty(\"weight\"))"," {"," wt = parseInt(val.weight, 10);"," if(!isNaN(wt))"," {"," val.weight = wt;"," }"," }"," val = (val) ? Y.merge(tmpl, val) : null;"," this._setStrokeProps(val);"," return val;"," }"," },"," "," //Not used. Remove in future."," autoSize: {"," value: false"," },",""," // Only implemented in SVG"," // Determines whether the instance will receive mouse events."," // "," // @config pointerEvents"," // @type string"," //"," pointerEvents: {"," value: \"visiblePainted\""," },",""," /**"," * Represents an SVG Path string. This will be parsed and added to shape's API to represent the SVG data across all implementations. Note that when using VML or SVG "," * implementations, part of this content will be added to the DOM using respective VML/SVG attributes. If your content comes from an untrusted source, you will need "," * to ensure that no malicious code is included in that content. "," *"," * @config data"," * @type String"," */"," data: {"," setter: function(val)"," {"," if(this.get(\"node\"))"," {"," this._parsePathData(val);"," }"," return val;"," }"," },",""," /**"," * Reference to the container Graphic."," *"," * @config graphic"," * @type Graphic"," */"," graphic: {"," readOnly: true,",""," getter: function()"," {"," return this._graphic;"," }"," }","};","Y.CanvasShape = CanvasShape;","/**"," * <a href=\"http://www.w3.org/TR/html5/the-canvas-element.html\">Canvas</a> implementation of the <a href=\"Path.html\">`Path`</a> class. "," * `CanvasPath` is not intended to be used directly. Instead, use the <a href=\"Path.html\">`Path`</a> class. "," * If the browser lacks <a href=\"http://www.w3.org/TR/SVG/\">SVG</a> capabilities but has "," * <a href=\"http://www.w3.org/TR/html5/the-canvas-element.html\">Canvas</a> capabilities, the <a href=\"Path.html\">`Path`</a> "," * class will point to the `CanvasPath` class."," *"," * @module graphics"," * @class CanvasPath"," * @extends CanvasShape"," */","CanvasPath = function(cfg)","{"," CanvasPath.superclass.constructor.apply(this, arguments);","};","CanvasPath.NAME = \"path\";","Y.extend(CanvasPath, Y.CanvasShape, {"," /**"," * Indicates the type of shape"," *"," * @property _type"," * @type String"," * @private"," */"," _type: \"path\",",""," /**"," * Draws the shape."," *"," * @method _draw"," * @private"," */"," _draw: function()"," {"," this._closePath();"," this._updateTransform();"," },",""," /**"," * Creates the dom node for the shape."," *"," * @method createNode"," * @return HTMLElement"," * @private"," */"," createNode: function()"," {"," var host = this,"," node = Y.config.doc.createElement('canvas'),"," name = host.name,"," concat = host._camelCaseConcat,"," id = host.get(\"id\");"," host._context = node.getContext('2d');"," node.setAttribute(\"overflow\", \"visible\");"," node.setAttribute(\"pointer-events\", \"none\");"," node.style.pointerEvents = \"none\";"," node.style.overflow = \"visible\";"," node.setAttribute(\"id\", id);"," id = \"#\" + id;"," host.node = node;"," host.addClass(_getClassName(SHAPE) + \" \" + _getClassName(concat(IMPLEMENTATION, SHAPE)) + \" \" + _getClassName(name) + \" \" + _getClassName(concat(IMPLEMENTATION, name))); "," },",""," /**"," * Completes a drawing operation. "," *"," * @method end"," */"," end: function()"," {"," this._draw();"," }","});","","CanvasPath.ATTRS = Y.merge(Y.CanvasShape.ATTRS, {"," /**"," * Indicates the width of the shape"," *"," * @config width"," * @type Number"," */"," width: {"," getter: function()"," {"," var offset = this._stroke && this._strokeWeight ? (this._strokeWeight * 2) : 0;"," return this._width - offset;"," },",""," setter: function(val)"," {"," this._width = val;"," return val;"," }"," },",""," /**"," * Indicates the height of the shape"," *"," * @config height"," * @type Number"," */"," height: {"," getter: function()"," {"," var offset = this._stroke && this._strokeWeight ? (this._strokeWeight * 2) : 0;"," return this._height - offset;"," },",""," setter: function(val)"," {"," this._height = val;"," return val;"," }"," },"," "," /**"," * Indicates the path used for the node."," *"," * @config path"," * @type String"," * @readOnly"," */"," path: {"," readOnly: true,",""," getter: function()"," {"," return this._path;"," }"," }","});","Y.CanvasPath = CanvasPath;","/**"," * <a href=\"http://www.w3.org/TR/html5/the-canvas-element.html\">Canvas</a> implementation of the <a href=\"Rect.html\">`Rect`</a> class. "," * `CanvasRect` is not intended to be used directly. Instead, use the <a href=\"Rect.html\">`Rect`</a> class. "," * If the browser lacks <a href=\"http://www.w3.org/TR/SVG/\">SVG</a> capabilities but has "," * <a href=\"http://www.w3.org/TR/html5/the-canvas-element.html\">Canvas</a> capabilities, the <a href=\"Rect.html\">`Rect`</a> "," * class will point to the `CanvasRect` class."," *"," * @module graphics"," * @class CanvasRect"," * @constructor"," */","CanvasRect = function()","{"," CanvasRect.superclass.constructor.apply(this, arguments);","};","CanvasRect.NAME = \"rect\";","Y.extend(CanvasRect, Y.CanvasShape, {"," /**"," * Indicates the type of shape"," *"," * @property _type"," * @type String"," * @private"," */"," _type: \"rect\",",""," /**"," * Draws the shape."," *"," * @method _draw"," * @private"," */"," _draw: function()"," {"," var w = this.get(\"width\"),"," h = this.get(\"height\");"," this.clear();"," this.drawRect(0, 0, w, h);"," this._closePath();"," }","});","CanvasRect.ATTRS = Y.CanvasShape.ATTRS;","Y.CanvasRect = CanvasRect;","/**"," * <a href=\"http://www.w3.org/TR/html5/the-canvas-element.html\">Canvas</a> implementation of the <a href=\"Ellipse.html\">`Ellipse`</a> class. "," * `CanvasEllipse` is not intended to be used directly. Instead, use the <a href=\"Ellipse.html\">`Ellipse`</a> class. "," * If the browser lacks <a href=\"http://www.w3.org/TR/SVG/\">SVG</a> capabilities but has "," * <a href=\"http://www.w3.org/TR/html5/the-canvas-element.html\">Canvas</a> capabilities, the <a href=\"Ellipse.html\">`Ellipse`</a> "," * class will point to the `CanvasEllipse` class."," *"," * @module graphics"," * @class CanvasEllipse"," * @constructor"," */","CanvasEllipse = function(cfg)","{"," CanvasEllipse.superclass.constructor.apply(this, arguments);","};","","CanvasEllipse.NAME = \"ellipse\";","","Y.extend(CanvasEllipse, CanvasShape, {"," /**"," * Indicates the type of shape"," *"," * @property _type"," * @type String"," * @private"," */"," _type: \"ellipse\",",""," /**"," * Draws the shape."," *"," * @method _draw"," * @private"," */"," _draw: function()"," {"," var w = this.get(\"width\"),"," h = this.get(\"height\");"," this.clear();"," this.drawEllipse(0, 0, w, h);"," this._closePath();"," }","});","CanvasEllipse.ATTRS = Y.merge(CanvasShape.ATTRS, {"," /**"," * Horizontal radius for the ellipse. "," *"," * @config xRadius"," * @type Number"," */"," xRadius: {"," setter: function(val)"," {"," this.set(\"width\", val * 2);"," },",""," getter: function()"," {"," var val = this.get(\"width\");"," if(val) "," {"," val *= 0.5;"," }"," return val;"," }"," },",""," /**"," * Vertical radius for the ellipse. "," *"," * @config yRadius"," * @type Number"," * @readOnly"," */"," yRadius: {"," setter: function(val)"," {"," this.set(\"height\", val * 2);"," },",""," getter: function()"," {"," var val = this.get(\"height\");"," if(val) "," {"," val *= 0.5;"," }"," return val;"," }"," }","});","Y.CanvasEllipse = CanvasEllipse;","/**"," * <a href=\"http://www.w3.org/TR/html5/the-canvas-element.html\">Canvas</a> implementation of the <a href=\"Circle.html\">`Circle`</a> class. "," * `CanvasCircle` is not intended to be used directly. Instead, use the <a href=\"Circle.html\">`Circle`</a> class. "," * If the browser lacks <a href=\"http://www.w3.org/TR/SVG/\">SVG</a> capabilities but has "," * <a href=\"http://www.w3.org/TR/html5/the-canvas-element.html\">Canvas</a> capabilities, the <a href=\"Circle.html\">`Circle`</a> "," * class will point to the `CanvasCircle` class."," *"," * @module graphics"," * @class CanvasCircle"," * @constructor"," */","CanvasCircle = function(cfg)","{"," CanvasCircle.superclass.constructor.apply(this, arguments);","};"," ","CanvasCircle.NAME = \"circle\";","","Y.extend(CanvasCircle, Y.CanvasShape, {"," /**"," * Indicates the type of shape"," *"," * @property _type"," * @type String"," * @private"," */"," _type: \"circle\",",""," /**"," * Draws the shape."," *"," * @method _draw"," * @private"," */"," _draw: function()"," {"," var radius = this.get(\"radius\");"," if(radius)"," {"," this.clear();"," this.drawCircle(0, 0, radius);"," this._closePath();"," }"," }","});","","CanvasCircle.ATTRS = Y.merge(Y.CanvasShape.ATTRS, {"," /**"," * Indicates the width of the shape"," *"," * @config width"," * @type Number"," */"," width: {"," setter: function(val)"," {"," this.set(\"radius\", val/2);"," return val;"," },",""," getter: function()"," {"," return this.get(\"radius\") * 2;"," }"," },",""," /**"," * Indicates the height of the shape"," *"," * @config height"," * @type Number"," */"," height: {"," setter: function(val)"," {"," this.set(\"radius\", val/2);"," return val;"," },",""," getter: function()"," {"," return this.get(\"radius\") * 2;"," }"," },",""," /**"," * Radius of the circle"," *"," * @config radius"," * @type Number"," */"," radius: {"," lazyAdd: false"," }","});","Y.CanvasCircle = CanvasCircle;","/**"," * Draws pie slices"," *"," * @module graphics"," * @class CanvasPieSlice"," * @constructor"," */","CanvasPieSlice = function()","{"," CanvasPieSlice.superclass.constructor.apply(this, arguments);","};","CanvasPieSlice.NAME = \"canvasPieSlice\";","Y.extend(CanvasPieSlice, Y.CanvasShape, {"," /**"," * Indicates the type of shape"," *"," * @property _type"," * @type String"," * @private"," */"," _type: \"path\",",""," /**"," * Change event listener"," *"," * @private"," * @method _updateHandler"," */"," _draw: function(e)"," {"," var x = this.get(\"cx\"),"," y = this.get(\"cy\"),"," startAngle = this.get(\"startAngle\"),"," arc = this.get(\"arc\"),"," radius = this.get(\"radius\");"," this.clear();"," this._left = x;"," this._right = radius;"," this._top = y;"," this._bottom = radius;"," this.drawWedge(x, y, startAngle, arc, radius);"," this.end();"," }"," });","CanvasPieSlice.ATTRS = Y.mix({"," cx: {"," value: 0"," },",""," cy: {"," value: 0"," },"," /**"," * Starting angle in relation to a circle in which to begin the pie slice drawing."," *"," * @config startAngle"," * @type Number"," */"," startAngle: {"," value: 0"," },",""," /**"," * Arc of the slice."," *"," * @config arc"," * @type Number"," */"," arc: {"," value: 0"," },",""," /**"," * Radius of the circle in which the pie slice is drawn"," *"," * @config radius"," * @type Number"," */"," radius: {"," value: 0"," }","}, Y.CanvasShape.ATTRS);","Y.CanvasPieSlice = CanvasPieSlice;","/**"," * <a href=\"http://www.w3.org/TR/html5/the-canvas-element.html\">Canvas</a> implementation of the `Graphic` class. "," * `CanvasGraphic` is not intended to be used directly. Instead, use the <a href=\"Graphic.html\">`Graphic`</a> class. "," * If the browser lacks <a href=\"http://www.w3.org/TR/SVG/\">SVG</a> capabilities but has "," * <a href=\"http://www.w3.org/TR/html5/the-canvas-element.html\">Canvas</a> capabilities, the <a href=\"Graphic.html\">`Graphic`</a> "," * class will point to the `CanvasGraphic` class."," *"," * @module graphics"," * @class CanvasGraphic"," * @constructor"," */","function CanvasGraphic(config) {"," "," CanvasGraphic.superclass.constructor.apply(this, arguments);","}","","CanvasGraphic.NAME = \"canvasGraphic\";","","CanvasGraphic.ATTRS = {"," /**"," * 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."," * "," * @config render"," * @type Node | String "," */"," render: {},"," "," /**"," * Unique id for class instance."," *"," * @config id"," * @type String"," */"," id: {"," valueFn: function()"," {"," return Y.guid();"," },",""," setter: function(val)"," {"," var node = this._node;"," if(node)"," {"," node.setAttribute(\"id\", val);"," }"," return val;"," }"," },",""," /**"," * Key value pairs in which a shape instance is associated with its id."," *"," * @config shapes"," * @type Object"," * @readOnly"," */"," shapes: {"," readOnly: true,",""," getter: function()"," {"," return this._shapes;"," }"," },",""," /**"," * Object containing size and coordinate data for the content of a Graphic in relation to the graphic instance's position."," *"," * @config contentBounds "," * @type Object"," * @readOnly"," */"," contentBounds: {"," readOnly: true,",""," getter: function()"," {"," return this._contentBounds;"," }"," },",""," /**"," * The outermost html element of the Graphic instance."," *"," * @config node"," * @type HTMLElement"," * @readOnly"," */"," node: {"," readOnly: true,",""," getter: function()"," {"," return this._node;"," }"," },",""," /**"," * Indicates the width of the `Graphic`. "," *"," * @config width"," * @type Number"," */"," width: {"," setter: function(val)"," {"," if(this._node)"," {"," this._node.style.width = val + \"px\"; "," }"," return val;"," }"," },",""," /**"," * Indicates the height of the `Graphic`. "," *"," * @config height "," * @type Number"," */"," height: {"," setter: function(val)"," {"," if(this._node)"," {"," this._node.style.height = val + \"px\";"," }"," return val;"," }"," },",""," /**"," * Determines the sizing of the Graphic. "," *"," * <dl>"," * <dt>sizeContentToGraphic</dt><dd>The Graphic's width and height attributes are, either explicitly set through the <code>width</code> and <code>height</code>"," * attributes 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, the <code>preserveAspectRatio</code> attribute will determine how the contents are sized.</dd>"," * <dt>sizeGraphicToContent</dt><dd>(Also accepts a value of true) The Graphic's width and height are determined by the size and positioning of the content.</dd>"," * <dt>false</dt><dd>The Graphic's width and height attributes are, either explicitly set through the <code>width</code> and <code>height</code>"," * attributes or are determined by the dimensions of the parent element. The contents of the Graphic instance are not affected by this setting.</dd>"," * </dl>"," *"," *"," * @config autoSize"," * @type Boolean | String"," * @default false"," */"," autoSize: {"," value: false"," },",""," /**"," * Determines how content is sized when <code>autoSize</code> is set to <code>sizeContentToGraphic</code>."," *"," * <dl>"," * <dt>none<dt><dd>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.</dd>"," * <dt>xMinYMin</dt><dd>Force uniform scaling position along the top left of the Graphic's node.</dd>"," * <dt>xMidYMin</dt><dd>Force uniform scaling horizontally centered and positioned at the top of the Graphic's node.<dd>"," * <dt>xMaxYMin</dt><dd>Force uniform scaling positioned horizontally from the right and vertically from the top.</dd>"," * <dt>xMinYMid</dt>Force uniform scaling positioned horizontally from the left and vertically centered.</dd>"," * <dt>xMidYMid (the default)</dt><dd>Force uniform scaling with the content centered.</dd>"," * <dt>xMaxYMid</dt><dd>Force uniform scaling positioned horizontally from the right and vertically centered.</dd>"," * <dt>xMinYMax</dt><dd>Force uniform scaling positioned horizontally from the left and vertically from the bottom.</dd>"," * <dt>xMidYMax</dt><dd>Force uniform scaling horizontally centered and position vertically from the bottom.</dd>"," * <dt>xMaxYMax</dt><dd>Force uniform scaling positioned horizontally from the right and vertically from the bottom.</dd>"," * </dl>"," * "," * @config preserveAspectRatio"," * @type String"," * @default xMidYMid"," */"," preserveAspectRatio: {"," value: \"xMidYMid\""," },",""," /**"," * 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."," *"," * @config resizeDown "," * @type Boolean"," */"," resizeDown: {"," value: false"," },",""," /**"," * Indicates the x-coordinate for the instance."," *"," * @config x"," * @type Number"," */"," x: {"," getter: function()"," {"," return this._x;"," },",""," setter: function(val)"," {"," this._x = val;"," if(this._node)"," {"," this._node.style.left = val + \"px\";"," }"," return val;"," }"," },",""," /**"," * Indicates the y-coordinate for the instance."," *"," * @config y"," * @type Number"," */"," y: {"," getter: function()"," {"," return this._y;"," },",""," setter: function(val)"," {"," this._y = val;"," if(this._node)"," {"," this._node.style.top = val + \"px\";"," }"," return val;"," }"," },",""," /**"," * 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."," *"," * @config autoDraw"," * @type Boolean"," * @default true"," * @private"," */"," autoDraw: {"," value: true"," },",""," /**"," * Indicates whether the `Graphic` and its children are visible."," *"," * @config visible"," * @type Boolean"," */"," visible: {"," value: true,",""," setter: function(val)"," {"," this._toggleVisible(val);"," return val;"," }"," }","};","","Y.extend(CanvasGraphic, Y.GraphicBase, {"," /**"," * Sets the value of an attribute."," *"," * @method set"," * @param {String|Object} name The name of the attribute. Alternatively, an object of key value pairs can "," * be passed in to set multiple attributes at once."," * @param {Any} value The value to set the attribute to. This value is ignored if an object is received as "," * the name param."," */"," set: function(attr, value) "," {"," var host = this,"," redrawAttrs = {"," autoDraw: true,"," autoSize: true,"," preserveAspectRatio: true,"," resizeDown: true"," },"," key,"," forceRedraw = false;"," AttributeLite.prototype.set.apply(host, arguments); "," if(host._state.autoDraw === true && Y.Object.size(this._shapes) > 0)"," {"," if(Y_LANG.isString && redrawAttrs[attr])"," {"," forceRedraw = true;"," }"," else if(Y_LANG.isObject(attr))"," {"," for(key in redrawAttrs)"," {"," if(redrawAttrs.hasOwnProperty(key) && attr[key])"," {"," forceRedraw = true;"," break;"," }"," }"," }"," }"," if(forceRedraw)"," {"," host._redraw();"," }"," },",""," /**"," * Storage for `x` attribute."," *"," * @property _x"," * @type Number"," * @private"," */"," _x: 0,",""," /**"," * Storage for `y` attribute."," *"," * @property _y"," * @type Number"," * @private"," */"," _y: 0,",""," /**"," * Gets the current position of the graphic instance in page coordinates."," *"," * @method getXY"," * @return Array The XY position of the shape."," */"," getXY: function()"," {"," var node = Y.one(this._node),"," xy;"," if(node)"," {"," xy = node.getXY();"," }"," return xy;"," },"," "," /**"," * Initializes the class."," *"," * @method initializer"," * @param {Object} config Optional attributes "," * @private"," */"," initializer: function(config) {"," var render = this.get(\"render\"),"," visibility = this.get(\"visible\") ? \"visible\" : \"hidden\","," w = this.get(\"width\") || 0,"," h = this.get(\"height\") || 0;"," this._shapes = {};"," this._redrawQueue = {};"," this._contentBounds = {"," left: 0,"," top: 0,"," right: 0,"," bottom: 0"," };"," this._node = DOCUMENT.createElement('div');"," this._node.style.position = \"absolute\";"," this._node.style.visibility = visibility;"," this.set(\"width\", w);"," this.set(\"height\", h);"," if(render)"," {"," this.render(render);"," }"," },",""," /**"," * Adds the graphics node to the dom."," * "," * @method render"," * @param {HTMLElement} parentNode node in which to render the graphics node into."," */"," render: function(render) {"," var parentNode = Y.one(render),"," node = this._node,"," w = this.get(\"width\") || parseInt(parentNode.getComputedStyle(\"width\"), 10),"," h = this.get(\"height\") || parseInt(parentNode.getComputedStyle(\"height\"), 10);"," parentNode = parentNode || DOCUMENT.body;"," parentNode.appendChild(node);"," node.style.display = \"block\";"," node.style.position = \"absolute\";"," node.style.left = \"0px\";"," node.style.top = \"0px\";"," this.set(\"width\", w);"," this.set(\"height\", h);"," this.parentNode = parentNode;"," return this;"," },",""," /**"," * Removes all nodes."," *"," * @method destroy"," */"," destroy: function()"," {"," this.removeAllShapes();"," if(this._node)"," {"," this._removeChildren(this._node);"," Y.one(this._node).destroy();"," }"," },",""," /**"," * Generates a shape instance by type."," *"," * @method addShape"," * @param {Object} cfg attributes for the shape"," * @return Shape"," */"," addShape: function(cfg)"," {"," cfg.graphic = this;"," if(!this.get(\"visible\"))"," {"," cfg.visible = false;"," }"," var shapeClass = this._getShapeClass(cfg.type),"," shape = new shapeClass(cfg);"," this._appendShape(shape);"," return shape;"," },",""," /**"," * Adds a shape instance to the graphic instance."," *"," * @method _appendShape"," * @param {Shape} shape The shape instance to be added to the graphic."," * @private"," */"," _appendShape: function(shape)"," {"," var node = shape.node,"," parentNode = this._frag || this._node;"," if(this.get(\"autoDraw\")) "," {"," parentNode.appendChild(node);"," }"," else"," {"," this._getDocFrag().appendChild(node);"," }"," },",""," /**"," * Removes a shape instance from from the graphic instance."," *"," * @method removeShape"," * @param {Shape|String} shape The instance or id of the shape to be removed."," */"," removeShape: function(shape)"," {"," if(!(shape instanceof CanvasShape))"," {"," if(Y_LANG.isString(shape))"," {"," shape = this._shapes[shape];"," }"," }"," if(shape && shape instanceof CanvasShape)"," {"," shape._destroy();"," delete this._shapes[shape.get(\"id\")];"," }"," if(this.get(\"autoDraw\")) "," {"," this._redraw();"," }"," return shape;"," },",""," /**"," * Removes all shape instances from the dom."," *"," * @method removeAllShapes"," */"," removeAllShapes: function()"," {"," var shapes = this._shapes,"," i;"," for(i in shapes)"," {"," if(shapes.hasOwnProperty(i))"," {"," shapes[i].destroy();"," }"," }"," this._shapes = {};"," },"," "," /**"," * Clears the graphics object."," *"," * @method clear"," */"," clear: function() {"," this.removeAllShapes();"," },",""," /**"," * Removes all child nodes."," *"," * @method _removeChildren"," * @param {HTMLElement} node"," * @private"," */"," _removeChildren: function(node)"," {"," if(node && node.hasChildNodes())"," {"," var child;"," while(node.firstChild)"," {"," child = node.firstChild;"," this._removeChildren(child);"," node.removeChild(child);"," }"," }"," },"," "," /**"," * Toggles visibility"," *"," * @method _toggleVisible"," * @param {Boolean} val indicates visibilitye"," * @private"," */"," _toggleVisible: function(val)"," {"," var i,"," shapes = this._shapes,"," visibility = val ? \"visible\" : \"hidden\";"," if(shapes)"," {"," for(i in shapes)"," {"," if(shapes.hasOwnProperty(i))"," {"," shapes[i].set(\"visible\", val);"," }"," }"," }"," if(this._node)"," {"," this._node.style.visibility = visibility;"," }"," },",""," /**"," * Returns a shape class. Used by `addShape`. "," *"," * @method _getShapeClass"," * @param {Shape | String} val Indicates which shape class. "," * @return Function "," * @private"," */"," _getShapeClass: function(val)"," {"," var shape = this._shapeClass[val];"," if(shape)"," {"," return shape;"," }"," return val;"," },"," "," /**"," * Look up for shape classes. Used by `addShape` to retrieve a class for instantiation."," *"," * @property _shapeClass"," * @type Object"," * @private"," */"," _shapeClass: {"," circle: Y.CanvasCircle,"," rect: Y.CanvasRect,"," path: Y.CanvasPath,"," ellipse: Y.CanvasEllipse,"," pieslice: Y.CanvasPieSlice"," },"," "," /**"," * Returns a shape based on the id of its dom node."," *"," * @method getShapeById"," * @param {String} id Dom id of the shape's node attribute."," * @return Shape"," */"," getShapeById: function(id)"," {"," var shape = this._shapes[id];"," return shape;"," },",""," /**"," * Allows for creating multiple shapes in order to batch appending and redraw operations."," *"," * @method batch"," * @param {Function} method Method to execute."," */"," batch: function(method)"," {"," var autoDraw = this.get(\"autoDraw\");"," this.set(\"autoDraw\", false);"," method();"," this.set(\"autoDraw\", autoDraw);"," },",""," /**"," * Returns a document fragment to for attaching shapes."," *"," * @method _getDocFrag"," * @return DocumentFragment"," * @private"," */"," _getDocFrag: function()"," {"," if(!this._frag)"," {"," this._frag = DOCUMENT.createDocumentFragment();"," }"," return this._frag;"," },"," "," /**"," * Redraws all shapes."," *"," * @method _redraw"," * @private"," */"," _redraw: function()"," {"," var autoSize = this.get(\"autoSize\"),"," preserveAspectRatio = this.get(\"preserveAspectRatio\"),"," box = this.get(\"resizeDown\") ? this._getUpdatedContentBounds() : this._contentBounds,"," contentWidth,"," contentHeight,"," w,"," h,"," xScale,"," yScale,"," translateX = 0,"," translateY = 0,"," matrix,"," node = this.get(\"node\");"," if(autoSize)"," {"," if(autoSize == \"sizeContentToGraphic\")"," {"," contentWidth = box.right - box.left;"," contentHeight = box.bottom - box.top;"," w = parseFloat(Y_DOM.getComputedStyle(node, \"width\"));"," h = parseFloat(Y_DOM.getComputedStyle(node, \"height\"));"," matrix = new Y.Matrix();"," if(preserveAspectRatio == \"none\")"," {"," xScale = w/contentWidth;"," yScale = h/contentHeight;"," }"," else"," {"," if(contentWidth/contentHeight !== w/h) "," {"," if(contentWidth * h/contentHeight > w)"," {"," xScale = yScale = w/contentWidth;"," translateY = this._calculateTranslate(preserveAspectRatio.slice(5).toLowerCase(), contentHeight * w/contentWidth, h);"," }"," else"," {"," xScale = yScale = h/contentHeight;"," translateX = this._calculateTranslate(preserveAspectRatio.slice(1, 4).toLowerCase(), contentWidth * h/contentHeight, w);"," }"," }"," }"," Y_DOM.setStyle(node, \"transformOrigin\", \"0% 0%\");"," translateX = translateX - (box.left * xScale);"," translateY = translateY - (box.top * yScale);"," matrix.translate(translateX, translateY);"," matrix.scale(xScale, yScale);"," Y_DOM.setStyle(node, \"transform\", matrix.toCSSText());"," }"," else"," {"," this.set(\"width\", box.right);"," this.set(\"height\", box.bottom);"," }"," }"," if(this._frag)"," {"," this._node.appendChild(this._frag);"," this._frag = null;"," }"," },"," "," /**"," * Determines the value for either an x or y value to be used for the <code>translate</code> of the Graphic."," *"," * @method _calculateTranslate"," * @param {String} position The position for placement. Possible values are min, mid and max."," * @param {Number} contentSize The total size of the content."," * @param {Number} boundsSize The total size of the Graphic."," * @return Number"," * @private"," */"," _calculateTranslate: function(position, contentSize, boundsSize)"," {"," var ratio = boundsSize - contentSize,"," coord;"," switch(position)"," {"," case \"mid\" :"," coord = ratio * 0.5;"," break;"," case \"max\" :"," coord = ratio;"," break;"," default :"," coord = 0;"," break;"," }"," return coord;"," },"," "," /**"," * Adds a shape to the redraw queue and calculates the contentBounds. Used internally "," * by `Shape` instances."," *"," * @method addToRedrawQueue"," * @param Shape shape The shape instance to add to the queue"," * @protected"," */"," addToRedrawQueue: function(shape)"," {"," var shapeBox,"," box;"," this._shapes[shape.get(\"id\")] = shape;"," if(!this.get(\"resizeDown\"))"," {"," shapeBox = shape.getBounds();"," box = this._contentBounds;"," box.left = box.left < shapeBox.left ? box.left : shapeBox.left;"," box.top = box.top < shapeBox.top ? box.top : shapeBox.top;"," box.right = box.right > shapeBox.right ? box.right : shapeBox.right;"," box.bottom = box.bottom > shapeBox.bottom ? box.bottom : shapeBox.bottom;"," this._contentBounds = box;"," }"," if(this.get(\"autoDraw\")) "," {"," this._redraw();"," }"," },",""," /**"," * Recalculates and returns the `contentBounds` for the `Graphic` instance."," *"," * @method _getUpdatedContentBounds"," * @return {Object} "," * @private"," */"," _getUpdatedContentBounds: function()"," {"," var bounds,"," i,"," shape,"," queue = this._shapes,"," box = {};"," for(i in queue)"," {"," if(queue.hasOwnProperty(i))"," {"," shape = queue[i];"," bounds = shape.getBounds();"," box.left = Y_LANG.isNumber(box.left) ? Math.min(box.left, bounds.left) : bounds.left;"," box.top = Y_LANG.isNumber(box.top) ? Math.min(box.top, bounds.top) : bounds.top;"," box.right = Y_LANG.isNumber(box.right) ? Math.max(box.right, bounds.right) : bounds.right;"," box.bottom = Y_LANG.isNumber(box.bottom) ? Math.max(box.bottom, bounds.bottom) : bounds.bottom;"," }"," }"," box.left = Y_LANG.isNumber(box.left) ? box.left : 0;"," box.top = Y_LANG.isNumber(box.top) ? box.top : 0;"," box.right = Y_LANG.isNumber(box.right) ? box.right : 0;"," box.bottom = Y_LANG.isNumber(box.bottom) ? box.bottom : 0;"," this._contentBounds = box;"," return box;"," },",""," /**"," * Inserts shape on the top of the tree."," *"," * @method _toFront"," * @param {CanvasShape} Shape to add."," * @private"," */"," _toFront: function(shape)"," {"," var contentNode = this.get(\"node\");"," if(shape instanceof Y.CanvasShape)"," {"," shape = shape.get(\"node\");"," }"," if(contentNode && shape)"," {"," contentNode.appendChild(shape);"," }"," },",""," /**"," * Inserts shape as the first child of the content node."," *"," * @method _toBack"," * @param {CanvasShape} Shape to add."," * @private"," */"," _toBack: function(shape)"," {"," var contentNode = this.get(\"node\"),"," targetNode;"," if(shape instanceof Y.CanvasShape)"," {"," shape = shape.get(\"node\");"," }"," if(contentNode && shape)"," {"," targetNode = contentNode.firstChild;"," if(targetNode)"," {"," contentNode.insertBefore(shape, targetNode);"," }"," else"," {"," contentNode.appendChild(shape);"," }"," }"," }","});","","Y.CanvasGraphic = CanvasGraphic;","","","}, '3.7.1', {\"requires\": [\"graphics\"]});"];
_yuitest_coverage["build/graphics-canvas/graphics-canvas.js"].lines = {"1":0,"3":0,"37":0,"41":0,"89":0,"90":0,"91":0,"94":0,"95":0,"101":0,"112":0,"124":0,"126":0,"128":0,"129":0,"131":0,"133":0,"134":0,"149":0,"150":0,"151":0,"152":0,"163":0,"165":0,"176":0,"179":0,"180":0,"181":0,"195":0,"207":0,"219":0,"232":0,"240":0,"242":0,"244":0,"245":0,"246":0,"247":0,"248":0,"249":0,"250":0,"251":0,"252":0,"253":0,"254":0,"259":0,"261":0,"262":0,"263":0,"264":0,"265":0,"266":0,"267":0,"270":0,"271":0,"283":0,"295":0,"307":0,"312":0,"313":0,"314":0,"315":0,"316":0,"317":0,"332":0,"347":0,"359":0,"376":0,"377":0,"379":0,"380":0,"381":0,"382":0,"383":0,"384":0,"385":0,"386":0,"387":0,"388":0,"389":0,"390":0,"391":0,"392":0,"393":0,"394":0,"395":0,"396":0,"410":0,"423":0,"435":0,"451":0,"453":0,"454":0,"455":0,"456":0,"457":0,"458":0,"459":0,"460":0,"461":0,"462":0,"463":0,"464":0,"465":0,"466":0,"467":0,"469":0,"482":0,"486":0,"487":0,"488":0,"489":0,"490":0,"491":0,"492":0,"507":0,"509":0,"510":0,"511":0,"512":0,"513":0,"514":0,"528":0,"540":0,"541":0,"542":0,"543":0,"545":0,"546":0,"547":0,"548":0,"549":0,"550":0,"551":0,"553":0,"554":0,"555":0,"556":0,"569":0,"570":0,"571":0,"572":0,"573":0,"574":0,"575":0,"576":0,"591":0,"592":0,"593":0,"594":0,"595":0,"596":0,"597":0,"598":0,"599":0,"600":0,"601":0,"602":0,"619":0,"632":0,"634":0,"636":0,"638":0,"641":0,"643":0,"648":0,"651":0,"655":0,"658":0,"661":0,"664":0,"665":0,"666":0,"668":0,"670":0,"671":0,"672":0,"673":0,"674":0,"675":0,"676":0,"679":0,"681":0,"682":0,"683":0,"692":0,"693":0,"703":0,"704":0,"721":0,"741":0,"743":0,"745":0,"746":0,"750":0,"751":0,"753":0,"754":0,"758":0,"760":0,"761":0,"765":0,"766":0,"768":0,"769":0,"771":0,"772":0,"774":0,"775":0,"776":0,"777":0,"778":0,"780":0,"781":0,"785":0,"787":0,"788":0,"790":0,"801":0,"822":0,"823":0,"824":0,"825":0,"826":0,"827":0,"828":0,"829":0,"830":0,"832":0,"834":0,"836":0,"838":0,"839":0,"840":0,"841":0,"842":0,"843":0,"849":0,"851":0,"852":0,"856":0,"857":0,"859":0,"861":0,"862":0,"863":0,"864":0,"865":0,"867":0,"868":0,"872":0,"874":0,"875":0,"876":0,"878":0,"881":0,"892":0,"893":0,"894":0,"895":0,"896":0,"897":0,"898":0,"899":0,"900":0,"901":0,"902":0,"903":0,"923":0,"924":0,"937":0,"942":0,"943":0,"946":0,"947":0,"948":0,"949":0,"952":0,"966":0,"975":0,"977":0,"978":0,"979":0,"980":0,"981":0,"983":0,"984":0,"985":0,"986":0,"987":0,"988":0,"1000":0,"1001":0,"1003":0,"1005":0,"1007":0,"1009":0,"1011":0,"1013":0,"1015":0,"1016":0,"1019":0,"1031":0,"1033":0,"1034":0,"1035":0,"1038":0,"1040":0,"1050":0,"1061":0,"1064":0,"1065":0,"1066":0,"1067":0,"1068":0,"1070":0,"1072":0,"1074":0,"1076":0,"1089":0,"1090":0,"1092":0,"1096":0,"1097":0,"1100":0,"1101":0,"1113":0,"1114":0,"1125":0,"1126":0,"1137":0,"1141":0,"1152":0,"1156":0,"1157":0,"1158":0,"1170":0,"1182":0,"1194":0,"1195":0,"1206":0,"1226":0,"1279":0,"1284":0,"1285":0,"1286":0,"1287":0,"1289":0,"1291":0,"1292":0,"1293":0,"1294":0,"1308":0,"1310":0,"1312":0,"1324":0,"1330":0,"1332":0,"1333":0,"1334":0,"1335":0,"1336":0,"1337":0,"1338":0,"1339":0,"1340":0,"1342":0,"1344":0,"1348":0,"1350":0,"1351":0,"1355":0,"1357":0,"1358":0,"1360":0,"1364":0,"1365":0,"1367":0,"1368":0,"1374":0,"1389":0,"1391":0,"1392":0,"1394":0,"1407":0,"1411":0,"1413":0,"1414":0,"1415":0,"1417":0,"1419":0,"1421":0,"1422":0,"1424":0,"1425":0,"1429":0,"1432":0,"1433":0,"1437":0,"1442":0,"1443":0,"1456":0,"1457":0,"1458":0,"1470":0,"1471":0,"1483":0,"1484":0,"1496":0,"1507":0,"1518":0,"1529":0,"1530":0,"1541":0,"1572":0,"1573":0,"1574":0,"1575":0,"1576":0,"1578":0,"1590":0,"1598":0,"1600":0,"1602":0,"1603":0,"1605":0,"1608":0,"1611":0,"1612":0,"1613":0,"1614":0,"1616":0,"1618":0,"1629":0,"1630":0,"1641":0,"1642":0,"1643":0,"1644":0,"1645":0,"1656":0,"1658":0,"1660":0,"1672":0,"1673":0,"1675":0,"1676":0,"1678":0,"1680":0,"1682":0,"1683":0,"1684":0,"1685":0,"1687":0,"1689":0,"1693":0,"1697":0,"1698":0,"1699":0,"1700":0,"1702":0,"1703":0,"1705":0,"1706":0,"1708":0,"1710":0,"1711":0,"1713":0,"1715":0,"1716":0,"1720":0,"1726":0,"1727":0,"1728":0,"1729":0,"1730":0,"1743":0,"1745":0,"1747":0,"1749":0,"1751":0,"1755":0,"1757":0,"1758":0,"1761":0,"1762":0,"1764":0,"1766":0,"1767":0,"1768":0,"1770":0,"1772":0,"1773":0,"1789":0,"1801":0,"1802":0,"1804":0,"1806":0,"1807":0,"1808":0,"1809":0,"1812":0,"1813":0,"1815":0,"1817":0,"1819":0,"1821":0,"1824":0,"1830":0,"1831":0,"1833":0,"1835":0,"1849":0,"1854":0,"1856":0,"1857":0,"1858":0,"1859":0,"1861":0,"1876":0,"1886":0,"1888":0,"1889":0,"1891":0,"1892":0,"1893":0,"1894":0,"1896":0,"1897":0,"1898":0,"1900":0,"1903":0,"1904":0,"1905":0,"1915":0,"1916":0,"1918":0,"1929":0,"1930":0,"1932":0,"1945":0,"1953":0,"1955":0,"1956":0,"1957":0,"1959":0,"1960":0,"1961":0,"1962":0,"1963":0,"1965":0,"1967":0,"1971":0,"1975":0,"1986":0,"1987":0,"1989":0,"1993":0,"2005":0,"2007":0,"2008":0,"2009":0,"2014":0,"2025":0,"2061":0,"2062":0,"2063":0,"2064":0,"2069":0,"2085":0,"2098":0,"2103":0,"2104":0,"2106":0,"2108":0,"2162":0,"2164":0,"2166":0,"2168":0,"2220":0,"2222":0,"2223":0,"2225":0,"2227":0,"2230":0,"2231":0,"2268":0,"2270":0,"2272":0,"2273":0,"2275":0,"2278":0,"2279":0,"2280":0,"2310":0,"2312":0,"2314":0,"2329":0,"2333":0,"2345":0,"2347":0,"2349":0,"2350":0,"2368":0,"2369":0,"2381":0,"2386":0,"2387":0,"2388":0,"2389":0,"2390":0,"2391":0,"2392":0,"2393":0,"2394":0,"2404":0,"2408":0,"2418":0,"2419":0,"2424":0,"2425":0,"2438":0,"2439":0,"2444":0,"2445":0,"2461":0,"2465":0,"2477":0,"2479":0,"2481":0,"2482":0,"2500":0,"2502":0,"2503":0,"2504":0,"2507":0,"2508":0,"2520":0,"2522":0,"2525":0,"2527":0,"2545":0,"2547":0,"2548":0,"2549":0,"2552":0,"2562":0,"2567":0,"2568":0,"2570":0,"2572":0,"2586":0,"2591":0,"2592":0,"2594":0,"2596":0,"2600":0,"2612":0,"2614":0,"2617":0,"2619":0,"2637":0,"2638":0,"2640":0,"2641":0,"2642":0,"2647":0,"2657":0,"2658":0,"2663":0,"2676":0,"2677":0,"2682":0,"2696":0,"2704":0,"2706":0,"2708":0,"2709":0,"2727":0,"2732":0,"2733":0,"2734":0,"2735":0,"2736":0,"2737":0,"2738":0,"2741":0,"2779":0,"2791":0,"2793":0,"2796":0,"2798":0,"2816":0,"2821":0,"2822":0,"2824":0,"2826":0,"2842":0,"2858":0,"2874":0,"2887":0,"2889":0,"2891":0,"2904":0,"2906":0,"2908":0,"2978":0,"2983":0,"2984":0,"2986":0,"2988":0,"3001":0,"3006":0,"3007":0,"3009":0,"3011":0,"3039":0,"3040":0,"3045":0,"3057":0,"3066":0,"3067":0,"3069":0,"3071":0,"3073":0,"3075":0,"3077":0,"3079":0,"3080":0,"3085":0,"3087":0,"3117":0,"3119":0,"3121":0,"3123":0,"3134":0,"3138":0,"3139":0,"3140":0,"3146":0,"3147":0,"3148":0,"3149":0,"3150":0,"3151":0,"3153":0,"3164":0,"3168":0,"3169":0,"3170":0,"3171":0,"3172":0,"3173":0,"3174":0,"3175":0,"3176":0,"3177":0,"3187":0,"3188":0,"3190":0,"3191":0,"3204":0,"3205":0,"3207":0,"3209":0,"3211":0,"3212":0,"3224":0,"3226":0,"3228":0,"3232":0,"3244":0,"3246":0,"3248":0,"3251":0,"3253":0,"3254":0,"3256":0,"3258":0,"3260":0,"3270":0,"3272":0,"3274":0,"3276":0,"3279":0,"3288":0,"3300":0,"3302":0,"3303":0,"3305":0,"3306":0,"3307":0,"3321":0,"3324":0,"3326":0,"3328":0,"3330":0,"3334":0,"3336":0,"3350":0,"3351":0,"3353":0,"3355":0,"3382":0,"3383":0,"3394":0,"3395":0,"3396":0,"3397":0,"3409":0,"3411":0,"3413":0,"3424":0,"3437":0,"3439":0,"3441":0,"3442":0,"3443":0,"3444":0,"3445":0,"3446":0,"3448":0,"3449":0,"3453":0,"3455":0,"3457":0,"3458":0,"3462":0,"3463":0,"3467":0,"3468":0,"3469":0,"3470":0,"3471":0,"3472":0,"3476":0,"3477":0,"3480":0,"3482":0,"3483":0,"3499":0,"3501":0,"3504":0,"3505":0,"3507":0,"3508":0,"3510":0,"3511":0,"3513":0,"3526":0,"3528":0,"3529":0,"3531":0,"3532":0,"3533":0,"3534":0,"3535":0,"3536":0,"3537":0,"3539":0,"3541":0,"3554":0,"3559":0,"3561":0,"3563":0,"3564":0,"3565":0,"3566":0,"3567":0,"3568":0,"3571":0,"3572":0,"3573":0,"3574":0,"3575":0,"3576":0,"3588":0,"3589":0,"3591":0,"3593":0,"3595":0,"3608":0,"3610":0,"3612":0,"3614":0,"3616":0,"3617":0,"3619":0,"3623":0,"3629":0};
_yuitest_coverage["build/graphics-canvas/graphics-canvas.js"].functions = {"CanvasDrawing:37":0,"_toRGBA:88":0,"_toRGB:111":0,"setSize:123":0,"_updateCoords:147":0,"_clearAndUpdateCoords:161":0,"_updateNodePosition:174":0,"_updateDrawingQueue:193":0,"lineTo:205":0,"relativeLineTo:217":0,"_lineTo:230":0,"moveTo:281":0,"relativeMoveTo:293":0,"_moveTo:306":0,"curveTo:331":0,"relativeCurveTo:346":0,"_curveTo:358":0,"quadraticCurveTo:409":0,"relativeQuadraticCurveTo:422":0,"_quadraticCurveTo:434":0,"drawCircle:481":0,"drawDiamond:505":0,"drawEllipse:527":0,"drawRect:568":0,"drawRoundRect:590":0,"drawWedge:617":0,"end:691":0,"closePath:701":0,"_getLinearGradient:720":0,"_getRadialGradient:800":0,"_initProps:891":0,"_createGraphic:922":0,"getBezierData:936":0,"_setCurveBoundingBox:964":0,"_trackSize:999":0,"CanvasShape:1031":0,"init:1048":0,"initializer:1059":0,"_setGraphic:1087":0,"addClass:1111":0,"removeClass:1123":0,"getXY:1135":0,"setXY:1150":0,"contains:1168":0,"test:1180":0,"compareTo:1193":0,"_getDefaultFill:1205":0,"_getDefaultStroke:1224":0,"createNode:1277":0,"on:1306":0,"_setStrokeProps:1322":0,"set:1387":0,"_setFillProps:1405":0,"translate:1454":0,"translateX:1468":0,"translateY:1481":0,"skew:1494":0,"skewX:1505":0,"skewY:1516":0,"rotate:1527":0,"scale:1539":0,"_addTransform:1570":0,"_updateTransform:1588":0,"_updateHandler:1627":0,"_draw:1639":0,"_closePath:1654":0,"_strokeAndFill:1741":0,"_drawDashedLine:1787":0,"clear:1829":0,"getBounds:1847":0,"_getContentRect:1874":0,"toFront:1913":0,"toBack:1927":0,"_parsePathData:1943":0,"destroy:1984":0,"_destroy:2003":0,"valueFn:2023":0,"setter:2059":0,"getter:2067":0,"getter:2083":0,"valueFn:2096":0,"setter:2101":0,"setter:2161":0,"setter:2218":0,"setter:2266":0,"setter:2308":0,"getter:2327":0,"CanvasPath:2345":0,"_draw:2366":0,"createNode:2379":0,"end:2402":0,"getter:2416":0,"setter:2422":0,"getter:2436":0,"setter:2442":0,"getter:2459":0,"CanvasRect:2477":0,"_draw:2498":0,"CanvasEllipse:2520":0,"_draw:2543":0,"setter:2560":0,"getter:2565":0,"setter:2584":0,"getter:2589":0,"CanvasCircle:2612":0,"_draw:2635":0,"setter:2655":0,"getter:2661":0,"setter:2674":0,"getter:2680":0,"CanvasPieSlice:2704":0,"_draw:2725":0,"CanvasGraphic:2791":0,"valueFn:2814":0,"setter:2819":0,"getter:2840":0,"getter:2856":0,"getter:2872":0,"setter:2885":0,"setter:2902":0,"getter:2976":0,"setter:2981":0,"getter:2999":0,"setter:3004":0,"setter:3037":0,"set:3055":0,"getXY:3115":0,"initializer:3133":0,"render:3163":0,"destroy:3185":0,"addShape:3202":0,"_appendShape:3222":0,"removeShape:3242":0,"removeAllShapes:3268":0,"clear:3287":0,"_removeChildren:3298":0,"_toggleVisible:3319":0,"_getShapeClass:3348":0,"getShapeById:3380":0,"batch:3392":0,"_getDocFrag:3407":0,"_redraw:3422":0,"_calculateTranslate:3497":0,"addToRedrawQueue:3524":0,"_getUpdatedContentBounds:3552":0,"_toFront:3586":0,"_toBack:3606":0,"(anonymous 1):1":0};
_yuitest_coverage["build/graphics-canvas/graphics-canvas.js"].coveredLines = 890;
_yuitest_coverage["build/graphics-canvas/graphics-canvas.js"].coveredFunctions = 148;
_yuitest_coverline("build/graphics-canvas/graphics-canvas.js", 1);
YUI.add('graphics-canvas', function (Y, NAME) {
_yuitest_coverfunc("build/graphics-canvas/graphics-canvas.js", "(anonymous 1)", 1);
_yuitest_coverline("build/graphics-canvas/graphics-canvas.js", 3);
var IMPLEMENTATION = "canvas",
SHAPE = "shape",
SPLITPATHPATTERN = /[a-z][^a-z]*/ig,
SPLITARGSPATTERN = /[-]?[0-9]*[0-9|\.][0-9]*/g,
DOCUMENT = Y.config.doc,
Y_LANG = Y.Lang,
AttributeLite = Y.AttributeLite,
CanvasShape,
CanvasPath,
CanvasRect,
CanvasEllipse,
CanvasCircle,
CanvasPieSlice,
Y_DOM = Y.DOM,
Y_Color = Y.Color,
PARSE_INT = parseInt,
PARSE_FLOAT = parseFloat,
IS_NUMBER = Y_LANG.isNumber,
RE = RegExp,
TORGB = Y_Color.toRGB,
TOHEX = Y_Color.toHex,
_getClassName = Y.ClassNameManager.getClassName;
/**
* <a href="http://www.w3.org/TR/html5/the-canvas-element.html">Canvas</a> implementation of the <a href="Drawing.html">`Drawing`</a> class.
* `CanvasDrawing` is not intended to be used directly. Instead, use the <a href="Drawing.html">`Drawing`</a> class.
* If the browser lacks <a href="http://www.w3.org/TR/SVG/">SVG</a> capabilities but has
* <a href="http://www.w3.org/TR/html5/the-canvas-element.html">Canvas</a> capabilities, the <a href="Drawing.html">`Drawing`</a>
* class will point to the `CanvasDrawing` class.
*
* @module graphics
* @class CanvasDrawing
* @constructor
*/
_yuitest_coverline("build/graphics-canvas/graphics-canvas.js", 37);
function CanvasDrawing()
{
}
_yuitest_coverline("build/graphics-canvas/graphics-canvas.js", 41);
CanvasDrawing.prototype = {
/**
* Maps path to methods
*
* @property _pathSymbolToMethod
* @type Object
* @private
*/
_pathSymbolToMethod: {
M: "moveTo",
m: "relativeMoveTo",
L: "lineTo",
l: "relativeLineTo",
C: "curveTo",
c: "relativeCurveTo",
Q: "quadraticCurveTo",
q: "relativeQuadraticCurveTo",
z: "closePath",
Z: "closePath"
},
/**
* Current x position of the drawing.
*
* @property _currentX
* @type Number
* @private
*/
_currentX: 0,
/**
* Current y position of the drqwing.
*
* @property _currentY
* @type Number
* @private
*/
_currentY: 0,
/**
* Parses hex color string and alpha value to rgba
*
* @method _toRGBA
* @param {Object} val Color value to parse. Can be hex string, rgb or name.
* @param {Number} alpha Numeric value between 0 and 1 representing the alpha level.
* @private
*/
_toRGBA: function(val, alpha) {
_yuitest_coverfunc("build/graphics-canvas/graphics-canvas.js", "_toRGBA", 88);
_yuitest_coverline("build/graphics-canvas/graphics-canvas.js", 89);
alpha = (alpha !== undefined) ? alpha : 1;
_yuitest_coverline("build/graphics-canvas/graphics-canvas.js", 90);
if (!Y_Color.re_RGB.test(val)) {
_yuitest_coverline("build/graphics-canvas/graphics-canvas.js", 91);
val = TOHEX(val);
}
_yuitest_coverline("build/graphics-canvas/graphics-canvas.js", 94);
if(Y_Color.re_hex.exec(val)) {
_yuitest_coverline("build/graphics-canvas/graphics-canvas.js", 95);
val = 'rgba(' + [
PARSE_INT(RE.$1, 16),
PARSE_INT(RE.$2, 16),
PARSE_INT(RE.$3, 16)
].join(',') + ',' + alpha + ')';
}
_yuitest_coverline("build/graphics-canvas/graphics-canvas.js", 101);
return val;
},
/**
* Converts color to rgb format
*
* @method _toRGB
* @param val Color value to convert.
* @private
*/
_toRGB: function(val) {
_yuitest_coverfunc("build/graphics-canvas/graphics-canvas.js", "_toRGB", 111);
_yuitest_coverline("build/graphics-canvas/graphics-canvas.js", 112);
return TORGB(val);
},
/**
* Sets the size of the graphics object.
*
* @method setSize
* @param w {Number} width to set for the instance.
* @param h {Number} height to set for the instance.
* @private
*/
setSize: function(w, h) {
_yuitest_coverfunc("build/graphics-canvas/graphics-canvas.js", "setSize", 123);
_yuitest_coverline("build/graphics-canvas/graphics-canvas.js", 124);
if(this.get("autoSize"))
{
_yuitest_coverline("build/graphics-canvas/graphics-canvas.js", 126);
if(w > this.node.getAttribute("width"))
{
_yuitest_coverline("build/graphics-canvas/graphics-canvas.js", 128);
this.node.style.width = w + "px";
_yuitest_coverline("build/graphics-canvas/graphics-canvas.js", 129);
this.node.setAttribute("width", w);
}
_yuitest_coverline("build/graphics-canvas/graphics-canvas.js", 131);
if(h > this.node.getAttribute("height"))
{
_yuitest_coverline("build/graphics-canvas/graphics-canvas.js", 133);
this.node.style.height = h + "px";
_yuitest_coverline("build/graphics-canvas/graphics-canvas.js", 134);
this.node.setAttribute("height", h);
}
}
},
/**
* Tracks coordinates. Used to calculate the start point of dashed lines.
*
* @method _updateCoords
* @param {Number} x x-coordinate
* @param {Number} y y-coordinate
* @private
*/
_updateCoords: function(x, y)
{
_yuitest_coverfunc("build/graphics-canvas/graphics-canvas.js", "_updateCoords", 147);
_yuitest_coverline("build/graphics-canvas/graphics-canvas.js", 149);
this._xcoords.push(x);
_yuitest_coverline("build/graphics-canvas/graphics-canvas.js", 150);
this._ycoords.push(y);
_yuitest_coverline("build/graphics-canvas/graphics-canvas.js", 151);
this._currentX = x;
_yuitest_coverline("build/graphics-canvas/graphics-canvas.js", 152);
this._currentY = y;
},
/**
* Clears the coordinate arrays. Called at the end of a drawing operation.
*
* @method _clearAndUpdateCoords
* @private
*/
_clearAndUpdateCoords: function()
{
_yuitest_coverfunc("build/graphics-canvas/graphics-canvas.js", "_clearAndUpdateCoords", 161);
_yuitest_coverline("build/graphics-canvas/graphics-canvas.js", 163);
var x = this._xcoords.pop() || 0,
y = this._ycoords.pop() || 0;
_yuitest_coverline("build/graphics-canvas/graphics-canvas.js", 165);
this._updateCoords(x, y);
},
/**
* Moves the shape's dom node.
*
* @method _updateNodePosition
* @private
*/
_updateNodePosition: function()
{
_yuitest_coverfunc("build/graphics-canvas/graphics-canvas.js", "_updateNodePosition", 174);
_yuitest_coverline("build/graphics-canvas/graphics-canvas.js", 176);
var node = this.get("node"),
x = this.get("x"),
y = this.get("y");
_yuitest_coverline("build/graphics-canvas/graphics-canvas.js", 179);
node.style.position = "absolute";
_yuitest_coverline("build/graphics-canvas/graphics-canvas.js", 180);
node.style.left = (x + this._left) + "px";
_yuitest_coverline("build/graphics-canvas/graphics-canvas.js", 181);
node.style.top = (y + this._top) + "px";
},
/**
* Queues up a method to be executed when a shape redraws.
*
* @method _updateDrawingQueue
* @param {Array} val An array containing data that can be parsed into a method and arguments. The value at zero-index of the array is a string reference of
* the drawing method that will be called. All subsequent indices are argument for that method. For example, `lineTo(10, 100)` would be structured as:
* `["lineTo", 10, 100]`.
* @private
*/
_updateDrawingQueue: function(val)
{
_yuitest_coverfunc("build/graphics-canvas/graphics-canvas.js", "_updateDrawingQueue", 193);
_yuitest_coverline("build/graphics-canvas/graphics-canvas.js", 195);
this._methods.push(val);
},
/**
* Draws a line segment from the current drawing position to the specified x and y coordinates.
*
* @method lineTo
* @param {Number} point1 x-coordinate for the end point.
* @param {Number} point2 y-coordinate for the end point.
*/
lineTo: function()
{
_yuitest_coverfunc("build/graphics-canvas/graphics-canvas.js", "lineTo", 205);
_yuitest_coverline("build/graphics-canvas/graphics-canvas.js", 207);
this._lineTo.apply(this, [Y.Array(arguments), false]);
},
/**
* Draws a line segment from the current drawing position to the relative x and y coordinates.
*
* @method lineTo
* @param {Number} point1 x-coordinate for the end point.
* @param {Number} point2 y-coordinate for the end point.
*/
relativeLineTo: function()
{
_yuitest_coverfunc("build/graphics-canvas/graphics-canvas.js", "relativeLineTo", 217);
_yuitest_coverline("build/graphics-canvas/graphics-canvas.js", 219);
this._lineTo.apply(this, [Y.Array(arguments), true]);
},
/**
* Implements lineTo methods.
*
* @method _lineTo
* @param {Array} args The arguments to be used.
* @param {Boolean} relative Indicates whether or not to use relative coordinates.
* @private
*/
_lineTo: function(args, relative)
{
_yuitest_coverfunc("build/graphics-canvas/graphics-canvas.js", "_lineTo", 230);
_yuitest_coverline("build/graphics-canvas/graphics-canvas.js", 232);
var point1 = args[0],
i,
len,
x,
y,
wt = this._stroke && this._strokeWeight ? this._strokeWeight : 0,
relativeX = relative ? parseFloat(this._currentX) : 0,
relativeY = relative ? parseFloat(this._currentY) : 0;
_yuitest_coverline("build/graphics-canvas/graphics-canvas.js", 240);
if(!this._lineToMethods)
{
_yuitest_coverline("build/graphics-canvas/graphics-canvas.js", 242);
this._lineToMethods = [];
}
_yuitest_coverline("build/graphics-canvas/graphics-canvas.js", 244);
len = args.length - 1;
_yuitest_coverline("build/graphics-canvas/graphics-canvas.js", 245);
if (typeof point1 === 'string' || typeof point1 === 'number') {
_yuitest_coverline("build/graphics-canvas/graphics-canvas.js", 246);
for (i = 0; i < len; i = i + 2) {
_yuitest_coverline("build/graphics-canvas/graphics-canvas.js", 247);
x = parseFloat(args[i]);
_yuitest_coverline("build/graphics-canvas/graphics-canvas.js", 248);
y = parseFloat(args[i + 1]);
_yuitest_coverline("build/graphics-canvas/graphics-canvas.js", 249);
x = x + relativeX;
_yuitest_coverline("build/graphics-canvas/graphics-canvas.js", 250);
y = y + relativeY;
_yuitest_coverline("build/graphics-canvas/graphics-canvas.js", 251);
this._updateDrawingQueue(["lineTo", x, y]);
_yuitest_coverline("build/graphics-canvas/graphics-canvas.js", 252);
this._trackSize(x - wt, y - wt);
_yuitest_coverline("build/graphics-canvas/graphics-canvas.js", 253);
this._trackSize(x + wt, y + wt);
_yuitest_coverline("build/graphics-canvas/graphics-canvas.js", 254);
this._updateCoords(x, y);
}
}
else
{
_yuitest_coverline("build/graphics-canvas/graphics-canvas.js", 259);
for (i = 0; i < len; i = i + 1)
{
_yuitest_coverline("build/graphics-canvas/graphics-canvas.js", 261);
x = parseFloat(args[i][0]);
_yuitest_coverline("build/graphics-canvas/graphics-canvas.js", 262);
y = parseFloat(args[i][1]);
_yuitest_coverline("build/graphics-canvas/graphics-canvas.js", 263);
this._updateDrawingQueue(["lineTo", x, y]);
_yuitest_coverline("build/graphics-canvas/graphics-canvas.js", 264);
this._lineToMethods[this._lineToMethods.length] = this._methods[this._methods.length - 1];
_yuitest_coverline("build/graphics-canvas/graphics-canvas.js", 265);
this._trackSize(x - wt, y - wt);
_yuitest_coverline("build/graphics-canvas/graphics-canvas.js", 266);
this._trackSize(x + wt, y + wt);
_yuitest_coverline("build/graphics-canvas/graphics-canvas.js", 267);
this._updateCoords(x, y);
}
}
_yuitest_coverline("build/graphics-canvas/graphics-canvas.js", 270);
this._drawingComplete = false;
_yuitest_coverline("build/graphics-canvas/graphics-canvas.js", 271);
return this;
},
/**
* Moves the current drawing position to specified x and y coordinates.
*
* @method moveTo
* @param {Number} x x-coordinate for the end point.
* @param {Number} y y-coordinate for the end point.
*/
moveTo: function()
{
_yuitest_coverfunc("build/graphics-canvas/graphics-canvas.js", "moveTo", 281);
_yuitest_coverline("build/graphics-canvas/graphics-canvas.js", 283);
this._moveTo.apply(this, [Y.Array(arguments), false]);
},
/**
* Moves the current drawing position relative to specified x and y coordinates.
*
* @method relativeMoveTo
* @param {Number} x x-coordinate for the end point.
* @param {Number} y y-coordinate for the end point.
*/
relativeMoveTo: function()
{
_yuitest_coverfunc("build/graphics-canvas/graphics-canvas.js", "relativeMoveTo", 293);
_yuitest_coverline("build/graphics-canvas/graphics-canvas.js", 295);
this._moveTo.apply(this, [Y.Array(arguments), true]);
},
/**
* Implements moveTo methods.
*
* @method _moveTo
* @param {Array} args The arguments to be used.
* @param {Boolean} relative Indicates whether or not to use relative coordinates.
* @private
*/
_moveTo: function(args, relative) {
_yuitest_coverfunc("build/graphics-canvas/graphics-canvas.js", "_moveTo", 306);
_yuitest_coverline("build/graphics-canvas/graphics-canvas.js", 307);
var wt = this._stroke && this._strokeWeight ? this._strokeWeight : 0,
relativeX = relative ? parseFloat(this._currentX) : 0,
relativeY = relative ? parseFloat(this._currentY) : 0,
x = parseFloat(args[0]) + relativeX,
y = parseFloat(args[1]) + relativeY;
_yuitest_coverline("build/graphics-canvas/graphics-canvas.js", 312);
this._updateDrawingQueue(["moveTo", x, y]);
_yuitest_coverline("build/graphics-canvas/graphics-canvas.js", 313);
this._trackSize(x - wt, y - wt);
_yuitest_coverline("build/graphics-canvas/graphics-canvas.js", 314);
this._trackSize(x + wt, y + wt);
_yuitest_coverline("build/graphics-canvas/graphics-canvas.js", 315);
this._updateCoords(x, y);
_yuitest_coverline("build/graphics-canvas/graphics-canvas.js", 316);
this._drawingComplete = false;
_yuitest_coverline("build/graphics-canvas/graphics-canvas.js", 317);
return this;
},
/**
* Draws a bezier curve.
*
* @method curveTo
* @param {Number} cp1x x-coordinate for the first control point.
* @param {Number} cp1y y-coordinate for the first control point.
* @param {Number} cp2x x-coordinate for the second control point.
* @param {Number} cp2y y-coordinate for the second control point.
* @param {Number} x x-coordinate for the end point.
* @param {Number} y y-coordinate for the end point.
*/
curveTo: function() {
_yuitest_coverfunc("build/graphics-canvas/graphics-canvas.js", "curveTo", 331);
_yuitest_coverline("build/graphics-canvas/graphics-canvas.js", 332);
this._curveTo.apply(this, [Y.Array(arguments), false]);
},
/**
* Draws a bezier curve relative to the current coordinates.
*
* @method curveTo
* @param {Number} cp1x x-coordinate for the first control point.
* @param {Number} cp1y y-coordinate for the first control point.
* @param {Number} cp2x x-coordinate for the second control point.
* @param {Number} cp2y y-coordinate for the second control point.
* @param {Number} x x-coordinate for the end point.
* @param {Number} y y-coordinate for the end point.
*/
relativeCurveTo: function() {
_yuitest_coverfunc("build/graphics-canvas/graphics-canvas.js", "relativeCurveTo", 346);
_yuitest_coverline("build/graphics-canvas/graphics-canvas.js", 347);
this._curveTo.apply(this, [Y.Array(arguments), true]);
},
/**
* Implements curveTo methods.
*
* @method _curveTo
* @param {Array} args The arguments to be used.
* @param {Boolean} relative Indicates whether or not to use relative coordinates.
* @private
*/
_curveTo: function(args, relative) {
_yuitest_coverfunc("build/graphics-canvas/graphics-canvas.js", "_curveTo", 358);
_yuitest_coverline("build/graphics-canvas/graphics-canvas.js", 359);
var w,
h,
cp1x,
cp1y,
cp2x,
cp2y,
x,
y,
pts,
right,
left,
bottom,
top,
i,
len,
relativeX = relative ? parseFloat(this._currentX) : 0,
relativeY = relative ? parseFloat(this._currentY) : 0;
_yuitest_coverline("build/graphics-canvas/graphics-canvas.js", 376);
len = args.length - 5;
_yuitest_coverline("build/graphics-canvas/graphics-canvas.js", 377);
for(i = 0; i < len; i = i + 6)
{
_yuitest_coverline("build/graphics-canvas/graphics-canvas.js", 379);
cp1x = parseFloat(args[i]) + relativeX;
_yuitest_coverline("build/graphics-canvas/graphics-canvas.js", 380);
cp1y = parseFloat(args[i + 1]) + relativeY;
_yuitest_coverline("build/graphics-canvas/graphics-canvas.js", 381);
cp2x = parseFloat(args[i + 2]) + relativeX;
_yuitest_coverline("build/graphics-canvas/graphics-canvas.js", 382);
cp2y = parseFloat(args[i + 3]) + relativeY;
_yuitest_coverline("build/graphics-canvas/graphics-canvas.js", 383);
x = parseFloat(args[i + 4]) + relativeX;
_yuitest_coverline("build/graphics-canvas/graphics-canvas.js", 384);
y = parseFloat(args[i + 5]) + relativeY;
_yuitest_coverline("build/graphics-canvas/graphics-canvas.js", 385);
this._updateDrawingQueue(["bezierCurveTo", cp1x, cp1y, cp2x, cp2y, x, y]);
_yuitest_coverline("build/graphics-canvas/graphics-canvas.js", 386);
this._drawingComplete = false;
_yuitest_coverline("build/graphics-canvas/graphics-canvas.js", 387);
right = Math.max(x, Math.max(cp1x, cp2x));
_yuitest_coverline("build/graphics-canvas/graphics-canvas.js", 388);
bottom = Math.max(y, Math.max(cp1y, cp2y));
_yuitest_coverline("build/graphics-canvas/graphics-canvas.js", 389);
left = Math.min(x, Math.min(cp1x, cp2x));
_yuitest_coverline("build/graphics-canvas/graphics-canvas.js", 390);
top = Math.min(y, Math.min(cp1y, cp2y));
_yuitest_coverline("build/graphics-canvas/graphics-canvas.js", 391);
w = Math.abs(right - left);
_yuitest_coverline("build/graphics-canvas/graphics-canvas.js", 392);
h = Math.abs(bottom - top);
_yuitest_coverline("build/graphics-canvas/graphics-canvas.js", 393);
pts = [[this._currentX, this._currentY] , [cp1x, cp1y], [cp2x, cp2y], [x, y]];
_yuitest_coverline("build/graphics-canvas/graphics-canvas.js", 394);
this._setCurveBoundingBox(pts, w, h);
_yuitest_coverline("build/graphics-canvas/graphics-canvas.js", 395);
this._currentX = x;
_yuitest_coverline("build/graphics-canvas/graphics-canvas.js", 396);
this._currentY = y;
}
},
/**
* Draws a quadratic bezier curve.
*
* @method quadraticCurveTo
* @param {Number} cpx x-coordinate for the control point.
* @param {Number} cpy y-coordinate for the control point.
* @param {Number} x x-coordinate for the end point.
* @param {Number} y y-coordinate for the end point.
*/
quadraticCurveTo: function() {
_yuitest_coverfunc("build/graphics-canvas/graphics-canvas.js", "quadraticCurveTo", 409);
_yuitest_coverline("build/graphics-canvas/graphics-canvas.js", 410);
this._quadraticCurveTo.apply(this, [Y.Array(arguments), false]);
},
/**
* Draws a quadratic bezier curve relative to the current position.
*
* @method relativeQuadraticCurveTo
* @param {Number} cpx x-coordinate for the control point.
* @param {Number} cpy y-coordinate for the control point.
* @param {Number} x x-coordinate for the end point.
* @param {Number} y y-coordinate for the end point.
*/
relativeQuadraticCurveTo: function() {
_yuitest_coverfunc("build/graphics-canvas/graphics-canvas.js", "relativeQuadraticCurveTo", 422);
_yuitest_coverline("build/graphics-canvas/graphics-canvas.js", 423);
this._quadraticCurveTo.apply(this, [Y.Array(arguments), true]);
},
/**
* Implements quadraticCurveTo methods.
*
* @method _quadraticCurveTo
* @param {Array} args The arguments to be used.
* @param {Boolean} relative Indicates whether or not to use relative coordinates.
* @private
*/
_quadraticCurveTo: function(args, relative) {
_yuitest_coverfunc("build/graphics-canvas/graphics-canvas.js", "_quadraticCurveTo", 434);
_yuitest_coverline("build/graphics-canvas/graphics-canvas.js", 435);
var cpx,
cpy,
x,
y,
w,
h,
pts,
right,
left,
bottom,
top,
i,
len = args.length - 3,
wt = this._stroke && this._strokeWeight ? this._strokeWeight : 0,
relativeX = relative ? parseFloat(this._currentX) : 0,
relativeY = relative ? parseFloat(this._currentY) : 0;
_yuitest_coverline("build/graphics-canvas/graphics-canvas.js", 451);
for(i = 0; i < len; i = i + 4)
{
_yuitest_coverline("build/graphics-canvas/graphics-canvas.js", 453);
cpx = parseFloat(args[i]) + relativeX;
_yuitest_coverline("build/graphics-canvas/graphics-canvas.js", 454);
cpy = parseFloat(args[i + 1]) + relativeY;
_yuitest_coverline("build/graphics-canvas/graphics-canvas.js", 455);
x = parseFloat(args[i + 2]) + relativeX;
_yuitest_coverline("build/graphics-canvas/graphics-canvas.js", 456);
y = parseFloat(args[i + 3]) + relativeY;
_yuitest_coverline("build/graphics-canvas/graphics-canvas.js", 457);
this._drawingComplete = false;
_yuitest_coverline("build/graphics-canvas/graphics-canvas.js", 458);
right = Math.max(x, cpx);
_yuitest_coverline("build/graphics-canvas/graphics-canvas.js", 459);
bottom = Math.max(y, cpy);
_yuitest_coverline("build/graphics-canvas/graphics-canvas.js", 460);
left = Math.min(x, cpx);
_yuitest_coverline("build/graphics-canvas/graphics-canvas.js", 461);
top = Math.min(y, cpy);
_yuitest_coverline("build/graphics-canvas/graphics-canvas.js", 462);
w = Math.abs(right - left);
_yuitest_coverline("build/graphics-canvas/graphics-canvas.js", 463);
h = Math.abs(bottom - top);
_yuitest_coverline("build/graphics-canvas/graphics-canvas.js", 464);
pts = [[this._currentX, this._currentY] , [cpx, cpy], [x, y]];
_yuitest_coverline("build/graphics-canvas/graphics-canvas.js", 465);
this._setCurveBoundingBox(pts, w, h);
_yuitest_coverline("build/graphics-canvas/graphics-canvas.js", 466);
this._updateDrawingQueue(["quadraticCurveTo", cpx, cpy, x, y]);
_yuitest_coverline("build/graphics-canvas/graphics-canvas.js", 467);
this._updateCoords(x, y);
}
_yuitest_coverline("build/graphics-canvas/graphics-canvas.js", 469);
return this;
},
/**
* Draws a circle. Used internally by `CanvasCircle` class.
*
* @method drawCircle
* @param {Number} x y-coordinate
* @param {Number} y x-coordinate
* @param {Number} r radius
* @protected
*/
drawCircle: function(x, y, radius) {
_yuitest_coverfunc("build/graphics-canvas/graphics-canvas.js", "drawCircle", 481);
_yuitest_coverline("build/graphics-canvas/graphics-canvas.js", 482);
var startAngle = 0,
endAngle = 2 * Math.PI,
wt = this._stroke && this._strokeWeight ? this._strokeWeight : 0,
circum = radius * 2;
_yuitest_coverline("build/graphics-canvas/graphics-canvas.js", 486);
circum += wt;
_yuitest_coverline("build/graphics-canvas/graphics-canvas.js", 487);
this._drawingComplete = false;
_yuitest_coverline("build/graphics-canvas/graphics-canvas.js", 488);
this._trackSize(x + circum, y + circum);
_yuitest_coverline("build/graphics-canvas/graphics-canvas.js", 489);
this._trackSize(x - wt, y - wt);
_yuitest_coverline("build/graphics-canvas/graphics-canvas.js", 490);
this._updateCoords(x, y);
_yuitest_coverline("build/graphics-canvas/graphics-canvas.js", 491);
this._updateDrawingQueue(["arc", x + radius, y + radius, radius, startAngle, endAngle, false]);
_yuitest_coverline("build/graphics-canvas/graphics-canvas.js", 492);
return this;
},
/**
* Draws a diamond.
*
* @method drawDiamond
* @param {Number} x y-coordinate
* @param {Number} y x-coordinate
* @param {Number} width width
* @param {Number} height height
* @protected
*/
drawDiamond: function(x, y, width, height)
{
_yuitest_coverfunc("build/graphics-canvas/graphics-canvas.js", "drawDiamond", 505);
_yuitest_coverline("build/graphics-canvas/graphics-canvas.js", 507);
var midWidth = width * 0.5,
midHeight = height * 0.5;
_yuitest_coverline("build/graphics-canvas/graphics-canvas.js", 509);
this.moveTo(x + midWidth, y);
_yuitest_coverline("build/graphics-canvas/graphics-canvas.js", 510);
this.lineTo(x + width, y + midHeight);
_yuitest_coverline("build/graphics-canvas/graphics-canvas.js", 511);
this.lineTo(x + midWidth, y + height);
_yuitest_coverline("build/graphics-canvas/graphics-canvas.js", 512);
this.lineTo(x, y + midHeight);
_yuitest_coverline("build/graphics-canvas/graphics-canvas.js", 513);
this.lineTo(x + midWidth, y);
_yuitest_coverline("build/graphics-canvas/graphics-canvas.js", 514);
return this;
},
/**
* Draws an ellipse. Used internally by `CanvasEllipse` class.
*
* @method drawEllipse
* @param {Number} x x-coordinate
* @param {Number} y y-coordinate
* @param {Number} w width
* @param {Number} h height
* @protected
*/
drawEllipse: function(x, y, w, h) {
_yuitest_coverfunc("build/graphics-canvas/graphics-canvas.js", "drawEllipse", 527);
_yuitest_coverline("build/graphics-canvas/graphics-canvas.js", 528);
var l = 8,
theta = -(45/180) * Math.PI,
angle = 0,
angleMid,
radius = w/2,
yRadius = h/2,
i,
centerX = x + radius,
centerY = y + yRadius,
ax, ay, bx, by, cx, cy,
wt = this._stroke && this._strokeWeight ? this._strokeWeight : 0;
_yuitest_coverline("build/graphics-canvas/graphics-canvas.js", 540);
ax = centerX + Math.cos(0) * radius;
_yuitest_coverline("build/graphics-canvas/graphics-canvas.js", 541);
ay = centerY + Math.sin(0) * yRadius;
_yuitest_coverline("build/graphics-canvas/graphics-canvas.js", 542);
this.moveTo(ax, ay);
_yuitest_coverline("build/graphics-canvas/graphics-canvas.js", 543);
for(i = 0; i < l; i++)
{
_yuitest_coverline("build/graphics-canvas/graphics-canvas.js", 545);
angle += theta;
_yuitest_coverline("build/graphics-canvas/graphics-canvas.js", 546);
angleMid = angle - (theta / 2);
_yuitest_coverline("build/graphics-canvas/graphics-canvas.js", 547);
bx = centerX + Math.cos(angle) * radius;
_yuitest_coverline("build/graphics-canvas/graphics-canvas.js", 548);
by = centerY + Math.sin(angle) * yRadius;
_yuitest_coverline("build/graphics-canvas/graphics-canvas.js", 549);
cx = centerX + Math.cos(angleMid) * (radius / Math.cos(theta / 2));
_yuitest_coverline("build/graphics-canvas/graphics-canvas.js", 550);
cy = centerY + Math.sin(angleMid) * (yRadius / Math.cos(theta / 2));
_yuitest_coverline("build/graphics-canvas/graphics-canvas.js", 551);
this._updateDrawingQueue(["quadraticCurveTo", cx, cy, bx, by]);
}
_yuitest_coverline("build/graphics-canvas/graphics-canvas.js", 553);
this._trackSize(x + w + wt, y + h + wt);
_yuitest_coverline("build/graphics-canvas/graphics-canvas.js", 554);
this._trackSize(x - wt, y - wt);
_yuitest_coverline("build/graphics-canvas/graphics-canvas.js", 555);
this._updateCoords(x, y);
_yuitest_coverline("build/graphics-canvas/graphics-canvas.js", 556);
return this;
},
/**
* Draws a rectangle.
*
* @method drawRect
* @param {Number} x x-coordinate
* @param {Number} y y-coordinate
* @param {Number} w width
* @param {Number} h height
*/
drawRect: function(x, y, w, h) {
_yuitest_coverfunc("build/graphics-canvas/graphics-canvas.js", "drawRect", 568);
_yuitest_coverline("build/graphics-canvas/graphics-canvas.js", 569);
var wt = this._stroke && this._strokeWeight ? this._strokeWeight : 0;
_yuitest_coverline("build/graphics-canvas/graphics-canvas.js", 570);
this._drawingComplete = false;
_yuitest_coverline("build/graphics-canvas/graphics-canvas.js", 571);
this.moveTo(x, y);
_yuitest_coverline("build/graphics-canvas/graphics-canvas.js", 572);
this.lineTo(x + w, y);
_yuitest_coverline("build/graphics-canvas/graphics-canvas.js", 573);
this.lineTo(x + w, y + h);
_yuitest_coverline("build/graphics-canvas/graphics-canvas.js", 574);
this.lineTo(x, y + h);
_yuitest_coverline("build/graphics-canvas/graphics-canvas.js", 575);
this.lineTo(x, y);
_yuitest_coverline("build/graphics-canvas/graphics-canvas.js", 576);
return this;
},
/**
* Draws a rectangle with rounded corners.
*
* @method drawRect
* @param {Number} x x-coordinate
* @param {Number} y y-coordinate
* @param {Number} w width
* @param {Number} h height
* @param {Number} ew width of the ellipse used to draw the rounded corners
* @param {Number} eh height of the ellipse used to draw the rounded corners
*/
drawRoundRect: function(x, y, w, h, ew, eh) {
_yuitest_coverfunc("build/graphics-canvas/graphics-canvas.js", "drawRoundRect", 590);
_yuitest_coverline("build/graphics-canvas/graphics-canvas.js", 591);
var wt = this._stroke && this._strokeWeight ? this._strokeWeight : 0;
_yuitest_coverline("build/graphics-canvas/graphics-canvas.js", 592);
this._drawingComplete = false;
_yuitest_coverline("build/graphics-canvas/graphics-canvas.js", 593);
this.moveTo( x, y + eh);
_yuitest_coverline("build/graphics-canvas/graphics-canvas.js", 594);
this.lineTo(x, y + h - eh);
_yuitest_coverline("build/graphics-canvas/graphics-canvas.js", 595);
this.quadraticCurveTo(x, y + h, x + ew, y + h);
_yuitest_coverline("build/graphics-canvas/graphics-canvas.js", 596);
this.lineTo(x + w - ew, y + h);
_yuitest_coverline("build/graphics-canvas/graphics-canvas.js", 597);
this.quadraticCurveTo(x + w, y + h, x + w, y + h - eh);
_yuitest_coverline("build/graphics-canvas/graphics-canvas.js", 598);
this.lineTo(x + w, y + eh);
_yuitest_coverline("build/graphics-canvas/graphics-canvas.js", 599);
this.quadraticCurveTo(x + w, y, x + w - ew, y);
_yuitest_coverline("build/graphics-canvas/graphics-canvas.js", 600);
this.lineTo(x + ew, y);
_yuitest_coverline("build/graphics-canvas/graphics-canvas.js", 601);
this.quadraticCurveTo(x, y, x, y + eh);
_yuitest_coverline("build/graphics-canvas/graphics-canvas.js", 602);
return this;
},
/**
* Draws a wedge.
*
* @method drawWedge
* @param {Number} x x-coordinate of the wedge's center point
* @param {Number} y y-coordinate of the wedge's center point
* @param {Number} startAngle starting angle in degrees
* @param {Number} arc sweep of the wedge. Negative values draw clockwise.
* @param {Number} radius radius of wedge. If [optional] yRadius is defined, then radius is the x radius.
* @param {Number} yRadius [optional] y radius for wedge.
* @private
*/
drawWedge: function(x, y, startAngle, arc, radius, yRadius)
{
_yuitest_coverfunc("build/graphics-canvas/graphics-canvas.js", "drawWedge", 617);
_yuitest_coverline("build/graphics-canvas/graphics-canvas.js", 619);
var wt = this._stroke && this._strokeWeight ? this._strokeWeight : 0,
segs,
segAngle,
theta,
angle,
angleMid,
ax,
ay,
bx,
by,
cx,
cy,
i = 0;
_yuitest_coverline("build/graphics-canvas/graphics-canvas.js", 632);
yRadius = yRadius || radius;
_yuitest_coverline("build/graphics-canvas/graphics-canvas.js", 634);
this._drawingComplete = false;
// move to x,y position
_yuitest_coverline("build/graphics-canvas/graphics-canvas.js", 636);
this._updateDrawingQueue(["moveTo", x, y]);
_yuitest_coverline("build/graphics-canvas/graphics-canvas.js", 638);
yRadius = yRadius || radius;
// limit sweep to reasonable numbers
_yuitest_coverline("build/graphics-canvas/graphics-canvas.js", 641);
if(Math.abs(arc) > 360)
{
_yuitest_coverline("build/graphics-canvas/graphics-canvas.js", 643);
arc = 360;
}
// First we calculate how many segments are needed
// for a smooth arc.
_yuitest_coverline("build/graphics-canvas/graphics-canvas.js", 648);
segs = Math.ceil(Math.abs(arc) / 45);
// Now calculate the sweep of each segment.
_yuitest_coverline("build/graphics-canvas/graphics-canvas.js", 651);
segAngle = arc / segs;
// The math requires radians rather than degrees. To convert from degrees
// use the formula (degrees/180)*Math.PI to get radians.
_yuitest_coverline("build/graphics-canvas/graphics-canvas.js", 655);
theta = -(segAngle / 180) * Math.PI;
// convert angle startAngle to radians
_yuitest_coverline("build/graphics-canvas/graphics-canvas.js", 658);
angle = (startAngle / 180) * Math.PI;
// draw the curve in segments no larger than 45 degrees.
_yuitest_coverline("build/graphics-canvas/graphics-canvas.js", 661);
if(segs > 0)
{
// draw a line from the center to the start of the curve
_yuitest_coverline("build/graphics-canvas/graphics-canvas.js", 664);
ax = x + Math.cos(startAngle / 180 * Math.PI) * radius;
_yuitest_coverline("build/graphics-canvas/graphics-canvas.js", 665);
ay = y + Math.sin(startAngle / 180 * Math.PI) * yRadius;
_yuitest_coverline("build/graphics-canvas/graphics-canvas.js", 666);
this.lineTo(ax, ay);
// Loop for drawing curve segments
_yuitest_coverline("build/graphics-canvas/graphics-canvas.js", 668);
for(i = 0; i < segs; ++i)
{
_yuitest_coverline("build/graphics-canvas/graphics-canvas.js", 670);
angle += theta;
_yuitest_coverline("build/graphics-canvas/graphics-canvas.js", 671);
angleMid = angle - (theta / 2);
_yuitest_coverline("build/graphics-canvas/graphics-canvas.js", 672);
bx = x + Math.cos(angle) * radius;
_yuitest_coverline("build/graphics-canvas/graphics-canvas.js", 673);
by = y + Math.sin(angle) * yRadius;
_yuitest_coverline("build/graphics-canvas/graphics-canvas.js", 674);
cx = x + Math.cos(angleMid) * (radius / Math.cos(theta / 2));
_yuitest_coverline("build/graphics-canvas/graphics-canvas.js", 675);
cy = y + Math.sin(angleMid) * (yRadius / Math.cos(theta / 2));
_yuitest_coverline("build/graphics-canvas/graphics-canvas.js", 676);
this._updateDrawingQueue(["quadraticCurveTo", cx, cy, bx, by]);
}
// close the wedge by drawing a line to the center
_yuitest_coverline("build/graphics-canvas/graphics-canvas.js", 679);
this._updateDrawingQueue(["lineTo", x, y]);
}
_yuitest_coverline("build/graphics-canvas/graphics-canvas.js", 681);
this._trackSize(-wt , -wt);
_yuitest_coverline("build/graphics-canvas/graphics-canvas.js", 682);
this._trackSize((radius * 2) + wt, (radius * 2) + wt);
_yuitest_coverline("build/graphics-canvas/graphics-canvas.js", 683);
return this;
},
/**
* Completes a drawing operation.
*
* @method end
*/
end: function() {
_yuitest_coverfunc("build/graphics-canvas/graphics-canvas.js", "end", 691);
_yuitest_coverline("build/graphics-canvas/graphics-canvas.js", 692);
this._closePath();
_yuitest_coverline("build/graphics-canvas/graphics-canvas.js", 693);
return this;
},
/**
* Ends a fill and stroke
*
* @method closePath
*/
closePath: function()
{
_yuitest_coverfunc("build/graphics-canvas/graphics-canvas.js", "closePath", 701);
_yuitest_coverline("build/graphics-canvas/graphics-canvas.js", 703);
this._updateDrawingQueue(["closePath"]);
_yuitest_coverline("build/graphics-canvas/graphics-canvas.js", 704);
this._updateDrawingQueue(["beginPath"]);
},
/**
* Clears the graphics object.
*
* @method clear
*/
/**
* Returns a linear gradient fill
*
* @method _getLinearGradient
* @return CanvasGradient
* @private
*/
_getLinearGradient: function() {
_yuitest_coverfunc("build/graphics-canvas/graphics-canvas.js", "_getLinearGradient", 720);
_yuitest_coverline("build/graphics-canvas/graphics-canvas.js", 721);
var isNumber = Y.Lang.isNumber,
fill = this.get("fill"),
stops = fill.stops,
opacity,
color,
stop,
i,
len = stops.length,
gradient,
x = 0,
y = 0,
w = this.get("width"),
h = this.get("height"),
r = fill.rotation || 0,
x1, x2, y1, y2,
cx = x + w/2,
cy = y + h/2,
offset,
radCon = Math.PI/180,
tanRadians = parseFloat(parseFloat(Math.tan(r * radCon)).toFixed(8));
_yuitest_coverline("build/graphics-canvas/graphics-canvas.js", 741);
if(Math.abs(tanRadians) * w/2 >= h/2)
{
_yuitest_coverline("build/graphics-canvas/graphics-canvas.js", 743);
if(r < 180)
{
_yuitest_coverline("build/graphics-canvas/graphics-canvas.js", 745);
y1 = y;
_yuitest_coverline("build/graphics-canvas/graphics-canvas.js", 746);
y2 = y + h;
}
else
{
_yuitest_coverline("build/graphics-canvas/graphics-canvas.js", 750);
y1 = y + h;
_yuitest_coverline("build/graphics-canvas/graphics-canvas.js", 751);
y2 = y;
}
_yuitest_coverline("build/graphics-canvas/graphics-canvas.js", 753);
x1 = cx - ((cy - y1)/tanRadians);
_yuitest_coverline("build/graphics-canvas/graphics-canvas.js", 754);
x2 = cx - ((cy - y2)/tanRadians);
}
else
{
_yuitest_coverline("build/graphics-canvas/graphics-canvas.js", 758);
if(r > 90 && r < 270)
{
_yuitest_coverline("build/graphics-canvas/graphics-canvas.js", 760);
x1 = x + w;
_yuitest_coverline("build/graphics-canvas/graphics-canvas.js", 761);
x2 = x;
}
else
{
_yuitest_coverline("build/graphics-canvas/graphics-canvas.js", 765);
x1 = x;
_yuitest_coverline("build/graphics-canvas/graphics-canvas.js", 766);
x2 = x + w;
}
_yuitest_coverline("build/graphics-canvas/graphics-canvas.js", 768);
y1 = ((tanRadians * (cx - x1)) - cy) * -1;
_yuitest_coverline("build/graphics-canvas/graphics-canvas.js", 769);
y2 = ((tanRadians * (cx - x2)) - cy) * -1;
}
_yuitest_coverline("build/graphics-canvas/graphics-canvas.js", 771);
gradient = this._context.createLinearGradient(x1, y1, x2, y2);
_yuitest_coverline("build/graphics-canvas/graphics-canvas.js", 772);
for(i = 0; i < len; ++i)
{
_yuitest_coverline("build/graphics-canvas/graphics-canvas.js", 774);
stop = stops[i];
_yuitest_coverline("build/graphics-canvas/graphics-canvas.js", 775);
opacity = stop.opacity;
_yuitest_coverline("build/graphics-canvas/graphics-canvas.js", 776);
color = stop.color;
_yuitest_coverline("build/graphics-canvas/graphics-canvas.js", 777);
offset = stop.offset;
_yuitest_coverline("build/graphics-canvas/graphics-canvas.js", 778);
if(isNumber(opacity))
{
_yuitest_coverline("build/graphics-canvas/graphics-canvas.js", 780);
opacity = Math.max(0, Math.min(1, opacity));
_yuitest_coverline("build/graphics-canvas/graphics-canvas.js", 781);
color = this._toRGBA(color, opacity);
}
else
{
_yuitest_coverline("build/graphics-canvas/graphics-canvas.js", 785);
color = TORGB(color);
}
_yuitest_coverline("build/graphics-canvas/graphics-canvas.js", 787);
offset = stop.offset || i/(len - 1);
_yuitest_coverline("build/graphics-canvas/graphics-canvas.js", 788);
gradient.addColorStop(offset, color);
}
_yuitest_coverline("build/graphics-canvas/graphics-canvas.js", 790);
return gradient;
},
/**
* Returns a radial gradient fill
*
* @method _getRadialGradient
* @return CanvasGradient
* @private
*/
_getRadialGradient: function() {
_yuitest_coverfunc("build/graphics-canvas/graphics-canvas.js", "_getRadialGradient", 800);
_yuitest_coverline("build/graphics-canvas/graphics-canvas.js", 801);
var isNumber = Y.Lang.isNumber,
fill = this.get("fill"),
r = fill.r,
fx = fill.fx,
fy = fill.fy,
stops = fill.stops,
opacity,
color,
stop,
i,
len = stops.length,
gradient,
x = 0,
y = 0,
w = this.get("width"),
h = this.get("height"),
x1, x2, y1, y2, r2,
xc, yc, xn, yn, d,
offset,
ratio,
stopMultiplier;
_yuitest_coverline("build/graphics-canvas/graphics-canvas.js", 822);
xc = x + w/2;
_yuitest_coverline("build/graphics-canvas/graphics-canvas.js", 823);
yc = y + h/2;
_yuitest_coverline("build/graphics-canvas/graphics-canvas.js", 824);
x1 = w * fx;
_yuitest_coverline("build/graphics-canvas/graphics-canvas.js", 825);
y1 = h * fy;
_yuitest_coverline("build/graphics-canvas/graphics-canvas.js", 826);
x2 = x + w/2;
_yuitest_coverline("build/graphics-canvas/graphics-canvas.js", 827);
y2 = y + h/2;
_yuitest_coverline("build/graphics-canvas/graphics-canvas.js", 828);
r2 = w * r;
_yuitest_coverline("build/graphics-canvas/graphics-canvas.js", 829);
d = Math.sqrt( Math.pow(Math.abs(xc - x1), 2) + Math.pow(Math.abs(yc - y1), 2) );
_yuitest_coverline("build/graphics-canvas/graphics-canvas.js", 830);
if(d >= r2)
{
_yuitest_coverline("build/graphics-canvas/graphics-canvas.js", 832);
ratio = d/r2;
//hack. gradient won't show if it is exactly on the edge of the arc
_yuitest_coverline("build/graphics-canvas/graphics-canvas.js", 834);
if(ratio === 1)
{
_yuitest_coverline("build/graphics-canvas/graphics-canvas.js", 836);
ratio = 1.01;
}
_yuitest_coverline("build/graphics-canvas/graphics-canvas.js", 838);
xn = (x1 - xc)/ratio;
_yuitest_coverline("build/graphics-canvas/graphics-canvas.js", 839);
yn = (y1 - yc)/ratio;
_yuitest_coverline("build/graphics-canvas/graphics-canvas.js", 840);
xn = xn > 0 ? Math.floor(xn) : Math.ceil(xn);
_yuitest_coverline("build/graphics-canvas/graphics-canvas.js", 841);
yn = yn > 0 ? Math.floor(yn) : Math.ceil(yn);
_yuitest_coverline("build/graphics-canvas/graphics-canvas.js", 842);
x1 = xc + xn;
_yuitest_coverline("build/graphics-canvas/graphics-canvas.js", 843);
y1 = yc + yn;
}
//If the gradient radius is greater than the circle's, adjusting the radius stretches the gradient properly.
//If the gradient radius is less than the circle's, adjusting the radius of the gradient will not work.
//Instead, adjust the color stops to reflect the smaller radius.
_yuitest_coverline("build/graphics-canvas/graphics-canvas.js", 849);
if(r >= 0.5)
{
_yuitest_coverline("build/graphics-canvas/graphics-canvas.js", 851);
gradient = this._context.createRadialGradient(x1, y1, r, x2, y2, r * w);
_yuitest_coverline("build/graphics-canvas/graphics-canvas.js", 852);
stopMultiplier = 1;
}
else
{
_yuitest_coverline("build/graphics-canvas/graphics-canvas.js", 856);
gradient = this._context.createRadialGradient(x1, y1, r, x2, y2, w/2);
_yuitest_coverline("build/graphics-canvas/graphics-canvas.js", 857);
stopMultiplier = r * 2;
}
_yuitest_coverline("build/graphics-canvas/graphics-canvas.js", 859);
for(i = 0; i < len; ++i)
{
_yuitest_coverline("build/graphics-canvas/graphics-canvas.js", 861);
stop = stops[i];
_yuitest_coverline("build/graphics-canvas/graphics-canvas.js", 862);
opacity = stop.opacity;
_yuitest_coverline("build/graphics-canvas/graphics-canvas.js", 863);
color = stop.color;
_yuitest_coverline("build/graphics-canvas/graphics-canvas.js", 864);
offset = stop.offset;
_yuitest_coverline("build/graphics-canvas/graphics-canvas.js", 865);
if(isNumber(opacity))
{
_yuitest_coverline("build/graphics-canvas/graphics-canvas.js", 867);
opacity = Math.max(0, Math.min(1, opacity));
_yuitest_coverline("build/graphics-canvas/graphics-canvas.js", 868);
color = this._toRGBA(color, opacity);
}
else
{
_yuitest_coverline("build/graphics-canvas/graphics-canvas.js", 872);
color = TORGB(color);
}
_yuitest_coverline("build/graphics-canvas/graphics-canvas.js", 874);
offset = stop.offset || i/(len - 1);
_yuitest_coverline("build/graphics-canvas/graphics-canvas.js", 875);
offset *= stopMultiplier;
_yuitest_coverline("build/graphics-canvas/graphics-canvas.js", 876);
if(offset <= 1)
{
_yuitest_coverline("build/graphics-canvas/graphics-canvas.js", 878);
gradient.addColorStop(offset, color);
}
}
_yuitest_coverline("build/graphics-canvas/graphics-canvas.js", 881);
return gradient;
},
/**
* Clears all values
*
* @method _initProps
* @private
*/
_initProps: function() {
_yuitest_coverfunc("build/graphics-canvas/graphics-canvas.js", "_initProps", 891);
_yuitest_coverline("build/graphics-canvas/graphics-canvas.js", 892);
this._methods = [];
_yuitest_coverline("build/graphics-canvas/graphics-canvas.js", 893);
this._lineToMethods = [];
_yuitest_coverline("build/graphics-canvas/graphics-canvas.js", 894);
this._xcoords = [0];
_yuitest_coverline("build/graphics-canvas/graphics-canvas.js", 895);
this._ycoords = [0];
_yuitest_coverline("build/graphics-canvas/graphics-canvas.js", 896);
this._width = 0;
_yuitest_coverline("build/graphics-canvas/graphics-canvas.js", 897);
this._height = 0;
_yuitest_coverline("build/graphics-canvas/graphics-canvas.js", 898);
this._left = 0;
_yuitest_coverline("build/graphics-canvas/graphics-canvas.js", 899);
this._top = 0;
_yuitest_coverline("build/graphics-canvas/graphics-canvas.js", 900);
this._right = 0;
_yuitest_coverline("build/graphics-canvas/graphics-canvas.js", 901);
this._bottom = 0;
_yuitest_coverline("build/graphics-canvas/graphics-canvas.js", 902);
this._currentX = 0;
_yuitest_coverline("build/graphics-canvas/graphics-canvas.js", 903);
this._currentY = 0;
},
/**
* Indicates a drawing has completed.
*
* @property _drawingComplete
* @type Boolean
* @private
*/
_drawingComplete: false,
/**
* Creates canvas element
*
* @method _createGraphic
* @return HTMLCanvasElement
* @private
*/
_createGraphic: function(config) {
_yuitest_coverfunc("build/graphics-canvas/graphics-canvas.js", "_createGraphic", 922);
_yuitest_coverline("build/graphics-canvas/graphics-canvas.js", 923);
var graphic = Y.config.doc.createElement('canvas');
_yuitest_coverline("build/graphics-canvas/graphics-canvas.js", 924);
return graphic;
},
/**
* Returns the points on a curve
*
* @method getBezierData
* @param Array points Array containing the begin, end and control points of a curve.
* @param Number t The value for incrementing the next set of points.
* @return Array
* @private
*/
getBezierData: function(points, t) {
_yuitest_coverfunc("build/graphics-canvas/graphics-canvas.js", "getBezierData", 936);
_yuitest_coverline("build/graphics-canvas/graphics-canvas.js", 937);
var n = points.length,
tmp = [],
i,
j;
_yuitest_coverline("build/graphics-canvas/graphics-canvas.js", 942);
for (i = 0; i < n; ++i){
_yuitest_coverline("build/graphics-canvas/graphics-canvas.js", 943);
tmp[i] = [points[i][0], points[i][1]]; // save input
}
_yuitest_coverline("build/graphics-canvas/graphics-canvas.js", 946);
for (j = 1; j < n; ++j) {
_yuitest_coverline("build/graphics-canvas/graphics-canvas.js", 947);
for (i = 0; i < n - j; ++i) {
_yuitest_coverline("build/graphics-canvas/graphics-canvas.js", 948);
tmp[i][0] = (1 - t) * tmp[i][0] + t * tmp[parseInt(i + 1, 10)][0];
_yuitest_coverline("build/graphics-canvas/graphics-canvas.js", 949);
tmp[i][1] = (1 - t) * tmp[i][1] + t * tmp[parseInt(i + 1, 10)][1];
}
}
_yuitest_coverline("build/graphics-canvas/graphics-canvas.js", 952);
return [ tmp[0][0], tmp[0][1] ];
},
/**
* Calculates the bounding box for a curve
*
* @method _setCurveBoundingBox
* @param Array pts Array containing points for start, end and control points of a curve.
* @param Number w Width used to calculate the number of points to describe the curve.
* @param Number h Height used to calculate the number of points to describe the curve.
* @private
*/
_setCurveBoundingBox: function(pts, w, h)
{
_yuitest_coverfunc("build/graphics-canvas/graphics-canvas.js", "_setCurveBoundingBox", 964);
_yuitest_coverline("build/graphics-canvas/graphics-canvas.js", 966);
var i = 0,
left = this._currentX,
right = left,
top = this._currentY,
bottom = top,
len = Math.round(Math.sqrt((w * w) + (h * h))),
t = 1/len,
wt = this._stroke && this._strokeWeight ? this._strokeWeight : 0,
xy;
_yuitest_coverline("build/graphics-canvas/graphics-canvas.js", 975);
for(i = 0; i < len; ++i)
{
_yuitest_coverline("build/graphics-canvas/graphics-canvas.js", 977);
xy = this.getBezierData(pts, t * i);
_yuitest_coverline("build/graphics-canvas/graphics-canvas.js", 978);
left = isNaN(left) ? xy[0] : Math.min(xy[0], left);
_yuitest_coverline("build/graphics-canvas/graphics-canvas.js", 979);
right = isNaN(right) ? xy[0] : Math.max(xy[0], right);
_yuitest_coverline("build/graphics-canvas/graphics-canvas.js", 980);
top = isNaN(top) ? xy[1] : Math.min(xy[1], top);
_yuitest_coverline("build/graphics-canvas/graphics-canvas.js", 981);
bottom = isNaN(bottom) ? xy[1] : Math.max(xy[1], bottom);
}
_yuitest_coverline("build/graphics-canvas/graphics-canvas.js", 983);
left = Math.round(left * 10)/10;
_yuitest_coverline("build/graphics-canvas/graphics-canvas.js", 984);
right = Math.round(right * 10)/10;
_yuitest_coverline("build/graphics-canvas/graphics-canvas.js", 985);
top = Math.round(top * 10)/10;
_yuitest_coverline("build/graphics-canvas/graphics-canvas.js", 986);
bottom = Math.round(bottom * 10)/10;
_yuitest_coverline("build/graphics-canvas/graphics-canvas.js", 987);
this._trackSize(right + wt, bottom + wt);
_yuitest_coverline("build/graphics-canvas/graphics-canvas.js", 988);
this._trackSize(left - wt, top - wt);
},
/**
* Updates the size of the graphics object
*
* @method _trackSize
* @param {Number} w width
* @param {Number} h height
* @private
*/
_trackSize: function(w, h) {
_yuitest_coverfunc("build/graphics-canvas/graphics-canvas.js", "_trackSize", 999);
_yuitest_coverline("build/graphics-canvas/graphics-canvas.js", 1000);
if (w > this._right) {
_yuitest_coverline("build/graphics-canvas/graphics-canvas.js", 1001);
this._right = w;
}
_yuitest_coverline("build/graphics-canvas/graphics-canvas.js", 1003);
if(w < this._left)
{
_yuitest_coverline("build/graphics-canvas/graphics-canvas.js", 1005);
this._left = w;
}
_yuitest_coverline("build/graphics-canvas/graphics-canvas.js", 1007);
if (h < this._top)
{
_yuitest_coverline("build/graphics-canvas/graphics-canvas.js", 1009);
this._top = h;
}
_yuitest_coverline("build/graphics-canvas/graphics-canvas.js", 1011);
if (h > this._bottom)
{
_yuitest_coverline("build/graphics-canvas/graphics-canvas.js", 1013);
this._bottom = h;
}
_yuitest_coverline("build/graphics-canvas/graphics-canvas.js", 1015);
this._width = this._right - this._left;
_yuitest_coverline("build/graphics-canvas/graphics-canvas.js", 1016);
this._height = this._bottom - this._top;
}
};
_yuitest_coverline("build/graphics-canvas/graphics-canvas.js", 1019);
Y.CanvasDrawing = CanvasDrawing;
/**
* <a href="http://www.w3.org/TR/html5/the-canvas-element.html">Canvas</a> implementation of the <a href="Shape.html">`Shape`</a> class.
* `CanvasShape` is not intended to be used directly. Instead, use the <a href="Shape.html">`Shape`</a> class.
* If the browser lacks <a href="http://www.w3.org/TR/SVG/">SVG</a> capabilities but has
* <a href="http://www.w3.org/TR/html5/the-canvas-element.html">Canvas</a> capabilities, the <a href="Shape.html">`Shape`</a>
* class will point to the `CanvasShape` class.
*
* @module graphics
* @class CanvasShape
* @constructor
*/
_yuitest_coverline("build/graphics-canvas/graphics-canvas.js", 1031);
CanvasShape = function(cfg)
{
_yuitest_coverfunc("build/graphics-canvas/graphics-canvas.js", "CanvasShape", 1031);
_yuitest_coverline("build/graphics-canvas/graphics-canvas.js", 1033);
this._transforms = [];
_yuitest_coverline("build/graphics-canvas/graphics-canvas.js", 1034);
this.matrix = new Y.Matrix();
_yuitest_coverline("build/graphics-canvas/graphics-canvas.js", 1035);
CanvasShape.superclass.constructor.apply(this, arguments);
};
_yuitest_coverline("build/graphics-canvas/graphics-canvas.js", 1038);
CanvasShape.NAME = "shape";
_yuitest_coverline("build/graphics-canvas/graphics-canvas.js", 1040);
Y.extend(CanvasShape, Y.GraphicBase, Y.mix({
/**
* Init method, invoked during construction.
* Calls `initializer` method.
*
* @method init
* @protected
*/
init: function()
{
_yuitest_coverfunc("build/graphics-canvas/graphics-canvas.js", "init", 1048);
_yuitest_coverline("build/graphics-canvas/graphics-canvas.js", 1050);
this.initializer.apply(this, arguments);
},
/**
* Initializes the shape
*
* @private
* @method _initialize
*/
initializer: function(cfg)
{
_yuitest_coverfunc("build/graphics-canvas/graphics-canvas.js", "initializer", 1059);
_yuitest_coverline("build/graphics-canvas/graphics-canvas.js", 1061);
var host = this,
graphic = cfg.graphic,
data = this.get("data");
_yuitest_coverline("build/graphics-canvas/graphics-canvas.js", 1064);
host._initProps();
_yuitest_coverline("build/graphics-canvas/graphics-canvas.js", 1065);
host.createNode();
_yuitest_coverline("build/graphics-canvas/graphics-canvas.js", 1066);
host._xcoords = [0];
_yuitest_coverline("build/graphics-canvas/graphics-canvas.js", 1067);
host._ycoords = [0];
_yuitest_coverline("build/graphics-canvas/graphics-canvas.js", 1068);
if(graphic)
{
_yuitest_coverline("build/graphics-canvas/graphics-canvas.js", 1070);
this._setGraphic(graphic);
}
_yuitest_coverline("build/graphics-canvas/graphics-canvas.js", 1072);
if(data)
{
_yuitest_coverline("build/graphics-canvas/graphics-canvas.js", 1074);
host._parsePathData(data);
}
_yuitest_coverline("build/graphics-canvas/graphics-canvas.js", 1076);
host._updateHandler();
},
/**
* Set the Graphic instance for the shape.
*
* @method _setGraphic
* @param {Graphic | Node | HTMLElement | String} render This param is used to determine the graphic instance. If it is a `Graphic` instance, it will be assigned
* to the `graphic` attribute. Otherwise, a new Graphic instance will be created and rendered into the dom element that the render represents.
* @private
*/
_setGraphic: function(render)
{
_yuitest_coverfunc("build/graphics-canvas/graphics-canvas.js", "_setGraphic", 1087);
_yuitest_coverline("build/graphics-canvas/graphics-canvas.js", 1089);
var graphic;
_yuitest_coverline("build/graphics-canvas/graphics-canvas.js", 1090);
if(render instanceof Y.CanvasGraphic)
{
_yuitest_coverline("build/graphics-canvas/graphics-canvas.js", 1092);
this._graphic = render;
}
else
{
_yuitest_coverline("build/graphics-canvas/graphics-canvas.js", 1096);
render = Y.one(render);
_yuitest_coverline("build/graphics-canvas/graphics-canvas.js", 1097);
graphic = new Y.CanvasGraphic({
render: render
});
_yuitest_coverline("build/graphics-canvas/graphics-canvas.js", 1100);
graphic._appendShape(this);
_yuitest_coverline("build/graphics-canvas/graphics-canvas.js", 1101);
this._graphic = graphic;
}
},
/**
* Add a class name to each node.
*
* @method addClass
* @param {String} className the class name to add to the node's class attribute
*/
addClass: function(className)
{
_yuitest_coverfunc("build/graphics-canvas/graphics-canvas.js", "addClass", 1111);
_yuitest_coverline("build/graphics-canvas/graphics-canvas.js", 1113);
var node = Y.one(this.get("node"));
_yuitest_coverline("build/graphics-canvas/graphics-canvas.js", 1114);
node.addClass(className);
},
/**
* Removes a class name from each node.
*
* @method removeClass
* @param {String} className the class name to remove from the node's class attribute
*/
removeClass: function(className)
{
_yuitest_coverfunc("build/graphics-canvas/graphics-canvas.js", "removeClass", 1123);
_yuitest_coverline("build/graphics-canvas/graphics-canvas.js", 1125);
var node = Y.one(this.get("node"));
_yuitest_coverline("build/graphics-canvas/graphics-canvas.js", 1126);
node.removeClass(className);
},
/**
* Gets the current position of the node in page coordinates.
*
* @method getXY
* @return Array The XY position of the shape.
*/
getXY: function()
{
_yuitest_coverfunc("build/graphics-canvas/graphics-canvas.js", "getXY", 1135);
_yuitest_coverline("build/graphics-canvas/graphics-canvas.js", 1137);
var graphic = this.get("graphic"),
parentXY = graphic.getXY(),
x = this.get("x"),
y = this.get("y");
_yuitest_coverline("build/graphics-canvas/graphics-canvas.js", 1141);
return [parentXY[0] + x, parentXY[1] + y];
},
/**
* Set the position of the shape in page coordinates, regardless of how the node is positioned.
*
* @method setXY
* @param {Array} Contains X & Y values for new position (coordinates are page-based)
*/
setXY: function(xy)
{
_yuitest_coverfunc("build/graphics-canvas/graphics-canvas.js", "setXY", 1150);
_yuitest_coverline("build/graphics-canvas/graphics-canvas.js", 1152);
var graphic = this.get("graphic"),
parentXY = graphic.getXY(),
x = xy[0] - parentXY[0],
y = xy[1] - parentXY[1];
_yuitest_coverline("build/graphics-canvas/graphics-canvas.js", 1156);
this._set("x", x);
_yuitest_coverline("build/graphics-canvas/graphics-canvas.js", 1157);
this._set("y", y);
_yuitest_coverline("build/graphics-canvas/graphics-canvas.js", 1158);
this._updateNodePosition(x, y);
},
/**
* Determines whether the node is an ancestor of another HTML element in the DOM hierarchy.
*
* @method contains
* @param {CanvasShape | HTMLElement} needle The possible node or descendent
* @return Boolean Whether or not this shape is the needle or its ancestor.
*/
contains: function(needle)
{
_yuitest_coverfunc("build/graphics-canvas/graphics-canvas.js", "contains", 1168);
_yuitest_coverline("build/graphics-canvas/graphics-canvas.js", 1170);
return needle === Y.one(this.node);
},
/**
* Test if the supplied node matches the supplied selector.
*
* @method test
* @param {String} selector The CSS selector to test against.
* @return Boolean Wheter or not the shape matches the selector.
*/
test: function(selector)
{
_yuitest_coverfunc("build/graphics-canvas/graphics-canvas.js", "test", 1180);
_yuitest_coverline("build/graphics-canvas/graphics-canvas.js", 1182);
return Y.one(this.get("node")).test(selector);
//return Y.Selector.test(this.node, selector);
},
/**
* Compares nodes to determine if they match.
* Node instances can be compared to each other and/or HTMLElements.
* @method compareTo
* @param {HTMLElement | Node} refNode The reference node to compare to the node.
* @return {Boolean} True if the nodes match, false if they do not.
*/
compareTo: function(refNode) {
_yuitest_coverfunc("build/graphics-canvas/graphics-canvas.js", "compareTo", 1193);
_yuitest_coverline("build/graphics-canvas/graphics-canvas.js", 1194);
var node = this.node;
_yuitest_coverline("build/graphics-canvas/graphics-canvas.js", 1195);
return node === refNode;
},
/**
* Value function for fill attribute
*
* @method _getDefaultFill
* @return Object
* @private
*/
_getDefaultFill: function() {
_yuitest_coverfunc("build/graphics-canvas/graphics-canvas.js", "_getDefaultFill", 1205);
_yuitest_coverline("build/graphics-canvas/graphics-canvas.js", 1206);
return {
type: "solid",
opacity: 1,
cx: 0.5,
cy: 0.5,
fx: 0.5,
fy: 0.5,
r: 0.5
};
},
/**
* Value function for stroke attribute
*
* @method _getDefaultStroke
* @return Object
* @private
*/
_getDefaultStroke: function()
{
_yuitest_coverfunc("build/graphics-canvas/graphics-canvas.js", "_getDefaultStroke", 1224);
_yuitest_coverline("build/graphics-canvas/graphics-canvas.js", 1226);
return {
weight: 1,
dashstyle: "none",
color: "#000",
opacity: 1.0
};
},
/**
* Left edge of the path
*
* @property _left
* @type Number
* @private
*/
_left: 0,
/**
* Right edge of the path
*
* @property _right
* @type Number
* @private
*/
_right: 0,
/**
* Top edge of the path
*
* @property _top
* @type Number
* @private
*/
_top: 0,
/**
* Bottom edge of the path
*
* @property _bottom
* @type Number
* @private
*/
_bottom: 0,
/**
* Creates the dom node for the shape.
*
* @method createNode
* @return HTMLElement
* @private
*/
createNode: function()
{
_yuitest_coverfunc("build/graphics-canvas/graphics-canvas.js", "createNode", 1277);
_yuitest_coverline("build/graphics-canvas/graphics-canvas.js", 1279);
var host = this,
node = Y.config.doc.createElement('canvas'),
id = host.get("id"),
concat = host._camelCaseConcat,
name = host.name;
_yuitest_coverline("build/graphics-canvas/graphics-canvas.js", 1284);
host._context = node.getContext('2d');
_yuitest_coverline("build/graphics-canvas/graphics-canvas.js", 1285);
node.setAttribute("overflow", "visible");
_yuitest_coverline("build/graphics-canvas/graphics-canvas.js", 1286);
node.style.overflow = "visible";
_yuitest_coverline("build/graphics-canvas/graphics-canvas.js", 1287);
if(!host.get("visible"))
{
_yuitest_coverline("build/graphics-canvas/graphics-canvas.js", 1289);
node.style.visibility = "hidden";
}
_yuitest_coverline("build/graphics-canvas/graphics-canvas.js", 1291);
node.setAttribute("id", id);
_yuitest_coverline("build/graphics-canvas/graphics-canvas.js", 1292);
id = "#" + id;
_yuitest_coverline("build/graphics-canvas/graphics-canvas.js", 1293);
host.node = node;
_yuitest_coverline("build/graphics-canvas/graphics-canvas.js", 1294);
host.addClass(_getClassName(SHAPE) + " " + _getClassName(concat(IMPLEMENTATION, SHAPE)) + " " + _getClassName(name) + " " + _getClassName(concat(IMPLEMENTATION, name)));
},
/**
* Overrides default `on` method. Checks to see if its a dom interaction event. If so,
* return an event attached to the `node` element. If not, return the normal functionality.
*
* @method on
* @param {String} type event type
* @param {Object} callback function
* @private
*/
on: function(type, fn)
{
_yuitest_coverfunc("build/graphics-canvas/graphics-canvas.js", "on", 1306);
_yuitest_coverline("build/graphics-canvas/graphics-canvas.js", 1308);
if(Y.Node.DOM_EVENTS[type])
{
_yuitest_coverline("build/graphics-canvas/graphics-canvas.js", 1310);
return Y.one("#" + this.get("id")).on(type, fn);
}
_yuitest_coverline("build/graphics-canvas/graphics-canvas.js", 1312);
return Y.on.apply(this, arguments);
},
/**
* Adds a stroke to the shape node.
*
* @method _strokeChangeHandler
* @param {Object} stroke Properties of the `stroke` attribute.
* @private
*/
_setStrokeProps: function(stroke)
{
_yuitest_coverfunc("build/graphics-canvas/graphics-canvas.js", "_setStrokeProps", 1322);
_yuitest_coverline("build/graphics-canvas/graphics-canvas.js", 1324);
var color,
weight,
opacity,
linejoin,
linecap,
dashstyle;
_yuitest_coverline("build/graphics-canvas/graphics-canvas.js", 1330);
if(stroke)
{
_yuitest_coverline("build/graphics-canvas/graphics-canvas.js", 1332);
color = stroke.color;
_yuitest_coverline("build/graphics-canvas/graphics-canvas.js", 1333);
weight = PARSE_FLOAT(stroke.weight);
_yuitest_coverline("build/graphics-canvas/graphics-canvas.js", 1334);
opacity = PARSE_FLOAT(stroke.opacity);
_yuitest_coverline("build/graphics-canvas/graphics-canvas.js", 1335);
linejoin = stroke.linejoin || "round";
_yuitest_coverline("build/graphics-canvas/graphics-canvas.js", 1336);
linecap = stroke.linecap || "butt";
_yuitest_coverline("build/graphics-canvas/graphics-canvas.js", 1337);
dashstyle = stroke.dashstyle;
_yuitest_coverline("build/graphics-canvas/graphics-canvas.js", 1338);
this._miterlimit = null;
_yuitest_coverline("build/graphics-canvas/graphics-canvas.js", 1339);
this._dashstyle = (dashstyle && Y.Lang.isArray(dashstyle) && dashstyle.length > 1) ? dashstyle : null;
_yuitest_coverline("build/graphics-canvas/graphics-canvas.js", 1340);
this._strokeWeight = weight;
_yuitest_coverline("build/graphics-canvas/graphics-canvas.js", 1342);
if (IS_NUMBER(weight) && weight > 0)
{
_yuitest_coverline("build/graphics-canvas/graphics-canvas.js", 1344);
this._stroke = 1;
}
else
{
_yuitest_coverline("build/graphics-canvas/graphics-canvas.js", 1348);
this._stroke = 0;
}
_yuitest_coverline("build/graphics-canvas/graphics-canvas.js", 1350);
if (IS_NUMBER(opacity)) {
_yuitest_coverline("build/graphics-canvas/graphics-canvas.js", 1351);
this._strokeStyle = this._toRGBA(color, opacity);
}
else
{
_yuitest_coverline("build/graphics-canvas/graphics-canvas.js", 1355);
this._strokeStyle = color;
}
_yuitest_coverline("build/graphics-canvas/graphics-canvas.js", 1357);
this._linecap = linecap;
_yuitest_coverline("build/graphics-canvas/graphics-canvas.js", 1358);
if(linejoin == "round" || linejoin == "bevel")
{
_yuitest_coverline("build/graphics-canvas/graphics-canvas.js", 1360);
this._linejoin = linejoin;
}
else
{
_yuitest_coverline("build/graphics-canvas/graphics-canvas.js", 1364);
linejoin = parseInt(linejoin, 10);
_yuitest_coverline("build/graphics-canvas/graphics-canvas.js", 1365);
if(IS_NUMBER(linejoin))
{
_yuitest_coverline("build/graphics-canvas/graphics-canvas.js", 1367);
this._miterlimit = Math.max(linejoin, 1);
_yuitest_coverline("build/graphics-canvas/graphics-canvas.js", 1368);
this._linejoin = "miter";
}
}
}
else
{
_yuitest_coverline("build/graphics-canvas/graphics-canvas.js", 1374);
this._stroke = 0;
}
},
/**
* Sets the value of an attribute.
*
* @method set
* @param {String|Object} name The name of the attribute. Alternatively, an object of key value pairs can
* be passed in to set multiple attributes at once.
* @param {Any} value The value to set the attribute to. This value is ignored if an object is received as
* the name param.
*/
set: function()
{
_yuitest_coverfunc("build/graphics-canvas/graphics-canvas.js", "set", 1387);
_yuitest_coverline("build/graphics-canvas/graphics-canvas.js", 1389);
var host = this,
val = arguments[0];
_yuitest_coverline("build/graphics-canvas/graphics-canvas.js", 1391);
AttributeLite.prototype.set.apply(host, arguments);
_yuitest_coverline("build/graphics-canvas/graphics-canvas.js", 1392);
if(host.initialized)
{
_yuitest_coverline("build/graphics-canvas/graphics-canvas.js", 1394);
host._updateHandler();
}
},
/**
* Adds a fill to the shape node.
*
* @method _setFillProps
* @param {Object} fill Properties of the `fill` attribute.
* @private
*/
_setFillProps: function(fill)
{
_yuitest_coverfunc("build/graphics-canvas/graphics-canvas.js", "_setFillProps", 1405);
_yuitest_coverline("build/graphics-canvas/graphics-canvas.js", 1407);
var isNumber = IS_NUMBER,
color,
opacity,
type;
_yuitest_coverline("build/graphics-canvas/graphics-canvas.js", 1411);
if(fill)
{
_yuitest_coverline("build/graphics-canvas/graphics-canvas.js", 1413);
color = fill.color;
_yuitest_coverline("build/graphics-canvas/graphics-canvas.js", 1414);
type = fill.type;
_yuitest_coverline("build/graphics-canvas/graphics-canvas.js", 1415);
if(type == "linear" || type == "radial")
{
_yuitest_coverline("build/graphics-canvas/graphics-canvas.js", 1417);
this._fillType = type;
}
else {_yuitest_coverline("build/graphics-canvas/graphics-canvas.js", 1419);
if(color)
{
_yuitest_coverline("build/graphics-canvas/graphics-canvas.js", 1421);
opacity = fill.opacity;
_yuitest_coverline("build/graphics-canvas/graphics-canvas.js", 1422);
if (isNumber(opacity))
{
_yuitest_coverline("build/graphics-canvas/graphics-canvas.js", 1424);
opacity = Math.max(0, Math.min(1, opacity));
_yuitest_coverline("build/graphics-canvas/graphics-canvas.js", 1425);
color = this._toRGBA(color, opacity);
}
else
{
_yuitest_coverline("build/graphics-canvas/graphics-canvas.js", 1429);
color = TORGB(color);
}
_yuitest_coverline("build/graphics-canvas/graphics-canvas.js", 1432);
this._fillColor = color;
_yuitest_coverline("build/graphics-canvas/graphics-canvas.js", 1433);
this._fillType = 'solid';
}
else
{
_yuitest_coverline("build/graphics-canvas/graphics-canvas.js", 1437);
this._fillColor = null;
}}
}
else
{
_yuitest_coverline("build/graphics-canvas/graphics-canvas.js", 1442);
this._fillType = null;
_yuitest_coverline("build/graphics-canvas/graphics-canvas.js", 1443);
this._fillColor = null;
}
},
/**
* Specifies a 2d translation.
*
* @method translate
* @param {Number} x The value to transate on the x-axis.
* @param {Number} y The value to translate on the y-axis.
*/
translate: function(x, y)
{
_yuitest_coverfunc("build/graphics-canvas/graphics-canvas.js", "translate", 1454);
_yuitest_coverline("build/graphics-canvas/graphics-canvas.js", 1456);
this._translateX += x;
_yuitest_coverline("build/graphics-canvas/graphics-canvas.js", 1457);
this._translateY += y;
_yuitest_coverline("build/graphics-canvas/graphics-canvas.js", 1458);
this._addTransform("translate", arguments);
},
/**
* Translates the shape along the x-axis. When translating x and y coordinates,
* use the `translate` method.
*
* @method translateX
* @param {Number} x The value to translate.
*/
translateX: function(x)
{
_yuitest_coverfunc("build/graphics-canvas/graphics-canvas.js", "translateX", 1468);
_yuitest_coverline("build/graphics-canvas/graphics-canvas.js", 1470);
this._translateX += x;
_yuitest_coverline("build/graphics-canvas/graphics-canvas.js", 1471);
this._addTransform("translateX", arguments);
},
/**
* Performs a translate on the y-coordinate. When translating x and y coordinates,
* use the `translate` method.
*
* @method translateY
* @param {Number} y The value to translate.
*/
translateY: function(y)
{
_yuitest_coverfunc("build/graphics-canvas/graphics-canvas.js", "translateY", 1481);
_yuitest_coverline("build/graphics-canvas/graphics-canvas.js", 1483);
this._translateY += y;
_yuitest_coverline("build/graphics-canvas/graphics-canvas.js", 1484);
this._addTransform("translateY", arguments);
},
/**
* Skews the shape around the x-axis and y-axis.
*
* @method skew
* @param {Number} x The value to skew on the x-axis.
* @param {Number} y The value to skew on the y-axis.
*/
skew: function(x, y)
{
_yuitest_coverfunc("build/graphics-canvas/graphics-canvas.js", "skew", 1494);
_yuitest_coverline("build/graphics-canvas/graphics-canvas.js", 1496);
this._addTransform("skew", arguments);
},
/**
* Skews the shape around the x-axis.
*
* @method skewX
* @param {Number} x x-coordinate
*/
skewX: function(x)
{
_yuitest_coverfunc("build/graphics-canvas/graphics-canvas.js", "skewX", 1505);
_yuitest_coverline("build/graphics-canvas/graphics-canvas.js", 1507);
this._addTransform("skewX", arguments);
},
/**
* Skews the shape around the y-axis.
*
* @method skewY
* @param {Number} y y-coordinate
*/
skewY: function(y)
{
_yuitest_coverfunc("build/graphics-canvas/graphics-canvas.js", "skewY", 1516);
_yuitest_coverline("build/graphics-canvas/graphics-canvas.js", 1518);
this._addTransform("skewY", arguments);
},
/**
* Rotates the shape clockwise around it transformOrigin.
*
* @method rotate
* @param {Number} deg The degree of the rotation.
*/
rotate: function(deg)
{
_yuitest_coverfunc("build/graphics-canvas/graphics-canvas.js", "rotate", 1527);
_yuitest_coverline("build/graphics-canvas/graphics-canvas.js", 1529);
this._rotation = deg;
_yuitest_coverline("build/graphics-canvas/graphics-canvas.js", 1530);
this._addTransform("rotate", arguments);
},
/**
* Specifies a 2d scaling operation.
*
* @method scale
* @param {Number} val
*/
scale: function(x, y)
{
_yuitest_coverfunc("build/graphics-canvas/graphics-canvas.js", "scale", 1539);
_yuitest_coverline("build/graphics-canvas/graphics-canvas.js", 1541);
this._addTransform("scale", arguments);
},
/**
* Storage for `rotation` atribute.
*
* @property _rotation
* @type Number
* @private
*/
_rotation: 0,
/**
* Storage for the transform attribute.
*
* @property _transform
* @type String
* @private
*/
_transform: "",
/**
* Adds a transform to the shape.
*
* @method _addTransform
* @param {String} type The transform being applied.
* @param {Array} args The arguments for the transform.
* @private
*/
_addTransform: function(type, args)
{
_yuitest_coverfunc("build/graphics-canvas/graphics-canvas.js", "_addTransform", 1570);
_yuitest_coverline("build/graphics-canvas/graphics-canvas.js", 1572);
args = Y.Array(args);
_yuitest_coverline("build/graphics-canvas/graphics-canvas.js", 1573);
this._transform = Y_LANG.trim(this._transform + " " + type + "(" + args.join(", ") + ")");
_yuitest_coverline("build/graphics-canvas/graphics-canvas.js", 1574);
args.unshift(type);
_yuitest_coverline("build/graphics-canvas/graphics-canvas.js", 1575);
this._transforms.push(args);
_yuitest_coverline("build/graphics-canvas/graphics-canvas.js", 1576);
if(this.initialized)
{
_yuitest_coverline("build/graphics-canvas/graphics-canvas.js", 1578);
this._updateTransform();
}
},
/**
* Applies all transforms.
*
* @method _updateTransform
* @private
*/
_updateTransform: function()
{
_yuitest_coverfunc("build/graphics-canvas/graphics-canvas.js", "_updateTransform", 1588);
_yuitest_coverline("build/graphics-canvas/graphics-canvas.js", 1590);
var node = this.node,
key,
transform,
transformOrigin = this.get("transformOrigin"),
matrix = this.matrix,
i,
len = this._transforms.length;
_yuitest_coverline("build/graphics-canvas/graphics-canvas.js", 1598);
if(this._transforms && this._transforms.length > 0)
{
_yuitest_coverline("build/graphics-canvas/graphics-canvas.js", 1600);
for(i = 0; i < len; ++i)
{
_yuitest_coverline("build/graphics-canvas/graphics-canvas.js", 1602);
key = this._transforms[i].shift();
_yuitest_coverline("build/graphics-canvas/graphics-canvas.js", 1603);
if(key)
{
_yuitest_coverline("build/graphics-canvas/graphics-canvas.js", 1605);
matrix[key].apply(matrix, this._transforms[i]);
}
}
_yuitest_coverline("build/graphics-canvas/graphics-canvas.js", 1608);
transform = matrix.toCSSText();
}
_yuitest_coverline("build/graphics-canvas/graphics-canvas.js", 1611);
this._graphic.addToRedrawQueue(this);
_yuitest_coverline("build/graphics-canvas/graphics-canvas.js", 1612);
transformOrigin = (100 * transformOrigin[0]) + "% " + (100 * transformOrigin[1]) + "%";
_yuitest_coverline("build/graphics-canvas/graphics-canvas.js", 1613);
Y_DOM.setStyle(node, "transformOrigin", transformOrigin);
_yuitest_coverline("build/graphics-canvas/graphics-canvas.js", 1614);
if(transform)
{
_yuitest_coverline("build/graphics-canvas/graphics-canvas.js", 1616);
Y_DOM.setStyle(node, "transform", transform);
}
_yuitest_coverline("build/graphics-canvas/graphics-canvas.js", 1618);
this._transforms = [];
},
/**
* Updates `Shape` based on attribute changes.
*
* @method _updateHandler
* @private
*/
_updateHandler: function()
{
_yuitest_coverfunc("build/graphics-canvas/graphics-canvas.js", "_updateHandler", 1627);
_yuitest_coverline("build/graphics-canvas/graphics-canvas.js", 1629);
this._draw();
_yuitest_coverline("build/graphics-canvas/graphics-canvas.js", 1630);
this._updateTransform();
},
/**
* Updates the shape.
*
* @method _draw
* @private
*/
_draw: function()
{
_yuitest_coverfunc("build/graphics-canvas/graphics-canvas.js", "_draw", 1639);
_yuitest_coverline("build/graphics-canvas/graphics-canvas.js", 1641);
var node = this.node;
_yuitest_coverline("build/graphics-canvas/graphics-canvas.js", 1642);
this.clear();
_yuitest_coverline("build/graphics-canvas/graphics-canvas.js", 1643);
this._closePath();
_yuitest_coverline("build/graphics-canvas/graphics-canvas.js", 1644);
node.style.left = this.get("x") + "px";
_yuitest_coverline("build/graphics-canvas/graphics-canvas.js", 1645);
node.style.top = this.get("y") + "px";
},
/**
* Completes a shape or drawing
*
* @method _closePath
* @private
*/
_closePath: function()
{
_yuitest_coverfunc("build/graphics-canvas/graphics-canvas.js", "_closePath", 1654);
_yuitest_coverline("build/graphics-canvas/graphics-canvas.js", 1656);
if(!this._methods)
{
_yuitest_coverline("build/graphics-canvas/graphics-canvas.js", 1658);
return;
}
_yuitest_coverline("build/graphics-canvas/graphics-canvas.js", 1660);
var node = this.get("node"),
w = this._right - this._left,
h = this._bottom - this._top,
context = this._context,
methods = [],
cachedMethods = this._methods.concat(),
i,
j,
method,
args,
argsLen,
len = 0;
_yuitest_coverline("build/graphics-canvas/graphics-canvas.js", 1672);
this._context.clearRect(0, 0, node.width, node.height);
_yuitest_coverline("build/graphics-canvas/graphics-canvas.js", 1673);
if(this._methods)
{
_yuitest_coverline("build/graphics-canvas/graphics-canvas.js", 1675);
len = cachedMethods.length;
_yuitest_coverline("build/graphics-canvas/graphics-canvas.js", 1676);
if(!len || len < 1)
{
_yuitest_coverline("build/graphics-canvas/graphics-canvas.js", 1678);
return;
}
_yuitest_coverline("build/graphics-canvas/graphics-canvas.js", 1680);
for(i = 0; i < len; ++i)
{
_yuitest_coverline("build/graphics-canvas/graphics-canvas.js", 1682);
methods[i] = cachedMethods[i].concat();
_yuitest_coverline("build/graphics-canvas/graphics-canvas.js", 1683);
args = methods[i];
_yuitest_coverline("build/graphics-canvas/graphics-canvas.js", 1684);
argsLen = (args[0] == "quadraticCurveTo" || args[0] == "bezierCurveTo") ? args.length : 3;
_yuitest_coverline("build/graphics-canvas/graphics-canvas.js", 1685);
for(j = 1; j < argsLen; ++j)
{
_yuitest_coverline("build/graphics-canvas/graphics-canvas.js", 1687);
if(j % 2 === 0)
{
_yuitest_coverline("build/graphics-canvas/graphics-canvas.js", 1689);
args[j] = args[j] - this._top;
}
else
{
_yuitest_coverline("build/graphics-canvas/graphics-canvas.js", 1693);
args[j] = args[j] - this._left;
}
}
}
_yuitest_coverline("build/graphics-canvas/graphics-canvas.js", 1697);
node.setAttribute("width", Math.min(w, 2000));
_yuitest_coverline("build/graphics-canvas/graphics-canvas.js", 1698);
node.setAttribute("height", Math.min(2000, h));
_yuitest_coverline("build/graphics-canvas/graphics-canvas.js", 1699);
context.beginPath();
_yuitest_coverline("build/graphics-canvas/graphics-canvas.js", 1700);
for(i = 0; i < len; ++i)
{
_yuitest_coverline("build/graphics-canvas/graphics-canvas.js", 1702);
args = methods[i].concat();
_yuitest_coverline("build/graphics-canvas/graphics-canvas.js", 1703);
if(args && args.length > 0)
{
_yuitest_coverline("build/graphics-canvas/graphics-canvas.js", 1705);
method = args.shift();
_yuitest_coverline("build/graphics-canvas/graphics-canvas.js", 1706);
if(method)
{
_yuitest_coverline("build/graphics-canvas/graphics-canvas.js", 1708);
if(method == "closePath")
{
_yuitest_coverline("build/graphics-canvas/graphics-canvas.js", 1710);
context.closePath();
_yuitest_coverline("build/graphics-canvas/graphics-canvas.js", 1711);
this._strokeAndFill(context);
}
else {_yuitest_coverline("build/graphics-canvas/graphics-canvas.js", 1713);
if(method && method == "lineTo" && this._dashstyle)
{
_yuitest_coverline("build/graphics-canvas/graphics-canvas.js", 1715);
args.unshift(this._xcoords[i] - this._left, this._ycoords[i] - this._top);
_yuitest_coverline("build/graphics-canvas/graphics-canvas.js", 1716);
this._drawDashedLine.apply(this, args);
}
else
{
_yuitest_coverline("build/graphics-canvas/graphics-canvas.js", 1720);
context[method].apply(context, args);
}}
}
}
}
_yuitest_coverline("build/graphics-canvas/graphics-canvas.js", 1726);
this._strokeAndFill(context);
_yuitest_coverline("build/graphics-canvas/graphics-canvas.js", 1727);
this._drawingComplete = true;
_yuitest_coverline("build/graphics-canvas/graphics-canvas.js", 1728);
this._clearAndUpdateCoords();
_yuitest_coverline("build/graphics-canvas/graphics-canvas.js", 1729);
this._updateNodePosition();
_yuitest_coverline("build/graphics-canvas/graphics-canvas.js", 1730);
this._methods = cachedMethods;
}
},
/**
* Completes a stroke and/or fill operation on the context.
*
* @method _strokeAndFill
* @param {Context} Reference to the context element of the canvas instance.
* @private
*/
_strokeAndFill: function(context)
{
_yuitest_coverfunc("build/graphics-canvas/graphics-canvas.js", "_strokeAndFill", 1741);
_yuitest_coverline("build/graphics-canvas/graphics-canvas.js", 1743);
if (this._fillType)
{
_yuitest_coverline("build/graphics-canvas/graphics-canvas.js", 1745);
if(this._fillType == "linear")
{
_yuitest_coverline("build/graphics-canvas/graphics-canvas.js", 1747);
context.fillStyle = this._getLinearGradient();
}
else {_yuitest_coverline("build/graphics-canvas/graphics-canvas.js", 1749);
if(this._fillType == "radial")
{
_yuitest_coverline("build/graphics-canvas/graphics-canvas.js", 1751);
context.fillStyle = this._getRadialGradient();
}
else
{
_yuitest_coverline("build/graphics-canvas/graphics-canvas.js", 1755);
context.fillStyle = this._fillColor;
}}
_yuitest_coverline("build/graphics-canvas/graphics-canvas.js", 1757);
context.closePath();
_yuitest_coverline("build/graphics-canvas/graphics-canvas.js", 1758);
context.fill();
}
_yuitest_coverline("build/graphics-canvas/graphics-canvas.js", 1761);
if (this._stroke) {
_yuitest_coverline("build/graphics-canvas/graphics-canvas.js", 1762);
if(this._strokeWeight)
{
_yuitest_coverline("build/graphics-canvas/graphics-canvas.js", 1764);
context.lineWidth = this._strokeWeight;
}
_yuitest_coverline("build/graphics-canvas/graphics-canvas.js", 1766);
context.lineCap = this._linecap;
_yuitest_coverline("build/graphics-canvas/graphics-canvas.js", 1767);
context.lineJoin = this._linejoin;
_yuitest_coverline("build/graphics-canvas/graphics-canvas.js", 1768);
if(this._miterlimit)
{
_yuitest_coverline("build/graphics-canvas/graphics-canvas.js", 1770);
context.miterLimit = this._miterlimit;
}
_yuitest_coverline("build/graphics-canvas/graphics-canvas.js", 1772);
context.strokeStyle = this._strokeStyle;
_yuitest_coverline("build/graphics-canvas/graphics-canvas.js", 1773);
context.stroke();
}
},
/**
* Draws a dashed line between two points.
*
* @method _drawDashedLine
* @param {Number} xStart The x position of the start of the line
* @param {Number} yStart The y position of the start of the line
* @param {Number} xEnd The x position of the end of the line
* @param {Number} yEnd The y position of the end of the line
* @private
*/
_drawDashedLine: function(xStart, yStart, xEnd, yEnd)
{
_yuitest_coverfunc("build/graphics-canvas/graphics-canvas.js", "_drawDashedLine", 1787);
_yuitest_coverline("build/graphics-canvas/graphics-canvas.js", 1789);
var context = this._context,
dashsize = this._dashstyle[0],
gapsize = this._dashstyle[1],
segmentLength = dashsize + gapsize,
xDelta = xEnd - xStart,
yDelta = yEnd - yStart,
delta = Math.sqrt(Math.pow(xDelta, 2) + Math.pow(yDelta, 2)),
segmentCount = Math.floor(Math.abs(delta / segmentLength)),
radians = Math.atan2(yDelta, xDelta),
xCurrent = xStart,
yCurrent = yStart,
i;
_yuitest_coverline("build/graphics-canvas/graphics-canvas.js", 1801);
xDelta = Math.cos(radians) * segmentLength;
_yuitest_coverline("build/graphics-canvas/graphics-canvas.js", 1802);
yDelta = Math.sin(radians) * segmentLength;
_yuitest_coverline("build/graphics-canvas/graphics-canvas.js", 1804);
for(i = 0; i < segmentCount; ++i)
{
_yuitest_coverline("build/graphics-canvas/graphics-canvas.js", 1806);
context.moveTo(xCurrent, yCurrent);
_yuitest_coverline("build/graphics-canvas/graphics-canvas.js", 1807);
context.lineTo(xCurrent + Math.cos(radians) * dashsize, yCurrent + Math.sin(radians) * dashsize);
_yuitest_coverline("build/graphics-canvas/graphics-canvas.js", 1808);
xCurrent += xDelta;
_yuitest_coverline("build/graphics-canvas/graphics-canvas.js", 1809);
yCurrent += yDelta;
}
_yuitest_coverline("build/graphics-canvas/graphics-canvas.js", 1812);
context.moveTo(xCurrent, yCurrent);
_yuitest_coverline("build/graphics-canvas/graphics-canvas.js", 1813);
delta = Math.sqrt((xEnd - xCurrent) * (xEnd - xCurrent) + (yEnd - yCurrent) * (yEnd - yCurrent));
_yuitest_coverline("build/graphics-canvas/graphics-canvas.js", 1815);
if(delta > dashsize)
{
_yuitest_coverline("build/graphics-canvas/graphics-canvas.js", 1817);
context.lineTo(xCurrent + Math.cos(radians) * dashsize, yCurrent + Math.sin(radians) * dashsize);
}
else {_yuitest_coverline("build/graphics-canvas/graphics-canvas.js", 1819);
if(delta > 0)
{
_yuitest_coverline("build/graphics-canvas/graphics-canvas.js", 1821);
context.lineTo(xCurrent + Math.cos(radians) * delta, yCurrent + Math.sin(radians) * delta);
}}
_yuitest_coverline("build/graphics-canvas/graphics-canvas.js", 1824);
context.moveTo(xEnd, yEnd);
},
//This should move to CanvasDrawing class.
//Currently docmented in CanvasDrawing class.
clear: function() {
_yuitest_coverfunc("build/graphics-canvas/graphics-canvas.js", "clear", 1829);
_yuitest_coverline("build/graphics-canvas/graphics-canvas.js", 1830);
this._initProps();
_yuitest_coverline("build/graphics-canvas/graphics-canvas.js", 1831);
if(this.node)
{
_yuitest_coverline("build/graphics-canvas/graphics-canvas.js", 1833);
this._context.clearRect(0, 0, this.node.width, this.node.height);
}
_yuitest_coverline("build/graphics-canvas/graphics-canvas.js", 1835);
return this;
},
/**
* Returns the bounds for a shape.
*
* Calculates the a new bounding box from the original corner coordinates (base on size and position) and the transform matrix.
* The calculated bounding box is used by the graphic instance to calculate its viewBox.
*
* @method getBounds
* @return Object
*/
getBounds: function()
{
_yuitest_coverfunc("build/graphics-canvas/graphics-canvas.js", "getBounds", 1847);
_yuitest_coverline("build/graphics-canvas/graphics-canvas.js", 1849);
var type = this._type,
w = this.get("width"),
h = this.get("height"),
x = this.get("x"),
y = this.get("y");
_yuitest_coverline("build/graphics-canvas/graphics-canvas.js", 1854);
if(type == "path")
{
_yuitest_coverline("build/graphics-canvas/graphics-canvas.js", 1856);
x = x + this._left;
_yuitest_coverline("build/graphics-canvas/graphics-canvas.js", 1857);
y = y + this._top;
_yuitest_coverline("build/graphics-canvas/graphics-canvas.js", 1858);
w = this._right - this._left;
_yuitest_coverline("build/graphics-canvas/graphics-canvas.js", 1859);
h = this._bottom - this._top;
}
_yuitest_coverline("build/graphics-canvas/graphics-canvas.js", 1861);
return this._getContentRect(w, h, x, y);
},
/**
* Calculates the bounding box for the shape.
*
* @method _getContentRect
* @param {Number} w width of the shape
* @param {Number} h height of the shape
* @param {Number} x x-coordinate of the shape
* @param {Number} y y-coordinate of the shape
* @private
*/
_getContentRect: function(w, h, x, y)
{
_yuitest_coverfunc("build/graphics-canvas/graphics-canvas.js", "_getContentRect", 1874);
_yuitest_coverline("build/graphics-canvas/graphics-canvas.js", 1876);
var transformOrigin = this.get("transformOrigin"),
transformX = transformOrigin[0] * w,
transformY = transformOrigin[1] * h,
transforms = this.matrix.getTransformArray(this.get("transform")),
matrix = new Y.Matrix(),
i,
len = transforms.length,
transform,
key,
contentRect;
_yuitest_coverline("build/graphics-canvas/graphics-canvas.js", 1886);
if(this._type == "path")
{
_yuitest_coverline("build/graphics-canvas/graphics-canvas.js", 1888);
transformX = transformX + x;
_yuitest_coverline("build/graphics-canvas/graphics-canvas.js", 1889);
transformY = transformY + y;
}
_yuitest_coverline("build/graphics-canvas/graphics-canvas.js", 1891);
transformX = !isNaN(transformX) ? transformX : 0;
_yuitest_coverline("build/graphics-canvas/graphics-canvas.js", 1892);
transformY = !isNaN(transformY) ? transformY : 0;
_yuitest_coverline("build/graphics-canvas/graphics-canvas.js", 1893);
matrix.translate(transformX, transformY);
_yuitest_coverline("build/graphics-canvas/graphics-canvas.js", 1894);
for(i = 0; i < len; i = i + 1)
{
_yuitest_coverline("build/graphics-canvas/graphics-canvas.js", 1896);
transform = transforms[i];
_yuitest_coverline("build/graphics-canvas/graphics-canvas.js", 1897);
key = transform.shift();
_yuitest_coverline("build/graphics-canvas/graphics-canvas.js", 1898);
if(key)
{
_yuitest_coverline("build/graphics-canvas/graphics-canvas.js", 1900);
matrix[key].apply(matrix, transform);
}
}
_yuitest_coverline("build/graphics-canvas/graphics-canvas.js", 1903);
matrix.translate(-transformX, -transformY);
_yuitest_coverline("build/graphics-canvas/graphics-canvas.js", 1904);
contentRect = matrix.getContentRect(w, h, x, y);
_yuitest_coverline("build/graphics-canvas/graphics-canvas.js", 1905);
return contentRect;
},
/**
* Places the shape above all other shapes.
*
* @method toFront
*/
toFront: function()
{
_yuitest_coverfunc("build/graphics-canvas/graphics-canvas.js", "toFront", 1913);
_yuitest_coverline("build/graphics-canvas/graphics-canvas.js", 1915);
var graphic = this.get("graphic");
_yuitest_coverline("build/graphics-canvas/graphics-canvas.js", 1916);
if(graphic)
{
_yuitest_coverline("build/graphics-canvas/graphics-canvas.js", 1918);
graphic._toFront(this);
}
},
/**
* Places the shape underneath all other shapes.
*
* @method toFront
*/
toBack: function()
{
_yuitest_coverfunc("build/graphics-canvas/graphics-canvas.js", "toBack", 1927);
_yuitest_coverline("build/graphics-canvas/graphics-canvas.js", 1929);
var graphic = this.get("graphic");
_yuitest_coverline("build/graphics-canvas/graphics-canvas.js", 1930);
if(graphic)
{
_yuitest_coverline("build/graphics-canvas/graphics-canvas.js", 1932);
graphic._toBack(this);
}
},
/**
* Parses path data string and call mapped methods.
*
* @method _parsePathData
* @param {String} val The path data
* @private
*/
_parsePathData: function(val)
{
_yuitest_coverfunc("build/graphics-canvas/graphics-canvas.js", "_parsePathData", 1943);
_yuitest_coverline("build/graphics-canvas/graphics-canvas.js", 1945);
var method,
methodSymbol,
args,
commandArray = Y.Lang.trim(val.match(SPLITPATHPATTERN)),
i,
len,
str,
symbolToMethod = this._pathSymbolToMethod;
_yuitest_coverline("build/graphics-canvas/graphics-canvas.js", 1953);
if(commandArray)
{
_yuitest_coverline("build/graphics-canvas/graphics-canvas.js", 1955);
this.clear();
_yuitest_coverline("build/graphics-canvas/graphics-canvas.js", 1956);
len = commandArray.length || 0;
_yuitest_coverline("build/graphics-canvas/graphics-canvas.js", 1957);
for(i = 0; i < len; i = i + 1)
{
_yuitest_coverline("build/graphics-canvas/graphics-canvas.js", 1959);
str = commandArray[i];
_yuitest_coverline("build/graphics-canvas/graphics-canvas.js", 1960);
methodSymbol = str.substr(0, 1);
_yuitest_coverline("build/graphics-canvas/graphics-canvas.js", 1961);
args = str.substr(1).match(SPLITARGSPATTERN);
_yuitest_coverline("build/graphics-canvas/graphics-canvas.js", 1962);
method = symbolToMethod[methodSymbol];
_yuitest_coverline("build/graphics-canvas/graphics-canvas.js", 1963);
if(method)
{
_yuitest_coverline("build/graphics-canvas/graphics-canvas.js", 1965);
if(args)
{
_yuitest_coverline("build/graphics-canvas/graphics-canvas.js", 1967);
this[method].apply(this, args);
}
else
{
_yuitest_coverline("build/graphics-canvas/graphics-canvas.js", 1971);
this[method].apply(this);
}
}
}
_yuitest_coverline("build/graphics-canvas/graphics-canvas.js", 1975);
this.end();
}
},
/**
* Destroys the shape instance.
*
* @method destroy
*/
destroy: function()
{
_yuitest_coverfunc("build/graphics-canvas/graphics-canvas.js", "destroy", 1984);
_yuitest_coverline("build/graphics-canvas/graphics-canvas.js", 1986);
var graphic = this.get("graphic");
_yuitest_coverline("build/graphics-canvas/graphics-canvas.js", 1987);
if(graphic)
{
_yuitest_coverline("build/graphics-canvas/graphics-canvas.js", 1989);
graphic.removeShape(this);
}
else
{
_yuitest_coverline("build/graphics-canvas/graphics-canvas.js", 1993);
this._destroy();
}
},
/**
* Implementation for shape destruction
*
* @method destroy
* @protected
*/
_destroy: function()
{
_yuitest_coverfunc("build/graphics-canvas/graphics-canvas.js", "_destroy", 2003);
_yuitest_coverline("build/graphics-canvas/graphics-canvas.js", 2005);
if(this.node)
{
_yuitest_coverline("build/graphics-canvas/graphics-canvas.js", 2007);
Y.one(this.node).remove(true);
_yuitest_coverline("build/graphics-canvas/graphics-canvas.js", 2008);
this._context = null;
_yuitest_coverline("build/graphics-canvas/graphics-canvas.js", 2009);
this.node = null;
}
}
}, Y.CanvasDrawing.prototype));
_yuitest_coverline("build/graphics-canvas/graphics-canvas.js", 2014);
CanvasShape.ATTRS = {
/**
* An array of x, y values which indicates the transformOrigin in which to rotate the shape. Valid values range between 0 and 1 representing a
* fraction of the shape's corresponding bounding box dimension. The default value is [0.5, 0.5].
*
* @config transformOrigin
* @type Array
*/
transformOrigin: {
valueFn: function()
{
_yuitest_coverfunc("build/graphics-canvas/graphics-canvas.js", "valueFn", 2023);
_yuitest_coverline("build/graphics-canvas/graphics-canvas.js", 2025);
return [0.5, 0.5];
}
},
/**
* <p>A string containing, in order, transform operations applied to the shape instance. The `transform` string can contain the following values:
*
* <dl>
* <dt>rotate</dt><dd>Rotates the shape clockwise around it transformOrigin.</dd>
* <dt>translate</dt><dd>Specifies a 2d translation.</dd>
* <dt>skew</dt><dd>Skews the shape around the x-axis and y-axis.</dd>
* <dt>scale</dt><dd>Specifies a 2d scaling operation.</dd>
* <dt>translateX</dt><dd>Translates the shape along the x-axis.</dd>
* <dt>translateY</dt><dd>Translates the shape along the y-axis.</dd>
* <dt>skewX</dt><dd>Skews the shape around the x-axis.</dd>
* <dt>skewY</dt><dd>Skews the shape around the y-axis.</dd>
* <dt>matrix</dt><dd>Specifies a 2D transformation matrix comprised of the specified six values.</dd>
* </dl>
* </p>
* <p>Applying transforms through the transform attribute will reset the transform matrix and apply a new transform. The shape class also contains corresponding methods for each transform
* that will apply the transform to the current matrix. The below code illustrates how you might use the `transform` attribute to instantiate a recangle with a rotation of 45 degrees.</p>
var myRect = new Y.Rect({
type:"rect",
width: 50,
height: 40,
transform: "rotate(45)"
};
* <p>The code below would apply `translate` and `rotate` to an existing shape.</p>
myRect.set("transform", "translate(40, 50) rotate(45)");
* @config transform
* @type String
*/
transform: {
setter: function(val)
{
_yuitest_coverfunc("build/graphics-canvas/graphics-canvas.js", "setter", 2059);
_yuitest_coverline("build/graphics-canvas/graphics-canvas.js", 2061);
this.matrix.init();
_yuitest_coverline("build/graphics-canvas/graphics-canvas.js", 2062);
this._transforms = this.matrix.getTransformArray(val);
_yuitest_coverline("build/graphics-canvas/graphics-canvas.js", 2063);
this._transform = val;
_yuitest_coverline("build/graphics-canvas/graphics-canvas.js", 2064);
return val;
},
getter: function()
{
_yuitest_coverfunc("build/graphics-canvas/graphics-canvas.js", "getter", 2067);
_yuitest_coverline("build/graphics-canvas/graphics-canvas.js", 2069);
return this._transform;
}
},
/**
* Dom node for the shape
*
* @config node
* @type HTMLElement
* @readOnly
*/
node: {
readOnly: true,
getter: function()
{
_yuitest_coverfunc("build/graphics-canvas/graphics-canvas.js", "getter", 2083);
_yuitest_coverline("build/graphics-canvas/graphics-canvas.js", 2085);
return this.node;
}
},
/**
* Unique id for class instance.
*
* @config id
* @type String
*/
id: {
valueFn: function()
{
_yuitest_coverfunc("build/graphics-canvas/graphics-canvas.js", "valueFn", 2096);
_yuitest_coverline("build/graphics-canvas/graphics-canvas.js", 2098);
return Y.guid();
},
setter: function(val)
{
_yuitest_coverfunc("build/graphics-canvas/graphics-canvas.js", "setter", 2101);
_yuitest_coverline("build/graphics-canvas/graphics-canvas.js", 2103);
var node = this.node;
_yuitest_coverline("build/graphics-canvas/graphics-canvas.js", 2104);
if(node)
{
_yuitest_coverline("build/graphics-canvas/graphics-canvas.js", 2106);
node.setAttribute("id", val);
}
_yuitest_coverline("build/graphics-canvas/graphics-canvas.js", 2108);
return val;
}
},
/**
* Indicates the width of the shape
*
* @config width
* @type Number
*/
width: {
value: 0
},
/**
* Indicates the height of the shape
*
* @config height
* @type Number
*/
height: {
value: 0
},
/**
* Indicates the x position of shape.
*
* @config x
* @type Number
*/
x: {
value: 0
},
/**
* Indicates the y position of shape.
*
* @config y
* @type Number
*/
y: {
value: 0
},
/**
* Indicates whether the shape is visible.
*
* @config visible
* @type Boolean
*/
visible: {
value: true,
setter: function(val){
_yuitest_coverfunc("build/graphics-canvas/graphics-canvas.js", "setter", 2161);
_yuitest_coverline("build/graphics-canvas/graphics-canvas.js", 2162);
var node = this.get("node"),
visibility = val ? "visible" : "hidden";
_yuitest_coverline("build/graphics-canvas/graphics-canvas.js", 2164);
if(node)
{
_yuitest_coverline("build/graphics-canvas/graphics-canvas.js", 2166);
node.style.visibility = visibility;
}
_yuitest_coverline("build/graphics-canvas/graphics-canvas.js", 2168);
return val;
}
},
/**
* Contains information about the fill of the shape.
* <dl>
* <dt>color</dt><dd>The color of the fill.</dd>
* <dt>opacity</dt><dd>Number between 0 and 1 that indicates the opacity of the fill. The default value is 1.</dd>
* <dt>type</dt><dd>Type of fill.
* <dl>
* <dt>solid</dt><dd>Solid single color fill. (default)</dd>
* <dt>linear</dt><dd>Linear gradient fill.</dd>
* <dt>radial</dt><dd>Radial gradient fill.</dd>
* </dl>
* </dd>
* </dl>
* <p>If a `linear` or `radial` is specified as the fill type. The following additional property is used:
* <dl>
* <dt>stops</dt><dd>An array of objects containing the following properties:
* <dl>
* <dt>color</dt><dd>The color of the stop.</dd>
* <dt>opacity</dt><dd>Number between 0 and 1 that indicates the opacity of the stop. The default value is 1. Note: No effect for IE 6 - 8</dd>
* <dt>offset</dt><dd>Number between 0 and 1 indicating where the color stop is positioned.</dd>
* </dl>
* </dd>
* <p>Linear gradients also have the following property:</p>
* <dt>rotation</dt><dd>Linear gradients flow left to right by default. The rotation property allows you to change the flow by rotation. (e.g. A rotation of 180 would make the gradient pain from right to left.)</dd>
* <p>Radial gradients have the following additional properties:</p>
* <dt>r</dt><dd>Radius of the gradient circle.</dd>
* <dt>fx</dt><dd>Focal point x-coordinate of the gradient.</dd>
* <dt>fy</dt><dd>Focal point y-coordinate of the gradient.</dd>
* </dl>
* <p>The corresponding `SVGShape` class implements the following additional properties.</p>
* <dl>
* <dt>cx</dt><dd>
* <p>The x-coordinate of the center of the gradient circle. Determines where the color stop begins. The default value 0.5.</p>
* </dd>
* <dt>cy</dt><dd>
* <p>The y-coordinate of the center of the gradient circle. Determines where the color stop begins. The default value 0.5.</p>
* </dd>
* </dl>
* <p>These properties are not currently implemented in `CanvasShape` or `VMLShape`.</p>
*
* @config fill
* @type Object
*/
fill: {
valueFn: "_getDefaultFill",
setter: function(val)
{
_yuitest_coverfunc("build/graphics-canvas/graphics-canvas.js", "setter", 2218);
_yuitest_coverline("build/graphics-canvas/graphics-canvas.js", 2220);
var fill,
tmpl = this.get("fill") || this._getDefaultFill();
_yuitest_coverline("build/graphics-canvas/graphics-canvas.js", 2222);
fill = (val) ? Y.merge(tmpl, val) : null;
_yuitest_coverline("build/graphics-canvas/graphics-canvas.js", 2223);
if(fill && fill.color)
{
_yuitest_coverline("build/graphics-canvas/graphics-canvas.js", 2225);
if(fill.color === undefined || fill.color == "none")
{
_yuitest_coverline("build/graphics-canvas/graphics-canvas.js", 2227);
fill.color = null;
}
}
_yuitest_coverline("build/graphics-canvas/graphics-canvas.js", 2230);
this._setFillProps(fill);
_yuitest_coverline("build/graphics-canvas/graphics-canvas.js", 2231);
return fill;
}
},
/**
* Contains information about the stroke of the shape.
* <dl>
* <dt>color</dt><dd>The color of the stroke.</dd>
* <dt>weight</dt><dd>Number that indicates the width of the stroke.</dd>
* <dt>opacity</dt><dd>Number between 0 and 1 that indicates the opacity of the stroke. The default value is 1.</dd>
* <dt>dashstyle</dt>Indicates whether to draw a dashed stroke. When set to "none", a solid stroke is drawn. When set to an array, the first index indicates the
* length of the dash. The second index indicates the length of gap.
* <dt>linecap</dt><dd>Specifies the linecap for the stroke. The following values can be specified:
* <dl>
* <dt>butt (default)</dt><dd>Specifies a butt linecap.</dd>
* <dt>square</dt><dd>Specifies a sqare linecap.</dd>
* <dt>round</dt><dd>Specifies a round linecap.</dd>
* </dl>
* </dd>
* <dt>linejoin</dt><dd>Specifies a linejoin for the stroke. The following values can be specified:
* <dl>
* <dt>round (default)</dt><dd>Specifies that the linejoin will be round.</dd>
* <dt>bevel</dt><dd>Specifies a bevel for the linejoin.</dd>
* <dt>miter limit</dt><dd>An integer specifying the miter limit of a miter linejoin. If you want to specify a linejoin of miter, you simply specify the limit as opposed to having
* separate miter and miter limit values.</dd>
* </dl>
* </dd>
* </dl>
*
* @config stroke
* @type Object
*/
stroke: {
valueFn: "_getDefaultStroke",
setter: function(val)
{
_yuitest_coverfunc("build/graphics-canvas/graphics-canvas.js", "setter", 2266);
_yuitest_coverline("build/graphics-canvas/graphics-canvas.js", 2268);
var tmpl = this.get("stroke") || this._getDefaultStroke(),
wt;
_yuitest_coverline("build/graphics-canvas/graphics-canvas.js", 2270);
if(val && val.hasOwnProperty("weight"))
{
_yuitest_coverline("build/graphics-canvas/graphics-canvas.js", 2272);
wt = parseInt(val.weight, 10);
_yuitest_coverline("build/graphics-canvas/graphics-canvas.js", 2273);
if(!isNaN(wt))
{
_yuitest_coverline("build/graphics-canvas/graphics-canvas.js", 2275);
val.weight = wt;
}
}
_yuitest_coverline("build/graphics-canvas/graphics-canvas.js", 2278);
val = (val) ? Y.merge(tmpl, val) : null;
_yuitest_coverline("build/graphics-canvas/graphics-canvas.js", 2279);
this._setStrokeProps(val);
_yuitest_coverline("build/graphics-canvas/graphics-canvas.js", 2280);
return val;
}
},
//Not used. Remove in future.
autoSize: {
value: false
},
// Only implemented in SVG
// Determines whether the instance will receive mouse events.
//
// @config pointerEvents
// @type string
//
pointerEvents: {
value: "visiblePainted"
},
/**
* Represents an SVG Path string. This will be parsed and added to shape's API to represent the SVG data across all implementations. Note that when using VML or SVG
* implementations, part of this content will be added to the DOM using respective VML/SVG attributes. If your content comes from an untrusted source, you will need
* to ensure that no malicious code is included in that content.
*
* @config data
* @type String
*/
data: {
setter: function(val)
{
_yuitest_coverfunc("build/graphics-canvas/graphics-canvas.js", "setter", 2308);
_yuitest_coverline("build/graphics-canvas/graphics-canvas.js", 2310);
if(this.get("node"))
{
_yuitest_coverline("build/graphics-canvas/graphics-canvas.js", 2312);
this._parsePathData(val);
}
_yuitest_coverline("build/graphics-canvas/graphics-canvas.js", 2314);
return val;
}
},
/**
* Reference to the container Graphic.
*
* @config graphic
* @type Graphic
*/
graphic: {
readOnly: true,
getter: function()
{
_yuitest_coverfunc("build/graphics-canvas/graphics-canvas.js", "getter", 2327);
_yuitest_coverline("build/graphics-canvas/graphics-canvas.js", 2329);
return this._graphic;
}
}
};
_yuitest_coverline("build/graphics-canvas/graphics-canvas.js", 2333);
Y.CanvasShape = CanvasShape;
/**
* <a href="http://www.w3.org/TR/html5/the-canvas-element.html">Canvas</a> implementation of the <a href="Path.html">`Path`</a> class.
* `CanvasPath` is not intended to be used directly. Instead, use the <a href="Path.html">`Path`</a> class.
* If the browser lacks <a href="http://www.w3.org/TR/SVG/">SVG</a> capabilities but has
* <a href="http://www.w3.org/TR/html5/the-canvas-element.html">Canvas</a> capabilities, the <a href="Path.html">`Path`</a>
* class will point to the `CanvasPath` class.
*
* @module graphics
* @class CanvasPath
* @extends CanvasShape
*/
_yuitest_coverline("build/graphics-canvas/graphics-canvas.js", 2345);
CanvasPath = function(cfg)
{
_yuitest_coverfunc("build/graphics-canvas/graphics-canvas.js", "CanvasPath", 2345);
_yuitest_coverline("build/graphics-canvas/graphics-canvas.js", 2347);
CanvasPath.superclass.constructor.apply(this, arguments);
};
_yuitest_coverline("build/graphics-canvas/graphics-canvas.js", 2349);
CanvasPath.NAME = "path";
_yuitest_coverline("build/graphics-canvas/graphics-canvas.js", 2350);
Y.extend(CanvasPath, Y.CanvasShape, {
/**
* Indicates the type of shape
*
* @property _type
* @type String
* @private
*/
_type: "path",
/**
* Draws the shape.
*
* @method _draw
* @private
*/
_draw: function()
{
_yuitest_coverfunc("build/graphics-canvas/graphics-canvas.js", "_draw", 2366);
_yuitest_coverline("build/graphics-canvas/graphics-canvas.js", 2368);
this._closePath();
_yuitest_coverline("build/graphics-canvas/graphics-canvas.js", 2369);
this._updateTransform();
},
/**
* Creates the dom node for the shape.
*
* @method createNode
* @return HTMLElement
* @private
*/
createNode: function()
{
_yuitest_coverfunc("build/graphics-canvas/graphics-canvas.js", "createNode", 2379);
_yuitest_coverline("build/graphics-canvas/graphics-canvas.js", 2381);
var host = this,
node = Y.config.doc.createElement('canvas'),
name = host.name,
concat = host._camelCaseConcat,
id = host.get("id");
_yuitest_coverline("build/graphics-canvas/graphics-canvas.js", 2386);
host._context = node.getContext('2d');
_yuitest_coverline("build/graphics-canvas/graphics-canvas.js", 2387);
node.setAttribute("overflow", "visible");
_yuitest_coverline("build/graphics-canvas/graphics-canvas.js", 2388);
node.setAttribute("pointer-events", "none");
_yuitest_coverline("build/graphics-canvas/graphics-canvas.js", 2389);
node.style.pointerEvents = "none";
_yuitest_coverline("build/graphics-canvas/graphics-canvas.js", 2390);
node.style.overflow = "visible";
_yuitest_coverline("build/graphics-canvas/graphics-canvas.js", 2391);
node.setAttribute("id", id);
_yuitest_coverline("build/graphics-canvas/graphics-canvas.js", 2392);
id = "#" + id;
_yuitest_coverline("build/graphics-canvas/graphics-canvas.js", 2393);
host.node = node;
_yuitest_coverline("build/graphics-canvas/graphics-canvas.js", 2394);
host.addClass(_getClassName(SHAPE) + " " + _getClassName(concat(IMPLEMENTATION, SHAPE)) + " " + _getClassName(name) + " " + _getClassName(concat(IMPLEMENTATION, name)));
},
/**
* Completes a drawing operation.
*
* @method end
*/
end: function()
{
_yuitest_coverfunc("build/graphics-canvas/graphics-canvas.js", "end", 2402);
_yuitest_coverline("build/graphics-canvas/graphics-canvas.js", 2404);
this._draw();
}
});
_yuitest_coverline("build/graphics-canvas/graphics-canvas.js", 2408);
CanvasPath.ATTRS = Y.merge(Y.CanvasShape.ATTRS, {
/**
* Indicates the width of the shape
*
* @config width
* @type Number
*/
width: {
getter: function()
{
_yuitest_coverfunc("build/graphics-canvas/graphics-canvas.js", "getter", 2416);
_yuitest_coverline("build/graphics-canvas/graphics-canvas.js", 2418);
var offset = this._stroke && this._strokeWeight ? (this._strokeWeight * 2) : 0;
_yuitest_coverline("build/graphics-canvas/graphics-canvas.js", 2419);
return this._width - offset;
},
setter: function(val)
{
_yuitest_coverfunc("build/graphics-canvas/graphics-canvas.js", "setter", 2422);
_yuitest_coverline("build/graphics-canvas/graphics-canvas.js", 2424);
this._width = val;
_yuitest_coverline("build/graphics-canvas/graphics-canvas.js", 2425);
return val;
}
},
/**
* Indicates the height of the shape
*
* @config height
* @type Number
*/
height: {
getter: function()
{
_yuitest_coverfunc("build/graphics-canvas/graphics-canvas.js", "getter", 2436);
_yuitest_coverline("build/graphics-canvas/graphics-canvas.js", 2438);
var offset = this._stroke && this._strokeWeight ? (this._strokeWeight * 2) : 0;
_yuitest_coverline("build/graphics-canvas/graphics-canvas.js", 2439);
return this._height - offset;
},
setter: function(val)
{
_yuitest_coverfunc("build/graphics-canvas/graphics-canvas.js", "setter", 2442);
_yuitest_coverline("build/graphics-canvas/graphics-canvas.js", 2444);
this._height = val;
_yuitest_coverline("build/graphics-canvas/graphics-canvas.js", 2445);
return val;
}
},
/**
* Indicates the path used for the node.
*
* @config path
* @type String
* @readOnly
*/
path: {
readOnly: true,
getter: function()
{
_yuitest_coverfunc("build/graphics-canvas/graphics-canvas.js", "getter", 2459);
_yuitest_coverline("build/graphics-canvas/graphics-canvas.js", 2461);
return this._path;
}
}
});
_yuitest_coverline("build/graphics-canvas/graphics-canvas.js", 2465);
Y.CanvasPath = CanvasPath;
/**
* <a href="http://www.w3.org/TR/html5/the-canvas-element.html">Canvas</a> implementation of the <a href="Rect.html">`Rect`</a> class.
* `CanvasRect` is not intended to be used directly. Instead, use the <a href="Rect.html">`Rect`</a> class.
* If the browser lacks <a href="http://www.w3.org/TR/SVG/">SVG</a> capabilities but has
* <a href="http://www.w3.org/TR/html5/the-canvas-element.html">Canvas</a> capabilities, the <a href="Rect.html">`Rect`</a>
* class will point to the `CanvasRect` class.
*
* @module graphics
* @class CanvasRect
* @constructor
*/
_yuitest_coverline("build/graphics-canvas/graphics-canvas.js", 2477);
CanvasRect = function()
{
_yuitest_coverfunc("build/graphics-canvas/graphics-canvas.js", "CanvasRect", 2477);
_yuitest_coverline("build/graphics-canvas/graphics-canvas.js", 2479);
CanvasRect.superclass.constructor.apply(this, arguments);
};
_yuitest_coverline("build/graphics-canvas/graphics-canvas.js", 2481);
CanvasRect.NAME = "rect";
_yuitest_coverline("build/graphics-canvas/graphics-canvas.js", 2482);
Y.extend(CanvasRect, Y.CanvasShape, {
/**
* Indicates the type of shape
*
* @property _type
* @type String
* @private
*/
_type: "rect",
/**
* Draws the shape.
*
* @method _draw
* @private
*/
_draw: function()
{
_yuitest_coverfunc("build/graphics-canvas/graphics-canvas.js", "_draw", 2498);
_yuitest_coverline("build/graphics-canvas/graphics-canvas.js", 2500);
var w = this.get("width"),
h = this.get("height");
_yuitest_coverline("build/graphics-canvas/graphics-canvas.js", 2502);
this.clear();
_yuitest_coverline("build/graphics-canvas/graphics-canvas.js", 2503);
this.drawRect(0, 0, w, h);
_yuitest_coverline("build/graphics-canvas/graphics-canvas.js", 2504);
this._closePath();
}
});
_yuitest_coverline("build/graphics-canvas/graphics-canvas.js", 2507);
CanvasRect.ATTRS = Y.CanvasShape.ATTRS;
_yuitest_coverline("build/graphics-canvas/graphics-canvas.js", 2508);
Y.CanvasRect = CanvasRect;
/**
* <a href="http://www.w3.org/TR/html5/the-canvas-element.html">Canvas</a> implementation of the <a href="Ellipse.html">`Ellipse`</a> class.
* `CanvasEllipse` is not intended to be used directly. Instead, use the <a href="Ellipse.html">`Ellipse`</a> class.
* If the browser lacks <a href="http://www.w3.org/TR/SVG/">SVG</a> capabilities but has
* <a href="http://www.w3.org/TR/html5/the-canvas-element.html">Canvas</a> capabilities, the <a href="Ellipse.html">`Ellipse`</a>
* class will point to the `CanvasEllipse` class.
*
* @module graphics
* @class CanvasEllipse
* @constructor
*/
_yuitest_coverline("build/graphics-canvas/graphics-canvas.js", 2520);
CanvasEllipse = function(cfg)
{
_yuitest_coverfunc("build/graphics-canvas/graphics-canvas.js", "CanvasEllipse", 2520);
_yuitest_coverline("build/graphics-canvas/graphics-canvas.js", 2522);
CanvasEllipse.superclass.constructor.apply(this, arguments);
};
_yuitest_coverline("build/graphics-canvas/graphics-canvas.js", 2525);
CanvasEllipse.NAME = "ellipse";
_yuitest_coverline("build/graphics-canvas/graphics-canvas.js", 2527);
Y.extend(CanvasEllipse, CanvasShape, {
/**
* Indicates the type of shape
*
* @property _type
* @type String
* @private
*/
_type: "ellipse",
/**
* Draws the shape.
*
* @method _draw
* @private
*/
_draw: function()
{
_yuitest_coverfunc("build/graphics-canvas/graphics-canvas.js", "_draw", 2543);
_yuitest_coverline("build/graphics-canvas/graphics-canvas.js", 2545);
var w = this.get("width"),
h = this.get("height");
_yuitest_coverline("build/graphics-canvas/graphics-canvas.js", 2547);
this.clear();
_yuitest_coverline("build/graphics-canvas/graphics-canvas.js", 2548);
this.drawEllipse(0, 0, w, h);
_yuitest_coverline("build/graphics-canvas/graphics-canvas.js", 2549);
this._closePath();
}
});
_yuitest_coverline("build/graphics-canvas/graphics-canvas.js", 2552);
CanvasEllipse.ATTRS = Y.merge(CanvasShape.ATTRS, {
/**
* Horizontal radius for the ellipse.
*
* @config xRadius
* @type Number
*/
xRadius: {
setter: function(val)
{
_yuitest_coverfunc("build/graphics-canvas/graphics-canvas.js", "setter", 2560);
_yuitest_coverline("build/graphics-canvas/graphics-canvas.js", 2562);
this.set("width", val * 2);
},
getter: function()
{
_yuitest_coverfunc("build/graphics-canvas/graphics-canvas.js", "getter", 2565);
_yuitest_coverline("build/graphics-canvas/graphics-canvas.js", 2567);
var val = this.get("width");
_yuitest_coverline("build/graphics-canvas/graphics-canvas.js", 2568);
if(val)
{
_yuitest_coverline("build/graphics-canvas/graphics-canvas.js", 2570);
val *= 0.5;
}
_yuitest_coverline("build/graphics-canvas/graphics-canvas.js", 2572);
return val;
}
},
/**
* Vertical radius for the ellipse.
*
* @config yRadius
* @type Number
* @readOnly
*/
yRadius: {
setter: function(val)
{
_yuitest_coverfunc("build/graphics-canvas/graphics-canvas.js", "setter", 2584);
_yuitest_coverline("build/graphics-canvas/graphics-canvas.js", 2586);
this.set("height", val * 2);
},
getter: function()
{
_yuitest_coverfunc("build/graphics-canvas/graphics-canvas.js", "getter", 2589);
_yuitest_coverline("build/graphics-canvas/graphics-canvas.js", 2591);
var val = this.get("height");
_yuitest_coverline("build/graphics-canvas/graphics-canvas.js", 2592);
if(val)
{
_yuitest_coverline("build/graphics-canvas/graphics-canvas.js", 2594);
val *= 0.5;
}
_yuitest_coverline("build/graphics-canvas/graphics-canvas.js", 2596);
return val;
}
}
});
_yuitest_coverline("build/graphics-canvas/graphics-canvas.js", 2600);
Y.CanvasEllipse = CanvasEllipse;
/**
* <a href="http://www.w3.org/TR/html5/the-canvas-element.html">Canvas</a> implementation of the <a href="Circle.html">`Circle`</a> class.
* `CanvasCircle` is not intended to be used directly. Instead, use the <a href="Circle.html">`Circle`</a> class.
* If the browser lacks <a href="http://www.w3.org/TR/SVG/">SVG</a> capabilities but has
* <a href="http://www.w3.org/TR/html5/the-canvas-element.html">Canvas</a> capabilities, the <a href="Circle.html">`Circle`</a>
* class will point to the `CanvasCircle` class.
*
* @module graphics
* @class CanvasCircle
* @constructor
*/
_yuitest_coverline("build/graphics-canvas/graphics-canvas.js", 2612);
CanvasCircle = function(cfg)
{
_yuitest_coverfunc("build/graphics-canvas/graphics-canvas.js", "CanvasCircle", 2612);
_yuitest_coverline("build/graphics-canvas/graphics-canvas.js", 2614);
CanvasCircle.superclass.constructor.apply(this, arguments);
};
_yuitest_coverline("build/graphics-canvas/graphics-canvas.js", 2617);
CanvasCircle.NAME = "circle";
_yuitest_coverline("build/graphics-canvas/graphics-canvas.js", 2619);
Y.extend(CanvasCircle, Y.CanvasShape, {
/**
* Indicates the type of shape
*
* @property _type
* @type String
* @private
*/
_type: "circle",
/**
* Draws the shape.
*
* @method _draw
* @private
*/
_draw: function()
{
_yuitest_coverfunc("build/graphics-canvas/graphics-canvas.js", "_draw", 2635);
_yuitest_coverline("build/graphics-canvas/graphics-canvas.js", 2637);
var radius = this.get("radius");
_yuitest_coverline("build/graphics-canvas/graphics-canvas.js", 2638);
if(radius)
{
_yuitest_coverline("build/graphics-canvas/graphics-canvas.js", 2640);
this.clear();
_yuitest_coverline("build/graphics-canvas/graphics-canvas.js", 2641);
this.drawCircle(0, 0, radius);
_yuitest_coverline("build/graphics-canvas/graphics-canvas.js", 2642);
this._closePath();
}
}
});
_yuitest_coverline("build/graphics-canvas/graphics-canvas.js", 2647);
CanvasCircle.ATTRS = Y.merge(Y.CanvasShape.ATTRS, {
/**
* Indicates the width of the shape
*
* @config width
* @type Number
*/
width: {
setter: function(val)
{
_yuitest_coverfunc("build/graphics-canvas/graphics-canvas.js", "setter", 2655);
_yuitest_coverline("build/graphics-canvas/graphics-canvas.js", 2657);
this.set("radius", val/2);
_yuitest_coverline("build/graphics-canvas/graphics-canvas.js", 2658);
return val;
},
getter: function()
{
_yuitest_coverfunc("build/graphics-canvas/graphics-canvas.js", "getter", 2661);
_yuitest_coverline("build/graphics-canvas/graphics-canvas.js", 2663);
return this.get("radius") * 2;
}
},
/**
* Indicates the height of the shape
*
* @config height
* @type Number
*/
height: {
setter: function(val)
{
_yuitest_coverfunc("build/graphics-canvas/graphics-canvas.js", "setter", 2674);
_yuitest_coverline("build/graphics-canvas/graphics-canvas.js", 2676);
this.set("radius", val/2);
_yuitest_coverline("build/graphics-canvas/graphics-canvas.js", 2677);
return val;
},
getter: function()
{
_yuitest_coverfunc("build/graphics-canvas/graphics-canvas.js", "getter", 2680);
_yuitest_coverline("build/graphics-canvas/graphics-canvas.js", 2682);
return this.get("radius") * 2;
}
},
/**
* Radius of the circle
*
* @config radius
* @type Number
*/
radius: {
lazyAdd: false
}
});
_yuitest_coverline("build/graphics-canvas/graphics-canvas.js", 2696);
Y.CanvasCircle = CanvasCircle;
/**
* Draws pie slices
*
* @module graphics
* @class CanvasPieSlice
* @constructor
*/
_yuitest_coverline("build/graphics-canvas/graphics-canvas.js", 2704);
CanvasPieSlice = function()
{
_yuitest_coverfunc("build/graphics-canvas/graphics-canvas.js", "CanvasPieSlice", 2704);
_yuitest_coverline("build/graphics-canvas/graphics-canvas.js", 2706);
CanvasPieSlice.superclass.constructor.apply(this, arguments);
};
_yuitest_coverline("build/graphics-canvas/graphics-canvas.js", 2708);
CanvasPieSlice.NAME = "canvasPieSlice";
_yuitest_coverline("build/graphics-canvas/graphics-canvas.js", 2709);
Y.extend(CanvasPieSlice, Y.CanvasShape, {
/**
* Indicates the type of shape
*
* @property _type
* @type String
* @private
*/
_type: "path",
/**
* Change event listener
*
* @private
* @method _updateHandler
*/
_draw: function(e)
{
_yuitest_coverfunc("build/graphics-canvas/graphics-canvas.js", "_draw", 2725);
_yuitest_coverline("build/graphics-canvas/graphics-canvas.js", 2727);
var x = this.get("cx"),
y = this.get("cy"),
startAngle = this.get("startAngle"),
arc = this.get("arc"),
radius = this.get("radius");
_yuitest_coverline("build/graphics-canvas/graphics-canvas.js", 2732);
this.clear();
_yuitest_coverline("build/graphics-canvas/graphics-canvas.js", 2733);
this._left = x;
_yuitest_coverline("build/graphics-canvas/graphics-canvas.js", 2734);
this._right = radius;
_yuitest_coverline("build/graphics-canvas/graphics-canvas.js", 2735);
this._top = y;
_yuitest_coverline("build/graphics-canvas/graphics-canvas.js", 2736);
this._bottom = radius;
_yuitest_coverline("build/graphics-canvas/graphics-canvas.js", 2737);
this.drawWedge(x, y, startAngle, arc, radius);
_yuitest_coverline("build/graphics-canvas/graphics-canvas.js", 2738);
this.end();
}
});
_yuitest_coverline("build/graphics-canvas/graphics-canvas.js", 2741);
CanvasPieSlice.ATTRS = Y.mix({
cx: {
value: 0
},
cy: {
value: 0
},
/**
* Starting angle in relation to a circle in which to begin the pie slice drawing.
*
* @config startAngle
* @type Number
*/
startAngle: {
value: 0
},
/**
* Arc of the slice.
*
* @config arc
* @type Number
*/
arc: {
value: 0
},
/**
* Radius of the circle in which the pie slice is drawn
*
* @config radius
* @type Number
*/
radius: {
value: 0
}
}, Y.CanvasShape.ATTRS);
_yuitest_coverline("build/graphics-canvas/graphics-canvas.js", 2779);
Y.CanvasPieSlice = CanvasPieSlice;
/**
* <a href="http://www.w3.org/TR/html5/the-canvas-element.html">Canvas</a> implementation of the `Graphic` class.
* `CanvasGraphic` is not intended to be used directly. Instead, use the <a href="Graphic.html">`Graphic`</a> class.
* If the browser lacks <a href="http://www.w3.org/TR/SVG/">SVG</a> capabilities but has
* <a href="http://www.w3.org/TR/html5/the-canvas-element.html">Canvas</a> capabilities, the <a href="Graphic.html">`Graphic`</a>
* class will point to the `CanvasGraphic` class.
*
* @module graphics
* @class CanvasGraphic
* @constructor
*/
_yuitest_coverline("build/graphics-canvas/graphics-canvas.js", 2791);
function CanvasGraphic(config) {
_yuitest_coverfunc("build/graphics-canvas/graphics-canvas.js", "CanvasGraphic", 2791);
_yuitest_coverline("build/graphics-canvas/graphics-canvas.js", 2793);
CanvasGraphic.superclass.constructor.apply(this, arguments);
}
_yuitest_coverline("build/graphics-canvas/graphics-canvas.js", 2796);
CanvasGraphic.NAME = "canvasGraphic";
_yuitest_coverline("build/graphics-canvas/graphics-canvas.js", 2798);
CanvasGraphic.ATTRS = {
/**
* 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.
*
* @config render
* @type Node | String
*/
render: {},
/**
* Unique id for class instance.
*
* @config id
* @type String
*/
id: {
valueFn: function()
{
_yuitest_coverfunc("build/graphics-canvas/graphics-canvas.js", "valueFn", 2814);
_yuitest_coverline("build/graphics-canvas/graphics-canvas.js", 2816);
return Y.guid();
},
setter: function(val)
{
_yuitest_coverfunc("build/graphics-canvas/graphics-canvas.js", "setter", 2819);
_yuitest_coverline("build/graphics-canvas/graphics-canvas.js", 2821);
var node = this._node;
_yuitest_coverline("build/graphics-canvas/graphics-canvas.js", 2822);
if(node)
{
_yuitest_coverline("build/graphics-canvas/graphics-canvas.js", 2824);
node.setAttribute("id", val);
}
_yuitest_coverline("build/graphics-canvas/graphics-canvas.js", 2826);
return val;
}
},
/**
* Key value pairs in which a shape instance is associated with its id.
*
* @config shapes
* @type Object
* @readOnly
*/
shapes: {
readOnly: true,
getter: function()
{
_yuitest_coverfunc("build/graphics-canvas/graphics-canvas.js", "getter", 2840);
_yuitest_coverline("build/graphics-canvas/graphics-canvas.js", 2842);
return this._shapes;
}
},
/**
* Object containing size and coordinate data for the content of a Graphic in relation to the graphic instance's position.
*
* @config contentBounds
* @type Object
* @readOnly
*/
contentBounds: {
readOnly: true,
getter: function()
{
_yuitest_coverfunc("build/graphics-canvas/graphics-canvas.js", "getter", 2856);
_yuitest_coverline("build/graphics-canvas/graphics-canvas.js", 2858);
return this._contentBounds;
}
},
/**
* The outermost html element of the Graphic instance.
*
* @config node
* @type HTMLElement
* @readOnly
*/
node: {
readOnly: true,
getter: function()
{
_yuitest_coverfunc("build/graphics-canvas/graphics-canvas.js", "getter", 2872);
_yuitest_coverline("build/graphics-canvas/graphics-canvas.js", 2874);
return this._node;
}
},
/**
* Indicates the width of the `Graphic`.
*
* @config width
* @type Number
*/
width: {
setter: function(val)
{
_yuitest_coverfunc("build/graphics-canvas/graphics-canvas.js", "setter", 2885);
_yuitest_coverline("build/graphics-canvas/graphics-canvas.js", 2887);
if(this._node)
{
_yuitest_coverline("build/graphics-canvas/graphics-canvas.js", 2889);
this._node.style.width = val + "px";
}
_yuitest_coverline("build/graphics-canvas/graphics-canvas.js", 2891);
return val;
}
},
/**
* Indicates the height of the `Graphic`.
*
* @config height
* @type Number
*/
height: {
setter: function(val)
{
_yuitest_coverfunc("build/graphics-canvas/graphics-canvas.js", "setter", 2902);
_yuitest_coverline("build/graphics-canvas/graphics-canvas.js", 2904);
if(this._node)
{
_yuitest_coverline("build/graphics-canvas/graphics-canvas.js", 2906);
this._node.style.height = val + "px";
}
_yuitest_coverline("build/graphics-canvas/graphics-canvas.js", 2908);
return val;
}
},
/**
* Determines the sizing of the Graphic.
*
* <dl>
* <dt>sizeContentToGraphic</dt><dd>The Graphic's width and height attributes are, either explicitly set through the <code>width</code> and <code>height</code>
* attributes 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, the <code>preserveAspectRatio</code> attribute will determine how the contents are sized.</dd>
* <dt>sizeGraphicToContent</dt><dd>(Also accepts a value of true) The Graphic's width and height are determined by the size and positioning of the content.</dd>
* <dt>false</dt><dd>The Graphic's width and height attributes are, either explicitly set through the <code>width</code> and <code>height</code>
* attributes or are determined by the dimensions of the parent element. The contents of the Graphic instance are not affected by this setting.</dd>
* </dl>
*
*
* @config autoSize
* @type Boolean | String
* @default false
*/
autoSize: {
value: false
},
/**
* Determines how content is sized when <code>autoSize</code> is set to <code>sizeContentToGraphic</code>.
*
* <dl>
* <dt>none<dt><dd>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.</dd>
* <dt>xMinYMin</dt><dd>Force uniform scaling position along the top left of the Graphic's node.</dd>
* <dt>xMidYMin</dt><dd>Force uniform scaling horizontally centered and positioned at the top of the Graphic's node.<dd>
* <dt>xMaxYMin</dt><dd>Force uniform scaling positioned horizontally from the right and vertically from the top.</dd>
* <dt>xMinYMid</dt>Force uniform scaling positioned horizontally from the left and vertically centered.</dd>
* <dt>xMidYMid (the default)</dt><dd>Force uniform scaling with the content centered.</dd>
* <dt>xMaxYMid</dt><dd>Force uniform scaling positioned horizontally from the right and vertically centered.</dd>
* <dt>xMinYMax</dt><dd>Force uniform scaling positioned horizontally from the left and vertically from the bottom.</dd>
* <dt>xMidYMax</dt><dd>Force uniform scaling horizontally centered and position vertically from the bottom.</dd>
* <dt>xMaxYMax</dt><dd>Force uniform scaling positioned horizontally from the right and vertically from the bottom.</dd>
* </dl>
*
* @config preserveAspectRatio
* @type String
* @default xMidYMid
*/
preserveAspectRatio: {
value: "xMidYMid"
},
/**
* 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.
*
* @config resizeDown
* @type Boolean
*/
resizeDown: {
value: false
},
/**
* Indicates the x-coordinate for the instance.
*
* @config x
* @type Number
*/
x: {
getter: function()
{
_yuitest_coverfunc("build/graphics-canvas/graphics-canvas.js", "getter", 2976);
_yuitest_coverline("build/graphics-canvas/graphics-canvas.js", 2978);
return this._x;
},
setter: function(val)
{
_yuitest_coverfunc("build/graphics-canvas/graphics-canvas.js", "setter", 2981);
_yuitest_coverline("build/graphics-canvas/graphics-canvas.js", 2983);
this._x = val;
_yuitest_coverline("build/graphics-canvas/graphics-canvas.js", 2984);
if(this._node)
{
_yuitest_coverline("build/graphics-canvas/graphics-canvas.js", 2986);
this._node.style.left = val + "px";
}
_yuitest_coverline("build/graphics-canvas/graphics-canvas.js", 2988);
return val;
}
},
/**
* Indicates the y-coordinate for the instance.
*
* @config y
* @type Number
*/
y: {
getter: function()
{
_yuitest_coverfunc("build/graphics-canvas/graphics-canvas.js", "getter", 2999);
_yuitest_coverline("build/graphics-canvas/graphics-canvas.js", 3001);
return this._y;
},
setter: function(val)
{
_yuitest_coverfunc("build/graphics-canvas/graphics-canvas.js", "setter", 3004);
_yuitest_coverline("build/graphics-canvas/graphics-canvas.js", 3006);
this._y = val;
_yuitest_coverline("build/graphics-canvas/graphics-canvas.js", 3007);
if(this._node)
{
_yuitest_coverline("build/graphics-canvas/graphics-canvas.js", 3009);
this._node.style.top = val + "px";
}
_yuitest_coverline("build/graphics-canvas/graphics-canvas.js", 3011);
return val;
}
},
/**
* 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.
*
* @config autoDraw
* @type Boolean
* @default true
* @private
*/
autoDraw: {
value: true
},
/**
* Indicates whether the `Graphic` and its children are visible.
*
* @config visible
* @type Boolean
*/
visible: {
value: true,
setter: function(val)
{
_yuitest_coverfunc("build/graphics-canvas/graphics-canvas.js", "setter", 3037);
_yuitest_coverline("build/graphics-canvas/graphics-canvas.js", 3039);
this._toggleVisible(val);
_yuitest_coverline("build/graphics-canvas/graphics-canvas.js", 3040);
return val;
}
}
};
_yuitest_coverline("build/graphics-canvas/graphics-canvas.js", 3045);
Y.extend(CanvasGraphic, Y.GraphicBase, {
/**
* Sets the value of an attribute.
*
* @method set
* @param {String|Object} name The name of the attribute. Alternatively, an object of key value pairs can
* be passed in to set multiple attributes at once.
* @param {Any} value The value to set the attribute to. This value is ignored if an object is received as
* the name param.
*/
set: function(attr, value)
{
_yuitest_coverfunc("build/graphics-canvas/graphics-canvas.js", "set", 3055);
_yuitest_coverline("build/graphics-canvas/graphics-canvas.js", 3057);
var host = this,
redrawAttrs = {
autoDraw: true,
autoSize: true,
preserveAspectRatio: true,
resizeDown: true
},
key,
forceRedraw = false;
_yuitest_coverline("build/graphics-canvas/graphics-canvas.js", 3066);
AttributeLite.prototype.set.apply(host, arguments);
_yuitest_coverline("build/graphics-canvas/graphics-canvas.js", 3067);
if(host._state.autoDraw === true && Y.Object.size(this._shapes) > 0)
{
_yuitest_coverline("build/graphics-canvas/graphics-canvas.js", 3069);
if(Y_LANG.isString && redrawAttrs[attr])
{
_yuitest_coverline("build/graphics-canvas/graphics-canvas.js", 3071);
forceRedraw = true;
}
else {_yuitest_coverline("build/graphics-canvas/graphics-canvas.js", 3073);
if(Y_LANG.isObject(attr))
{
_yuitest_coverline("build/graphics-canvas/graphics-canvas.js", 3075);
for(key in redrawAttrs)
{
_yuitest_coverline("build/graphics-canvas/graphics-canvas.js", 3077);
if(redrawAttrs.hasOwnProperty(key) && attr[key])
{
_yuitest_coverline("build/graphics-canvas/graphics-canvas.js", 3079);
forceRedraw = true;
_yuitest_coverline("build/graphics-canvas/graphics-canvas.js", 3080);
break;
}
}
}}
}
_yuitest_coverline("build/graphics-canvas/graphics-canvas.js", 3085);
if(forceRedraw)
{
_yuitest_coverline("build/graphics-canvas/graphics-canvas.js", 3087);
host._redraw();
}
},
/**
* Storage for `x` attribute.
*
* @property _x
* @type Number
* @private
*/
_x: 0,
/**
* Storage for `y` attribute.
*
* @property _y
* @type Number
* @private
*/
_y: 0,
/**
* Gets the current position of the graphic instance in page coordinates.
*
* @method getXY
* @return Array The XY position of the shape.
*/
getXY: function()
{
_yuitest_coverfunc("build/graphics-canvas/graphics-canvas.js", "getXY", 3115);
_yuitest_coverline("build/graphics-canvas/graphics-canvas.js", 3117);
var node = Y.one(this._node),
xy;
_yuitest_coverline("build/graphics-canvas/graphics-canvas.js", 3119);
if(node)
{
_yuitest_coverline("build/graphics-canvas/graphics-canvas.js", 3121);
xy = node.getXY();
}
_yuitest_coverline("build/graphics-canvas/graphics-canvas.js", 3123);
return xy;
},
/**
* Initializes the class.
*
* @method initializer
* @param {Object} config Optional attributes
* @private
*/
initializer: function(config) {
_yuitest_coverfunc("build/graphics-canvas/graphics-canvas.js", "initializer", 3133);
_yuitest_coverline("build/graphics-canvas/graphics-canvas.js", 3134);
var render = this.get("render"),
visibility = this.get("visible") ? "visible" : "hidden",
w = this.get("width") || 0,
h = this.get("height") || 0;
_yuitest_coverline("build/graphics-canvas/graphics-canvas.js", 3138);
this._shapes = {};
_yuitest_coverline("build/graphics-canvas/graphics-canvas.js", 3139);
this._redrawQueue = {};
_yuitest_coverline("build/graphics-canvas/graphics-canvas.js", 3140);
this._contentBounds = {
left: 0,
top: 0,
right: 0,
bottom: 0
};
_yuitest_coverline("build/graphics-canvas/graphics-canvas.js", 3146);
this._node = DOCUMENT.createElement('div');
_yuitest_coverline("build/graphics-canvas/graphics-canvas.js", 3147);
this._node.style.position = "absolute";
_yuitest_coverline("build/graphics-canvas/graphics-canvas.js", 3148);
this._node.style.visibility = visibility;
_yuitest_coverline("build/graphics-canvas/graphics-canvas.js", 3149);
this.set("width", w);
_yuitest_coverline("build/graphics-canvas/graphics-canvas.js", 3150);
this.set("height", h);
_yuitest_coverline("build/graphics-canvas/graphics-canvas.js", 3151);
if(render)
{
_yuitest_coverline("build/graphics-canvas/graphics-canvas.js", 3153);
this.render(render);
}
},
/**
* Adds the graphics node to the dom.
*
* @method render
* @param {HTMLElement} parentNode node in which to render the graphics node into.
*/
render: function(render) {
_yuitest_coverfunc("build/graphics-canvas/graphics-canvas.js", "render", 3163);
_yuitest_coverline("build/graphics-canvas/graphics-canvas.js", 3164);
var parentNode = Y.one(render),
node = this._node,
w = this.get("width") || parseInt(parentNode.getComputedStyle("width"), 10),
h = this.get("height") || parseInt(parentNode.getComputedStyle("height"), 10);
_yuitest_coverline("build/graphics-canvas/graphics-canvas.js", 3168);
parentNode = parentNode || DOCUMENT.body;
_yuitest_coverline("build/graphics-canvas/graphics-canvas.js", 3169);
parentNode.appendChild(node);
_yuitest_coverline("build/graphics-canvas/graphics-canvas.js", 3170);
node.style.display = "block";
_yuitest_coverline("build/graphics-canvas/graphics-canvas.js", 3171);
node.style.position = "absolute";
_yuitest_coverline("build/graphics-canvas/graphics-canvas.js", 3172);
node.style.left = "0px";
_yuitest_coverline("build/graphics-canvas/graphics-canvas.js", 3173);
node.style.top = "0px";
_yuitest_coverline("build/graphics-canvas/graphics-canvas.js", 3174);
this.set("width", w);
_yuitest_coverline("build/graphics-canvas/graphics-canvas.js", 3175);
this.set("height", h);
_yuitest_coverline("build/graphics-canvas/graphics-canvas.js", 3176);
this.parentNode = parentNode;
_yuitest_coverline("build/graphics-canvas/graphics-canvas.js", 3177);
return this;
},
/**
* Removes all nodes.
*
* @method destroy
*/
destroy: function()
{
_yuitest_coverfunc("build/graphics-canvas/graphics-canvas.js", "destroy", 3185);
_yuitest_coverline("build/graphics-canvas/graphics-canvas.js", 3187);
this.removeAllShapes();
_yuitest_coverline("build/graphics-canvas/graphics-canvas.js", 3188);
if(this._node)
{
_yuitest_coverline("build/graphics-canvas/graphics-canvas.js", 3190);
this._removeChildren(this._node);
_yuitest_coverline("build/graphics-canvas/graphics-canvas.js", 3191);
Y.one(this._node).destroy();
}
},
/**
* Generates a shape instance by type.
*
* @method addShape
* @param {Object} cfg attributes for the shape
* @return Shape
*/
addShape: function(cfg)
{
_yuitest_coverfunc("build/graphics-canvas/graphics-canvas.js", "addShape", 3202);
_yuitest_coverline("build/graphics-canvas/graphics-canvas.js", 3204);
cfg.graphic = this;
_yuitest_coverline("build/graphics-canvas/graphics-canvas.js", 3205);
if(!this.get("visible"))
{
_yuitest_coverline("build/graphics-canvas/graphics-canvas.js", 3207);
cfg.visible = false;
}
_yuitest_coverline("build/graphics-canvas/graphics-canvas.js", 3209);
var shapeClass = this._getShapeClass(cfg.type),
shape = new shapeClass(cfg);
_yuitest_coverline("build/graphics-canvas/graphics-canvas.js", 3211);
this._appendShape(shape);
_yuitest_coverline("build/graphics-canvas/graphics-canvas.js", 3212);
return shape;
},
/**
* Adds a shape instance to the graphic instance.
*
* @method _appendShape
* @param {Shape} shape The shape instance to be added to the graphic.
* @private
*/
_appendShape: function(shape)
{
_yuitest_coverfunc("build/graphics-canvas/graphics-canvas.js", "_appendShape", 3222);
_yuitest_coverline("build/graphics-canvas/graphics-canvas.js", 3224);
var node = shape.node,
parentNode = this._frag || this._node;
_yuitest_coverline("build/graphics-canvas/graphics-canvas.js", 3226);
if(this.get("autoDraw"))
{
_yuitest_coverline("build/graphics-canvas/graphics-canvas.js", 3228);
parentNode.appendChild(node);
}
else
{
_yuitest_coverline("build/graphics-canvas/graphics-canvas.js", 3232);
this._getDocFrag().appendChild(node);
}
},
/**
* Removes a shape instance from from the graphic instance.
*
* @method removeShape
* @param {Shape|String} shape The instance or id of the shape to be removed.
*/
removeShape: function(shape)
{
_yuitest_coverfunc("build/graphics-canvas/graphics-canvas.js", "removeShape", 3242);
_yuitest_coverline("build/graphics-canvas/graphics-canvas.js", 3244);
if(!(shape instanceof CanvasShape))
{
_yuitest_coverline("build/graphics-canvas/graphics-canvas.js", 3246);
if(Y_LANG.isString(shape))
{
_yuitest_coverline("build/graphics-canvas/graphics-canvas.js", 3248);
shape = this._shapes[shape];
}
}
_yuitest_coverline("build/graphics-canvas/graphics-canvas.js", 3251);
if(shape && shape instanceof CanvasShape)
{
_yuitest_coverline("build/graphics-canvas/graphics-canvas.js", 3253);
shape._destroy();
_yuitest_coverline("build/graphics-canvas/graphics-canvas.js", 3254);
delete this._shapes[shape.get("id")];
}
_yuitest_coverline("build/graphics-canvas/graphics-canvas.js", 3256);
if(this.get("autoDraw"))
{
_yuitest_coverline("build/graphics-canvas/graphics-canvas.js", 3258);
this._redraw();
}
_yuitest_coverline("build/graphics-canvas/graphics-canvas.js", 3260);
return shape;
},
/**
* Removes all shape instances from the dom.
*
* @method removeAllShapes
*/
removeAllShapes: function()
{
_yuitest_coverfunc("build/graphics-canvas/graphics-canvas.js", "removeAllShapes", 3268);
_yuitest_coverline("build/graphics-canvas/graphics-canvas.js", 3270);
var shapes = this._shapes,
i;
_yuitest_coverline("build/graphics-canvas/graphics-canvas.js", 3272);
for(i in shapes)
{
_yuitest_coverline("build/graphics-canvas/graphics-canvas.js", 3274);
if(shapes.hasOwnProperty(i))
{
_yuitest_coverline("build/graphics-canvas/graphics-canvas.js", 3276);
shapes[i].destroy();
}
}
_yuitest_coverline("build/graphics-canvas/graphics-canvas.js", 3279);
this._shapes = {};
},
/**
* Clears the graphics object.
*
* @method clear
*/
clear: function() {
_yuitest_coverfunc("build/graphics-canvas/graphics-canvas.js", "clear", 3287);
_yuitest_coverline("build/graphics-canvas/graphics-canvas.js", 3288);
this.removeAllShapes();
},
/**
* Removes all child nodes.
*
* @method _removeChildren
* @param {HTMLElement} node
* @private
*/
_removeChildren: function(node)
{
_yuitest_coverfunc("build/graphics-canvas/graphics-canvas.js", "_removeChildren", 3298);
_yuitest_coverline("build/graphics-canvas/graphics-canvas.js", 3300);
if(node && node.hasChildNodes())
{
_yuitest_coverline("build/graphics-canvas/graphics-canvas.js", 3302);
var child;
_yuitest_coverline("build/graphics-canvas/graphics-canvas.js", 3303);
while(node.firstChild)
{
_yuitest_coverline("build/graphics-canvas/graphics-canvas.js", 3305);
child = node.firstChild;
_yuitest_coverline("build/graphics-canvas/graphics-canvas.js", 3306);
this._removeChildren(child);
_yuitest_coverline("build/graphics-canvas/graphics-canvas.js", 3307);
node.removeChild(child);
}
}
},
/**
* Toggles visibility
*
* @method _toggleVisible
* @param {Boolean} val indicates visibilitye
* @private
*/
_toggleVisible: function(val)
{
_yuitest_coverfunc("build/graphics-canvas/graphics-canvas.js", "_toggleVisible", 3319);
_yuitest_coverline("build/graphics-canvas/graphics-canvas.js", 3321);
var i,
shapes = this._shapes,
visibility = val ? "visible" : "hidden";
_yuitest_coverline("build/graphics-canvas/graphics-canvas.js", 3324);
if(shapes)
{
_yuitest_coverline("build/graphics-canvas/graphics-canvas.js", 3326);
for(i in shapes)
{
_yuitest_coverline("build/graphics-canvas/graphics-canvas.js", 3328);
if(shapes.hasOwnProperty(i))
{
_yuitest_coverline("build/graphics-canvas/graphics-canvas.js", 3330);
shapes[i].set("visible", val);
}
}
}
_yuitest_coverline("build/graphics-canvas/graphics-canvas.js", 3334);
if(this._node)
{
_yuitest_coverline("build/graphics-canvas/graphics-canvas.js", 3336);
this._node.style.visibility = visibility;
}
},
/**
* Returns a shape class. Used by `addShape`.
*
* @method _getShapeClass
* @param {Shape | String} val Indicates which shape class.
* @return Function
* @private
*/
_getShapeClass: function(val)
{
_yuitest_coverfunc("build/graphics-canvas/graphics-canvas.js", "_getShapeClass", 3348);
_yuitest_coverline("build/graphics-canvas/graphics-canvas.js", 3350);
var shape = this._shapeClass[val];
_yuitest_coverline("build/graphics-canvas/graphics-canvas.js", 3351);
if(shape)
{
_yuitest_coverline("build/graphics-canvas/graphics-canvas.js", 3353);
return shape;
}
_yuitest_coverline("build/graphics-canvas/graphics-canvas.js", 3355);
return val;
},
/**
* Look up for shape classes. Used by `addShape` to retrieve a class for instantiation.
*
* @property _shapeClass
* @type Object
* @private
*/
_shapeClass: {
circle: Y.CanvasCircle,
rect: Y.CanvasRect,
path: Y.CanvasPath,
ellipse: Y.CanvasEllipse,
pieslice: Y.CanvasPieSlice
},
/**
* Returns a shape based on the id of its dom node.
*
* @method getShapeById
* @param {String} id Dom id of the shape's node attribute.
* @return Shape
*/
getShapeById: function(id)
{
_yuitest_coverfunc("build/graphics-canvas/graphics-canvas.js", "getShapeById", 3380);
_yuitest_coverline("build/graphics-canvas/graphics-canvas.js", 3382);
var shape = this._shapes[id];
_yuitest_coverline("build/graphics-canvas/graphics-canvas.js", 3383);
return shape;
},
/**
* Allows for creating multiple shapes in order to batch appending and redraw operations.
*
* @method batch
* @param {Function} method Method to execute.
*/
batch: function(method)
{
_yuitest_coverfunc("build/graphics-canvas/graphics-canvas.js", "batch", 3392);
_yuitest_coverline("build/graphics-canvas/graphics-canvas.js", 3394);
var autoDraw = this.get("autoDraw");
_yuitest_coverline("build/graphics-canvas/graphics-canvas.js", 3395);
this.set("autoDraw", false);
_yuitest_coverline("build/graphics-canvas/graphics-canvas.js", 3396);
method();
_yuitest_coverline("build/graphics-canvas/graphics-canvas.js", 3397);
this.set("autoDraw", autoDraw);
},
/**
* Returns a document fragment to for attaching shapes.
*
* @method _getDocFrag
* @return DocumentFragment
* @private
*/
_getDocFrag: function()
{
_yuitest_coverfunc("build/graphics-canvas/graphics-canvas.js", "_getDocFrag", 3407);
_yuitest_coverline("build/graphics-canvas/graphics-canvas.js", 3409);
if(!this._frag)
{
_yuitest_coverline("build/graphics-canvas/graphics-canvas.js", 3411);
this._frag = DOCUMENT.createDocumentFragment();
}
_yuitest_coverline("build/graphics-canvas/graphics-canvas.js", 3413);
return this._frag;
},
/**
* Redraws all shapes.
*
* @method _redraw
* @private
*/
_redraw: function()
{
_yuitest_coverfunc("build/graphics-canvas/graphics-canvas.js", "_redraw", 3422);
_yuitest_coverline("build/graphics-canvas/graphics-canvas.js", 3424);
var autoSize = this.get("autoSize"),
preserveAspectRatio = this.get("preserveAspectRatio"),
box = this.get("resizeDown") ? this._getUpdatedContentBounds() : this._contentBounds,
contentWidth,
contentHeight,
w,
h,
xScale,
yScale,
translateX = 0,
translateY = 0,
matrix,
node = this.get("node");
_yuitest_coverline("build/graphics-canvas/graphics-canvas.js", 3437);
if(autoSize)
{
_yuitest_coverline("build/graphics-canvas/graphics-canvas.js", 3439);
if(autoSize == "sizeContentToGraphic")
{
_yuitest_coverline("build/graphics-canvas/graphics-canvas.js", 3441);
contentWidth = box.right - box.left;
_yuitest_coverline("build/graphics-canvas/graphics-canvas.js", 3442);
contentHeight = box.bottom - box.top;
_yuitest_coverline("build/graphics-canvas/graphics-canvas.js", 3443);
w = parseFloat(Y_DOM.getComputedStyle(node, "width"));
_yuitest_coverline("build/graphics-canvas/graphics-canvas.js", 3444);
h = parseFloat(Y_DOM.getComputedStyle(node, "height"));
_yuitest_coverline("build/graphics-canvas/graphics-canvas.js", 3445);
matrix = new Y.Matrix();
_yuitest_coverline("build/graphics-canvas/graphics-canvas.js", 3446);
if(preserveAspectRatio == "none")
{
_yuitest_coverline("build/graphics-canvas/graphics-canvas.js", 3448);
xScale = w/contentWidth;
_yuitest_coverline("build/graphics-canvas/graphics-canvas.js", 3449);
yScale = h/contentHeight;
}
else
{
_yuitest_coverline("build/graphics-canvas/graphics-canvas.js", 3453);
if(contentWidth/contentHeight !== w/h)
{
_yuitest_coverline("build/graphics-canvas/graphics-canvas.js", 3455);
if(contentWidth * h/contentHeight > w)
{
_yuitest_coverline("build/graphics-canvas/graphics-canvas.js", 3457);
xScale = yScale = w/contentWidth;
_yuitest_coverline("build/graphics-canvas/graphics-canvas.js", 3458);
translateY = this._calculateTranslate(preserveAspectRatio.slice(5).toLowerCase(), contentHeight * w/contentWidth, h);
}
else
{
_yuitest_coverline("build/graphics-canvas/graphics-canvas.js", 3462);
xScale = yScale = h/contentHeight;
_yuitest_coverline("build/graphics-canvas/graphics-canvas.js", 3463);
translateX = this._calculateTranslate(preserveAspectRatio.slice(1, 4).toLowerCase(), contentWidth * h/contentHeight, w);
}
}
}
_yuitest_coverline("build/graphics-canvas/graphics-canvas.js", 3467);
Y_DOM.setStyle(node, "transformOrigin", "0% 0%");
_yuitest_coverline("build/graphics-canvas/graphics-canvas.js", 3468);
translateX = translateX - (box.left * xScale);
_yuitest_coverline("build/graphics-canvas/graphics-canvas.js", 3469);
translateY = translateY - (box.top * yScale);
_yuitest_coverline("build/graphics-canvas/graphics-canvas.js", 3470);
matrix.translate(translateX, translateY);
_yuitest_coverline("build/graphics-canvas/graphics-canvas.js", 3471);
matrix.scale(xScale, yScale);
_yuitest_coverline("build/graphics-canvas/graphics-canvas.js", 3472);
Y_DOM.setStyle(node, "transform", matrix.toCSSText());
}
else
{
_yuitest_coverline("build/graphics-canvas/graphics-canvas.js", 3476);
this.set("width", box.right);
_yuitest_coverline("build/graphics-canvas/graphics-canvas.js", 3477);
this.set("height", box.bottom);
}
}
_yuitest_coverline("build/graphics-canvas/graphics-canvas.js", 3480);
if(this._frag)
{
_yuitest_coverline("build/graphics-canvas/graphics-canvas.js", 3482);
this._node.appendChild(this._frag);
_yuitest_coverline("build/graphics-canvas/graphics-canvas.js", 3483);
this._frag = null;
}
},
/**
* Determines the value for either an x or y value to be used for the <code>translate</code> of the Graphic.
*
* @method _calculateTranslate
* @param {String} position The position for placement. Possible values are min, mid and max.
* @param {Number} contentSize The total size of the content.
* @param {Number} boundsSize The total size of the Graphic.
* @return Number
* @private
*/
_calculateTranslate: function(position, contentSize, boundsSize)
{
_yuitest_coverfunc("build/graphics-canvas/graphics-canvas.js", "_calculateTranslate", 3497);
_yuitest_coverline("build/graphics-canvas/graphics-canvas.js", 3499);
var ratio = boundsSize - contentSize,
coord;
_yuitest_coverline("build/graphics-canvas/graphics-canvas.js", 3501);
switch(position)
{
case "mid" :
_yuitest_coverline("build/graphics-canvas/graphics-canvas.js", 3504);
coord = ratio * 0.5;
_yuitest_coverline("build/graphics-canvas/graphics-canvas.js", 3505);
break;
case "max" :
_yuitest_coverline("build/graphics-canvas/graphics-canvas.js", 3507);
coord = ratio;
_yuitest_coverline("build/graphics-canvas/graphics-canvas.js", 3508);
break;
default :
_yuitest_coverline("build/graphics-canvas/graphics-canvas.js", 3510);
coord = 0;
_yuitest_coverline("build/graphics-canvas/graphics-canvas.js", 3511);
break;
}
_yuitest_coverline("build/graphics-canvas/graphics-canvas.js", 3513);
return coord;
},
/**
* Adds a shape to the redraw queue and calculates the contentBounds. Used internally
* by `Shape` instances.
*
* @method addToRedrawQueue
* @param Shape shape The shape instance to add to the queue
* @protected
*/
addToRedrawQueue: function(shape)
{
_yuitest_coverfunc("build/graphics-canvas/graphics-canvas.js", "addToRedrawQueue", 3524);
_yuitest_coverline("build/graphics-canvas/graphics-canvas.js", 3526);
var shapeBox,
box;
_yuitest_coverline("build/graphics-canvas/graphics-canvas.js", 3528);
this._shapes[shape.get("id")] = shape;
_yuitest_coverline("build/graphics-canvas/graphics-canvas.js", 3529);
if(!this.get("resizeDown"))
{
_yuitest_coverline("build/graphics-canvas/graphics-canvas.js", 3531);
shapeBox = shape.getBounds();
_yuitest_coverline("build/graphics-canvas/graphics-canvas.js", 3532);
box = this._contentBounds;
_yuitest_coverline("build/graphics-canvas/graphics-canvas.js", 3533);
box.left = box.left < shapeBox.left ? box.left : shapeBox.left;
_yuitest_coverline("build/graphics-canvas/graphics-canvas.js", 3534);
box.top = box.top < shapeBox.top ? box.top : shapeBox.top;
_yuitest_coverline("build/graphics-canvas/graphics-canvas.js", 3535);
box.right = box.right > shapeBox.right ? box.right : shapeBox.right;
_yuitest_coverline("build/graphics-canvas/graphics-canvas.js", 3536);
box.bottom = box.bottom > shapeBox.bottom ? box.bottom : shapeBox.bottom;
_yuitest_coverline("build/graphics-canvas/graphics-canvas.js", 3537);
this._contentBounds = box;
}
_yuitest_coverline("build/graphics-canvas/graphics-canvas.js", 3539);
if(this.get("autoDraw"))
{
_yuitest_coverline("build/graphics-canvas/graphics-canvas.js", 3541);
this._redraw();
}
},
/**
* Recalculates and returns the `contentBounds` for the `Graphic` instance.
*
* @method _getUpdatedContentBounds
* @return {Object}
* @private
*/
_getUpdatedContentBounds: function()
{
_yuitest_coverfunc("build/graphics-canvas/graphics-canvas.js", "_getUpdatedContentBounds", 3552);
_yuitest_coverline("build/graphics-canvas/graphics-canvas.js", 3554);
var bounds,
i,
shape,
queue = this._shapes,
box = {};
_yuitest_coverline("build/graphics-canvas/graphics-canvas.js", 3559);
for(i in queue)
{
_yuitest_coverline("build/graphics-canvas/graphics-canvas.js", 3561);
if(queue.hasOwnProperty(i))
{
_yuitest_coverline("build/graphics-canvas/graphics-canvas.js", 3563);
shape = queue[i];
_yuitest_coverline("build/graphics-canvas/graphics-canvas.js", 3564);
bounds = shape.getBounds();
_yuitest_coverline("build/graphics-canvas/graphics-canvas.js", 3565);
box.left = Y_LANG.isNumber(box.left) ? Math.min(box.left, bounds.left) : bounds.left;
_yuitest_coverline("build/graphics-canvas/graphics-canvas.js", 3566);
box.top = Y_LANG.isNumber(box.top) ? Math.min(box.top, bounds.top) : bounds.top;
_yuitest_coverline("build/graphics-canvas/graphics-canvas.js", 3567);
box.right = Y_LANG.isNumber(box.right) ? Math.max(box.right, bounds.right) : bounds.right;
_yuitest_coverline("build/graphics-canvas/graphics-canvas.js", 3568);
box.bottom = Y_LANG.isNumber(box.bottom) ? Math.max(box.bottom, bounds.bottom) : bounds.bottom;
}
}
_yuitest_coverline("build/graphics-canvas/graphics-canvas.js", 3571);
box.left = Y_LANG.isNumber(box.left) ? box.left : 0;
_yuitest_coverline("build/graphics-canvas/graphics-canvas.js", 3572);
box.top = Y_LANG.isNumber(box.top) ? box.top : 0;
_yuitest_coverline("build/graphics-canvas/graphics-canvas.js", 3573);
box.right = Y_LANG.isNumber(box.right) ? box.right : 0;
_yuitest_coverline("build/graphics-canvas/graphics-canvas.js", 3574);
box.bottom = Y_LANG.isNumber(box.bottom) ? box.bottom : 0;
_yuitest_coverline("build/graphics-canvas/graphics-canvas.js", 3575);
this._contentBounds = box;
_yuitest_coverline("build/graphics-canvas/graphics-canvas.js", 3576);
return box;
},
/**
* Inserts shape on the top of the tree.
*
* @method _toFront
* @param {CanvasShape} Shape to add.
* @private
*/
_toFront: function(shape)
{
_yuitest_coverfunc("build/graphics-canvas/graphics-canvas.js", "_toFront", 3586);
_yuitest_coverline("build/graphics-canvas/graphics-canvas.js", 3588);
var contentNode = this.get("node");
_yuitest_coverline("build/graphics-canvas/graphics-canvas.js", 3589);
if(shape instanceof Y.CanvasShape)
{
_yuitest_coverline("build/graphics-canvas/graphics-canvas.js", 3591);
shape = shape.get("node");
}
_yuitest_coverline("build/graphics-canvas/graphics-canvas.js", 3593);
if(contentNode && shape)
{
_yuitest_coverline("build/graphics-canvas/graphics-canvas.js", 3595);
contentNode.appendChild(shape);
}
},
/**
* Inserts shape as the first child of the content node.
*
* @method _toBack
* @param {CanvasShape} Shape to add.
* @private
*/
_toBack: function(shape)
{
_yuitest_coverfunc("build/graphics-canvas/graphics-canvas.js", "_toBack", 3606);
_yuitest_coverline("build/graphics-canvas/graphics-canvas.js", 3608);
var contentNode = this.get("node"),
targetNode;
_yuitest_coverline("build/graphics-canvas/graphics-canvas.js", 3610);
if(shape instanceof Y.CanvasShape)
{
_yuitest_coverline("build/graphics-canvas/graphics-canvas.js", 3612);
shape = shape.get("node");
}
_yuitest_coverline("build/graphics-canvas/graphics-canvas.js", 3614);
if(contentNode && shape)
{
_yuitest_coverline("build/graphics-canvas/graphics-canvas.js", 3616);
targetNode = contentNode.firstChild;
_yuitest_coverline("build/graphics-canvas/graphics-canvas.js", 3617);
if(targetNode)
{
_yuitest_coverline("build/graphics-canvas/graphics-canvas.js", 3619);
contentNode.insertBefore(shape, targetNode);
}
else
{
_yuitest_coverline("build/graphics-canvas/graphics-canvas.js", 3623);
contentNode.appendChild(shape);
}
}
}
});
_yuitest_coverline("build/graphics-canvas/graphics-canvas.js", 3629);
Y.CanvasGraphic = CanvasGraphic;
}, '3.7.1', {"requires": ["graphics"]});