<?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>Flassari.is &#187; mask</title>
	<atom:link href="http://flassari.is/tag/mask/feed/" rel="self" type="application/rss+xml" />
	<link>http://flassari.is</link>
	<description></description>
	<lastBuildDate>Sat, 28 Jan 2012 08:17:03 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.1.1</generator>
		<item>
		<title>AS3 Polygon Clipper</title>
		<link>http://flassari.is/2011/05/as3-polygon-clipper/</link>
		<comments>http://flassari.is/2011/05/as3-polygon-clipper/#comments</comments>
		<pubDate>Mon, 23 May 2011 09:00:35 +0000</pubDate>
		<dc:creator>Flassari</dc:creator>
				<category><![CDATA[Alchemy]]></category>
		<category><![CDATA[AS3]]></category>
		<category><![CDATA[Flash]]></category>
		<category><![CDATA[Math]]></category>
		<category><![CDATA[alchemy]]></category>
		<category><![CDATA[boolean]]></category>
		<category><![CDATA[clip]]></category>
		<category><![CDATA[clipper]]></category>
		<category><![CDATA[clipping]]></category>
		<category><![CDATA[commercial]]></category>
		<category><![CDATA[delete]]></category>
		<category><![CDATA[free]]></category>
		<category><![CDATA[github]]></category>
		<category><![CDATA[GPC]]></category>
		<category><![CDATA[library]]></category>
		<category><![CDATA[mask]]></category>
		<category><![CDATA[open source]]></category>
		<category><![CDATA[polygon]]></category>
		<category><![CDATA[polygon boolean operation]]></category>
		<category><![CDATA[remove]]></category>
		<category><![CDATA[subtract]]></category>
		<category><![CDATA[swc]]></category>

		<guid isPermaLink="false">http://flassari.is/?p=408</guid>
		<description><![CDATA[I was looking for an open source polygon clipper library for AS3 to use on a commercial project. I found a few ports of the General Polygon Clipper library (GPC) but it is only free for non-commercial projects. After more searching around I found this excellent library called Clipper by Angus Johnson. It did not [...]]]></description>
			<content:encoded><![CDATA[<p><center><img src="http://flassari.is/wp-content/uploads/2011/05/A-B.png" title="Polygon Clipper" /></center><br />
I was looking for an open source polygon clipper library for AS3 to use on a commercial project.<br />
I found a <a href="http://code.google.com/p/gpcas/">few</a> <a href="http://code.google.com/p/polygonal/wiki/GeneralPolygonClipperAlgorithm">ports</a> of the General Polygon Clipper library (<a href="http://www.cs.man.ac.uk/~toby/alan/software/">GPC</a>) but it is <a href="http://www.cs.man.ac.uk/~toby/alan/software/#Licensing">only free for non-commercial projects</a>.<br />
After more searching around I found this excellent library called <a href="http://www.angusj.com/delphi/clipper.php">Clipper by Angus Johnson</a>. It did not have an AS3 port so I made one using <a href="http://labs.adobe.com/technologies/alchemy/">Alchemy</a> to wrap the c++ code.</p>
<p>The SWC and source code can be found on github: <a href="https://github.com/Flassari/as3clipper">https://github.com/Flassari/as3clipper</a></p>
<p>It is completely free and open source for both personal and commercial projects. Clipper uses the <a href="http://www.boost.org/LICENSE_1_0.txt">Boost Software License</a>.</p>
<p>Supported clipping operations: difference, intersection, union and XOR.</p>
<p>Here&#8217;s an example of how to use the AS3 port after importing the Clipper.swc file:</p>
<pre class="brush:as3">import com.flassari.geom.Clipper;
import com.flassari.geom.ClipType;

var subjectPolygon:Array = [new Point(0, 0), new Point(200, 0), new Point(100, 200)];

var clipPolygon:Array = [new Point(0, 100), new Point(200, 100), new Point(300, 200)];

var resultPolygons:Array = Clipper.clipPolygon(subjectPolygon, clipPolygon, ClipType.DIFFERENCE);</pre>
]]></content:encoded>
			<wfw:commentRss>http://flassari.is/2011/05/as3-polygon-clipper/feed/</wfw:commentRss>
		<slash:comments>3</slash:comments>
		</item>
		<item>
		<title>Pie mask in AS3</title>
		<link>http://flassari.is/2009/11/pie-mask-in-as3/</link>
		<comments>http://flassari.is/2009/11/pie-mask-in-as3/#comments</comments>
		<pubDate>Fri, 13 Nov 2009 17:02:17 +0000</pubDate>
		<dc:creator>Flassari</dc:creator>
				<category><![CDATA[AS3]]></category>
		<category><![CDATA[Flash]]></category>
		<category><![CDATA[Math]]></category>
		<category><![CDATA[mask]]></category>
		<category><![CDATA[percentage]]></category>
		<category><![CDATA[pie]]></category>
		<category><![CDATA[progress]]></category>
		<category><![CDATA[timer]]></category>

		<guid isPermaLink="false">http://flassari.is/?p=240</guid>
		<description><![CDATA[Sometimes I have the need for a rotational progress bar that acts like a pie growing bigger (or smaller if that strikes your fancy). As usual, I made my own =) [...] ]]></description>
			<content:encoded><![CDATA[<p>Sometimes I have the need for a rotational progress bar that acts like a pie growing bigger (or smaller if that strikes your fancy). As usual, I made my own =)<br />
The function drawPieMask takes first the <strong>graphics</strong> object of the displayObject instance and draws a part of pie on it, <strong>percentage</strong> set&#8217;s how big the part is.<br />
If you want to offset the rotation of the pie (it starts to the right by default) you can set the <strong>rotation</strong> parameter. Note that rotation is in radians, not degrees, but you can multiply your degrees by (Math.PI/180) to convert to radians.<br />
Lastly, the <strong>sides</strong> property determines how many sides the circle drawn in the mask has. You can see an example of different pie masks after the code.</p>
<p>To make the code as customizable as possible, it does not make a call to beginFill in case you want to set your own fill (or gradientfill even?).<br />
If you just want to use it as a basic mask, just call beginFill(0) before and endFill() after the call to drawPieMask.</p>
<pre class="brush: as3">function drawPieMask(graphics:Graphics, percentage:Number, radius:Number = 50, x:Number = 0, y:Number = 0, rotation:Number = 0, sides:int = 6):void {
	// graphics should have its beginFill function already called by now
	graphics.moveTo(x, y);
	if (sides < 3) sides = 3; // 3 sides minimum
	// Increase the length of the radius to cover the whole target
	radius /= Math.cos(1/sides * Math.PI);
	// Shortcut function
	var lineToRadians:Function = function(rads:Number):void {
		graphics.lineTo(Math.cos(rads) * radius + x, Math.sin(rads) * radius + y);
	};
	// Find how many sides we have to draw
	var sidesToDraw:int = Math.floor(percentage * sides);
	for (var i:int = 0; i <= sidesToDraw; i++)
		lineToRadians((i / sides) * (Math.PI * 2) + rotation);
	// Draw the last fractioned side
	if (percentage * sides != sidesToDraw)
		lineToRadians(percentage * (Math.PI * 2) + rotation);
}</pre>
<p>Example of different sides values. The last circle has a pie with 3 sides as a mask.<br />
<object classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000" width="450" height="310"><param name="movie" value="/wp-content/uploads/2009/11/PieMaskExample.swf" /><!--[if !IE]>--><object type="application/x-shockwave-flash" data="/wp-content/uploads/2009/11/PieMaskExample.swf" width="450" height="310"><!--<![endif]-->
<div>
<p><a href="http://www.adobe.com/go/getflashplayer"><img src="http://www.adobe.com/images/shared/download_buttons/get_flash_player.gif" alt="Get Adobe Flash player" /></a></p>
<p><!--[if !IE]>--></object><!--<![endif]--></object></p>
<p>You can get the <a href='http://flassari.is/wp-content/uploads/2009/11/PieMaskExample.zip'>example fla here.</a></p>
]]></content:encoded>
			<wfw:commentRss>http://flassari.is/2009/11/pie-mask-in-as3/feed/</wfw:commentRss>
		<slash:comments>11</slash:comments>
		</item>
	</channel>
</rss>

