09688ec5ffb8b9cf9883a770e2f9ebd60b28888dTripp/**
0fdefaa9ca017edfb76b736c825b34186f33045aTripp * <a href="http://www.w3.org/TR/html5/the-canvas-element.html">Canvas</a> implementation of the <a href="Shape.html">`Shape`</a> class.
0fdefaa9ca017edfb76b736c825b34186f33045aTripp * `CanvasShape` is not intended to be used directly. Instead, use the <a href="Shape.html">`Shape`</a> class.
0fdefaa9ca017edfb76b736c825b34186f33045aTripp * If the browser lacks <a href="http://www.w3.org/TR/SVG/">SVG</a> capabilities but has
0fdefaa9ca017edfb76b736c825b34186f33045aTripp * <a href="http://www.w3.org/TR/html5/the-canvas-element.html">Canvas</a> capabilities, the <a href="Shape.html">`Shape`</a>
0fdefaa9ca017edfb76b736c825b34186f33045aTripp * class will point to the `CanvasShape` class.
09688ec5ffb8b9cf9883a770e2f9ebd60b28888dTripp *
a75ebc38c1de401b679953a9b87bd323f0f48d02Tripp * @module graphics
09688ec5ffb8b9cf9883a770e2f9ebd60b28888dTripp * @class CanvasShape
66ca16dd76367c074fe4df1dcf7b555489a9bf85Tripp * @constructor
09688ec5ffb8b9cf9883a770e2f9ebd60b28888dTripp */
828c58761d90445b8b9d20a82d85dc1479317f71TrippCanvasShape = function(cfg)
828c58761d90445b8b9d20a82d85dc1479317f71Tripp{
ed59119d8c00addb07c7ee6c8aefcd1d9cb876f1Tripp this._transforms = [];
ed59119d8c00addb07c7ee6c8aefcd1d9cb876f1Tripp this.matrix = new Y.Matrix();
c7ba96d16d58075a9ab8d5c1e46c6c83ce11cb4eTripp CanvasShape.superclass.constructor.apply(this, arguments);
828c58761d90445b8b9d20a82d85dc1479317f71Tripp};
c7ba96d16d58075a9ab8d5c1e46c6c83ce11cb4eTripp
828c58761d90445b8b9d20a82d85dc1479317f71TrippCanvasShape.NAME = "canvasShape";
c7ba96d16d58075a9ab8d5c1e46c6c83ce11cb4eTripp
6c2524a3f545f556615ff052e6676c5adb53c5d5TrippY.extend(CanvasShape, Y.GraphicBase, Y.mix({
66ca16dd76367c074fe4df1dcf7b555489a9bf85Tripp /**
66ca16dd76367c074fe4df1dcf7b555489a9bf85Tripp * Init method, invoked during construction.
66ca16dd76367c074fe4df1dcf7b555489a9bf85Tripp * Calls `initializer` method.
66ca16dd76367c074fe4df1dcf7b555489a9bf85Tripp *
66ca16dd76367c074fe4df1dcf7b555489a9bf85Tripp * @method init
66ca16dd76367c074fe4df1dcf7b555489a9bf85Tripp * @protected
e7c7565d9550eaa87043aef0df77125ada996deaTripp */
e7c7565d9550eaa87043aef0df77125ada996deaTripp init: function()
828c58761d90445b8b9d20a82d85dc1479317f71Tripp {
828c58761d90445b8b9d20a82d85dc1479317f71Tripp this.initializer.apply(this, arguments);
828c58761d90445b8b9d20a82d85dc1479317f71Tripp },
828c58761d90445b8b9d20a82d85dc1479317f71Tripp
828c58761d90445b8b9d20a82d85dc1479317f71Tripp /**
828c58761d90445b8b9d20a82d85dc1479317f71Tripp * Initializes the shape
828c58761d90445b8b9d20a82d85dc1479317f71Tripp *
828c58761d90445b8b9d20a82d85dc1479317f71Tripp * @private
828c58761d90445b8b9d20a82d85dc1479317f71Tripp * @method _initialize
828c58761d90445b8b9d20a82d85dc1479317f71Tripp */
828c58761d90445b8b9d20a82d85dc1479317f71Tripp initializer: function(cfg)
828c58761d90445b8b9d20a82d85dc1479317f71Tripp {
753e68bea51094492944cd3cd92191c91d1e7c50Tripp var host = this,
753e68bea51094492944cd3cd92191c91d1e7c50Tripp graphic = cfg.graphic;
c7ba96d16d58075a9ab8d5c1e46c6c83ce11cb4eTripp host._initProps();
828c58761d90445b8b9d20a82d85dc1479317f71Tripp host.createNode();
828c58761d90445b8b9d20a82d85dc1479317f71Tripp host._xcoords = [0];
828c58761d90445b8b9d20a82d85dc1479317f71Tripp host._ycoords = [0];
753e68bea51094492944cd3cd92191c91d1e7c50Tripp if(graphic)
753e68bea51094492944cd3cd92191c91d1e7c50Tripp {
753e68bea51094492944cd3cd92191c91d1e7c50Tripp this._setGraphic(graphic);
753e68bea51094492944cd3cd92191c91d1e7c50Tripp }
828c58761d90445b8b9d20a82d85dc1479317f71Tripp host._updateHandler();
828c58761d90445b8b9d20a82d85dc1479317f71Tripp },
753e68bea51094492944cd3cd92191c91d1e7c50Tripp
753e68bea51094492944cd3cd92191c91d1e7c50Tripp /**
753e68bea51094492944cd3cd92191c91d1e7c50Tripp * Set the Graphic instance for the shape.
753e68bea51094492944cd3cd92191c91d1e7c50Tripp *
753e68bea51094492944cd3cd92191c91d1e7c50Tripp * @method _setGraphic
753e68bea51094492944cd3cd92191c91d1e7c50Tripp * @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
753e68bea51094492944cd3cd92191c91d1e7c50Tripp * to the `graphic` attribute. Otherwise, a new Graphic instance will be created and rendered into the dom element that the render represents.
753e68bea51094492944cd3cd92191c91d1e7c50Tripp * @private
753e68bea51094492944cd3cd92191c91d1e7c50Tripp */
753e68bea51094492944cd3cd92191c91d1e7c50Tripp _setGraphic: function(render)
753e68bea51094492944cd3cd92191c91d1e7c50Tripp {
753e68bea51094492944cd3cd92191c91d1e7c50Tripp var graphic;
753e68bea51094492944cd3cd92191c91d1e7c50Tripp if(render instanceof Y.CanvasGraphic)
753e68bea51094492944cd3cd92191c91d1e7c50Tripp {
753e68bea51094492944cd3cd92191c91d1e7c50Tripp this._graphic = render;
753e68bea51094492944cd3cd92191c91d1e7c50Tripp }
753e68bea51094492944cd3cd92191c91d1e7c50Tripp else
753e68bea51094492944cd3cd92191c91d1e7c50Tripp {
753e68bea51094492944cd3cd92191c91d1e7c50Tripp render = Y.one(render);
753e68bea51094492944cd3cd92191c91d1e7c50Tripp graphic = new Y.CanvasGraphic({
753e68bea51094492944cd3cd92191c91d1e7c50Tripp render: render
753e68bea51094492944cd3cd92191c91d1e7c50Tripp });
753e68bea51094492944cd3cd92191c91d1e7c50Tripp graphic._appendShape(this);
753e68bea51094492944cd3cd92191c91d1e7c50Tripp this._graphic = graphic;
753e68bea51094492944cd3cd92191c91d1e7c50Tripp }
753e68bea51094492944cd3cd92191c91d1e7c50Tripp },
828c58761d90445b8b9d20a82d85dc1479317f71Tripp
828c58761d90445b8b9d20a82d85dc1479317f71Tripp /**
828c58761d90445b8b9d20a82d85dc1479317f71Tripp * Add a class name to each node.
828c58761d90445b8b9d20a82d85dc1479317f71Tripp *
828c58761d90445b8b9d20a82d85dc1479317f71Tripp * @method addClass
828c58761d90445b8b9d20a82d85dc1479317f71Tripp * @param {String} className the class name to add to the node's class attribute
828c58761d90445b8b9d20a82d85dc1479317f71Tripp */
828c58761d90445b8b9d20a82d85dc1479317f71Tripp addClass: function(className)
828c58761d90445b8b9d20a82d85dc1479317f71Tripp {
828c58761d90445b8b9d20a82d85dc1479317f71Tripp var node = Y.one(this.get("node"));
828c58761d90445b8b9d20a82d85dc1479317f71Tripp node.addClass(className);
828c58761d90445b8b9d20a82d85dc1479317f71Tripp },
828c58761d90445b8b9d20a82d85dc1479317f71Tripp
828c58761d90445b8b9d20a82d85dc1479317f71Tripp /**
828c58761d90445b8b9d20a82d85dc1479317f71Tripp * Removes a class name from each node.
828c58761d90445b8b9d20a82d85dc1479317f71Tripp *
828c58761d90445b8b9d20a82d85dc1479317f71Tripp * @method removeClass
828c58761d90445b8b9d20a82d85dc1479317f71Tripp * @param {String} className the class name to remove from the node's class attribute
828c58761d90445b8b9d20a82d85dc1479317f71Tripp */
828c58761d90445b8b9d20a82d85dc1479317f71Tripp removeClass: function(className)
828c58761d90445b8b9d20a82d85dc1479317f71Tripp {
828c58761d90445b8b9d20a82d85dc1479317f71Tripp var node = Y.one(this.get("node"));
828c58761d90445b8b9d20a82d85dc1479317f71Tripp node.removeClass(className);
828c58761d90445b8b9d20a82d85dc1479317f71Tripp },
828c58761d90445b8b9d20a82d85dc1479317f71Tripp
828c58761d90445b8b9d20a82d85dc1479317f71Tripp /**
828c58761d90445b8b9d20a82d85dc1479317f71Tripp * Gets the current position of the node in page coordinates.
828c58761d90445b8b9d20a82d85dc1479317f71Tripp *
828c58761d90445b8b9d20a82d85dc1479317f71Tripp * @method getXY
828c58761d90445b8b9d20a82d85dc1479317f71Tripp * @return Array The XY position of the shape.
828c58761d90445b8b9d20a82d85dc1479317f71Tripp */
828c58761d90445b8b9d20a82d85dc1479317f71Tripp getXY: function()
828c58761d90445b8b9d20a82d85dc1479317f71Tripp {
828c58761d90445b8b9d20a82d85dc1479317f71Tripp var graphic = this.get("graphic"),
828c58761d90445b8b9d20a82d85dc1479317f71Tripp parentXY = graphic.getXY(),
828c58761d90445b8b9d20a82d85dc1479317f71Tripp x = this.get("x"),
828c58761d90445b8b9d20a82d85dc1479317f71Tripp y = this.get("y");
828c58761d90445b8b9d20a82d85dc1479317f71Tripp return [parentXY[0] + x, parentXY[1] + y];
828c58761d90445b8b9d20a82d85dc1479317f71Tripp },
828c58761d90445b8b9d20a82d85dc1479317f71Tripp
828c58761d90445b8b9d20a82d85dc1479317f71Tripp /**
828c58761d90445b8b9d20a82d85dc1479317f71Tripp * Set the position of the shape in page coordinates, regardless of how the node is positioned.
828c58761d90445b8b9d20a82d85dc1479317f71Tripp *
828c58761d90445b8b9d20a82d85dc1479317f71Tripp * @method setXY
828c58761d90445b8b9d20a82d85dc1479317f71Tripp * @param {Array} Contains X & Y values for new position (coordinates are page-based)
828c58761d90445b8b9d20a82d85dc1479317f71Tripp */
828c58761d90445b8b9d20a82d85dc1479317f71Tripp setXY: function(xy)
828c58761d90445b8b9d20a82d85dc1479317f71Tripp {
828c58761d90445b8b9d20a82d85dc1479317f71Tripp var graphic = this.get("graphic"),
828c58761d90445b8b9d20a82d85dc1479317f71Tripp parentXY = graphic.getXY(),
828c58761d90445b8b9d20a82d85dc1479317f71Tripp x = xy[0] - parentXY[0],
828c58761d90445b8b9d20a82d85dc1479317f71Tripp y = xy[1] - parentXY[1];
828c58761d90445b8b9d20a82d85dc1479317f71Tripp this._set("x", x);
828c58761d90445b8b9d20a82d85dc1479317f71Tripp this._set("y", y);
828c58761d90445b8b9d20a82d85dc1479317f71Tripp this._updateNodePosition(x, y);
828c58761d90445b8b9d20a82d85dc1479317f71Tripp },
828c58761d90445b8b9d20a82d85dc1479317f71Tripp
828c58761d90445b8b9d20a82d85dc1479317f71Tripp /**
828c58761d90445b8b9d20a82d85dc1479317f71Tripp * Determines whether the node is an ancestor of another HTML element in the DOM hierarchy.
828c58761d90445b8b9d20a82d85dc1479317f71Tripp *
828c58761d90445b8b9d20a82d85dc1479317f71Tripp * @method contains
828c58761d90445b8b9d20a82d85dc1479317f71Tripp * @param {CanvasShape | HTMLElement} needle The possible node or descendent
828c58761d90445b8b9d20a82d85dc1479317f71Tripp * @return Boolean Whether or not this shape is the needle or its ancestor.
828c58761d90445b8b9d20a82d85dc1479317f71Tripp */
828c58761d90445b8b9d20a82d85dc1479317f71Tripp contains: function(needle)
828c58761d90445b8b9d20a82d85dc1479317f71Tripp {
828c58761d90445b8b9d20a82d85dc1479317f71Tripp return needle === Y.one(this.node);
828c58761d90445b8b9d20a82d85dc1479317f71Tripp },
828c58761d90445b8b9d20a82d85dc1479317f71Tripp
828c58761d90445b8b9d20a82d85dc1479317f71Tripp /**
828c58761d90445b8b9d20a82d85dc1479317f71Tripp * Test if the supplied node matches the supplied selector.
828c58761d90445b8b9d20a82d85dc1479317f71Tripp *
828c58761d90445b8b9d20a82d85dc1479317f71Tripp * @method test
828c58761d90445b8b9d20a82d85dc1479317f71Tripp * @param {String} selector The CSS selector to test against.
828c58761d90445b8b9d20a82d85dc1479317f71Tripp * @return Boolean Wheter or not the shape matches the selector.
828c58761d90445b8b9d20a82d85dc1479317f71Tripp */
828c58761d90445b8b9d20a82d85dc1479317f71Tripp test: function(selector)
828c58761d90445b8b9d20a82d85dc1479317f71Tripp {
828c58761d90445b8b9d20a82d85dc1479317f71Tripp return Y.one(this.get("node")).test(selector);
828c58761d90445b8b9d20a82d85dc1479317f71Tripp //return Y.Selector.test(this.node, selector);
828c58761d90445b8b9d20a82d85dc1479317f71Tripp },
828c58761d90445b8b9d20a82d85dc1479317f71Tripp
828c58761d90445b8b9d20a82d85dc1479317f71Tripp /**
828c58761d90445b8b9d20a82d85dc1479317f71Tripp * Compares nodes to determine if they match.
828c58761d90445b8b9d20a82d85dc1479317f71Tripp * Node instances can be compared to each other and/or HTMLElements.
828c58761d90445b8b9d20a82d85dc1479317f71Tripp * @method compareTo
828c58761d90445b8b9d20a82d85dc1479317f71Tripp * @param {HTMLElement | Node} refNode The reference node to compare to the node.
828c58761d90445b8b9d20a82d85dc1479317f71Tripp * @return {Boolean} True if the nodes match, false if they do not.
828c58761d90445b8b9d20a82d85dc1479317f71Tripp */
828c58761d90445b8b9d20a82d85dc1479317f71Tripp compareTo: function(refNode) {
828c58761d90445b8b9d20a82d85dc1479317f71Tripp var node = this.node;
828c58761d90445b8b9d20a82d85dc1479317f71Tripp return node === refNode;
828c58761d90445b8b9d20a82d85dc1479317f71Tripp },
828c58761d90445b8b9d20a82d85dc1479317f71Tripp
828c58761d90445b8b9d20a82d85dc1479317f71Tripp /**
828c58761d90445b8b9d20a82d85dc1479317f71Tripp * Value function for fill attribute
828c58761d90445b8b9d20a82d85dc1479317f71Tripp *
828c58761d90445b8b9d20a82d85dc1479317f71Tripp * @method _getDefaultFill
828c58761d90445b8b9d20a82d85dc1479317f71Tripp * @return Object
66ca16dd76367c074fe4df1dcf7b555489a9bf85Tripp * @private
828c58761d90445b8b9d20a82d85dc1479317f71Tripp */
828c58761d90445b8b9d20a82d85dc1479317f71Tripp _getDefaultFill: function() {
828c58761d90445b8b9d20a82d85dc1479317f71Tripp return {
828c58761d90445b8b9d20a82d85dc1479317f71Tripp type: "solid",
828c58761d90445b8b9d20a82d85dc1479317f71Tripp cx: 0.5,
828c58761d90445b8b9d20a82d85dc1479317f71Tripp cy: 0.5,
828c58761d90445b8b9d20a82d85dc1479317f71Tripp fx: 0.5,
828c58761d90445b8b9d20a82d85dc1479317f71Tripp fy: 0.5,
828c58761d90445b8b9d20a82d85dc1479317f71Tripp r: 0.5
828c58761d90445b8b9d20a82d85dc1479317f71Tripp };
828c58761d90445b8b9d20a82d85dc1479317f71Tripp },
828c58761d90445b8b9d20a82d85dc1479317f71Tripp
828c58761d90445b8b9d20a82d85dc1479317f71Tripp /**
828c58761d90445b8b9d20a82d85dc1479317f71Tripp * Value function for stroke attribute
828c58761d90445b8b9d20a82d85dc1479317f71Tripp *
828c58761d90445b8b9d20a82d85dc1479317f71Tripp * @method _getDefaultStroke
828c58761d90445b8b9d20a82d85dc1479317f71Tripp * @return Object
66ca16dd76367c074fe4df1dcf7b555489a9bf85Tripp * @private
828c58761d90445b8b9d20a82d85dc1479317f71Tripp */
828c58761d90445b8b9d20a82d85dc1479317f71Tripp _getDefaultStroke: function()
828c58761d90445b8b9d20a82d85dc1479317f71Tripp {
828c58761d90445b8b9d20a82d85dc1479317f71Tripp return {
828c58761d90445b8b9d20a82d85dc1479317f71Tripp weight: 1,
828c58761d90445b8b9d20a82d85dc1479317f71Tripp dashstyle: "none",
828c58761d90445b8b9d20a82d85dc1479317f71Tripp color: "#000",
828c58761d90445b8b9d20a82d85dc1479317f71Tripp opacity: 1.0
828c58761d90445b8b9d20a82d85dc1479317f71Tripp };
828c58761d90445b8b9d20a82d85dc1479317f71Tripp },
828c58761d90445b8b9d20a82d85dc1479317f71Tripp
828c58761d90445b8b9d20a82d85dc1479317f71Tripp /**
828c58761d90445b8b9d20a82d85dc1479317f71Tripp * Left edge of the path
828c58761d90445b8b9d20a82d85dc1479317f71Tripp *
66ca16dd76367c074fe4df1dcf7b555489a9bf85Tripp * @property _left
66ca16dd76367c074fe4df1dcf7b555489a9bf85Tripp * @type Number
828c58761d90445b8b9d20a82d85dc1479317f71Tripp * @private
828c58761d90445b8b9d20a82d85dc1479317f71Tripp */
828c58761d90445b8b9d20a82d85dc1479317f71Tripp _left: 0,
828c58761d90445b8b9d20a82d85dc1479317f71Tripp
828c58761d90445b8b9d20a82d85dc1479317f71Tripp /**
828c58761d90445b8b9d20a82d85dc1479317f71Tripp * Right edge of the path
828c58761d90445b8b9d20a82d85dc1479317f71Tripp *
66ca16dd76367c074fe4df1dcf7b555489a9bf85Tripp * @property _right
66ca16dd76367c074fe4df1dcf7b555489a9bf85Tripp * @type Number
828c58761d90445b8b9d20a82d85dc1479317f71Tripp * @private
828c58761d90445b8b9d20a82d85dc1479317f71Tripp */
828c58761d90445b8b9d20a82d85dc1479317f71Tripp _right: 0,
828c58761d90445b8b9d20a82d85dc1479317f71Tripp
828c58761d90445b8b9d20a82d85dc1479317f71Tripp /**
828c58761d90445b8b9d20a82d85dc1479317f71Tripp * Top edge of the path
828c58761d90445b8b9d20a82d85dc1479317f71Tripp *
66ca16dd76367c074fe4df1dcf7b555489a9bf85Tripp * @property _top
66ca16dd76367c074fe4df1dcf7b555489a9bf85Tripp * @type Number
828c58761d90445b8b9d20a82d85dc1479317f71Tripp * @private
828c58761d90445b8b9d20a82d85dc1479317f71Tripp */
828c58761d90445b8b9d20a82d85dc1479317f71Tripp _top: 0,
828c58761d90445b8b9d20a82d85dc1479317f71Tripp
828c58761d90445b8b9d20a82d85dc1479317f71Tripp /**
828c58761d90445b8b9d20a82d85dc1479317f71Tripp * Bottom edge of the path
828c58761d90445b8b9d20a82d85dc1479317f71Tripp *
66ca16dd76367c074fe4df1dcf7b555489a9bf85Tripp * @property _bottom
66ca16dd76367c074fe4df1dcf7b555489a9bf85Tripp * @type Number
828c58761d90445b8b9d20a82d85dc1479317f71Tripp * @private
828c58761d90445b8b9d20a82d85dc1479317f71Tripp */
828c58761d90445b8b9d20a82d85dc1479317f71Tripp _bottom: 0,
828c58761d90445b8b9d20a82d85dc1479317f71Tripp
828c58761d90445b8b9d20a82d85dc1479317f71Tripp /**
828c58761d90445b8b9d20a82d85dc1479317f71Tripp * Creates the dom node for the shape.
828c58761d90445b8b9d20a82d85dc1479317f71Tripp *
66ca16dd76367c074fe4df1dcf7b555489a9bf85Tripp * @method createNode
828c58761d90445b8b9d20a82d85dc1479317f71Tripp * @return HTMLElement
66ca16dd76367c074fe4df1dcf7b555489a9bf85Tripp * @private
828c58761d90445b8b9d20a82d85dc1479317f71Tripp */
828c58761d90445b8b9d20a82d85dc1479317f71Tripp createNode: function()
828c58761d90445b8b9d20a82d85dc1479317f71Tripp {
828c58761d90445b8b9d20a82d85dc1479317f71Tripp var node = Y.config.doc.createElement('canvas'),
828c58761d90445b8b9d20a82d85dc1479317f71Tripp id = this.get("id");
828c58761d90445b8b9d20a82d85dc1479317f71Tripp this._context = node.getContext('2d');
c7ba96d16d58075a9ab8d5c1e46c6c83ce11cb4eTripp node.setAttribute("overflow", "visible");
c7ba96d16d58075a9ab8d5c1e46c6c83ce11cb4eTripp node.style.overflow = "visible";
e188eaea1f0e60d808be8a4f6ccdbbd3c9b5039bTripp if(!this.get("visible"))
e188eaea1f0e60d808be8a4f6ccdbbd3c9b5039bTripp {
e188eaea1f0e60d808be8a4f6ccdbbd3c9b5039bTripp node.style.visibility = "hidden";
e188eaea1f0e60d808be8a4f6ccdbbd3c9b5039bTripp }
828c58761d90445b8b9d20a82d85dc1479317f71Tripp node.setAttribute("id", id);
828c58761d90445b8b9d20a82d85dc1479317f71Tripp id = "#" + id;
828c58761d90445b8b9d20a82d85dc1479317f71Tripp this.node = node;
0341dba359758fa73cc2f2ae9f6f8ebe9bfa94beTripp this.addClass("yui3-" + SHAPE + " yui3-" + this.name);
828c58761d90445b8b9d20a82d85dc1479317f71Tripp },
828c58761d90445b8b9d20a82d85dc1479317f71Tripp
828c58761d90445b8b9d20a82d85dc1479317f71Tripp /**
66ca16dd76367c074fe4df1dcf7b555489a9bf85Tripp * Overrides default `on` method. Checks to see if its a dom interaction event. If so,
66ca16dd76367c074fe4df1dcf7b555489a9bf85Tripp * return an event attached to the `node` element. If not, return the normal functionality.
66ca16dd76367c074fe4df1dcf7b555489a9bf85Tripp *
66ca16dd76367c074fe4df1dcf7b555489a9bf85Tripp * @method on
66ca16dd76367c074fe4df1dcf7b555489a9bf85Tripp * @param {String} type event type
66ca16dd76367c074fe4df1dcf7b555489a9bf85Tripp * @param {Object} callback function
828c58761d90445b8b9d20a82d85dc1479317f71Tripp * @private
828c58761d90445b8b9d20a82d85dc1479317f71Tripp */
828c58761d90445b8b9d20a82d85dc1479317f71Tripp on: function(type, fn)
828c58761d90445b8b9d20a82d85dc1479317f71Tripp {
080b31a43c2a1d068c28eaa3e243bdd6e8a89ffaTripp if(Y.Node.DOM_EVENTS[type])
09688ec5ffb8b9cf9883a770e2f9ebd60b28888dTripp {
080b31a43c2a1d068c28eaa3e243bdd6e8a89ffaTripp return Y.one("#" + this.get("id")).on(type, fn);
828c58761d90445b8b9d20a82d85dc1479317f71Tripp }
828c58761d90445b8b9d20a82d85dc1479317f71Tripp return Y.on.apply(this, arguments);
828c58761d90445b8b9d20a82d85dc1479317f71Tripp },
828c58761d90445b8b9d20a82d85dc1479317f71Tripp
828c58761d90445b8b9d20a82d85dc1479317f71Tripp /**
828c58761d90445b8b9d20a82d85dc1479317f71Tripp * Adds a stroke to the shape node.
828c58761d90445b8b9d20a82d85dc1479317f71Tripp *
828c58761d90445b8b9d20a82d85dc1479317f71Tripp * @method _strokeChangeHandler
66ca16dd76367c074fe4df1dcf7b555489a9bf85Tripp * @param {Object} stroke Properties of the `stroke` attribute.
828c58761d90445b8b9d20a82d85dc1479317f71Tripp * @private
828c58761d90445b8b9d20a82d85dc1479317f71Tripp */
828c58761d90445b8b9d20a82d85dc1479317f71Tripp _setStrokeProps: function(stroke)
828c58761d90445b8b9d20a82d85dc1479317f71Tripp {
828c58761d90445b8b9d20a82d85dc1479317f71Tripp var color = stroke.color,
aeee02c921674c7c98f1e3cbfdaa32b7da4a1ad5Tripp weight = PARSE_FLOAT(stroke.weight),
aeee02c921674c7c98f1e3cbfdaa32b7da4a1ad5Tripp opacity = PARSE_FLOAT(stroke.opacity),
828c58761d90445b8b9d20a82d85dc1479317f71Tripp linejoin = stroke.linejoin || "round",
828c58761d90445b8b9d20a82d85dc1479317f71Tripp linecap = stroke.linecap || "butt",
828c58761d90445b8b9d20a82d85dc1479317f71Tripp dashstyle = stroke.dashstyle;
828c58761d90445b8b9d20a82d85dc1479317f71Tripp this._miterlimit = null;
828c58761d90445b8b9d20a82d85dc1479317f71Tripp this._dashstyle = (dashstyle && Y.Lang.isArray(dashstyle) && dashstyle.length > 1) ? dashstyle : null;
828c58761d90445b8b9d20a82d85dc1479317f71Tripp this._strokeWeight = weight;
828c58761d90445b8b9d20a82d85dc1479317f71Tripp
aeee02c921674c7c98f1e3cbfdaa32b7da4a1ad5Tripp if (IS_NUMBER(weight) && weight > 0)
09688ec5ffb8b9cf9883a770e2f9ebd60b28888dTripp {
828c58761d90445b8b9d20a82d85dc1479317f71Tripp this._stroke = 1;
828c58761d90445b8b9d20a82d85dc1479317f71Tripp }
828c58761d90445b8b9d20a82d85dc1479317f71Tripp else
09688ec5ffb8b9cf9883a770e2f9ebd60b28888dTripp {
828c58761d90445b8b9d20a82d85dc1479317f71Tripp this._stroke = 0;
828c58761d90445b8b9d20a82d85dc1479317f71Tripp }
aeee02c921674c7c98f1e3cbfdaa32b7da4a1ad5Tripp if (IS_NUMBER(opacity)) {
b08d5c81743759d32bccaf4bec55aa102491026eTripp this._strokeStyle = this._toRGBA(color, opacity);
828c58761d90445b8b9d20a82d85dc1479317f71Tripp }
828c58761d90445b8b9d20a82d85dc1479317f71Tripp else
09688ec5ffb8b9cf9883a770e2f9ebd60b28888dTripp {
828c58761d90445b8b9d20a82d85dc1479317f71Tripp this._strokeStyle = color;
828c58761d90445b8b9d20a82d85dc1479317f71Tripp }
828c58761d90445b8b9d20a82d85dc1479317f71Tripp this._linecap = linecap;
828c58761d90445b8b9d20a82d85dc1479317f71Tripp if(linejoin == "round" || linejoin == "square")
09688ec5ffb8b9cf9883a770e2f9ebd60b28888dTripp {
828c58761d90445b8b9d20a82d85dc1479317f71Tripp this._linejoin = linejoin;
828c58761d90445b8b9d20a82d85dc1479317f71Tripp }
828c58761d90445b8b9d20a82d85dc1479317f71Tripp else
09688ec5ffb8b9cf9883a770e2f9ebd60b28888dTripp {
828c58761d90445b8b9d20a82d85dc1479317f71Tripp linejoin = parseInt(linejoin, 10);
aeee02c921674c7c98f1e3cbfdaa32b7da4a1ad5Tripp if(IS_NUMBER(linejoin))
09688ec5ffb8b9cf9883a770e2f9ebd60b28888dTripp {
828c58761d90445b8b9d20a82d85dc1479317f71Tripp this._miterlimit = Math.max(linejoin, 1);
828c58761d90445b8b9d20a82d85dc1479317f71Tripp this._linejoin = "miter";
09688ec5ffb8b9cf9883a770e2f9ebd60b28888dTripp }
828c58761d90445b8b9d20a82d85dc1479317f71Tripp }
828c58761d90445b8b9d20a82d85dc1479317f71Tripp },
828c58761d90445b8b9d20a82d85dc1479317f71Tripp
66ca16dd76367c074fe4df1dcf7b555489a9bf85Tripp /**
66ca16dd76367c074fe4df1dcf7b555489a9bf85Tripp * Sets the value of an attribute.
66ca16dd76367c074fe4df1dcf7b555489a9bf85Tripp *
66ca16dd76367c074fe4df1dcf7b555489a9bf85Tripp * @method set
66ca16dd76367c074fe4df1dcf7b555489a9bf85Tripp * @param {String|Object} name The name of the attribute. Alternatively, an object of key value pairs can
66ca16dd76367c074fe4df1dcf7b555489a9bf85Tripp * be passed in to set multiple attributes at once.
66ca16dd76367c074fe4df1dcf7b555489a9bf85Tripp * @param {Any} value The value to set the attribute to. This value is ignored if an object is received as
66ca16dd76367c074fe4df1dcf7b555489a9bf85Tripp * the name param.
66ca16dd76367c074fe4df1dcf7b555489a9bf85Tripp */
828c58761d90445b8b9d20a82d85dc1479317f71Tripp set: function()
828c58761d90445b8b9d20a82d85dc1479317f71Tripp {
828c58761d90445b8b9d20a82d85dc1479317f71Tripp var host = this,
828c58761d90445b8b9d20a82d85dc1479317f71Tripp val = arguments[0];
828c58761d90445b8b9d20a82d85dc1479317f71Tripp AttributeLite.prototype.set.apply(host, arguments);
9cc2c5945426b2b79c0a258026d750be74795924Tripp if(host.initialized)
09688ec5ffb8b9cf9883a770e2f9ebd60b28888dTripp {
828c58761d90445b8b9d20a82d85dc1479317f71Tripp host._updateHandler();
828c58761d90445b8b9d20a82d85dc1479317f71Tripp }
828c58761d90445b8b9d20a82d85dc1479317f71Tripp },
828c58761d90445b8b9d20a82d85dc1479317f71Tripp
828c58761d90445b8b9d20a82d85dc1479317f71Tripp /**
828c58761d90445b8b9d20a82d85dc1479317f71Tripp * Adds a fill to the shape node.
828c58761d90445b8b9d20a82d85dc1479317f71Tripp *
66ca16dd76367c074fe4df1dcf7b555489a9bf85Tripp * @method _setFillProps
66ca16dd76367c074fe4df1dcf7b555489a9bf85Tripp * @param {Object} fill Properties of the `fill` attribute.
828c58761d90445b8b9d20a82d85dc1479317f71Tripp * @private
828c58761d90445b8b9d20a82d85dc1479317f71Tripp */
828c58761d90445b8b9d20a82d85dc1479317f71Tripp _setFillProps: function(fill)
828c58761d90445b8b9d20a82d85dc1479317f71Tripp {
aeee02c921674c7c98f1e3cbfdaa32b7da4a1ad5Tripp var isNumber = IS_NUMBER,
828c58761d90445b8b9d20a82d85dc1479317f71Tripp color = fill.color,
828c58761d90445b8b9d20a82d85dc1479317f71Tripp opacity,
828c58761d90445b8b9d20a82d85dc1479317f71Tripp type = fill.type;
828c58761d90445b8b9d20a82d85dc1479317f71Tripp if(type == "linear" || type == "radial")
09688ec5ffb8b9cf9883a770e2f9ebd60b28888dTripp {
828c58761d90445b8b9d20a82d85dc1479317f71Tripp this._fillType = type;
828c58761d90445b8b9d20a82d85dc1479317f71Tripp }
828c58761d90445b8b9d20a82d85dc1479317f71Tripp else if(color)
09688ec5ffb8b9cf9883a770e2f9ebd60b28888dTripp {
828c58761d90445b8b9d20a82d85dc1479317f71Tripp opacity = fill.opacity;
828c58761d90445b8b9d20a82d85dc1479317f71Tripp if (isNumber(opacity))
09688ec5ffb8b9cf9883a770e2f9ebd60b28888dTripp {
828c58761d90445b8b9d20a82d85dc1479317f71Tripp opacity = Math.max(0, Math.min(1, opacity));
b08d5c81743759d32bccaf4bec55aa102491026eTripp color = this._toRGBA(color, opacity);
09688ec5ffb8b9cf9883a770e2f9ebd60b28888dTripp }
09688ec5ffb8b9cf9883a770e2f9ebd60b28888dTripp else
09688ec5ffb8b9cf9883a770e2f9ebd60b28888dTripp {
b08d5c81743759d32bccaf4bec55aa102491026eTripp color = TORGB(color);
09688ec5ffb8b9cf9883a770e2f9ebd60b28888dTripp }
09688ec5ffb8b9cf9883a770e2f9ebd60b28888dTripp
828c58761d90445b8b9d20a82d85dc1479317f71Tripp this._fillColor = color;
828c58761d90445b8b9d20a82d85dc1479317f71Tripp this._fillType = 'solid';
828c58761d90445b8b9d20a82d85dc1479317f71Tripp }
828c58761d90445b8b9d20a82d85dc1479317f71Tripp else
09688ec5ffb8b9cf9883a770e2f9ebd60b28888dTripp {
828c58761d90445b8b9d20a82d85dc1479317f71Tripp this._fillColor = null;
828c58761d90445b8b9d20a82d85dc1479317f71Tripp }
828c58761d90445b8b9d20a82d85dc1479317f71Tripp },
828c58761d90445b8b9d20a82d85dc1479317f71Tripp
828c58761d90445b8b9d20a82d85dc1479317f71Tripp /**
6a3585e2672045e8e28e6a45f279f80aef446959Tripp * Specifies a 2d translation.
828c58761d90445b8b9d20a82d85dc1479317f71Tripp *
828c58761d90445b8b9d20a82d85dc1479317f71Tripp * @method translate
ed59119d8c00addb07c7ee6c8aefcd1d9cb876f1Tripp * @param {Number} x The value to transate on the x-axis.
ed59119d8c00addb07c7ee6c8aefcd1d9cb876f1Tripp * @param {Number} y The value to translate on the y-axis.
828c58761d90445b8b9d20a82d85dc1479317f71Tripp */
828c58761d90445b8b9d20a82d85dc1479317f71Tripp translate: function(x, y)
6c4ec9d420df654d019b936fd06bef6f769db4cbTripp {
ed59119d8c00addb07c7ee6c8aefcd1d9cb876f1Tripp this._translateX += x;
ed59119d8c00addb07c7ee6c8aefcd1d9cb876f1Tripp this._translateY += y;
ed59119d8c00addb07c7ee6c8aefcd1d9cb876f1Tripp this._addTransform("translate", arguments);
6c4ec9d420df654d019b936fd06bef6f769db4cbTripp },
6c4ec9d420df654d019b936fd06bef6f769db4cbTripp
6c4ec9d420df654d019b936fd06bef6f769db4cbTripp /**
6a3585e2672045e8e28e6a45f279f80aef446959Tripp * Translates the shape along the x-axis. When translating x and y coordinates,
ed59119d8c00addb07c7ee6c8aefcd1d9cb876f1Tripp * use the `translate` method.
6c4ec9d420df654d019b936fd06bef6f769db4cbTripp *
ed59119d8c00addb07c7ee6c8aefcd1d9cb876f1Tripp * @method translateX
0fdefaa9ca017edfb76b736c825b34186f33045aTripp * @param {Number} x The value to translate.
6c4ec9d420df654d019b936fd06bef6f769db4cbTripp */
ed59119d8c00addb07c7ee6c8aefcd1d9cb876f1Tripp translateX: function(x)
ed59119d8c00addb07c7ee6c8aefcd1d9cb876f1Tripp {
ed59119d8c00addb07c7ee6c8aefcd1d9cb876f1Tripp this._translateX += x;
ed59119d8c00addb07c7ee6c8aefcd1d9cb876f1Tripp this._addTransform("translateX", arguments);
ed59119d8c00addb07c7ee6c8aefcd1d9cb876f1Tripp },
ed59119d8c00addb07c7ee6c8aefcd1d9cb876f1Tripp
ed59119d8c00addb07c7ee6c8aefcd1d9cb876f1Tripp /**
ed59119d8c00addb07c7ee6c8aefcd1d9cb876f1Tripp * Performs a translate on the y-coordinate. When translating x and y coordinates,
ed59119d8c00addb07c7ee6c8aefcd1d9cb876f1Tripp * use the `translate` method.
ed59119d8c00addb07c7ee6c8aefcd1d9cb876f1Tripp *
ed59119d8c00addb07c7ee6c8aefcd1d9cb876f1Tripp * @method translateY
ed59119d8c00addb07c7ee6c8aefcd1d9cb876f1Tripp * @param {Number} y The value to translate.
ed59119d8c00addb07c7ee6c8aefcd1d9cb876f1Tripp */
ed59119d8c00addb07c7ee6c8aefcd1d9cb876f1Tripp translateY: function(y)
ed59119d8c00addb07c7ee6c8aefcd1d9cb876f1Tripp {
ed59119d8c00addb07c7ee6c8aefcd1d9cb876f1Tripp this._translateY += y;
ed59119d8c00addb07c7ee6c8aefcd1d9cb876f1Tripp this._addTransform("translateY", arguments);
ed59119d8c00addb07c7ee6c8aefcd1d9cb876f1Tripp },
ed59119d8c00addb07c7ee6c8aefcd1d9cb876f1Tripp
ed59119d8c00addb07c7ee6c8aefcd1d9cb876f1Tripp /**
6a3585e2672045e8e28e6a45f279f80aef446959Tripp * Skews the shape around the x-axis and y-axis.
ed59119d8c00addb07c7ee6c8aefcd1d9cb876f1Tripp *
ed59119d8c00addb07c7ee6c8aefcd1d9cb876f1Tripp * @method skew
ed59119d8c00addb07c7ee6c8aefcd1d9cb876f1Tripp * @param {Number} x The value to skew on the x-axis.
ed59119d8c00addb07c7ee6c8aefcd1d9cb876f1Tripp * @param {Number} y The value to skew on the y-axis.
ed59119d8c00addb07c7ee6c8aefcd1d9cb876f1Tripp */
ed59119d8c00addb07c7ee6c8aefcd1d9cb876f1Tripp skew: function(x, y)
ed59119d8c00addb07c7ee6c8aefcd1d9cb876f1Tripp {
ed59119d8c00addb07c7ee6c8aefcd1d9cb876f1Tripp this._addTransform("skew", arguments);
ed59119d8c00addb07c7ee6c8aefcd1d9cb876f1Tripp },
828c58761d90445b8b9d20a82d85dc1479317f71Tripp
828c58761d90445b8b9d20a82d85dc1479317f71Tripp /**
6a3585e2672045e8e28e6a45f279f80aef446959Tripp * Skews the shape around the x-axis.
828c58761d90445b8b9d20a82d85dc1479317f71Tripp *
66ca16dd76367c074fe4df1dcf7b555489a9bf85Tripp * @method skewX
828c58761d90445b8b9d20a82d85dc1479317f71Tripp * @param {Number} x x-coordinate
828c58761d90445b8b9d20a82d85dc1479317f71Tripp */
828c58761d90445b8b9d20a82d85dc1479317f71Tripp skewX: function(x)
828c58761d90445b8b9d20a82d85dc1479317f71Tripp {
ed59119d8c00addb07c7ee6c8aefcd1d9cb876f1Tripp this._addTransform("skewX", arguments);
828c58761d90445b8b9d20a82d85dc1479317f71Tripp },
828c58761d90445b8b9d20a82d85dc1479317f71Tripp
828c58761d90445b8b9d20a82d85dc1479317f71Tripp /**
6a3585e2672045e8e28e6a45f279f80aef446959Tripp * Skews the shape around the y-axis.
828c58761d90445b8b9d20a82d85dc1479317f71Tripp *
66ca16dd76367c074fe4df1dcf7b555489a9bf85Tripp * @method skewY
66ca16dd76367c074fe4df1dcf7b555489a9bf85Tripp * @param {Number} y y-coordinate
828c58761d90445b8b9d20a82d85dc1479317f71Tripp */
828c58761d90445b8b9d20a82d85dc1479317f71Tripp skewY: function(y)
828c58761d90445b8b9d20a82d85dc1479317f71Tripp {
ed59119d8c00addb07c7ee6c8aefcd1d9cb876f1Tripp this._addTransform("skewY", arguments);
828c58761d90445b8b9d20a82d85dc1479317f71Tripp },
828c58761d90445b8b9d20a82d85dc1479317f71Tripp
828c58761d90445b8b9d20a82d85dc1479317f71Tripp /**
6a3585e2672045e8e28e6a45f279f80aef446959Tripp * Rotates the shape clockwise around it transformOrigin.
828c58761d90445b8b9d20a82d85dc1479317f71Tripp *
828c58761d90445b8b9d20a82d85dc1479317f71Tripp * @method rotate
66ca16dd76367c074fe4df1dcf7b555489a9bf85Tripp * @param {Number} deg The degree of the rotation.
828c58761d90445b8b9d20a82d85dc1479317f71Tripp */
ed59119d8c00addb07c7ee6c8aefcd1d9cb876f1Tripp rotate: function(deg)
ed59119d8c00addb07c7ee6c8aefcd1d9cb876f1Tripp {
828c58761d90445b8b9d20a82d85dc1479317f71Tripp this._rotation = deg;
ed59119d8c00addb07c7ee6c8aefcd1d9cb876f1Tripp this._addTransform("rotate", arguments);
ed59119d8c00addb07c7ee6c8aefcd1d9cb876f1Tripp },
828c58761d90445b8b9d20a82d85dc1479317f71Tripp
828c58761d90445b8b9d20a82d85dc1479317f71Tripp /**
6a3585e2672045e8e28e6a45f279f80aef446959Tripp * Specifies a 2d scaling operation.
828c58761d90445b8b9d20a82d85dc1479317f71Tripp *
828c58761d90445b8b9d20a82d85dc1479317f71Tripp * @method scale
828c58761d90445b8b9d20a82d85dc1479317f71Tripp * @param {Number} val
828c58761d90445b8b9d20a82d85dc1479317f71Tripp */
ed59119d8c00addb07c7ee6c8aefcd1d9cb876f1Tripp scale: function(x, y)
828c58761d90445b8b9d20a82d85dc1479317f71Tripp {
ed59119d8c00addb07c7ee6c8aefcd1d9cb876f1Tripp this._addTransform("scale", arguments);
828c58761d90445b8b9d20a82d85dc1479317f71Tripp },
9cc2c5945426b2b79c0a258026d750be74795924Tripp
ed59119d8c00addb07c7ee6c8aefcd1d9cb876f1Tripp /**
ed59119d8c00addb07c7ee6c8aefcd1d9cb876f1Tripp * Storage for `rotation` atribute.
ed59119d8c00addb07c7ee6c8aefcd1d9cb876f1Tripp *
ed59119d8c00addb07c7ee6c8aefcd1d9cb876f1Tripp * @property _rotation
ed59119d8c00addb07c7ee6c8aefcd1d9cb876f1Tripp * @type Number
ed59119d8c00addb07c7ee6c8aefcd1d9cb876f1Tripp * @private
ed59119d8c00addb07c7ee6c8aefcd1d9cb876f1Tripp */
ed59119d8c00addb07c7ee6c8aefcd1d9cb876f1Tripp _rotation: 0,
2ebe57b26e070070dacbe6e2b3351d5cefaee874Tripp
2ebe57b26e070070dacbe6e2b3351d5cefaee874Tripp /**
2ebe57b26e070070dacbe6e2b3351d5cefaee874Tripp * Storage for the transform attribute.
2ebe57b26e070070dacbe6e2b3351d5cefaee874Tripp *
2ebe57b26e070070dacbe6e2b3351d5cefaee874Tripp * @property _transform
2ebe57b26e070070dacbe6e2b3351d5cefaee874Tripp * @type String
2ebe57b26e070070dacbe6e2b3351d5cefaee874Tripp * @private
2ebe57b26e070070dacbe6e2b3351d5cefaee874Tripp */
2ebe57b26e070070dacbe6e2b3351d5cefaee874Tripp _transform: "",
ed59119d8c00addb07c7ee6c8aefcd1d9cb876f1Tripp
9cc2c5945426b2b79c0a258026d750be74795924Tripp /**
66ca16dd76367c074fe4df1dcf7b555489a9bf85Tripp * Adds a transform to the shape.
66ca16dd76367c074fe4df1dcf7b555489a9bf85Tripp *
66ca16dd76367c074fe4df1dcf7b555489a9bf85Tripp * @method _addTransform
66ca16dd76367c074fe4df1dcf7b555489a9bf85Tripp * @param {String} type The transform being applied.
66ca16dd76367c074fe4df1dcf7b555489a9bf85Tripp * @param {Array} args The arguments for the transform.
9cc2c5945426b2b79c0a258026d750be74795924Tripp * @private
9cc2c5945426b2b79c0a258026d750be74795924Tripp */
9cc2c5945426b2b79c0a258026d750be74795924Tripp _addTransform: function(type, args)
9cc2c5945426b2b79c0a258026d750be74795924Tripp {
ed59119d8c00addb07c7ee6c8aefcd1d9cb876f1Tripp args = Y.Array(args);
2ebe57b26e070070dacbe6e2b3351d5cefaee874Tripp this._transform = Y_LANG.trim(this._transform + " " + type + "(" + args.join(", ") + ")");
ed59119d8c00addb07c7ee6c8aefcd1d9cb876f1Tripp args.unshift(type);
ed59119d8c00addb07c7ee6c8aefcd1d9cb876f1Tripp this._transforms.push(args);
2ebe57b26e070070dacbe6e2b3351d5cefaee874Tripp if(this.initialized)
9cc2c5945426b2b79c0a258026d750be74795924Tripp {
9cc2c5945426b2b79c0a258026d750be74795924Tripp this._updateTransform();
9cc2c5945426b2b79c0a258026d750be74795924Tripp }
9cc2c5945426b2b79c0a258026d750be74795924Tripp },
828c58761d90445b8b9d20a82d85dc1479317f71Tripp
828c58761d90445b8b9d20a82d85dc1479317f71Tripp /**
66ca16dd76367c074fe4df1dcf7b555489a9bf85Tripp * Applies all transforms.
66ca16dd76367c074fe4df1dcf7b555489a9bf85Tripp *
66ca16dd76367c074fe4df1dcf7b555489a9bf85Tripp * @method _updateTransform
828c58761d90445b8b9d20a82d85dc1479317f71Tripp * @private
828c58761d90445b8b9d20a82d85dc1479317f71Tripp */
9cc2c5945426b2b79c0a258026d750be74795924Tripp _updateTransform: function()
828c58761d90445b8b9d20a82d85dc1479317f71Tripp {
9cc2c5945426b2b79c0a258026d750be74795924Tripp var node = this.node,
9cc2c5945426b2b79c0a258026d750be74795924Tripp key,
ed59119d8c00addb07c7ee6c8aefcd1d9cb876f1Tripp transform,
ed59119d8c00addb07c7ee6c8aefcd1d9cb876f1Tripp transformOrigin = this.get("transformOrigin"),
ed59119d8c00addb07c7ee6c8aefcd1d9cb876f1Tripp matrix = this.matrix,
ed59119d8c00addb07c7ee6c8aefcd1d9cb876f1Tripp i = 0,
ed59119d8c00addb07c7ee6c8aefcd1d9cb876f1Tripp len = this._transforms.length;
ed59119d8c00addb07c7ee6c8aefcd1d9cb876f1Tripp
ed59119d8c00addb07c7ee6c8aefcd1d9cb876f1Tripp if(this._transforms && this._transforms.length > 0)
ed59119d8c00addb07c7ee6c8aefcd1d9cb876f1Tripp {
ed59119d8c00addb07c7ee6c8aefcd1d9cb876f1Tripp for(; i < len; ++i)
ed59119d8c00addb07c7ee6c8aefcd1d9cb876f1Tripp {
ed59119d8c00addb07c7ee6c8aefcd1d9cb876f1Tripp key = this._transforms[i].shift();
ed59119d8c00addb07c7ee6c8aefcd1d9cb876f1Tripp if(key)
ed59119d8c00addb07c7ee6c8aefcd1d9cb876f1Tripp {
ed59119d8c00addb07c7ee6c8aefcd1d9cb876f1Tripp matrix[key].apply(matrix, this._transforms[i]);
ed59119d8c00addb07c7ee6c8aefcd1d9cb876f1Tripp }
ed59119d8c00addb07c7ee6c8aefcd1d9cb876f1Tripp }
ed59119d8c00addb07c7ee6c8aefcd1d9cb876f1Tripp transform = matrix.toCSSText();
ed59119d8c00addb07c7ee6c8aefcd1d9cb876f1Tripp }
ed59119d8c00addb07c7ee6c8aefcd1d9cb876f1Tripp
9cc2c5945426b2b79c0a258026d750be74795924Tripp this._graphic.addToRedrawQueue(this);
828c58761d90445b8b9d20a82d85dc1479317f71Tripp transformOrigin = (100 * transformOrigin[0]) + "% " + (100 * transformOrigin[1]) + "%";
828c58761d90445b8b9d20a82d85dc1479317f71Tripp node.style.MozTransformOrigin = transformOrigin;
828c58761d90445b8b9d20a82d85dc1479317f71Tripp node.style.webkitTransformOrigin = transformOrigin;
828c58761d90445b8b9d20a82d85dc1479317f71Tripp node.style.msTransformOrigin = transformOrigin;
828c58761d90445b8b9d20a82d85dc1479317f71Tripp node.style.OTransformOrigin = transformOrigin;
9cc2c5945426b2b79c0a258026d750be74795924Tripp if(transform)
9cc2c5945426b2b79c0a258026d750be74795924Tripp {
9cc2c5945426b2b79c0a258026d750be74795924Tripp node.style.MozTransform = transform;
9cc2c5945426b2b79c0a258026d750be74795924Tripp node.style.webkitTransform = transform;
9cc2c5945426b2b79c0a258026d750be74795924Tripp node.style.msTransform = transform;
9cc2c5945426b2b79c0a258026d750be74795924Tripp node.style.OTransform = transform;
9cc2c5945426b2b79c0a258026d750be74795924Tripp }
ed59119d8c00addb07c7ee6c8aefcd1d9cb876f1Tripp this._transforms = [];
828c58761d90445b8b9d20a82d85dc1479317f71Tripp },
828c58761d90445b8b9d20a82d85dc1479317f71Tripp
828c58761d90445b8b9d20a82d85dc1479317f71Tripp /**
66ca16dd76367c074fe4df1dcf7b555489a9bf85Tripp * Updates `Shape` based on attribute changes.
66ca16dd76367c074fe4df1dcf7b555489a9bf85Tripp *
66ca16dd76367c074fe4df1dcf7b555489a9bf85Tripp * @method _updateHandler
828c58761d90445b8b9d20a82d85dc1479317f71Tripp * @private
828c58761d90445b8b9d20a82d85dc1479317f71Tripp */
828c58761d90445b8b9d20a82d85dc1479317f71Tripp _updateHandler: function()
828c58761d90445b8b9d20a82d85dc1479317f71Tripp {
828c58761d90445b8b9d20a82d85dc1479317f71Tripp this._draw();
9cc2c5945426b2b79c0a258026d750be74795924Tripp this._updateTransform();
828c58761d90445b8b9d20a82d85dc1479317f71Tripp },
828c58761d90445b8b9d20a82d85dc1479317f71Tripp
828c58761d90445b8b9d20a82d85dc1479317f71Tripp /**
66ca16dd76367c074fe4df1dcf7b555489a9bf85Tripp * Updates the shape.
66ca16dd76367c074fe4df1dcf7b555489a9bf85Tripp *
66ca16dd76367c074fe4df1dcf7b555489a9bf85Tripp * @method _draw
828c58761d90445b8b9d20a82d85dc1479317f71Tripp * @private
828c58761d90445b8b9d20a82d85dc1479317f71Tripp */
828c58761d90445b8b9d20a82d85dc1479317f71Tripp _draw: function()
828c58761d90445b8b9d20a82d85dc1479317f71Tripp {
66ca16dd76367c074fe4df1dcf7b555489a9bf85Tripp var node = this.node;
c7ba96d16d58075a9ab8d5c1e46c6c83ce11cb4eTripp this.clear();
14bfa36e35102dbf271dcff98f773a01c75bd503Tripp this._closePath();
9cc2c5945426b2b79c0a258026d750be74795924Tripp node.style.left = this.get("x") + "px";
9cc2c5945426b2b79c0a258026d750be74795924Tripp node.style.top = this.get("y") + "px";
828c58761d90445b8b9d20a82d85dc1479317f71Tripp },
828c58761d90445b8b9d20a82d85dc1479317f71Tripp
828c58761d90445b8b9d20a82d85dc1479317f71Tripp /**
828c58761d90445b8b9d20a82d85dc1479317f71Tripp * Completes a shape or drawing
828c58761d90445b8b9d20a82d85dc1479317f71Tripp *
14bfa36e35102dbf271dcff98f773a01c75bd503Tripp * @method _closePath
828c58761d90445b8b9d20a82d85dc1479317f71Tripp * @private
828c58761d90445b8b9d20a82d85dc1479317f71Tripp */
14bfa36e35102dbf271dcff98f773a01c75bd503Tripp _closePath: function()
828c58761d90445b8b9d20a82d85dc1479317f71Tripp {
828c58761d90445b8b9d20a82d85dc1479317f71Tripp if(!this._methods)
09688ec5ffb8b9cf9883a770e2f9ebd60b28888dTripp {
828c58761d90445b8b9d20a82d85dc1479317f71Tripp return;
828c58761d90445b8b9d20a82d85dc1479317f71Tripp }
828c58761d90445b8b9d20a82d85dc1479317f71Tripp var node = this.get("node"),
c7ba96d16d58075a9ab8d5c1e46c6c83ce11cb4eTripp w = this._right - this._left,
c7ba96d16d58075a9ab8d5c1e46c6c83ce11cb4eTripp h = this._bottom - this._top,
828c58761d90445b8b9d20a82d85dc1479317f71Tripp context = this._context,
828c58761d90445b8b9d20a82d85dc1479317f71Tripp methods = [],
828c58761d90445b8b9d20a82d85dc1479317f71Tripp cachedMethods = this._methods.concat(),
828c58761d90445b8b9d20a82d85dc1479317f71Tripp i = 0,
828c58761d90445b8b9d20a82d85dc1479317f71Tripp j,
828c58761d90445b8b9d20a82d85dc1479317f71Tripp method,
828c58761d90445b8b9d20a82d85dc1479317f71Tripp args,
c7ba96d16d58075a9ab8d5c1e46c6c83ce11cb4eTripp argsLen,
828c58761d90445b8b9d20a82d85dc1479317f71Tripp len = 0;
c7ba96d16d58075a9ab8d5c1e46c6c83ce11cb4eTripp this._context.clearRect(0, 0, node.width, node.height);
828c58761d90445b8b9d20a82d85dc1479317f71Tripp if(this._methods)
828c58761d90445b8b9d20a82d85dc1479317f71Tripp {
828c58761d90445b8b9d20a82d85dc1479317f71Tripp len = cachedMethods.length;
828c58761d90445b8b9d20a82d85dc1479317f71Tripp if(!len || len < 1)
09688ec5ffb8b9cf9883a770e2f9ebd60b28888dTripp {
09688ec5ffb8b9cf9883a770e2f9ebd60b28888dTripp return;
09688ec5ffb8b9cf9883a770e2f9ebd60b28888dTripp }
828c58761d90445b8b9d20a82d85dc1479317f71Tripp for(; i < len; ++i)
828c58761d90445b8b9d20a82d85dc1479317f71Tripp {
828c58761d90445b8b9d20a82d85dc1479317f71Tripp methods[i] = cachedMethods[i].concat();
828c58761d90445b8b9d20a82d85dc1479317f71Tripp args = methods[i];
c7ba96d16d58075a9ab8d5c1e46c6c83ce11cb4eTripp argsLen = args[0] == "quadraticCurveTo" ? args.length : 3;
c7ba96d16d58075a9ab8d5c1e46c6c83ce11cb4eTripp for(j = 1; j < argsLen; ++j)
09688ec5ffb8b9cf9883a770e2f9ebd60b28888dTripp {
828c58761d90445b8b9d20a82d85dc1479317f71Tripp if(j % 2 === 0)
828c58761d90445b8b9d20a82d85dc1479317f71Tripp {
828c58761d90445b8b9d20a82d85dc1479317f71Tripp args[j] = args[j] - this._top;
828c58761d90445b8b9d20a82d85dc1479317f71Tripp }
828c58761d90445b8b9d20a82d85dc1479317f71Tripp else
828c58761d90445b8b9d20a82d85dc1479317f71Tripp {
828c58761d90445b8b9d20a82d85dc1479317f71Tripp args[j] = args[j] - this._left;
828c58761d90445b8b9d20a82d85dc1479317f71Tripp }
09688ec5ffb8b9cf9883a770e2f9ebd60b28888dTripp }
828c58761d90445b8b9d20a82d85dc1479317f71Tripp }
14bfa36e35102dbf271dcff98f773a01c75bd503Tripp node.setAttribute("width", Math.min(w, 2000));
14bfa36e35102dbf271dcff98f773a01c75bd503Tripp node.setAttribute("height", Math.min(2000, h));
14bfa36e35102dbf271dcff98f773a01c75bd503Tripp context.beginPath();
828c58761d90445b8b9d20a82d85dc1479317f71Tripp for(i = 0; i < len; ++i)
828c58761d90445b8b9d20a82d85dc1479317f71Tripp {
828c58761d90445b8b9d20a82d85dc1479317f71Tripp args = methods[i].concat();
828c58761d90445b8b9d20a82d85dc1479317f71Tripp if(args && args.length > 0)
09688ec5ffb8b9cf9883a770e2f9ebd60b28888dTripp {
828c58761d90445b8b9d20a82d85dc1479317f71Tripp method = args.shift();
828c58761d90445b8b9d20a82d85dc1479317f71Tripp if(method)
09688ec5ffb8b9cf9883a770e2f9ebd60b28888dTripp {
14bfa36e35102dbf271dcff98f773a01c75bd503Tripp if(method == "closePath")
14bfa36e35102dbf271dcff98f773a01c75bd503Tripp {
14bfa36e35102dbf271dcff98f773a01c75bd503Tripp this._strokeAndFill(context);
14bfa36e35102dbf271dcff98f773a01c75bd503Tripp }
828c58761d90445b8b9d20a82d85dc1479317f71Tripp if(method && method == "lineTo" && this._dashstyle)
09688ec5ffb8b9cf9883a770e2f9ebd60b28888dTripp {
828c58761d90445b8b9d20a82d85dc1479317f71Tripp args.unshift(this._xcoords[i] - this._left, this._ycoords[i] - this._top);
828c58761d90445b8b9d20a82d85dc1479317f71Tripp this._drawDashedLine.apply(this, args);
09688ec5ffb8b9cf9883a770e2f9ebd60b28888dTripp }
09688ec5ffb8b9cf9883a770e2f9ebd60b28888dTripp else
09688ec5ffb8b9cf9883a770e2f9ebd60b28888dTripp {
c7ba96d16d58075a9ab8d5c1e46c6c83ce11cb4eTripp context[method].apply(context, args);
09688ec5ffb8b9cf9883a770e2f9ebd60b28888dTripp }
09688ec5ffb8b9cf9883a770e2f9ebd60b28888dTripp }
09688ec5ffb8b9cf9883a770e2f9ebd60b28888dTripp }
828c58761d90445b8b9d20a82d85dc1479317f71Tripp }
09688ec5ffb8b9cf9883a770e2f9ebd60b28888dTripp
14bfa36e35102dbf271dcff98f773a01c75bd503Tripp this._strokeAndFill(context);
828c58761d90445b8b9d20a82d85dc1479317f71Tripp this._drawingComplete = true;
828c58761d90445b8b9d20a82d85dc1479317f71Tripp this._clearAndUpdateCoords();
828c58761d90445b8b9d20a82d85dc1479317f71Tripp this._updateNodePosition();
828c58761d90445b8b9d20a82d85dc1479317f71Tripp this._methods = cachedMethods;
828c58761d90445b8b9d20a82d85dc1479317f71Tripp }
828c58761d90445b8b9d20a82d85dc1479317f71Tripp },
828c58761d90445b8b9d20a82d85dc1479317f71Tripp
14bfa36e35102dbf271dcff98f773a01c75bd503Tripp /**
14bfa36e35102dbf271dcff98f773a01c75bd503Tripp * Completes a stroke and/or fill operation on the context.
14bfa36e35102dbf271dcff98f773a01c75bd503Tripp *
14bfa36e35102dbf271dcff98f773a01c75bd503Tripp * @method _strokeAndFill
14bfa36e35102dbf271dcff98f773a01c75bd503Tripp * @param {Context} Reference to the context element of the canvas instance.
14bfa36e35102dbf271dcff98f773a01c75bd503Tripp * @private
14bfa36e35102dbf271dcff98f773a01c75bd503Tripp */
14bfa36e35102dbf271dcff98f773a01c75bd503Tripp _strokeAndFill: function(context)
14bfa36e35102dbf271dcff98f773a01c75bd503Tripp {
14bfa36e35102dbf271dcff98f773a01c75bd503Tripp if (this._fillType)
14bfa36e35102dbf271dcff98f773a01c75bd503Tripp {
14bfa36e35102dbf271dcff98f773a01c75bd503Tripp if(this._fillType == "linear")
14bfa36e35102dbf271dcff98f773a01c75bd503Tripp {
14bfa36e35102dbf271dcff98f773a01c75bd503Tripp context.fillStyle = this._getLinearGradient();
14bfa36e35102dbf271dcff98f773a01c75bd503Tripp }
14bfa36e35102dbf271dcff98f773a01c75bd503Tripp else if(this._fillType == "radial")
14bfa36e35102dbf271dcff98f773a01c75bd503Tripp {
14bfa36e35102dbf271dcff98f773a01c75bd503Tripp context.fillStyle = this._getRadialGradient();
14bfa36e35102dbf271dcff98f773a01c75bd503Tripp }
14bfa36e35102dbf271dcff98f773a01c75bd503Tripp else
14bfa36e35102dbf271dcff98f773a01c75bd503Tripp {
14bfa36e35102dbf271dcff98f773a01c75bd503Tripp context.fillStyle = this._fillColor;
14bfa36e35102dbf271dcff98f773a01c75bd503Tripp }
14bfa36e35102dbf271dcff98f773a01c75bd503Tripp context.closePath();
14bfa36e35102dbf271dcff98f773a01c75bd503Tripp context.fill();
14bfa36e35102dbf271dcff98f773a01c75bd503Tripp }
14bfa36e35102dbf271dcff98f773a01c75bd503Tripp
14bfa36e35102dbf271dcff98f773a01c75bd503Tripp if (this._stroke) {
14bfa36e35102dbf271dcff98f773a01c75bd503Tripp if(this._strokeWeight)
14bfa36e35102dbf271dcff98f773a01c75bd503Tripp {
14bfa36e35102dbf271dcff98f773a01c75bd503Tripp context.lineWidth = this._strokeWeight;
14bfa36e35102dbf271dcff98f773a01c75bd503Tripp }
14bfa36e35102dbf271dcff98f773a01c75bd503Tripp context.lineCap = this._linecap;
14bfa36e35102dbf271dcff98f773a01c75bd503Tripp context.lineJoin = this._linejoin;
14bfa36e35102dbf271dcff98f773a01c75bd503Tripp if(this._miterlimit)
14bfa36e35102dbf271dcff98f773a01c75bd503Tripp {
14bfa36e35102dbf271dcff98f773a01c75bd503Tripp context.miterLimit = this._miterlimit;
14bfa36e35102dbf271dcff98f773a01c75bd503Tripp }
14bfa36e35102dbf271dcff98f773a01c75bd503Tripp context.strokeStyle = this._strokeStyle;
14bfa36e35102dbf271dcff98f773a01c75bd503Tripp context.stroke();
14bfa36e35102dbf271dcff98f773a01c75bd503Tripp }
14bfa36e35102dbf271dcff98f773a01c75bd503Tripp },
14bfa36e35102dbf271dcff98f773a01c75bd503Tripp
828c58761d90445b8b9d20a82d85dc1479317f71Tripp /**
828c58761d90445b8b9d20a82d85dc1479317f71Tripp * Draws a dashed line between two points.
828c58761d90445b8b9d20a82d85dc1479317f71Tripp *
828c58761d90445b8b9d20a82d85dc1479317f71Tripp * @method _drawDashedLine
828c58761d90445b8b9d20a82d85dc1479317f71Tripp * @param {Number} xStart The x position of the start of the line
828c58761d90445b8b9d20a82d85dc1479317f71Tripp * @param {Number} yStart The y position of the start of the line
828c58761d90445b8b9d20a82d85dc1479317f71Tripp * @param {Number} xEnd The x position of the end of the line
828c58761d90445b8b9d20a82d85dc1479317f71Tripp * @param {Number} yEnd The y position of the end of the line
828c58761d90445b8b9d20a82d85dc1479317f71Tripp * @private
828c58761d90445b8b9d20a82d85dc1479317f71Tripp */
828c58761d90445b8b9d20a82d85dc1479317f71Tripp _drawDashedLine: function(xStart, yStart, xEnd, yEnd)
828c58761d90445b8b9d20a82d85dc1479317f71Tripp {
828c58761d90445b8b9d20a82d85dc1479317f71Tripp var context = this._context,
828c58761d90445b8b9d20a82d85dc1479317f71Tripp dashsize = this._dashstyle[0],
828c58761d90445b8b9d20a82d85dc1479317f71Tripp gapsize = this._dashstyle[1],
828c58761d90445b8b9d20a82d85dc1479317f71Tripp segmentLength = dashsize + gapsize,
828c58761d90445b8b9d20a82d85dc1479317f71Tripp xDelta = xEnd - xStart,
828c58761d90445b8b9d20a82d85dc1479317f71Tripp yDelta = yEnd - yStart,
828c58761d90445b8b9d20a82d85dc1479317f71Tripp delta = Math.sqrt(Math.pow(xDelta, 2) + Math.pow(yDelta, 2)),
828c58761d90445b8b9d20a82d85dc1479317f71Tripp segmentCount = Math.floor(Math.abs(delta / segmentLength)),
828c58761d90445b8b9d20a82d85dc1479317f71Tripp radians = Math.atan2(yDelta, xDelta),
828c58761d90445b8b9d20a82d85dc1479317f71Tripp xCurrent = xStart,
828c58761d90445b8b9d20a82d85dc1479317f71Tripp yCurrent = yStart,
828c58761d90445b8b9d20a82d85dc1479317f71Tripp i;
828c58761d90445b8b9d20a82d85dc1479317f71Tripp xDelta = Math.cos(radians) * segmentLength;
828c58761d90445b8b9d20a82d85dc1479317f71Tripp yDelta = Math.sin(radians) * segmentLength;
828c58761d90445b8b9d20a82d85dc1479317f71Tripp
828c58761d90445b8b9d20a82d85dc1479317f71Tripp for(i = 0; i < segmentCount; ++i)
828c58761d90445b8b9d20a82d85dc1479317f71Tripp {
828c58761d90445b8b9d20a82d85dc1479317f71Tripp context.moveTo(xCurrent, yCurrent);
828c58761d90445b8b9d20a82d85dc1479317f71Tripp context.lineTo(xCurrent + Math.cos(radians) * dashsize, yCurrent + Math.sin(radians) * dashsize);
828c58761d90445b8b9d20a82d85dc1479317f71Tripp xCurrent += xDelta;
828c58761d90445b8b9d20a82d85dc1479317f71Tripp yCurrent += yDelta;
828c58761d90445b8b9d20a82d85dc1479317f71Tripp }
828c58761d90445b8b9d20a82d85dc1479317f71Tripp
828c58761d90445b8b9d20a82d85dc1479317f71Tripp context.moveTo(xCurrent, yCurrent);
828c58761d90445b8b9d20a82d85dc1479317f71Tripp delta = Math.sqrt((xEnd - xCurrent) * (xEnd - xCurrent) + (yEnd - yCurrent) * (yEnd - yCurrent));
828c58761d90445b8b9d20a82d85dc1479317f71Tripp
828c58761d90445b8b9d20a82d85dc1479317f71Tripp if(delta > dashsize)
828c58761d90445b8b9d20a82d85dc1479317f71Tripp {
828c58761d90445b8b9d20a82d85dc1479317f71Tripp context.lineTo(xCurrent + Math.cos(radians) * dashsize, yCurrent + Math.sin(radians) * dashsize);
828c58761d90445b8b9d20a82d85dc1479317f71Tripp }
828c58761d90445b8b9d20a82d85dc1479317f71Tripp else if(delta > 0)
828c58761d90445b8b9d20a82d85dc1479317f71Tripp {
828c58761d90445b8b9d20a82d85dc1479317f71Tripp context.lineTo(xCurrent + Math.cos(radians) * delta, yCurrent + Math.sin(radians) * delta);
828c58761d90445b8b9d20a82d85dc1479317f71Tripp }
828c58761d90445b8b9d20a82d85dc1479317f71Tripp
828c58761d90445b8b9d20a82d85dc1479317f71Tripp context.moveTo(xEnd, yEnd);
828c58761d90445b8b9d20a82d85dc1479317f71Tripp },
828c58761d90445b8b9d20a82d85dc1479317f71Tripp
0fdefaa9ca017edfb76b736c825b34186f33045aTripp //This should move to CanvasDrawing class.
0fdefaa9ca017edfb76b736c825b34186f33045aTripp //Currently docmented in CanvasDrawing class.
0fdefaa9ca017edfb76b736c825b34186f33045aTripp clear: function() {
828c58761d90445b8b9d20a82d85dc1479317f71Tripp this._initProps();
c7ba96d16d58075a9ab8d5c1e46c6c83ce11cb4eTripp if(this.node)
c7ba96d16d58075a9ab8d5c1e46c6c83ce11cb4eTripp {
c7ba96d16d58075a9ab8d5c1e46c6c83ce11cb4eTripp this._context.clearRect(0, 0, this.node.width, this.node.height);
c7ba96d16d58075a9ab8d5c1e46c6c83ce11cb4eTripp }
c7ba96d16d58075a9ab8d5c1e46c6c83ce11cb4eTripp return this;
a89ad754cce3cfc8aee71760e10217b54020360dTripp },
a89ad754cce3cfc8aee71760e10217b54020360dTripp
6a3585e2672045e8e28e6a45f279f80aef446959Tripp /**
a89ad754cce3cfc8aee71760e10217b54020360dTripp * Returns the bounds for a shape.
a89ad754cce3cfc8aee71760e10217b54020360dTripp *
6a3585e2672045e8e28e6a45f279f80aef446959Tripp * Calculates the a new bounding box from the original corner coordinates (base on size and position) and the transform matrix.
6a3585e2672045e8e28e6a45f279f80aef446959Tripp * The calculated bounding box is used by the graphic instance to calculate its viewBox.
6a3585e2672045e8e28e6a45f279f80aef446959Tripp *
a89ad754cce3cfc8aee71760e10217b54020360dTripp * @method getBounds
a89ad754cce3cfc8aee71760e10217b54020360dTripp * @return Object
a89ad754cce3cfc8aee71760e10217b54020360dTripp */
a89ad754cce3cfc8aee71760e10217b54020360dTripp getBounds: function()
a89ad754cce3cfc8aee71760e10217b54020360dTripp {
14bfa36e35102dbf271dcff98f773a01c75bd503Tripp var stroke = this.get("stroke"),
a89ad754cce3cfc8aee71760e10217b54020360dTripp w = this.get("width"),
a89ad754cce3cfc8aee71760e10217b54020360dTripp h = this.get("height"),
a89ad754cce3cfc8aee71760e10217b54020360dTripp x = this.get("x"),
a89ad754cce3cfc8aee71760e10217b54020360dTripp y = this.get("y"),
14bfa36e35102dbf271dcff98f773a01c75bd503Tripp wt = 0;
a89ad754cce3cfc8aee71760e10217b54020360dTripp if(stroke && stroke.weight)
a89ad754cce3cfc8aee71760e10217b54020360dTripp {
a89ad754cce3cfc8aee71760e10217b54020360dTripp wt = stroke.weight;
a89ad754cce3cfc8aee71760e10217b54020360dTripp }
14bfa36e35102dbf271dcff98f773a01c75bd503Tripp w = (x + w + wt) - (x - wt);
14bfa36e35102dbf271dcff98f773a01c75bd503Tripp h = (y + h + wt) - (y - wt);
14bfa36e35102dbf271dcff98f773a01c75bd503Tripp x -= wt;
14bfa36e35102dbf271dcff98f773a01c75bd503Tripp y -= wt;
14bfa36e35102dbf271dcff98f773a01c75bd503Tripp return this.matrix.getContentRect(w, h, x, y);
a89ad754cce3cfc8aee71760e10217b54020360dTripp },
a89ad754cce3cfc8aee71760e10217b54020360dTripp
66ca16dd76367c074fe4df1dcf7b555489a9bf85Tripp /**
43c28ae51ee9a58cf1be1f4397fba7d007d4ec4fTripp * Destroys the shape instance.
66ca16dd76367c074fe4df1dcf7b555489a9bf85Tripp *
66ca16dd76367c074fe4df1dcf7b555489a9bf85Tripp * @method destroy
66ca16dd76367c074fe4df1dcf7b555489a9bf85Tripp */
a89ad754cce3cfc8aee71760e10217b54020360dTripp destroy: function()
a89ad754cce3cfc8aee71760e10217b54020360dTripp {
43c28ae51ee9a58cf1be1f4397fba7d007d4ec4fTripp var graphic = this.get("graphic");
43c28ae51ee9a58cf1be1f4397fba7d007d4ec4fTripp if(graphic)
a89ad754cce3cfc8aee71760e10217b54020360dTripp {
43c28ae51ee9a58cf1be1f4397fba7d007d4ec4fTripp graphic.removeShape(this);
43c28ae51ee9a58cf1be1f4397fba7d007d4ec4fTripp }
43c28ae51ee9a58cf1be1f4397fba7d007d4ec4fTripp else
43c28ae51ee9a58cf1be1f4397fba7d007d4ec4fTripp {
43c28ae51ee9a58cf1be1f4397fba7d007d4ec4fTripp this._destroy();
43c28ae51ee9a58cf1be1f4397fba7d007d4ec4fTripp }
43c28ae51ee9a58cf1be1f4397fba7d007d4ec4fTripp },
43c28ae51ee9a58cf1be1f4397fba7d007d4ec4fTripp
43c28ae51ee9a58cf1be1f4397fba7d007d4ec4fTripp /**
43c28ae51ee9a58cf1be1f4397fba7d007d4ec4fTripp * Implementation for shape destruction
43c28ae51ee9a58cf1be1f4397fba7d007d4ec4fTripp *
43c28ae51ee9a58cf1be1f4397fba7d007d4ec4fTripp * @method destroy
43c28ae51ee9a58cf1be1f4397fba7d007d4ec4fTripp * @protected
43c28ae51ee9a58cf1be1f4397fba7d007d4ec4fTripp */
43c28ae51ee9a58cf1be1f4397fba7d007d4ec4fTripp _destroy: function()
43c28ae51ee9a58cf1be1f4397fba7d007d4ec4fTripp {
43c28ae51ee9a58cf1be1f4397fba7d007d4ec4fTripp if(this.node)
43c28ae51ee9a58cf1be1f4397fba7d007d4ec4fTripp {
43c28ae51ee9a58cf1be1f4397fba7d007d4ec4fTripp Y.one(this.node).remove(true);
43c28ae51ee9a58cf1be1f4397fba7d007d4ec4fTripp this._context = null;
43c28ae51ee9a58cf1be1f4397fba7d007d4ec4fTripp this.node = null;
a89ad754cce3cfc8aee71760e10217b54020360dTripp }
43c28ae51ee9a58cf1be1f4397fba7d007d4ec4fTripp }
5ecb8c8b041752f6b716054ff5cfc2c9992365c6Tripp}, Y.CanvasDrawing.prototype));
828c58761d90445b8b9d20a82d85dc1479317f71Tripp
828c58761d90445b8b9d20a82d85dc1479317f71TrippCanvasShape.ATTRS = {
828c58761d90445b8b9d20a82d85dc1479317f71Tripp /**
828c58761d90445b8b9d20a82d85dc1479317f71Tripp * 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
828c58761d90445b8b9d20a82d85dc1479317f71Tripp * fraction of the shape's corresponding bounding box dimension. The default value is [0.5, 0.5].
828c58761d90445b8b9d20a82d85dc1479317f71Tripp *
c093c1aed867e18aa4778708592e1ceb45d18cffTripp * @config transformOrigin
828c58761d90445b8b9d20a82d85dc1479317f71Tripp * @type Array
828c58761d90445b8b9d20a82d85dc1479317f71Tripp */
828c58761d90445b8b9d20a82d85dc1479317f71Tripp transformOrigin: {
828c58761d90445b8b9d20a82d85dc1479317f71Tripp valueFn: function()
828c58761d90445b8b9d20a82d85dc1479317f71Tripp {
828c58761d90445b8b9d20a82d85dc1479317f71Tripp return [0.5, 0.5];
828c58761d90445b8b9d20a82d85dc1479317f71Tripp }
828c58761d90445b8b9d20a82d85dc1479317f71Tripp },
2ebe57b26e070070dacbe6e2b3351d5cefaee874Tripp
2ebe57b26e070070dacbe6e2b3351d5cefaee874Tripp /**
6a3585e2672045e8e28e6a45f279f80aef446959Tripp * <p>A string containing, in order, transform operations applied to the shape instance. The `transform` string can contain the following values:
6a3585e2672045e8e28e6a45f279f80aef446959Tripp *
6a3585e2672045e8e28e6a45f279f80aef446959Tripp * <dl>
6a3585e2672045e8e28e6a45f279f80aef446959Tripp * <dt>rotate</dt><dd>Rotates the shape clockwise around it transformOrigin.</dd>
6a3585e2672045e8e28e6a45f279f80aef446959Tripp * <dt>translate</dt><dd>Specifies a 2d translation.</dd>
6a3585e2672045e8e28e6a45f279f80aef446959Tripp * <dt>skew</dt><dd>Skews the shape around the x-axis and y-axis.</dd>
6a3585e2672045e8e28e6a45f279f80aef446959Tripp * <dt>scale</dt><dd>Specifies a 2d scaling operation.</dd>
6a3585e2672045e8e28e6a45f279f80aef446959Tripp * <dt>translateX</dt><dd>Translates the shape along the x-axis.</dd>
6a3585e2672045e8e28e6a45f279f80aef446959Tripp * <dt>translateY</dt><dd>Translates the shape along the y-axis.</dd>
6a3585e2672045e8e28e6a45f279f80aef446959Tripp * <dt>skewX</dt><dd>Skews the shape around the x-axis.</dd>
6a3585e2672045e8e28e6a45f279f80aef446959Tripp * <dt>skewY</dt><dd>Skews the shape around the y-axis.</dd>
091085b5a65d589ca99904fd9e9dec757e17d543Tripp * <dt>matrix</dt><dd>Specifies a 2D transformation matrix comprised of the specified six values.</dd>
6a3585e2672045e8e28e6a45f279f80aef446959Tripp * </dl>
6a3585e2672045e8e28e6a45f279f80aef446959Tripp * </p>
6a3585e2672045e8e28e6a45f279f80aef446959Tripp * <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
6a3585e2672045e8e28e6a45f279f80aef446959Tripp * 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>
6a3585e2672045e8e28e6a45f279f80aef446959Tripp var myRect = new Y.Rect({
6a3585e2672045e8e28e6a45f279f80aef446959Tripp type:"rect",
6a3585e2672045e8e28e6a45f279f80aef446959Tripp width: 50,
6a3585e2672045e8e28e6a45f279f80aef446959Tripp height: 40,
6a3585e2672045e8e28e6a45f279f80aef446959Tripp transform: "rotate(45)"
6a3585e2672045e8e28e6a45f279f80aef446959Tripp };
6a3585e2672045e8e28e6a45f279f80aef446959Tripp * <p>The code below would apply `translate` and `rotate` to an existing shape.</p>
6a3585e2672045e8e28e6a45f279f80aef446959Tripp
6a3585e2672045e8e28e6a45f279f80aef446959Tripp myRect.set("transform", "translate(40, 50) rotate(45)");
2ebe57b26e070070dacbe6e2b3351d5cefaee874Tripp * @config transform
2ebe57b26e070070dacbe6e2b3351d5cefaee874Tripp * @type String
828c58761d90445b8b9d20a82d85dc1479317f71Tripp */
2ebe57b26e070070dacbe6e2b3351d5cefaee874Tripp transform: {
828c58761d90445b8b9d20a82d85dc1479317f71Tripp setter: function(val)
828c58761d90445b8b9d20a82d85dc1479317f71Tripp {
2ebe57b26e070070dacbe6e2b3351d5cefaee874Tripp this.matrix.init();
2ebe57b26e070070dacbe6e2b3351d5cefaee874Tripp this._transforms = this.matrix.getTransformArray(val);
2ebe57b26e070070dacbe6e2b3351d5cefaee874Tripp this._transform = val;
2ebe57b26e070070dacbe6e2b3351d5cefaee874Tripp if(this.initialized)
2ebe57b26e070070dacbe6e2b3351d5cefaee874Tripp {
2ebe57b26e070070dacbe6e2b3351d5cefaee874Tripp this._updateTransform();
2ebe57b26e070070dacbe6e2b3351d5cefaee874Tripp }
2ebe57b26e070070dacbe6e2b3351d5cefaee874Tripp return val;
09688ec5ffb8b9cf9883a770e2f9ebd60b28888dTripp },
09688ec5ffb8b9cf9883a770e2f9ebd60b28888dTripp
2ebe57b26e070070dacbe6e2b3351d5cefaee874Tripp getter: function()
2ebe57b26e070070dacbe6e2b3351d5cefaee874Tripp {
2ebe57b26e070070dacbe6e2b3351d5cefaee874Tripp return this._transform;
2ebe57b26e070070dacbe6e2b3351d5cefaee874Tripp }
828c58761d90445b8b9d20a82d85dc1479317f71Tripp },
828c58761d90445b8b9d20a82d85dc1479317f71Tripp
828c58761d90445b8b9d20a82d85dc1479317f71Tripp /**
66ca16dd76367c074fe4df1dcf7b555489a9bf85Tripp * Dom node for the shape
828c58761d90445b8b9d20a82d85dc1479317f71Tripp *
c093c1aed867e18aa4778708592e1ceb45d18cffTripp * @config node
828c58761d90445b8b9d20a82d85dc1479317f71Tripp * @type HTMLElement
828c58761d90445b8b9d20a82d85dc1479317f71Tripp * @readOnly
828c58761d90445b8b9d20a82d85dc1479317f71Tripp */
828c58761d90445b8b9d20a82d85dc1479317f71Tripp node: {
828c58761d90445b8b9d20a82d85dc1479317f71Tripp readOnly: true,
828c58761d90445b8b9d20a82d85dc1479317f71Tripp
828c58761d90445b8b9d20a82d85dc1479317f71Tripp getter: function()
828c58761d90445b8b9d20a82d85dc1479317f71Tripp {
828c58761d90445b8b9d20a82d85dc1479317f71Tripp return this.node;
828c58761d90445b8b9d20a82d85dc1479317f71Tripp }
828c58761d90445b8b9d20a82d85dc1479317f71Tripp },
828c58761d90445b8b9d20a82d85dc1479317f71Tripp
828c58761d90445b8b9d20a82d85dc1479317f71Tripp /**
828c58761d90445b8b9d20a82d85dc1479317f71Tripp * Unique id for class instance.
828c58761d90445b8b9d20a82d85dc1479317f71Tripp *
c093c1aed867e18aa4778708592e1ceb45d18cffTripp * @config id
828c58761d90445b8b9d20a82d85dc1479317f71Tripp * @type String
828c58761d90445b8b9d20a82d85dc1479317f71Tripp */
828c58761d90445b8b9d20a82d85dc1479317f71Tripp id: {
828c58761d90445b8b9d20a82d85dc1479317f71Tripp valueFn: function()
828c58761d90445b8b9d20a82d85dc1479317f71Tripp {
828c58761d90445b8b9d20a82d85dc1479317f71Tripp return Y.guid();
c7ba96d16d58075a9ab8d5c1e46c6c83ce11cb4eTripp },
c7ba96d16d58075a9ab8d5c1e46c6c83ce11cb4eTripp
c7ba96d16d58075a9ab8d5c1e46c6c83ce11cb4eTripp setter: function(val)
c7ba96d16d58075a9ab8d5c1e46c6c83ce11cb4eTripp {
c7ba96d16d58075a9ab8d5c1e46c6c83ce11cb4eTripp var node = this.node;
c7ba96d16d58075a9ab8d5c1e46c6c83ce11cb4eTripp if(node)
c7ba96d16d58075a9ab8d5c1e46c6c83ce11cb4eTripp {
c7ba96d16d58075a9ab8d5c1e46c6c83ce11cb4eTripp node.setAttribute("id", val);
c7ba96d16d58075a9ab8d5c1e46c6c83ce11cb4eTripp }
c7ba96d16d58075a9ab8d5c1e46c6c83ce11cb4eTripp return val;
828c58761d90445b8b9d20a82d85dc1479317f71Tripp }
828c58761d90445b8b9d20a82d85dc1479317f71Tripp },
828c58761d90445b8b9d20a82d85dc1479317f71Tripp
828c58761d90445b8b9d20a82d85dc1479317f71Tripp /**
e7c7565d9550eaa87043aef0df77125ada996deaTripp * Indicates the width of the shape
e7c7565d9550eaa87043aef0df77125ada996deaTripp *
c093c1aed867e18aa4778708592e1ceb45d18cffTripp * @config width
e7c7565d9550eaa87043aef0df77125ada996deaTripp * @type Number
828c58761d90445b8b9d20a82d85dc1479317f71Tripp */
c7ba96d16d58075a9ab8d5c1e46c6c83ce11cb4eTripp width: {
c7ba96d16d58075a9ab8d5c1e46c6c83ce11cb4eTripp value: 0
c7ba96d16d58075a9ab8d5c1e46c6c83ce11cb4eTripp },
828c58761d90445b8b9d20a82d85dc1479317f71Tripp
828c58761d90445b8b9d20a82d85dc1479317f71Tripp /**
e7c7565d9550eaa87043aef0df77125ada996deaTripp * Indicates the height of the shape
e7c7565d9550eaa87043aef0df77125ada996deaTripp *
c093c1aed867e18aa4778708592e1ceb45d18cffTripp * @config height
e7c7565d9550eaa87043aef0df77125ada996deaTripp * @type Number
828c58761d90445b8b9d20a82d85dc1479317f71Tripp */
c7ba96d16d58075a9ab8d5c1e46c6c83ce11cb4eTripp height: {
c7ba96d16d58075a9ab8d5c1e46c6c83ce11cb4eTripp value: 0
c7ba96d16d58075a9ab8d5c1e46c6c83ce11cb4eTripp },
828c58761d90445b8b9d20a82d85dc1479317f71Tripp
828c58761d90445b8b9d20a82d85dc1479317f71Tripp /**
e7c7565d9550eaa87043aef0df77125ada996deaTripp * Indicates the x position of shape.
e7c7565d9550eaa87043aef0df77125ada996deaTripp *
c093c1aed867e18aa4778708592e1ceb45d18cffTripp * @config x
e7c7565d9550eaa87043aef0df77125ada996deaTripp * @type Number
828c58761d90445b8b9d20a82d85dc1479317f71Tripp */
828c58761d90445b8b9d20a82d85dc1479317f71Tripp x: {
828c58761d90445b8b9d20a82d85dc1479317f71Tripp value: 0
828c58761d90445b8b9d20a82d85dc1479317f71Tripp },
828c58761d90445b8b9d20a82d85dc1479317f71Tripp
828c58761d90445b8b9d20a82d85dc1479317f71Tripp /**
e7c7565d9550eaa87043aef0df77125ada996deaTripp * Indicates the y position of shape.
e7c7565d9550eaa87043aef0df77125ada996deaTripp *
c093c1aed867e18aa4778708592e1ceb45d18cffTripp * @config y
e7c7565d9550eaa87043aef0df77125ada996deaTripp * @type Number
828c58761d90445b8b9d20a82d85dc1479317f71Tripp */
828c58761d90445b8b9d20a82d85dc1479317f71Tripp y: {
828c58761d90445b8b9d20a82d85dc1479317f71Tripp value: 0
828c58761d90445b8b9d20a82d85dc1479317f71Tripp },
828c58761d90445b8b9d20a82d85dc1479317f71Tripp
828c58761d90445b8b9d20a82d85dc1479317f71Tripp /**
828c58761d90445b8b9d20a82d85dc1479317f71Tripp * Indicates whether the shape is visible.
828c58761d90445b8b9d20a82d85dc1479317f71Tripp *
c093c1aed867e18aa4778708592e1ceb45d18cffTripp * @config visible
828c58761d90445b8b9d20a82d85dc1479317f71Tripp * @type Boolean
828c58761d90445b8b9d20a82d85dc1479317f71Tripp */
828c58761d90445b8b9d20a82d85dc1479317f71Tripp visible: {
828c58761d90445b8b9d20a82d85dc1479317f71Tripp value: true,
828c58761d90445b8b9d20a82d85dc1479317f71Tripp
828c58761d90445b8b9d20a82d85dc1479317f71Tripp setter: function(val){
e188eaea1f0e60d808be8a4f6ccdbbd3c9b5039bTripp var node = this.get("node"),
e188eaea1f0e60d808be8a4f6ccdbbd3c9b5039bTripp visibility = val ? "visible" : "hidden";
e188eaea1f0e60d808be8a4f6ccdbbd3c9b5039bTripp if(node)
e188eaea1f0e60d808be8a4f6ccdbbd3c9b5039bTripp {
e188eaea1f0e60d808be8a4f6ccdbbd3c9b5039bTripp node.style.visibility = visibility;
e188eaea1f0e60d808be8a4f6ccdbbd3c9b5039bTripp }
828c58761d90445b8b9d20a82d85dc1479317f71Tripp return val;
828c58761d90445b8b9d20a82d85dc1479317f71Tripp }
828c58761d90445b8b9d20a82d85dc1479317f71Tripp },
828c58761d90445b8b9d20a82d85dc1479317f71Tripp
828c58761d90445b8b9d20a82d85dc1479317f71Tripp /**
828c58761d90445b8b9d20a82d85dc1479317f71Tripp * Contains information about the fill of the shape.
e0caea9528bfbb244d27129aa9dea5aebc07fc18Tripp * <dl>
e0caea9528bfbb244d27129aa9dea5aebc07fc18Tripp * <dt>color</dt><dd>The color of the fill.</dd>
e0caea9528bfbb244d27129aa9dea5aebc07fc18Tripp * <dt>opacity</dt><dd>Number between 0 and 1 that indicates the opacity of the fill. The default value is 1.</dd>
e0caea9528bfbb244d27129aa9dea5aebc07fc18Tripp * <dt>type</dt><dd>Type of fill.
e0caea9528bfbb244d27129aa9dea5aebc07fc18Tripp * <dl>
e0caea9528bfbb244d27129aa9dea5aebc07fc18Tripp * <dt>solid</dt><dd>Solid single color fill. (default)</dd>
e0caea9528bfbb244d27129aa9dea5aebc07fc18Tripp * <dt>linear</dt><dd>Linear gradient fill.</dd>
e0caea9528bfbb244d27129aa9dea5aebc07fc18Tripp * <dt>radial</dt><dd>Radial gradient fill.</dd>
e0caea9528bfbb244d27129aa9dea5aebc07fc18Tripp * </dl>
e0caea9528bfbb244d27129aa9dea5aebc07fc18Tripp * </dd>
e0caea9528bfbb244d27129aa9dea5aebc07fc18Tripp * </dl>
e0caea9528bfbb244d27129aa9dea5aebc07fc18Tripp * <p>If a `linear` or `radial` is specified as the fill type. The following additional property is used:
e0caea9528bfbb244d27129aa9dea5aebc07fc18Tripp * <dl>
e0caea9528bfbb244d27129aa9dea5aebc07fc18Tripp * <dt>stops</dt><dd>An array of objects containing the following properties:
e0caea9528bfbb244d27129aa9dea5aebc07fc18Tripp * <dl>
e0caea9528bfbb244d27129aa9dea5aebc07fc18Tripp * <dt>color</dt><dd>The color of the stop.</dd>
e0caea9528bfbb244d27129aa9dea5aebc07fc18Tripp * <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>
e0caea9528bfbb244d27129aa9dea5aebc07fc18Tripp * <dt>offset</dt><dd>Number between 0 and 1 indicating where the color stop is positioned.</dd>
e0caea9528bfbb244d27129aa9dea5aebc07fc18Tripp * </dl>
e0caea9528bfbb244d27129aa9dea5aebc07fc18Tripp * </dd>
e0caea9528bfbb244d27129aa9dea5aebc07fc18Tripp * <p>Linear gradients also have the following property:</p>
e0caea9528bfbb244d27129aa9dea5aebc07fc18Tripp * <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>
e0caea9528bfbb244d27129aa9dea5aebc07fc18Tripp * <p>Radial gradients have the following additional properties:</p>
e0caea9528bfbb244d27129aa9dea5aebc07fc18Tripp * <dt>r</dt><dd>Radius of the gradient circle.</dd>
e0caea9528bfbb244d27129aa9dea5aebc07fc18Tripp * <dt>fx</dt><dd>Focal point x-coordinate of the gradient.</dd>
e0caea9528bfbb244d27129aa9dea5aebc07fc18Tripp * <dt>fy</dt><dd>Focal point y-coordinate of the gradient.</dd>
e0caea9528bfbb244d27129aa9dea5aebc07fc18Tripp * </dl>
e0caea9528bfbb244d27129aa9dea5aebc07fc18Tripp * <p>The corresponding `SVGShape` class implements the following additional properties.</p>
e0caea9528bfbb244d27129aa9dea5aebc07fc18Tripp * <dl>
e0caea9528bfbb244d27129aa9dea5aebc07fc18Tripp * <dt>cx</dt><dd>
e0caea9528bfbb244d27129aa9dea5aebc07fc18Tripp * <p>The x-coordinate of the center of the gradient circle. Determines where the color stop begins. The default value 0.5.</p>
e0caea9528bfbb244d27129aa9dea5aebc07fc18Tripp * </dd>
e0caea9528bfbb244d27129aa9dea5aebc07fc18Tripp * <dt>cy</dt><dd>
e0caea9528bfbb244d27129aa9dea5aebc07fc18Tripp * <p>The y-coordinate of the center of the gradient circle. Determines where the color stop begins. The default value 0.5.</p>
e0caea9528bfbb244d27129aa9dea5aebc07fc18Tripp * </dd>
e0caea9528bfbb244d27129aa9dea5aebc07fc18Tripp * </dl>
e0caea9528bfbb244d27129aa9dea5aebc07fc18Tripp * <p>These properties are not currently implemented in `CanvasShape` or `VMLShape`.</p>
828c58761d90445b8b9d20a82d85dc1479317f71Tripp *
c093c1aed867e18aa4778708592e1ceb45d18cffTripp * @config fill
828c58761d90445b8b9d20a82d85dc1479317f71Tripp * @type Object
828c58761d90445b8b9d20a82d85dc1479317f71Tripp */
828c58761d90445b8b9d20a82d85dc1479317f71Tripp fill: {
828c58761d90445b8b9d20a82d85dc1479317f71Tripp valueFn: "_getDefaultFill",
828c58761d90445b8b9d20a82d85dc1479317f71Tripp
828c58761d90445b8b9d20a82d85dc1479317f71Tripp setter: function(val)
828c58761d90445b8b9d20a82d85dc1479317f71Tripp {
828c58761d90445b8b9d20a82d85dc1479317f71Tripp var fill,
828c58761d90445b8b9d20a82d85dc1479317f71Tripp tmpl = this.get("fill") || this._getDefaultFill();
828c58761d90445b8b9d20a82d85dc1479317f71Tripp fill = (val) ? Y.merge(tmpl, val) : null;
828c58761d90445b8b9d20a82d85dc1479317f71Tripp if(fill && fill.color)
09688ec5ffb8b9cf9883a770e2f9ebd60b28888dTripp {
828c58761d90445b8b9d20a82d85dc1479317f71Tripp if(fill.color === undefined || fill.color == "none")
828c58761d90445b8b9d20a82d85dc1479317f71Tripp {
828c58761d90445b8b9d20a82d85dc1479317f71Tripp fill.color = null;
828c58761d90445b8b9d20a82d85dc1479317f71Tripp }
09688ec5ffb8b9cf9883a770e2f9ebd60b28888dTripp }
828c58761d90445b8b9d20a82d85dc1479317f71Tripp this._setFillProps(fill);
828c58761d90445b8b9d20a82d85dc1479317f71Tripp return fill;
828c58761d90445b8b9d20a82d85dc1479317f71Tripp }
828c58761d90445b8b9d20a82d85dc1479317f71Tripp },
828c58761d90445b8b9d20a82d85dc1479317f71Tripp
828c58761d90445b8b9d20a82d85dc1479317f71Tripp /**
828c58761d90445b8b9d20a82d85dc1479317f71Tripp * Contains information about the stroke of the shape.
e0caea9528bfbb244d27129aa9dea5aebc07fc18Tripp * <dl>
e0caea9528bfbb244d27129aa9dea5aebc07fc18Tripp * <dt>color</dt><dd>The color of the stroke.</dd>
e0caea9528bfbb244d27129aa9dea5aebc07fc18Tripp * <dt>weight</dt><dd>Number that indicates the width of the stroke.</dd>
e0caea9528bfbb244d27129aa9dea5aebc07fc18Tripp * <dt>opacity</dt><dd>Number between 0 and 1 that indicates the opacity of the stroke. The default value is 1.</dd>
e0caea9528bfbb244d27129aa9dea5aebc07fc18Tripp * <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
e0caea9528bfbb244d27129aa9dea5aebc07fc18Tripp * length of the dash. The second index indicates the length of gap.
e0caea9528bfbb244d27129aa9dea5aebc07fc18Tripp * <dt>linecap</dt><dd>Specifies the linecap for the stroke. The following values can be specified:
e0caea9528bfbb244d27129aa9dea5aebc07fc18Tripp * <dl>
e0caea9528bfbb244d27129aa9dea5aebc07fc18Tripp * <dt>butt (default)</dt><dd>Specifies a butt linecap.</dd>
e0caea9528bfbb244d27129aa9dea5aebc07fc18Tripp * <dt>square</dt><dd>Specifies a sqare linecap.</dd>
e0caea9528bfbb244d27129aa9dea5aebc07fc18Tripp * <dt>round</dt><dd>Specifies a round linecap.</dd>
e0caea9528bfbb244d27129aa9dea5aebc07fc18Tripp * </dl>
e0caea9528bfbb244d27129aa9dea5aebc07fc18Tripp * </dd>
e0caea9528bfbb244d27129aa9dea5aebc07fc18Tripp * <dt>linejoin</dt><dd>Specifies a linejoin for the stroke. The following values can be specified:
e0caea9528bfbb244d27129aa9dea5aebc07fc18Tripp * <dl>
e0caea9528bfbb244d27129aa9dea5aebc07fc18Tripp * <dt>round (default)</dt><dd>Specifies that the linejoin will be round.</dd>
e0caea9528bfbb244d27129aa9dea5aebc07fc18Tripp * <dt>bevel</dt><dd>Specifies a bevel for the linejoin.</dd>
e0caea9528bfbb244d27129aa9dea5aebc07fc18Tripp * <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
e0caea9528bfbb244d27129aa9dea5aebc07fc18Tripp * separate miter and miter limit values.</dd>
e0caea9528bfbb244d27129aa9dea5aebc07fc18Tripp * </dl>
e0caea9528bfbb244d27129aa9dea5aebc07fc18Tripp * </dd>
e0caea9528bfbb244d27129aa9dea5aebc07fc18Tripp * </dl>
828c58761d90445b8b9d20a82d85dc1479317f71Tripp *
c093c1aed867e18aa4778708592e1ceb45d18cffTripp * @config stroke
828c58761d90445b8b9d20a82d85dc1479317f71Tripp * @type Object
828c58761d90445b8b9d20a82d85dc1479317f71Tripp */
828c58761d90445b8b9d20a82d85dc1479317f71Tripp stroke: {
828c58761d90445b8b9d20a82d85dc1479317f71Tripp valueFn: "_getDefaultStroke",
828c58761d90445b8b9d20a82d85dc1479317f71Tripp
828c58761d90445b8b9d20a82d85dc1479317f71Tripp setter: function(val)
828c58761d90445b8b9d20a82d85dc1479317f71Tripp {
2b904e83040752143af70b087f637e39035bb2e6Tripp var tmpl = this.get("stroke") || this._getDefaultStroke(),
2b904e83040752143af70b087f637e39035bb2e6Tripp wt;
2b904e83040752143af70b087f637e39035bb2e6Tripp if(val && val.hasOwnProperty("weight"))
2b904e83040752143af70b087f637e39035bb2e6Tripp {
2b904e83040752143af70b087f637e39035bb2e6Tripp wt = parseInt(val.weight, 10);
2b904e83040752143af70b087f637e39035bb2e6Tripp if(!isNaN(wt))
2b904e83040752143af70b087f637e39035bb2e6Tripp {
2b904e83040752143af70b087f637e39035bb2e6Tripp val.weight = wt;
2b904e83040752143af70b087f637e39035bb2e6Tripp }
2b904e83040752143af70b087f637e39035bb2e6Tripp }
828c58761d90445b8b9d20a82d85dc1479317f71Tripp val = (val) ? Y.merge(tmpl, val) : null;
828c58761d90445b8b9d20a82d85dc1479317f71Tripp this._setStrokeProps(val);
828c58761d90445b8b9d20a82d85dc1479317f71Tripp return val;
828c58761d90445b8b9d20a82d85dc1479317f71Tripp }
828c58761d90445b8b9d20a82d85dc1479317f71Tripp },
828c58761d90445b8b9d20a82d85dc1479317f71Tripp
a75ebc38c1de401b679953a9b87bd323f0f48d02Tripp //Not used. Remove in future.
828c58761d90445b8b9d20a82d85dc1479317f71Tripp autoSize: {
828c58761d90445b8b9d20a82d85dc1479317f71Tripp value: false
828c58761d90445b8b9d20a82d85dc1479317f71Tripp },
828c58761d90445b8b9d20a82d85dc1479317f71Tripp
a75ebc38c1de401b679953a9b87bd323f0f48d02Tripp // Only implemented in SVG
a75ebc38c1de401b679953a9b87bd323f0f48d02Tripp // Determines whether the instance will receive mouse events.
a75ebc38c1de401b679953a9b87bd323f0f48d02Tripp //
a75ebc38c1de401b679953a9b87bd323f0f48d02Tripp // @config pointerEvents
a75ebc38c1de401b679953a9b87bd323f0f48d02Tripp // @type string
a75ebc38c1de401b679953a9b87bd323f0f48d02Tripp //
828c58761d90445b8b9d20a82d85dc1479317f71Tripp pointerEvents: {
828c58761d90445b8b9d20a82d85dc1479317f71Tripp value: "visiblePainted"
828c58761d90445b8b9d20a82d85dc1479317f71Tripp },
828c58761d90445b8b9d20a82d85dc1479317f71Tripp
828c58761d90445b8b9d20a82d85dc1479317f71Tripp /**
828c58761d90445b8b9d20a82d85dc1479317f71Tripp * Reference to the container Graphic.
828c58761d90445b8b9d20a82d85dc1479317f71Tripp *
c093c1aed867e18aa4778708592e1ceb45d18cffTripp * @config graphic
828c58761d90445b8b9d20a82d85dc1479317f71Tripp * @type Graphic
828c58761d90445b8b9d20a82d85dc1479317f71Tripp */
828c58761d90445b8b9d20a82d85dc1479317f71Tripp graphic: {
828c58761d90445b8b9d20a82d85dc1479317f71Tripp readOnly: true,
828c58761d90445b8b9d20a82d85dc1479317f71Tripp
828c58761d90445b8b9d20a82d85dc1479317f71Tripp getter: function()
828c58761d90445b8b9d20a82d85dc1479317f71Tripp {
828c58761d90445b8b9d20a82d85dc1479317f71Tripp return this._graphic;
09688ec5ffb8b9cf9883a770e2f9ebd60b28888dTripp }
14bfa36e35102dbf271dcff98f773a01c75bd503Tripp }
828c58761d90445b8b9d20a82d85dc1479317f71Tripp};
828c58761d90445b8b9d20a82d85dc1479317f71TrippY.CanvasShape = CanvasShape;