Add Ellipse
Project: http://git-wip-us.apache.org/repos/asf/flex-asjs/repo Commit: http://git-wip-us.apache.org/repos/asf/flex-asjs/commit/e213ce76 Tree: http://git-wip-us.apache.org/repos/asf/flex-asjs/tree/e213ce76 Diff: http://git-wip-us.apache.org/repos/asf/flex-asjs/diff/e213ce76 Branch: refs/heads/develop Commit: e213ce76e479db0428ea950ca7c7f670d4eb64a1 Parents: 1a16bd3 Author: Om <[email protected]> Authored: Fri Sep 5 17:19:00 2014 -0700 Committer: Om <[email protected]> Committed: Fri Sep 5 17:19:00 2014 -0700 ---------------------------------------------------------------------- .../org/apache/flex/core/graphics/Ellipse.as | 40 +++++++++++++ .../org/apache/flex/core/graphics/Ellipse.js | 60 ++++++++++++++++++++ 2 files changed, 100 insertions(+) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/flex-asjs/blob/e213ce76/frameworks/as/projects/FlexJSUI/src/org/apache/flex/core/graphics/Ellipse.as ---------------------------------------------------------------------- diff --git a/frameworks/as/projects/FlexJSUI/src/org/apache/flex/core/graphics/Ellipse.as b/frameworks/as/projects/FlexJSUI/src/org/apache/flex/core/graphics/Ellipse.as new file mode 100644 index 0000000..b851ac3 --- /dev/null +++ b/frameworks/as/projects/FlexJSUI/src/org/apache/flex/core/graphics/Ellipse.as @@ -0,0 +1,40 @@ +package org.apache.flex.core.graphics +{ + + public class Ellipse extends GraphicShape + { + + private var _x:Number; + private var _y:Number; + private var _width:Number; + private var _height:Number; + + /** + * Draw the ellipse. + * @param x The x position of the top-left corner of the bounding box of the ellipse. + * @param y The y position of the top-left corner of the bounding box of the ellipse. + * @param width The width of the ellipse. + * @param height The height of the ellipse. + * + * @langversion 3.0 + * @playerversion Flash 10.2 + * @playerversion AIR 2.6 + * @productversion FlexJS 0.0 + */ + public function drawEllipse(x:Number, y:Number, width:Number, height:Number):void + { + graphics.clear(); + if(stroke) + { + graphics.lineStyle(stroke.weight,stroke.color,stroke.alpha); + } + if(fill) + { + graphics.beginFill(fill.color,fill.alpha); + } + graphics.drawEllipse(x,y,width,height); + graphics.endFill(); + } + + } +} \ No newline at end of file http://git-wip-us.apache.org/repos/asf/flex-asjs/blob/e213ce76/frameworks/js/FlexJS/src/org/apache/flex/core/graphics/Ellipse.js ---------------------------------------------------------------------- diff --git a/frameworks/js/FlexJS/src/org/apache/flex/core/graphics/Ellipse.js b/frameworks/js/FlexJS/src/org/apache/flex/core/graphics/Ellipse.js new file mode 100644 index 0000000..a2033df --- /dev/null +++ b/frameworks/js/FlexJS/src/org/apache/flex/core/graphics/Ellipse.js @@ -0,0 +1,60 @@ +/** + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +goog.provide('org.apache.flex.core.graphics.Ellipse'); + +goog.require('org.apache.flex.core.graphics.GraphicShape'); + + + +/** + * @constructor + * @extends {org.apache.flex.core.graphics.GraphicShape} + */ +org.apache.flex.core.graphics.Ellipse = function() { + org.apache.flex.core.graphics.Ellipse.base(this, 'constructor'); + +}; +goog.inherits(org.apache.flex.core.graphics.Ellipse, + org.apache.flex.core.graphics.GraphicShape); + + +/** + * Metadata + * + * @type {Object.<string, Array.<Object>>} + */ +org.apache.flex.core.graphics.Ellipse.prototype.FLEXJS_CLASS_INFO = + { names: [{ name: 'Ellipse', + qName: 'org.apache.flex.core.graphics.Ellipse' }] }; + + +/** + * @expose + * @param {number} x The x position of the top-left corner of the bounding box of the ellipse. + * @param {number} y The y position of the top-left corner of the bounding box of the ellipse. + * @param {number} width The width of the ellipse. + * @param {number} height The height of the ellipse. + */ +org.apache.flex.core.graphics.Ellipse.prototype.drawEllipse = function(x, y, width, height) { + var style = this.getStyleStr(); + var ellipse = document.createElementNS('http://www.w3.org/2000/svg', 'ellipse'); + ellipse.setAttribute('style', style); + ellipse.setAttribute('cx', String(width/2 + this.get_stroke().get_weight() )); + ellipse.setAttribute('cy', String(height/2 + this.get_stroke().get_weight() )); + ellipse.setAttribute('rx', String(width/2)); + ellipse.setAttribute('ry', String(height/2)); + this.element.appendChild(ellipse); + this.resize(x,y,width+this.get_stroke().get_weight()*2,height+this.get_stroke().get_weight()*2); +};
