<?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>nodename &#187; ActionScript</title>
	<atom:link href="http://nodename.com/blog/category/actionscript/feed/" rel="self" type="application/rss+xml" />
	<link>http://nodename.com/blog</link>
	<description></description>
	<lastBuildDate>Wed, 11 Apr 2012 20:39:41 +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>What I Did On My Summer Vacation</title>
		<link>http://nodename.com/blog/2011/07/29/what-i-did-on-my-summer-vacation/</link>
		<comments>http://nodename.com/blog/2011/07/29/what-i-did-on-my-summer-vacation/#comments</comments>
		<pubDate>Sat, 30 Jul 2011 07:46:06 +0000</pubDate>
		<dc:creator>alan</dc:creator>
				<category><![CDATA[ActionScript]]></category>
		<category><![CDATA[Generative]]></category>
		<category><![CDATA[geometry]]></category>

		<guid isPermaLink="false">http://nodename.com/blog/?p=790</guid>
		<description><![CDATA[A little geometry project in which I make things move <span style="color:#777"> . . . &#8594; Read More: <a href="http://nodename.com/blog/2011/07/29/what-i-did-on-my-summer-vacation/">What I Did On My Summer Vacation</a></span>]]></description>
			<content:encoded><![CDATA[<p><center><br />
<a href="/wpEmbeds/HilbertApp/bin-release/HilbertParticleFadeApp2D.html" rel="shadowbox;width=1000;height=1000"><img src="/wpEmbeds/HilbertApp/hype.png" alt="" /></a><br />
 </center></p>
<p>I attended the <a href="http://www.andersonranch.org/workshops/courses/details/index.php?page=digital-media&#038;id=2675">Dynamic Abstraction Workshop</a> taught by <a href="http://joshuadavis.com">Joshua Davis</a> at the Anderson Ranch Arts Center in Snowmass, Colorado, along with several flashy flexy friends. Click on the image to see my student project.</p>
<p>I don&#8217;t even want to tell you what Josh has planned for next year&#8217;s workshop until after I get my ticket!</p>
]]></content:encoded>
			<wfw:commentRss>http://nodename.com/blog/2011/07/29/what-i-did-on-my-summer-vacation/feed/</wfw:commentRss>
		<slash:comments>3</slash:comments>
		</item>
		<item>
		<title>Generating Generics: Creating Classes at Run Time in Flash</title>
		<link>http://nodename.com/blog/2011/04/26/generating-generics-creating-classes-at-run-time-in-flash/</link>
		<comments>http://nodename.com/blog/2011/04/26/generating-generics-creating-classes-at-run-time-in-flash/#comments</comments>
		<pubDate>Wed, 27 Apr 2011 04:24:16 +0000</pubDate>
		<dc:creator>alan</dc:creator>
				<category><![CDATA[ActionScript]]></category>

		<guid isPermaLink="false">http://nodename.com/blog/?p=771</guid>
		<description><![CDATA[A simple demonstration of class generation in Actionscript using the as3-commons-bytecode library
 <span style="color:#777"> . . . &#8594; Read More: <a href="http://nodename.com/blog/2011/04/26/generating-generics-creating-classes-at-run-time-in-flash/">Generating Generics: Creating Classes at Run Time in Flash</a></span>]]></description>
			<content:encoded><![CDATA[<p><a href="https://github.com/nodename/ClassCreationTest">Class Creation Test</a></p>
<p>This is a simple demonstration of class generation in Actionscript using the as3-commons-bytecode library.</p>
<p>Here I demonstrate creating parameterized classes (generics). In this example we create a Tuple class given a spec containing the names, types, and visibilities (public, protected, or private) of the class&#8217;s data members.  The class is named appropriately, e.g. Tuple&lt;String, Point, Rectangle&gt;, and it is given a constructor method that requires parameters of the indicated types in the order that they will have in the tuple.  I use the as3-commons-bytecode library to generate the class, and then load the class into the current ApplicationDomain.  Once a couple of specified classes are loaded, I examine them with describeType() and construct an instance of each generated class.</p>
<p>The bytecode for the constructor doesn&#8217;t depend in any way on the types of the parameters; it&#8217;s just a matter of putting them on the stack and initializing the respective properties with them.</p>
<p>One thing that held me up for a while was determining the proper namespace for protected and local properties. It turns out to be the fully qualified classname with a single colon as the final separator; who knew.</p>
<p>I haven&#8217;t provided accessors for the tuple properties, so for non-public members that would be an &#8216;exercise for the reader&#8217;.</p>
<p>I&#8217;m loading the generated classes immediately, but there&#8217;s code to write them out in swf format as well. So an AIR app like this could be included in a build process&#8230;</p>
<p>I was led to play with as3-commons-bytecode by the exciting work that Mike Labriola and James Ward presented at 360Flex in Denver. They demonstrate a bytecode-based framework for intercepting the load process of a Flex application and performing arbitrary changes before allowing Flex to start up.  The possibilities are vast:</p>
<p><a href="http://www.jamesward.com/2011/04/26/introducing-mixing-loom-runtime-actionscript-bytecode-modification/">Introducing Mixing Loom – Runtime ActionScript Bytecode Modification</a></p>
<p>Generating Generics? Somewhere, somebody must already be Making Mocks!</p>
<p><a class="FlattrButton" style="display:none;" rev="flattr;button:compact;" href="http://nodename.com/blog/2011/04/26/generating-generics-creating-classes-at-run-time-in-flash/"></a></p>
]]></content:encoded>
			<wfw:commentRss>http://nodename.com/blog/2011/04/26/generating-generics-creating-classes-at-run-time-in-flash/feed/</wfw:commentRss>
		<slash:comments>7</slash:comments>
		</item>
		<item>
		<title>Playing 52-Card Pickup To Win</title>
		<link>http://nodename.com/blog/2011/04/17/playing-52-card-pickup-to-win/</link>
		<comments>http://nodename.com/blog/2011/04/17/playing-52-card-pickup-to-win/#comments</comments>
		<pubDate>Mon, 18 Apr 2011 00:13:35 +0000</pubDate>
		<dc:creator>alan</dc:creator>
				<category><![CDATA[ActionScript]]></category>
		<category><![CDATA[Software Architecture]]></category>

		<guid isPermaLink="false">http://nodename.com/blog/?p=752</guid>
		<description><![CDATA[<p>So you come on board without having had a look at the code base. First off you find that the developer build process consists of a page of instructions that require you to do about fifteen more steps than &#8220;svn checkout; import Flash Builder project; profit.&#8221; Then, looking at those steps, you see no mention of <span style="color:#777"> . . . &#8594; Read More: <a href="http://nodename.com/blog/2011/04/17/playing-52-card-pickup-to-win/">Playing 52-Card Pickup To Win</a></span>]]></description>
			<content:encoded><![CDATA[<p>So you come on board without having had a look at the code base. First off you find that the developer build process consists of a page of instructions that require you to do about fifteen more steps than &#8220;svn checkout; import Flash Builder project; profit.&#8221; Then, looking at those steps, you see no mention of &#8220;linking&#8221; &#8220;libraries&#8221; into the application, but rather of adding a couple of source paths that contain about a thousand Actionscript files.</p>
<p>Your mission, should you choose to accept it, is to sort out the dependencies and break this <em>Close Encounters</em> heap into a tree of libraries. Of course this won&#8217;t be easy; when the code base has grown for a year &#8212; or FIVE &#8212; without that kind of discipline, you&#8217;re bound to have to hack through some pretty thick vines sooner or later.  But there are one or two tools you can use to ease the pain a bit and let you explore the tree, even while you&#8217;re just beginning the inevitable refactoring, and without moving a single source file. This way the development team can continue exactly as before while you fiddle around under their skirts.</p>
<p>The first goal is to separate all those &#8220;other&#8221; source files into one or more projects. So let&#8217;s try to make a single library swc out of all those source files.</p>
<p>You&#8217;re going to need enough heap space to build this uber swc, so follow Hasan Otuome&#8217;s <a href="http://technophi.com/2010/08/12/flash-builder-4-java-heap-space-issues/">instructions</a> for that. Don&#8217;t be stingy here: I gave myself 4096M. You&#8217;re not going to accomplish this on a MacBook Air.</p>
<p>You&#8217;re not going to want the IDE trying to build everything every time you save a little code change, so from here out keep &#8220;Project -> Build automatically&#8221; turned off.</p>
<p>Make a Flex Library Project to hold this swc. You do NOT have to make this project reside at the root of the source path. You can put it anywhere you like, out of the way of the other developers. Just ignore the &#8220;Main source folder&#8221; for your library project, and add the (ideally just one) path to the source as an &#8220;Additional source folder.&#8221;</p>
<p>If the IDE stops responding for a while, be patient. If you run out of Java heap space while trying to build the swc, clean all projects and try again. If that doesn&#8217;t work, give yourself even more heap space.</p>
<p>It may be that your entire tree is just too big to build a single swc from. Barring a RAM upgrade or something, you&#8217;re back to square one. You&#8217;ll have to get started right away figuring out where your first Voronoi shatter will take place. You&#8217;ll want to use smarter tools like &#8220;Find References&#8221; to get a feel for the structure of the code. Ask around &#8211; the other devs may have a pretty clear idea of what should depend on what, even if it&#8217;s not yet strictly true. An obvious choice is sectioning off any third-party code that&#8217;s in the tree. But first check to see whether the developers have modified it so that it depends on in-house code.  I have seen this happen.</p>
<p>Once you&#8217;ve got a swc, you can of course link that into your application instead of having all that code as &#8220;Additional source folders.&#8221;</p>
<p>Repeat.</p>
<p>Eventually you&#8217;ll have to edit some source files. If you&#8217;re still on the project :-)</p>
<p>NEW RULES</p>
<p>Describe the source layout of your project in terms of folder structure and library dependencies.<br />
What third-party libraries do you use? Have you modified them? How and why?<br />
Does your app use a framework? What parts of your app are allowed to communicate with the server and why?<br />
Describe the process for prioritizing tasks. What are the criteria for setting deadlines?<br />
If your project involves FLA animations, how are they integrated into the build? Do they contain code?<br />
Describe your commitment to developing reusable software components. Define &#8220;discovery phase.&#8221;<br />
Do you have any unit tests? Automated build?<br />
Who&#8217;s in charge here?</p>
]]></content:encoded>
			<wfw:commentRss>http://nodename.com/blog/2011/04/17/playing-52-card-pickup-to-win/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>The Arrogant Enum</title>
		<link>http://nodename.com/blog/2010/10/13/the-arrogant-enum/</link>
		<comments>http://nodename.com/blog/2010/10/13/the-arrogant-enum/#comments</comments>
		<pubDate>Thu, 14 Oct 2010 02:49:21 +0000</pubDate>
		<dc:creator>alan</dc:creator>
				<category><![CDATA[ActionScript]]></category>

		<guid isPermaLink="false">http://nodename.com/blog/?p=686</guid>
		<description><![CDATA[<p>This enum thinks it&#8217;s the last word in ActionScript enumerated-type implementations.  In fact it thinks it&#8217;s so hot that it calls itself the Ultimate Enum.  Check it out and see if it doesn&#8217;t do the trick for you.  If it doesn&#8217;t, please let me know and I hope we can improve it further.</p>
<p>Example <span style="color:#777"> . . . &#8594; Read More: <a href="http://nodename.com/blog/2010/10/13/the-arrogant-enum/">The Arrogant Enum</a></span>]]></description>
			<content:encoded><![CDATA[<p><a href="http://github.com/nodename/Ultimate-Enum">This enum</a> thinks it&#8217;s the last word in ActionScript enumerated-type implementations.  In fact it thinks it&#8217;s so hot that it calls itself the Ultimate Enum.  Check it out and see if it doesn&#8217;t do the trick for you.  If it doesn&#8217;t, please let me know and I hope we can improve it further.</p>
<p>Example enum classes using this implementation are <a href="http://github.com/nodename/Ultimate-Enum/tree/master/src_test/examples">here</a>.</p>
]]></content:encoded>
			<wfw:commentRss>http://nodename.com/blog/2010/10/13/the-arrogant-enum/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
		<item>
		<title>Blobs in Games: Polygon Map Generation, by Amit Patel</title>
		<link>http://nodename.com/blog/2010/10/02/blobs-in-games-polygon-map-generation-by-amit-patel/</link>
		<comments>http://nodename.com/blog/2010/10/02/blobs-in-games-polygon-map-generation-by-amit-patel/#comments</comments>
		<pubDate>Sat, 02 Oct 2010 23:20:07 +0000</pubDate>
		<dc:creator>alan</dc:creator>
				<category><![CDATA[ActionScript]]></category>
		<category><![CDATA[ボロノイ]]></category>
		<category><![CDATA[Delaunay]]></category>
		<category><![CDATA[Voronoi]]></category>

		<guid isPermaLink="false">http://nodename.com/blog/?p=670</guid>
		<description><![CDATA[<p>Amit Patel has published a great article on map generation based upon Voronoi polygons.  He generates the Voronoi polygons using my as3delaunay library.  But the polygons are just the beginning of his process&#8230;</p>
<p>Try the demo!  And &#8212; yum &#8212; see the <span style="color:#777"> . . . &#8594; Read More: <a href="http://nodename.com/blog/2010/10/02/blobs-in-games-polygon-map-generation-by-amit-patel/">Blobs in Games: Polygon Map Generation, by Amit Patel</a></span>]]></description>
			<content:encoded><![CDATA[<p>Amit Patel has published a <a href="http://www-cs-students.stanford.edu/~amitp/game-programming/polygon-map-generation/">great article on map generation</a> based upon Voronoi polygons.  He generates the Voronoi polygons using my <a href="http://github.com/nodename/as3delaunay">as3delaunay library</a>.  But the polygons are just the beginning of his process&#8230;</p>
<p><a href="http://www-cs-students.stanford.edu/~amitp/game-programming/polygon-map-generation/mapgen2.swf">Try the demo!</a>  And &#8212; yum &#8212; <a href="http://github.com/amitp/mapgen2">see the source code!</a></p>
]]></content:encoded>
			<wfw:commentRss>http://nodename.com/blog/2010/10/02/blobs-in-games-polygon-map-generation-by-amit-patel/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>Trees Grow</title>
		<link>http://nodename.com/blog/2009/12/14/trees-grow/</link>
		<comments>http://nodename.com/blog/2009/12/14/trees-grow/#comments</comments>
		<pubDate>Mon, 14 Dec 2009 13:54:48 +0000</pubDate>
		<dc:creator>alan</dc:creator>
				<category><![CDATA[ActionScript]]></category>
		<category><![CDATA[geometry]]></category>

		<guid isPermaLink="false">http://nodename.com/blog/?p=194</guid>
		<description><![CDATA[Constrained minimum spanning trees as shape fills, the moving version of my earlier post The Name of the Node. <span style="color:#777"> . . . &#8594; Read More: <a href="http://nodename.com/blog/2009/12/14/trees-grow/">Trees Grow</a></span>]]></description>
			<content:encoded><![CDATA[<style type="text/css">
#theMovie {
margin: 0 auto;
width: 640px;
border-width: 1;
border-style : solid ;
border-color : black ;
}
</style>
<p>Constrained minimum spanning trees as shape fills, the moving version of my earlier post <a href="http://nodename.com/blog/2009/05/12/the-name-of-the-node/">The Name of the Node</a>. On each frame one point is added, all the points move, and their spanning trees are drawn. Character: JIE2, &#8220;knot&#8221;.</p>
<div id="theMovie"><object width="640" height="505"><param name="movie" value="http://www.youtube.com/v/BHO6zeW9sQA&#038;hl=en&#038;fs=1&#038;rel=0&#038;ap=%2526fmt%3D18"></param><param name="allowFullScreen" value="true"></param><param name="allowscriptaccess" value="always"></param><embed src="http://www.youtube.com/v/BHO6zeW9sQA&#038;hl=en&#038;fs=1&#038;rel=0&#038;ap=%2526fmt%3D18" type="application/x-shockwave-flash" allowscriptaccess="always" allowfullscreen="true" width="640" height="505"></embed></object></div>
<p>(Be sure to view the movie in 480p.)</p>
<p>Note that since the segments are filled with trees, which may branch but never loop, the KOU3 (&#8220;mouth&#8221;) in the lower right quadrant is never a closed box. In every frame there is an escape path from the inside to the outside.</p>
]]></content:encoded>
			<wfw:commentRss>http://nodename.com/blog/2009/12/14/trees-grow/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>Roll Over, Delaunay: Voronoi Library Goes Open-Source</title>
		<link>http://nodename.com/blog/2009/12/03/roll-over-delaunay-voronoi-library-goes-open-source/</link>
		<comments>http://nodename.com/blog/2009/12/03/roll-over-delaunay-voronoi-library-goes-open-source/#comments</comments>
		<pubDate>Thu, 03 Dec 2009 04:28:55 +0000</pubDate>
		<dc:creator>alan</dc:creator>
				<category><![CDATA[ActionScript]]></category>
		<category><![CDATA[ボロノイ]]></category>
		<category><![CDATA[Delaunay]]></category>
		<category><![CDATA[Voronoi]]></category>

		<guid isPermaLink="false">http://nodename.com/blog/?p=377</guid>
		<description><![CDATA[I've released the as3delaunay library on github! <span style="color:#777"> . . . &#8594; Read More: <a href="http://nodename.com/blog/2009/12/03/roll-over-delaunay-voronoi-library-goes-open-source/">Roll Over, Delaunay: Voronoi Library Goes Open-Source</a></span>]]></description>
			<content:encoded><![CDATA[<p>A few people have asked for the code for my <a href="http://nodename.com/blog/2009/05/11/a-voronoi-toy/">Voronoi Toy</a>.  I haven&#8217;t made the entire program public yet, but I have released the underlying <a href="http://nodename.github.com/as3delaunay/">as3delaunay library</a>, which I originally ported from Steven Fortune&#8217;s C implementation of his plane-sweep algorithm.</p>
<p>In addition to the Voronoi diagram and the Delaunay triangulation, the library also provides the convex hull, minimum and maximum <a href="http://nodename.com/blog/2009/05/12/the-name-of-the-node/">spanning trees</a>, and several other related geometric entities.</p>
<p>You can download the source and compile it, or just get the compiled swc from the downloads page.</p>
<p>So far I have had two users, JakeTastic (<a href="http://jaketastic.com/blog/voronoi-shattering-complete/">Voronoi shattering complete!</a>) and Li (<a href="http://www.lidev.com.ar/?p=303">Faster Voronoi Noise</a>); thanks to them both for jumping on, and to Jake also for finding the two bugs :-)</p>
<p>There&#8217;s no documentation yet, but there is a <a href="http://github.com/nodename/as3delaunayTestRunner">test suite</a> which incorporates an example of using the library for nearest-site queries, and there&#8217;s also a <a href="http://groups.google.com/group/as3delaunay">mailing list</a>, where I&#8217;ve archived Fortune&#8217;s paper and his C code, as well as a growing page of interesting <a href="http://groups.google.com/group/as3delaunay/web/resources">links</a> related to Voronoi/Delaunay.</p>
<p>The library is hosted on github, so YOU can conveniently modify, fix, or enhance it!</p>
<p>Roadmap for possible enhancements:<br />
Generalize to support weighted Voronoi diagrams, both additive and multiplicative (This is described in Fortune&#8217;s paper)<br />
Generalize to use an arbitrary polygon as a boundary<br />
&#8230; what else?</p>
]]></content:encoded>
			<wfw:commentRss>http://nodename.com/blog/2009/12/03/roll-over-delaunay-voronoi-library-goes-open-source/feed/</wfw:commentRss>
		<slash:comments>17</slash:comments>
		</item>
		<item>
		<title>Implementing Enumerated Types in ActionScript 3</title>
		<link>http://nodename.com/blog/2009/09/05/implementing-enumerated-types-in-actionscript-3/</link>
		<comments>http://nodename.com/blog/2009/09/05/implementing-enumerated-types-in-actionscript-3/#comments</comments>
		<pubDate>Sun, 06 Sep 2009 03:39:33 +0000</pubDate>
		<dc:creator>alan</dc:creator>
				<category><![CDATA[ActionScript]]></category>
		<category><![CDATA[enumerated types]]></category>

		<guid isPermaLink="false">http://nodename.com/blog/?p=363</guid>
		<description><![CDATA[<p>UPDATE  I&#8217;ve improved on this implementation; please see the later post The Arrogant Enum.</p>
<p>This is about implementing an enum in AS3 with value restriction ( i.e. the programmer should be unable to diminish or add to the set of values) and type safety.</p>
<p>We&#8217;ll implement the data type as a Class.  In order to keep <span style="color:#777"> . . . &#8594; Read More: <a href="http://nodename.com/blog/2009/09/05/implementing-enumerated-types-in-actionscript-3/">Implementing Enumerated Types in ActionScript 3</a></span>]]></description>
			<content:encoded><![CDATA[<p><strong>UPDATE</strong>  I&#8217;ve improved on this implementation; please see the later post <a href="http://nodename.com/blog/2010/10/13/the-arrogant-enum/">The Arrogant Enum</a>.</p>
<p>This is about implementing an enum in AS3 with value restriction ( i.e. the programmer should be unable to diminish or add to the set of values) and type safety.</p>
<p>We&#8217;ll implement the data type as a Class.  In order to keep the programmer from adding to the set of values, we need to disallow invocation of the constructor.</p>
<p>Back when AS3 came out, there was much talk about the lack of private constructors and what to do about it, especially with regard to implementing the Singleton pattern. My favorite of the solutions is to define a file-level class and require it (the class, not an instance!) as a constructor parameter.</p>
<p>From there we can proceed just as Daniel Savarese describes in <a href="http://www.devx.com/getHelpOn/10MinuteSolution/20442/1763">Implementing Enumerated Types in Java</a>. </p>
<p>I don&#8217;t show how to implement an ordering on the enum values.  See the Savarese article for that, too.</p>
<pre>
package
{
	import flash.errors.IllegalOperationError;

	public final class PailContents
	{
		public static const WATER:PailContents = new PailContents(PrivateConstructorEnforcer, "water");
		public static const CHICKENFEED:PailContents = new PailContents(PrivateConstructorEnforcer, "chicken feed");
		public static const MILK:PailContents = new PailContents(PrivateConstructorEnforcer, "milk");
		public static const OATS:PailContents = new PailContents(PrivateConstructorEnforcer, "oats");

		private var _name:String;

		public function PailContents(lock:Class, name:String)
		{
			super();
			if (lock != PrivateConstructorEnforcer)
			{
				throw new IllegalOperationError("Invalid constructor access");
			}
			_name = name;
		}

		// don't forget to implement toString() to support implicit conversion to String for trace() etc:
		public function toString():String
		{
			return _name;
		}

	}
}

// defined outside the package, and therefore visible only within this source file:
class PrivateConstructorEnforcer {}
</pre>
]]></content:encoded>
			<wfw:commentRss>http://nodename.com/blog/2009/09/05/implementing-enumerated-types-in-actionscript-3/feed/</wfw:commentRss>
		<slash:comments>4</slash:comments>
		</item>
		<item>
		<title>Crystals, Evil Rangers, and Voronoi without an Engine</title>
		<link>http://nodename.com/blog/2009/07/01/crystals-evil-rangers-and-voronoi-without-an-engine/</link>
		<comments>http://nodename.com/blog/2009/07/01/crystals-evil-rangers-and-voronoi-without-an-engine/#comments</comments>
		<pubDate>Wed, 01 Jul 2009 20:41:03 +0000</pubDate>
		<dc:creator>alan</dc:creator>
				<category><![CDATA[ActionScript]]></category>
		<category><![CDATA[ボロノイ]]></category>
		<category><![CDATA[BitmapData]]></category>
		<category><![CDATA[geometry]]></category>
		<category><![CDATA[Voronoi]]></category>

		<guid isPermaLink="false">http://nodename.com/blog/?p=205</guid>
		<description><![CDATA[<p>In Flash we can HARNESS THE POWER OF BITMAPDATA (as it might be put in a conference session blurb) to grow Voronoi regions under differing conditions, without doing any algebra.  Click on the image to launch the Voronoi Generator.</p>
<p>

 </p>
<p>Variations on Voronoi Diagrams, from Geometry in Action:</p>
<p>One way of getting Voronoi diagrams is by growing <span style="color:#777"> . . . &#8594; Read More: <a href="http://nodename.com/blog/2009/07/01/crystals-evil-rangers-and-voronoi-without-an-engine/">Crystals, Evil Rangers, and Voronoi without an Engine</a></span>]]></description>
			<content:encoded><![CDATA[<p>In Flash we can HARNESS THE POWER OF BITMAPDATA (as it might be put in a conference session blurb) to grow Voronoi regions under differing conditions, without doing any algebra.  Click on the image to launch the Voronoi Generator.</p>
<p><center><br />
<a href="/wpEmbeds/GenerateVoronoi/GenerateVoronoi.swf" rel="shadowbox;width=800;height=650"><img src="/wpEmbeds/GenerateVoronoi/Disconnected.jpg" alt="Disconnected!" /></a><br />
 </center></p>
<p><a href="http://www.ics.uci.edu/~eppstein/gina/scot.drysdale.html#var">Variations on Voronoi Diagrams</a>, from <a href="http://www.ics.uci.edu/~eppstein/geom.html">Geometry in Action</a>:</p>
<blockquote><p>One way of getting Voronoi diagrams is by growing crystals. If you start a number of crystals, all growing at the same rate, and all starting at the same time, you get a number of growing circles. As these circles meet, straight line boundaries appear between them. Eventually, the entire plane will be filled up. Each crystal will exactly fill up the Voronoi region of its point of origin.</p>
<p>This is a little too simple. In reality, crystals start growing at different times. Even if they still grow at the same rate, if they start at different times, they will no longer meet in straight lines. Instead, they will meet in hyperbolic segments. The diagram you get is called the &#8220;additively weighted Voronoi diagram&#8221;. It&#8217;s defined just like the usual Voronoi diagram, but each site has a weight, and you measure distance to a site, you add its weight to the usual Euclidean distance.</p>
<p>Now suppose instead that all the crystals start at the same time, but grow at different rates. Now you get what&#8217;s called the &#8220;multiplicatively weighted Voronoi diagram&#8221;. Once again, each site is given a weight, but when you measure the distance to a site, you multiply by its weight. Now the boundaries between different regions are segments of circles.</p>
<p>This model still has some problems. For example, in a multiplicatively weighted Voronoi diagram, it&#8217;s possible for a region to be disconnected [ see picture above -- AS ]. Obviously, this can&#8217;t happen with real crystals. So there&#8217;s yat another version which treats existing crystals as obstacles, and lets fast-growing crystals grow around the slower ones. Now the boundaries between neighboring regions are sort of tear-shaped. This variation is called the &#8220;multiplicatively weighted crystal growth Voronoi diagram.&#8221;</p>
<p>There are several other variations. You can change the metric from the normal Euclidean distance to L<sub>1</sub>, or L<sub>p</sub>, or L<sub>infinity</sub>, or even stranger distance functions. You can weight the sites additively and mulitplicatively. You can change the sites from points to line segments or circles or polygons. You can generalize to higher dimensions. You can associate points with the farthest site, instead of their nearest site. And so on.</p>
<p>Different applications of Voronoi diagrams require different variations. For example, motion planning algorithms for circular robots often use the Voronoi diagram of the obstacles. If there is a path from one location to another, then there must be a path that follows the edges of the Voronoi diagram, since those edges are by definition as far from the obstacles as possible.</p></blockquote>
<p>The &#8220;L<sub>1</sub> metric&#8221; is called the <em>Manhattan metric</em> or <em>city-block distance</em>.  &#8220;Manhattan metric&#8221; is a misnomer, though, because in Manhattan the east-west blocks are much longer than the north-south blocks.</p>
<p>The crystal-growth model is equivalent to the &#8220;evil forest ranger model,&#8221; in which instead of watching for forest fires, the rangers set fire to their lookouts, sometimes at different times, and the fires may spread at different rates.  Voronoi diagrams indeed find application in crystallography and in forest-fire modelling.</p>
<p>And <a href="http://hoosiermuse.wordpress.com/2009/06/01/gary-snyder-in-the-north-cascades/">here</a> is a post about a far-from-evil lookout.</p>
]]></content:encoded>
			<wfw:commentRss>http://nodename.com/blog/2009/07/01/crystals-evil-rangers-and-voronoi-without-an-engine/feed/</wfw:commentRss>
		<slash:comments>4</slash:comments>
		</item>
		<item>
		<title>Marching Squares: Boundary detection</title>
		<link>http://nodename.com/blog/2009/06/18/marching-squares-boundary-detection/</link>
		<comments>http://nodename.com/blog/2009/06/18/marching-squares-boundary-detection/#comments</comments>
		<pubDate>Thu, 18 Jun 2009 23:30:59 +0000</pubDate>
		<dc:creator>alan</dc:creator>
				<category><![CDATA[ActionScript]]></category>
		<category><![CDATA[geometry]]></category>
		<category><![CDATA[morph]]></category>

		<guid isPermaLink="false">http://nodename.com/blog/?p=173</guid>
		<description><![CDATA[A little code for a change. <span style="color:#777"> . . . &#8594; Read More: <a href="http://nodename.com/blog/2009/06/18/marching-squares-boundary-detection/">Marching Squares: Boundary detection</a></span>]]></description>
			<content:encoded><![CDATA[<p>A little code for a change.</p>
<p><a href="http://www.sakri.net/blog/2009/05/28/detecting-edge-pixels-with-marching-squares-algorithm/#comments">Sakri</a> was working on this, and I ported a class from Java which I believe he adapted into his final implementation.  It&#8217;s a basic tool for morphing, 3D surface reconstruction, and <a href="http://en.nicoptere.net/?p=166">vectorization</a>.</p>
<p>I&#8217;ve cleaned up my version of it and I offer it here.  The important function signature looks like this:</p>
<pre>
public static function perimeter(data:BitmapData, x:int, y:int):Vector.&lt;Point&gt;
</pre>
<p>It returns a list of pixels representing the boundary between opaque and transparent pixels, starting from a single boundary point that you provide.</p>
<p>You can get a boundary point using Sakri&#8217;s and Mario&#8217;s <a href="http://www.quasimondo.com/archives/000683.php">EdgeFinder class</a>.</p>
<p>Download the <a href="http://nodename.com/wpEmbeds/MarchingSquares/MarchingSquares.as">source</a>.</p>
<p>How it works:  <a href="http://en.wikipedia.org/wiki/Marching_squares">Marching Squares on Wikipedia</a></p>
]]></content:encoded>
			<wfw:commentRss>http://nodename.com/blog/2009/06/18/marching-squares-boundary-detection/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
	</channel>
</rss>

