flex-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From bigosma...@apache.org
Subject [1/7] git commit: [flex-asjs] [refs/heads/develop] - Added support for LinearGradient on AS3 side. JS version, up next
Date Wed, 17 Sep 2014 01:25:25 GMT
Repository: flex-asjs
Updated Branches:
  refs/heads/develop e6419b7a8 -> 9999c237a


Added support for LinearGradient on AS3 side.  JS version, up next


Project: http://git-wip-us.apache.org/repos/asf/flex-asjs/repo
Commit: http://git-wip-us.apache.org/repos/asf/flex-asjs/commit/4fce4e59
Tree: http://git-wip-us.apache.org/repos/asf/flex-asjs/tree/4fce4e59
Diff: http://git-wip-us.apache.org/repos/asf/flex-asjs/diff/4fce4e59

Branch: refs/heads/develop
Commit: 4fce4e59e119a55d1959eec6cbb316d0d830fb57
Parents: e6419b7
Author: Om <bigosmallm@gmail.com>
Authored: Mon Sep 15 12:24:41 2014 -0700
Committer: Om <bigosmallm@gmail.com>
Committed: Tue Sep 16 18:24:44 2014 -0700

----------------------------------------------------------------------
 examples/FlexJSTest_SVG/src/GraphicsView.mxml   |  21 ++
 .../as/projects/FlexJSUI/src/FlexJSUIClasses.as |   1 +
 .../src/org/apache/flex/core/graphics/Circle.as |  15 +-
 .../org/apache/flex/core/graphics/Ellipse.as    |  13 +-
 .../apache/flex/core/graphics/GradientBase.as   | 191 +++++++++++++++++++
 .../apache/flex/core/graphics/GradientEntry.as  | 127 ++++++++++++
 .../apache/flex/core/graphics/GraphicShape.as   |  18 +-
 .../flex/core/graphics/GraphicsContainer.as     |  11 +-
 .../src/org/apache/flex/core/graphics/IFill.as  |   4 +-
 .../apache/flex/core/graphics/LinearGradient.as |  56 ++++++
 .../src/org/apache/flex/core/graphics/Path.as   |  13 +-
 .../src/org/apache/flex/core/graphics/Rect.as   |  13 +-
 .../org/apache/flex/core/graphics/SolidColor.as |   4 +-
 13 files changed, 432 insertions(+), 55 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/flex-asjs/blob/4fce4e59/examples/FlexJSTest_SVG/src/GraphicsView.mxml
