graphics-svg.js revision 4d8e74ffdfdb705ce94fa85c56257fccb211a9c0
096dfde2c1cb7bb1e0a4b76e21f2abf548b900d5Campbell Barton * Draws a bezier curve.
096dfde2c1cb7bb1e0a4b76e21f2abf548b900d5Campbell Barton * @method curveTo
096dfde2c1cb7bb1e0a4b76e21f2abf548b900d5Campbell Barton * @param {Number} cp1x x-coordinate for the first control point.
096dfde2c1cb7bb1e0a4b76e21f2abf548b900d5Campbell Barton * @param {Number} cp1y y-coordinate for the first control point.
096dfde2c1cb7bb1e0a4b76e21f2abf548b900d5Campbell Barton * @param {Number} cp2x x-coordinate for the second control point.
096dfde2c1cb7bb1e0a4b76e21f2abf548b900d5Campbell Barton * @param {Number} cp2y y-coordinate for the second control point.
096dfde2c1cb7bb1e0a4b76e21f2abf548b900d5Campbell Barton * @param {Number} x x-coordinate for the end point.
096dfde2c1cb7bb1e0a4b76e21f2abf548b900d5Campbell Barton * @param {Number} y y-coordinate for the end point.
096dfde2c1cb7bb1e0a4b76e21f2abf548b900d5Campbell Barton curveTo: function(cp1x, cp1y, cp2x, cp2y, x, y) {
096dfde2c1cb7bb1e0a4b76e21f2abf548b900d5Campbell Barton currentArray = this._pathArray[Math.max(0, this._pathArray.length - 1)];
096dfde2c1cb7bb1e0a4b76e21f2abf548b900d5Campbell Barton this._pathArray[pathArrayLen] = this._pathArray[pathArrayLen].concat([Math.round(cp1x), Math.round(cp1y), Math.round(cp2x) , Math.round(cp2y), x, y]);
874cad03a8450ed3464f6dfae2eb16108bec5bbdCampbell Barton * Draws a quadratic bezier curve.
874cad03a8450ed3464f6dfae2eb16108bec5bbdCampbell Barton * @method quadraticCurveTo
874cad03a8450ed3464f6dfae2eb16108bec5bbdCampbell Barton * @param {Number} cpx x-coordinate for the control point.
874cad03a8450ed3464f6dfae2eb16108bec5bbdCampbell Barton * @param {Number} cpy y-coordinate for the control point.
874cad03a8450ed3464f6dfae2eb16108bec5bbdCampbell Barton * @param {Number} x x-coordinate for the end point.
874cad03a8450ed3464f6dfae2eb16108bec5bbdCampbell Barton * @param {Number} y y-coordinate for the end point.
874cad03a8450ed3464f6dfae2eb16108bec5bbdCampbell Barton quadraticCurveTo: function(cpx, cpy, x, y) {
874cad03a8450ed3464f6dfae2eb16108bec5bbdCampbell Barton currentArray = this._pathArray[Math.max(0, this._pathArray.length - 1)];
874cad03a8450ed3464f6dfae2eb16108bec5bbdCampbell Barton this._pathArray[pathArrayLen] = this._pathArray[pathArrayLen].concat([Math.round(cpx), Math.round(cpy), Math.round(x), Math.round(y)]);
874cad03a8450ed3464f6dfae2eb16108bec5bbdCampbell Barton * Draws a rectangle.
874cad03a8450ed3464f6dfae2eb16108bec5bbdCampbell Barton * @method drawRect
874cad03a8450ed3464f6dfae2eb16108bec5bbdCampbell Barton * @param {Number} x x-coordinate
874cad03a8450ed3464f6dfae2eb16108bec5bbdCampbell Barton * @param {Number} y y-coordinate
874cad03a8450ed3464f6dfae2eb16108bec5bbdCampbell Barton * @param {Number} w width
874cad03a8450ed3464f6dfae2eb16108bec5bbdCampbell Barton * @param {Number} h height
874cad03a8450ed3464f6dfae2eb16108bec5bbdCampbell Barton drawRect: function(x, y, w, h) {
874cad03a8450ed3464f6dfae2eb16108bec5bbdCampbell Barton this.lineTo(x + w, y);
874cad03a8450ed3464f6dfae2eb16108bec5bbdCampbell Barton this.lineTo(x + w, y + h);
874cad03a8450ed3464f6dfae2eb16108bec5bbdCampbell Barton this.lineTo(x, y + h);
874cad03a8450ed3464f6dfae2eb16108bec5bbdCampbell Barton * Draws a rectangle with rounded corners.
874cad03a8450ed3464f6dfae2eb16108bec5bbdCampbell Barton * @method drawRect
874cad03a8450ed3464f6dfae2eb16108bec5bbdCampbell Barton * @param {Number} x x-coordinate
874cad03a8450ed3464f6dfae2eb16108bec5bbdCampbell Barton * @param {Number} y y-coordinate
874cad03a8450ed3464f6dfae2eb16108bec5bbdCampbell Barton * @param {Number} w width
874cad03a8450ed3464f6dfae2eb16108bec5bbdCampbell Barton * @param {Number} h height
3c147b1dc203f9815cb45e24add22478e936d1e8verbalshadow * @param {Number} ew width of the ellipse used to draw the rounded corners
096dfde2c1cb7bb1e0a4b76e21f2abf548b900d5Campbell Barton * @param {Number} eh height of the ellipse used to draw the rounded corners
68302bd782e6cff354ec4e6c6cfe88fb761cead9Campbell Barton drawRoundRect: function(x, y, w, h, ew, eh) {
* @param {Number} radius radius of wedge. If [optional] yRadius is defined, then radius is the x radius.
var segs,
ax,
ay,
bx,
by,
cx,
cy,
pathArrayLen++;
pathArrayLen++;
for(; i < segs; ++i)
* Draws a line segment using the current line style from the current drawing position to the specified x and y coordinates.
len,
_getCurrentArray: function()
if(!currentArray)
currentArray = [];
return currentArray;
moveTo: function(x, y) {
var pathArrayLen,
this._trackSize(x, y);
end: function() {
this._draw();
_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;
init: function()
var host = this;
classString = classString.replace(new RegExp(className + ' '), className).replace(new RegExp(className), '');
getXY: function()
_getDefaultFill: function() {
_getDefaultStroke: function()
createNode: function()
if(id)
if(pointerEvents)
_strokeChangeHandler: function(e)
dash,
_fillChangeHandler: function(e)
type;
if(fill)
var offset,
len,
def,
stop,
r = fill.r;
y2 = h;
y1 = h;
x1 = w;
x2 = w;
set: function()
var host = this;
translate: function(x, y)
this._translateX = x;
this._translateY = y;
_translate: function(x, y)
skewX: function(x)
skewY: function(y)
matrix: function(a, b, c, d, e, f)
if(!this._transformArgs)
this._transformArgs = {};
this._updateTransform();
_updateTransform: function()
key,
args,
val,
test,
if(this._transformArgs)
if(transform)
_draw: function()
this._fillChangeHandler();
this._strokeChangeHandler();
this._updateTransform();
_updateHandler: function(e)
this._draw();
getBounds: function()
right = x + w,
bottom = y + h,
tlx,
tly,
blx,
bly,
brx,
bry,
trx,
trY,
bounds = {},
return bounds;
* Returns the x coordinate for a bounding box's corner based on the corner's original x/y coordinates, rotation and transform origin of the rotation.
* Returns the y coordinate for a bounding box's corner based on the corner's original x/y coordinates, rotation and transform origin of the rotation.
destroy: function()
* 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
valueFn: function()
rotation: {
getter: function()
return this._rotation;
id: {
valueFn: function()
return Y.guid();
if(node)
return val;
width: {
height: {
visible: {
value: true,
return val;
* <dt>opacity</dt><dd>Number between 0 and 1 that indicates the opacity of the fill. The default value is 1.</dd>
* <p>If a gradient (linear or radial) is specified as the fill type. The following properties are used:
* <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 <= 8</dd>
fill: {
var fill,
return fill;
* <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
stroke: {
autoSize: {
value: false
valueFn: function()
if(node)
return val;
if(node)
return val;
translateX: {
getter: function()
return this._translateX;
return val;
translateY: {
getter: function()
return this._translateY;
return val;
gradientNode: {
return val;
autoDraw: {
getter: function()
node: {
readOnly: true,
getter: function()
return this.node;
graphic: {
readOnly: true,
getter: function()
return this._graphic;
_draw: function()
var pathArray,
len,
val,
val2,
if(this._pathArray)
switch(pathType)
if(path)
this._fillChangeHandler();
this._strokeChangeHandler();
this._updateTransform();
translate: function(x, y)
this._translateX = x;
this._translateY = y;
_updateHandler: function()
end: function()
this._draw();
clear: function()
this._pathArray = [];
getBounds: function()
bounds = {},
return bounds;
path: {
readOnly: true,
getter: function()
return this._path;
width: {
getter: function()
return val;
height: {
getter: function()
SVGRect = function()
_draw: function()
this._fillChangeHandler();
this._strokeChangeHandler();
this._updateTransform();
xRadius: {
getter: function()
if(val)
return val;
yRadius: {
getter: function()
if(val)
return val;
_draw: function()
this._fillChangeHandler();
this._strokeChangeHandler();
this._updateTransform();
width: {
return val;
getter: function()
height: {
return val;
getter: function()
radius: {
SVGPieSlice = function()
_updateHandler: function(e)
this.clear();
this._draw();
cx: {
cy: {
startAngle: {
arc: {
radius: {
render: {},
id: {
valueFn: function()
return Y.guid();
if(node)
return val;
shapes: {
readOnly: true,
getter: function()
return this._shapes;
* Object containing size and coordinate data for the content of a Graphic in relation to the coordSpace node.
readOnly: true,
getter: function()
return this._contentBounds;
node: {
readOnly: true,
getter: function()
return this._node;
width: {
if(this._node)
return val;
height: {
if(this._node)
return val;
* Determines how the size of instance is calculated. If true, the width and height are determined by the size of the contents.
* If false, the width and height values are either explicitly set or determined by the size of the parent node's dimensions.
autoSize: {
value: false
* When overflow is set to true, by default, the contentBounds will resize to greater values but not to smaller values. (for performance)
resizeDown: {
getter: function()
return this._resizeDown;
this._redraw();
return val;
getter: function()
return this._x;
if(this._node)
return val;
getter: function()
return this._y;
if(this._node)
return val;
* Indicates whether or not the instance will automatically redraw after a change is made to a shape.
autoDraw: {
value: true
visible: {
value: true,
return val;
getXY: function()
xy;
if(node)
return xy;
_resizeDown: false,
initializer: function() {
this._shapes = {};
this._contentBounds = {
this._gradients = {};
if(render)
destroy: function()
this.removeAllShapes();
return shape;
this._redraw();
return shape;
removeAllShapes: function()
for(i in shapes)
this._shapes = {};
var child;
clear: function() {
this.removeAllShapes();
if(shapes)
for(i in shapes)
if(shape)
return shape;
return val;
_shapeClass: {
return shape;
method();
this._redraw();
_getDocFrag: function()
if(!this._frag)
return this._frag;
_redraw: function()
this._contentNode.setAttribute("viewBox", "" + box.left + " " + box.top + " " + box.width + " " + box.height + "");
if(this._frag)
this._frag = null;
var shapeBox,
box;
this._redraw();
_getUpdatedContentBounds: function()
var bounds,
box = {
for(i in queue)
return box;
_createGraphics: function() {
return contentNode;
return node;
if(!this._defs)
return gradient;