----------------------------------------------------------------------
diff --git a/examples/FlexJSTest_SVG/src/GraphicsView.mxml b/examples/FlexJSTest_SVG/src/GraphicsView.mxml
index 5e562df..bad453c 100644
--- a/examples/FlexJSTest_SVG/src/GraphicsView.mxml
+++ b/examples/FlexJSTest_SVG/src/GraphicsView.mxml
@@ -26,7 +26,9 @@ limitations under the License.
         <![CDATA[            
 			import org.apache.flex.core.graphics.Circle;
 			import org.apache.flex.core.graphics.Ellipse;
+			import org.apache.flex.core.graphics.GradientEntry;
 			import org.apache.flex.core.graphics.GraphicsContainer;
+			import org.apache.flex.core.graphics.LinearGradient;
 			import org.apache.flex.core.graphics.Path;
 			import org.apache.flex.core.graphics.Rect;
 			import org.apache.flex.core.graphics.SolidColor;
@@ -195,21 +197,40 @@ limitations under the License.
 				var container:GraphicsContainer = new GraphicsContainer();
 				container.fill = fill;
 				container.stroke = stroke;
+				//Circle
 				container.drawCircle(300,300,200);
 				fill.color = 0x00FF00;
 				stroke.color = 0x0000FF;
+				//Rect
 				container.drawRect(0,400,500,200);
 				fill.color = 0x00FFFF;
 				stroke.color = 0xFF00FF;
+				//Ellipse
 				container.drawEllipse(600,300,200,300);
 				fill.color = 0xCCCC00;
 				stroke.color = 0x000000;
+				//Path
 				container.drawPath("M 100 350 q 150 -300 300 0");
 				fill.color = 0x00CCCC;
 				stroke.color = 0x0CCCC0C;
 				stroke.weight = 5;
 				container.drawPath("M 800 800 L 900 800 A 100 100 0 0 0 800 700 Z");
 				
+				//LinearGradient Fill
+				var lg:LinearGradient = new LinearGradient();
+				lg.entries = [new GradientEntry(1,0xFFFFFF,0), new GradientEntry(1,0x000000,1)];
+				lg.scaleX = 1;
+				lg.rotation = 0;
+				container.fill = lg;
+				container.drawRect(20,20,200,100);
+				this.addElement(container);
+
+				var lg:LinearGradient = new LinearGradient();
+				lg.entries = [new GradientEntry(0.5,0xFFFFFF,0), new GradientEntry(0.9,0x000000,1)];
+				lg.scaleX = 2;
+				lg.rotation = 90;
+				container.fill = lg;
+				container.drawCircle(400, 400, 300);
 				this.addElement(container);
 			}
 			

http://git-wip-us.apache.org/repos/asf/flex-asjs/blob/4fce4e59/frameworks/as/projects/FlexJSUI/src/FlexJSUIClasses.as
----------------------------------------------------------------------
diff --git a/frameworks/as/projects/FlexJSUI/src/FlexJSUIClasses.as b/frameworks/as/projects/FlexJSUI/src/FlexJSUIClasses.as
index 40bba34..a8e2a45 100644
--- a/frameworks/as/projects/FlexJSUI/src/FlexJSUIClasses.as
+++ b/frameworks/as/projects/FlexJSUI/src/FlexJSUIClasses.as
@@ -124,6 +124,7 @@ internal class FlexJSUIClasses
 	import org.apache.flex.core.graphics.SolidColor; SolidColor;
 	import org.apache.flex.core.graphics.SolidColorStroke; SolidColorStroke;
 	import org.apache.flex.core.graphics.GraphicsContainer; GraphicsContainer;
+	import org.apache.flex.core.graphics.LinearGradient; LinearGradient;
     
 	import mx.core.ClassFactory; ClassFactory;
     import mx.states.AddItems; AddItems;

http://git-wip-us.apache.org/repos/asf/flex-asjs/blob/4fce4e59/frameworks/as/projects/FlexJSUI/src/org/apache/flex/core/graphics/Circle.as
----------------------------------------------------------------------
diff --git a/frameworks/as/projects/FlexJSUI/src/org/apache/flex/core/graphics/Circle.as b/frameworks/as/projects/FlexJSUI/src/org/apache/flex/core/graphics/Circle.as
index 5e5cc29..d49a8a6 100644
--- a/frameworks/as/projects/FlexJSUI/src/org/apache/flex/core/graphics/Circle.as
+++ b/frameworks/as/projects/FlexJSUI/src/org/apache/flex/core/graphics/Circle.as
@@ -1,7 +1,6 @@
 package org.apache.flex.core.graphics
 {
-	import flash.display.CapsStyle;
-	import flash.display.JointStyle;
+	import flash.geom.Rectangle;
 
 	public class Circle extends GraphicShape
 	{
@@ -20,16 +19,10 @@ package org.apache.flex.core.graphics
 		public function drawCircle(x:Number, y:Number, radius:Number):void
 		{
 			graphics.clear();
-			if(stroke)
-			{
-				graphics.lineStyle(stroke.weight,stroke.color,stroke.alpha,false,"normal",CapsStyle.SQUARE,JointStyle.MITER);
-			}
-			if(fill)
-			{
-				graphics.beginFill(fill.color,fill.alpha);
-			}
+			applyStroke();
+			beginFill(new Rectangle(x, y, radius*2, radius*2));
 			graphics.drawCircle(x,y,radius);
-			graphics.endFill();
+			endFill();
 		}
 		
 	}

http://git-wip-us.apache.org/repos/asf/flex-asjs/blob/4fce4e59/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
index 0763c3b..db1a6ae 100644
--- 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
@@ -2,6 +2,7 @@ package org.apache.flex.core.graphics
 {
 	import flash.display.CapsStyle;
 	import flash.display.JointStyle;
+	import flash.geom.Rectangle;
 
 	public class Ellipse extends GraphicShape
 	{
@@ -21,16 +22,10 @@ package org.apache.flex.core.graphics
 		public function drawEllipse(x:Number, y:Number, width:Number, height:Number):void
 		{
 			graphics.clear();
-			if(stroke)
-			{
-				graphics.lineStyle(stroke.weight,stroke.color,stroke.alpha,false,"normal",CapsStyle.SQUARE,JointStyle.MITER);
-			}
-			if(fill)
-			{
-				graphics.beginFill(fill.color,fill.alpha);
-			}
+			applyStroke();
+			beginFill(new Rectangle(x, y, width, height));
 			graphics.drawEllipse(x,y,width,height);
-			graphics.endFill();
+			endFill();
 		}
 		
 	}

http://git-wip-us.apache.org/repos/asf/flex-asjs/blob/4fce4e59/frameworks/as/projects/FlexJSUI/src/org/apache/flex/core/graphics/GradientBase.as
----------------------------------------------------------------------
diff --git a/frameworks/as/projects/FlexJSUI/src/org/apache/flex/core/graphics/GradientBase.as
b/frameworks/as/projects/FlexJSUI/src/org/apache/flex/core/graphics/GradientBase.as
new file mode 100644
index 0000000..82c740b
--- /dev/null
+++ b/frameworks/as/projects/FlexJSUI/src/org/apache/flex/core/graphics/GradientBase.as
@@ -0,0 +1,191 @@
+/**
+ * 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.
+ */
+
+package org.apache.flex.core.graphics
+{
+
+	public class GradientBase
+	{
+		
+		protected var colors:Array /* of uint */ = [];
+		
+		protected var ratios:Array /* of Number */ = [];
+		
+		protected var alphas:Array /* of Number */ = [];
+		
+
+		/**
+		 *  Storage for the entries property.
+		 */
+		private var _entries:Array = [];
+		
+		/**
+		 *  @private
+		 *  Storage for the rotation property.
+		 */
+		private var _rotation:Number = 0.0;
+		
+		/**
+		 *  An Array of GradientEntry objects
+		 *  defining the fill patterns for the gradient fill.
+		 *
+		 */
+		public function get entries():Array
+		{
+			return _entries;
+		}
+		
+		/**
+		 *  @private
+		 */
+		public function set entries(value:Array):void
+		{
+			_entries = value;
+			processEntries();
+		}
+		
+		/**
+		 *  By default, the LinearGradientStroke defines a transition
+		 *  from left to right across the control. 
+		 *  Use the <code>rotation</code> property to control the transition direction.

+		 *  For example, a value of 180.0 causes the transition
+		 *  to occur from right to left, rather than from left to right.
+		 *
+		 *  @default 0.0
+		 *  
+		 *  @langversion 3.0
+		 *  @playerversion Flash 9
+		 *  @playerversion AIR 1.1
+		 *  @productversion Flex 3
+		 */
+		public function get rotation():Number
+		{
+			return _rotation;
+		}
+		
+		/**
+		 *  @private
+		 */
+		public function set rotation(value:Number):void
+		{
+			_rotation = value;   
+		}
+		
+		
+		private var _x:Number = 0;
+		
+		/**
+		 *  The distance by which to translate each point along the x axis.
+		 */
+		public function get x():Number
+		{
+			return _x;
+		}
+		
+		/**
+		 *  @private
+		 */
+		public function set x(value:Number):void
+		{
+			_x = value;
+		}
+		
+		private var _y:Number = 0;
+		
+		/**
+		 *  The distance by which to translate each point along the y axis.
+		 */
+		public function get y():Number
+		{
+			return _y;    
+		}
+		
+		/**
+		 *  @private
+		 */
+		public function set y(value:Number):void
+		{
+			_y = value;                
+		}
+
+		
+		protected function toRad(a:Number):Number {
+			return a*Math.PI/180;
+		}
+		
+		/**
+		 *  @private
+		 *  Extract the gradient information in the public <code>entries</code>
+		 *  Array into the internal <code>colors</code>, <code>ratios</code>,
+		 *  and <code>alphas</code> arrays.
+		 */
+		private function processEntries():void
+		{
+			colors = [];
+			ratios = [];
+			alphas = [];
+			
+			if (!_entries || _entries.length == 0)
+				return;
+			
+			var ratioConvert:Number = 255;
+			
+			var i:int;
+			
+			var n:int = _entries.length;
+			for (i = 0; i < n; i++)
+			{
+				var e:GradientEntry = _entries[i];
+				colors.push(e.color);
+				alphas.push(e.alpha);
+				ratios.push(e.ratio * ratioConvert);
+			}
+			
+			if (isNaN(ratios[0]))
+				ratios[0] = 0;
+			
+			if (isNaN(ratios[n - 1]))
+				ratios[n - 1] = 255;
+			
+			i = 1;
+			
+			while (true)
+			{
+				while (i < n && !isNaN(ratios[i]))
+				{
+					i++;
+				}
+				
+				if (i == n)
+					break;
+				
+				var start:int = i - 1;
+				
+				while (i < n && isNaN(ratios[i]))
+				{
+					i++;
+				}
+				
+				var br:Number = ratios[start];
+				var tr:Number = ratios[i];
+				
+				for (var j:int = 1; j < i - start; j++)
+				{
+					ratios[j] = br + j * (tr - br) / (i - start);
+				}
+			}
+		}
+
+	}
+}
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/flex-asjs/blob/4fce4e59/frameworks/as/projects/FlexJSUI/src/org/apache/flex/core/graphics/GradientEntry.as
----------------------------------------------------------------------
diff --git a/frameworks/as/projects/FlexJSUI/src/org/apache/flex/core/graphics/GradientEntry.as
b/frameworks/as/projects/FlexJSUI/src/org/apache/flex/core/graphics/GradientEntry.as
new file mode 100644
index 0000000..92a1765
--- /dev/null
+++ b/frameworks/as/projects/FlexJSUI/src/org/apache/flex/core/graphics/GradientEntry.as
@@ -0,0 +1,127 @@
+/**
+ * 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.
+ */
+
+package org.apache.flex.core.graphics
+{
+	public class GradientEntry
+	{
+		
+		//----------------------------------
+		//  alpha
+		//----------------------------------
+		
+		private var _alpha:Number = 1.0;
+		//----------------------------------
+		//  color
+		//----------------------------------
+		
+		private var _color:uint = 0x000000;
+		//----------------------------------
+		//  ratio
+		//----------------------------------
+		
+		private var _ratio:Number = 0x000000;
+		
+		
+		public function GradientEntry(alpha:Number, color:uint, ratio:Number)
+		{
+			_alpha = alpha;
+			_color = color;
+			_ratio = ratio;
+		}
+		
+		/**
+		 *  The transparency of a color.
+		 *  Possible values are 0.0 (invisible) through 1.0 (opaque). 
+		 *  
+		 *  @default 1.0
+		 *  
+	     *  @langversion 3.0
+	     *  @playerversion Flash 10.2
+	     *  @playerversion AIR 2.6
+	     *  @productversion FlexJS 0.3
+		 */
+		public function get alpha():Number
+		{
+			return _alpha;
+		}
+		
+		public function set alpha(value:Number):void
+		{
+			var oldValue:Number = _alpha;
+			if (value != oldValue)
+			{
+				_alpha = value;
+			}
+		}
+		
+		/**
+		 *  A color value. 
+		 *  
+		 *  @langversion 3.0
+		 *  @playerversion Flash 9
+		 *  @playerversion AIR 1.1
+	     *  @productversion FlexJS 0.3
+		 */
+		public function get color():uint
+		{
+			return _color;
+		}
+		
+		public function set color(value:uint):void
+		{
+			var oldValue:uint = _color;
+			if (value != oldValue)
+			{
+				_color = value;
+			}
+		}
+		
+		/**
+		 *  Where in the graphical element, as a percentage from 0.0 to 1.0,
+     	 *  Flex samples the associated color at 100%.  
+		 *  
+		 *  @langversion 3.0
+		 *  @playerversion Flash 9
+		 *  @playerversion AIR 1.1
+	     *  @productversion FlexJS 0.3
+		 */
+		public function get ratio():Number
+		{
+			return _ratio;
+		}
+
+		public function set ratio(value:Number):void
+		{
+			_ratio = value;
+		}
+		
+		/**
+		 * Begin drawing the fill on the given shape's graphic object
+		 */
+		public function begin(s:GraphicShape):void
+		{
+			s.graphics.beginFill(color,alpha);
+		}
+		
+		/**
+		 * End the fill
+		 */
+		public function end(s:GraphicShape):void
+		{
+			s.graphics.endFill();
+		}
+
+	}
+}
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/flex-asjs/blob/4fce4e59/frameworks/as/projects/FlexJSUI/src/org/apache/flex/core/graphics/GraphicShape.as
----------------------------------------------------------------------
diff --git a/frameworks/as/projects/FlexJSUI/src/org/apache/flex/core/graphics/GraphicShape.as
b/frameworks/as/projects/FlexJSUI/src/org/apache/flex/core/graphics/GraphicShape.as
index c2ab3f5..65c4f32 100644
--- a/frameworks/as/projects/FlexJSUI/src/org/apache/flex/core/graphics/GraphicShape.as
+++ b/frameworks/as/projects/FlexJSUI/src/org/apache/flex/core/graphics/GraphicShape.as
@@ -15,14 +15,16 @@
 package org.apache.flex.core.graphics
 {
 	
+	import flash.geom.Rectangle;
+	
 	import org.apache.flex.core.UIBase;
 	
 	public class GraphicShape extends UIBase
 	{
-		private var _fill:SolidColor;
-		private var _stroke:SolidColorStroke;
+		private var _fill:IFill;
+		private var _stroke:IStroke;
 		
-		public function get stroke():SolidColorStroke
+		public function get stroke():IStroke
 		{
 			return _stroke;
 		}
@@ -35,12 +37,12 @@ package org.apache.flex.core.graphics
 		 *  @playerversion AIR 1.1
 		 *  @productversion FlexJS 0.0
 		 */
-		public function set stroke(value:SolidColorStroke):void
+		public function set stroke(value:IStroke):void
 		{
 			_stroke = value;
 		}
 		
-		public function get fill():SolidColor
+		public function get fill():IFill
 		{
 			return _fill;
 		}
@@ -52,7 +54,7 @@ package org.apache.flex.core.graphics
 		 *  @playerversion AIR 1.1
 		 *  @productversion FlexJS 0.0
 		 */
-		public function set fill(value:SolidColor):void
+		public function set fill(value:IFill):void
 		{
 			_fill = value;
 		}
@@ -65,11 +67,11 @@ package org.apache.flex.core.graphics
 			}
 		}
 		
-		protected function beginFill():void
+		protected function beginFill(targetBounds:Rectangle):void
 		{
 			if(fill)
 			{
-				fill.begin(this);
+				fill.begin(this, targetBounds);
 			}
 		}
 		

http://git-wip-us.apache.org/repos/asf/flex-asjs/blob/4fce4e59/frameworks/as/projects/FlexJSUI/src/org/apache/flex/core/graphics/GraphicsContainer.as
----------------------------------------------------------------------
diff --git a/frameworks/as/projects/FlexJSUI/src/org/apache/flex/core/graphics/GraphicsContainer.as
b/frameworks/as/projects/FlexJSUI/src/org/apache/flex/core/graphics/GraphicsContainer.as
index 2d1c347..c99b3a7 100644
--- a/frameworks/as/projects/FlexJSUI/src/org/apache/flex/core/graphics/GraphicsContainer.as
+++ b/frameworks/as/projects/FlexJSUI/src/org/apache/flex/core/graphics/GraphicsContainer.as
@@ -14,9 +14,8 @@
  
 package org.apache.flex.core.graphics
 {
-	import flash.display.CapsStyle;
 	import flash.display.GraphicsPath;
-	import flash.display.JointStyle;
+	import flash.geom.Rectangle;
 	
 	import org.apache.flex.core.graphics.utils.PathHelper;
 	
@@ -45,7 +44,7 @@ package org.apache.flex.core.graphics
 		public function drawRect(x:Number, y:Number, width:Number, height:Number):void
 		{
 			applyStroke();
-			beginFill();
+			beginFill(new Rectangle(x, y, width, height));
 			graphics.drawRect(x, y, width, height);
 			endFill();
 		}
@@ -65,7 +64,7 @@ package org.apache.flex.core.graphics
 		public function drawEllipse(x:Number, y:Number, width:Number, height:Number):void
 		{
 			applyStroke();
-			beginFill();
+			beginFill(new Rectangle(x,y,width,height));
 			graphics.drawEllipse(x,y,width,height);
 			endFill();
 		}
@@ -84,7 +83,7 @@ package org.apache.flex.core.graphics
 		public function drawCircle(x:Number, y:Number, radius:Number):void
 		{
 			applyStroke();
-			beginFill();
+			beginFill(new Rectangle(x,y,radius*2, radius*2));
 			graphics.drawCircle(x,y,radius);
 			endFill();
 		}
@@ -107,7 +106,7 @@ package org.apache.flex.core.graphics
 		public function drawPath(data:String):void
 		{
 			applyStroke();
-			beginFill();
+			beginFill(new Rectangle());
 			var graphicsPath:GraphicsPath = PathHelper.getSegments(data);
 			graphics.drawPath(graphicsPath.commands, graphicsPath.data);
 			endFill();

http://git-wip-us.apache.org/repos/asf/flex-asjs/blob/4fce4e59/frameworks/as/projects/FlexJSUI/src/org/apache/flex/core/graphics/IFill.as
----------------------------------------------------------------------
diff --git a/frameworks/as/projects/FlexJSUI/src/org/apache/flex/core/graphics/IFill.as b/frameworks/as/projects/FlexJSUI/src/org/apache/flex/core/graphics/IFill.as
index 65c35b0..6ecbb8a 100644
--- a/frameworks/as/projects/FlexJSUI/src/org/apache/flex/core/graphics/IFill.as
+++ b/frameworks/as/projects/FlexJSUI/src/org/apache/flex/core/graphics/IFill.as
@@ -14,9 +14,11 @@
 
 package org.apache.flex.core.graphics
 {
+	import flash.geom.Rectangle;
+
 	public interface IFill
 	{
-		function begin(s:GraphicShape):void;
+		function begin(s:GraphicShape,targetBounds:Rectangle):void;
 		function end(s:GraphicShape):void;
 	}
 }
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/flex-asjs/blob/4fce4e59/frameworks/as/projects/FlexJSUI/src/org/apache/flex/core/graphics/LinearGradient.as
----------------------------------------------------------------------
diff --git a/frameworks/as/projects/FlexJSUI/src/org/apache/flex/core/graphics/LinearGradient.as
b/frameworks/as/projects/FlexJSUI/src/org/apache/flex/core/graphics/LinearGradient.as
new file mode 100644
index 0000000..87d1fb0
--- /dev/null
+++ b/frameworks/as/projects/FlexJSUI/src/org/apache/flex/core/graphics/LinearGradient.as
@@ -0,0 +1,56 @@
+/**
+ * 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.
+ */
+
+package org.apache.flex.core.graphics
+{
+	import flash.display.GradientType;
+	import flash.display.InterpolationMethod;
+	import flash.display.SpreadMethod;
+	import flash.geom.Matrix;
+	import flash.geom.Rectangle;
+	
+	public class LinearGradient extends GradientBase implements IFill
+	{
+		
+		private static var commonMatrix:Matrix = new Matrix();
+		private var _scaleX:Number;
+		
+		/**
+		 *  The horizontal scale of the gradient transform, which defines the width of the (unrotated)
gradient
+		 */
+		public function get scaleX():Number
+		{
+			return _scaleX;
+		}
+		
+		public function set scaleX(value:Number):void
+		{
+			_scaleX = value;
+		}
+		
+		public function begin(s:GraphicShape,targetBounds:Rectangle):void
+		{
+			commonMatrix.identity();
+			commonMatrix.createGradientBox(targetBounds.width,targetBounds.height,toRad(this.rotation));
+			
+			s.graphics.beginGradientFill(GradientType.LINEAR, colors, alphas, ratios,
+				commonMatrix, SpreadMethod.PAD, InterpolationMethod.RGB);
+		}
+		
+		public function end(s:GraphicShape):void
+		{
+			s.graphics.endFill();
+		}
+	}
+}
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/flex-asjs/blob/4fce4e59/frameworks/as/projects/FlexJSUI/src/org/apache/flex/core/graphics/Path.as
----------------------------------------------------------------------
diff --git a/frameworks/as/projects/FlexJSUI/src/org/apache/flex/core/graphics/Path.as b/frameworks/as/projects/FlexJSUI/src/org/apache/flex/core/graphics/Path.as
index 6f8324f..ec14340 100644
--- a/frameworks/as/projects/FlexJSUI/src/org/apache/flex/core/graphics/Path.as
+++ b/frameworks/as/projects/FlexJSUI/src/org/apache/flex/core/graphics/Path.as
@@ -29,22 +29,15 @@ package org.apache.flex.core.graphics
 		public function drawPath(x:Number,y:Number,data:String):void
 		{
 			graphics.clear();
-			if(stroke)
-			{
-				graphics.lineStyle(stroke.weight,stroke.color,stroke.alpha,false,"normal",CapsStyle.SQUARE,JointStyle.MITER);
-			}
-			if(fill)
-			{
-				graphics.beginFill(fill.color,fill.alpha);
-			}
+			applyStroke();
+			beginFill(new Rectangle());
 			segments = new PathSegmentsCollection(data);
 			if (segments)
 				segments.generateGraphicsPath(graphicsPath, x, y, 1, 1);
 			
 			graphics.drawPath(graphicsPath.commands, graphicsPath.data);
-			graphics.endFill();
+			endFill();
 		}
-		
 	}
 }
 

http://git-wip-us.apache.org/repos/asf/flex-asjs/blob/4fce4e59/frameworks/as/projects/FlexJSUI/src/org/apache/flex/core/graphics/Rect.as
----------------------------------------------------------------------
diff --git a/frameworks/as/projects/FlexJSUI/src/org/apache/flex/core/graphics/Rect.as b/frameworks/as/projects/FlexJSUI/src/org/apache/flex/core/graphics/Rect.as
index 989477d..6d82bf6 100644
--- a/frameworks/as/projects/FlexJSUI/src/org/apache/flex/core/graphics/Rect.as
+++ b/frameworks/as/projects/FlexJSUI/src/org/apache/flex/core/graphics/Rect.as
@@ -2,6 +2,7 @@ package org.apache.flex.core.graphics
 {
 	import flash.display.CapsStyle;
 	import flash.display.JointStyle;
+	import flash.geom.Rectangle;
 
 	public class Rect extends GraphicShape
 	{
@@ -21,16 +22,10 @@ package org.apache.flex.core.graphics
 		public function drawRect(x:Number, y:Number, width:Number, height:Number):void
 		{
 			graphics.clear();
-			if(stroke)
-			{
-				graphics.lineStyle(stroke.weight,stroke.color,stroke.alpha,false,"normal",CapsStyle.SQUARE,JointStyle.MITER);
-			}
-			if(fill)
-			{
-				graphics.beginFill(fill.color,fill.alpha);
-			}
+			applyStroke();
+			beginFill(new Rectangle(x, y, width, height));
 			graphics.drawRect(x, y, width, height);
-			graphics.endFill();
+			endFill();
 		}
 		
 	}

http://git-wip-us.apache.org/repos/asf/flex-asjs/blob/4fce4e59/frameworks/as/projects/FlexJSUI/src/org/apache/flex/core/graphics/SolidColor.as
----------------------------------------------------------------------
diff --git a/frameworks/as/projects/FlexJSUI/src/org/apache/flex/core/graphics/SolidColor.as
b/frameworks/as/projects/FlexJSUI/src/org/apache/flex/core/graphics/SolidColor.as
index 2c2dc08..bc0d913 100644
--- a/frameworks/as/projects/FlexJSUI/src/org/apache/flex/core/graphics/SolidColor.as
+++ b/frameworks/as/projects/FlexJSUI/src/org/apache/flex/core/graphics/SolidColor.as
@@ -14,6 +14,8 @@
 
 package org.apache.flex.core.graphics
 {
+	import flash.geom.Rectangle;
+
 	public class SolidColor implements IFill
 	{
 		
@@ -75,7 +77,7 @@ package org.apache.flex.core.graphics
 			}
 		}
 		
-		public function begin(s:GraphicShape):void
+		public function begin(s:GraphicShape,targetBounds:Rectangle):void
 		{
 			s.graphics.beginFill(color,alpha);
 		}


Mime
View raw message