<?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>simppa.fi/blog &#187; tips</title>
	<atom:link href="http://www.simppa.fi/blog/category/tips/feed/" rel="self" type="application/rss+xml" />
	<link>http://www.simppa.fi/blog</link>
	<description>minä kaikkeudessa.</description>
	<lastBuildDate>Wed, 11 Jan 2012 11:10:00 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.3.1</generator>
		<item>
		<title>The way we name our classes</title>
		<link>http://www.simppa.fi/blog/way-we-name-our-classes/</link>
		<comments>http://www.simppa.fi/blog/way-we-name-our-classes/#comments</comments>
		<pubDate>Fri, 01 Apr 2011 11:53:27 +0000</pubDate>
		<dc:creator>simo</dc:creator>
				<category><![CDATA[AS3.0]]></category>
		<category><![CDATA[design patterns]]></category>
		<category><![CDATA[flash]]></category>
		<category><![CDATA[tips]]></category>

		<guid isPermaLink="false">http://www.simppa.fi/blog/?p=1061</guid>
		<description><![CDATA[This minor detail has been haunting me for years. It&#8217;s not extremely significant, but really makes a difference with modern coding tools. I&#8217;m talking about the code hinting that all decent coding tools have. It&#8217;s such a priceless feature, but for some reason I often see libs that don&#8217;t take advantage of it. Most libs [...]]]></description>
			<content:encoded><![CDATA[<p>This minor detail has been haunting me for years. It&#8217;s not extremely significant, but really makes a difference with modern coding tools.</p>
<p>I&#8217;m talking about the code hinting that all decent coding tools have. It&#8217;s such a priceless feature, but for some reason I often see libs that don&#8217;t take advantage of it. Most libs are still coded in &#8220;clear English format&#8221;.<br />
<span id="more-1061"></span><br />
For example:</p>
<p><a href="http://www.simppa.fi/blog/wp-content/uploads/2011/04/Screen-shot-2011-04-01-at-2.18.18-PM.png"><img src="http://www.simppa.fi/blog/wp-content/uploads/2011/04/Screen-shot-2011-04-01-at-2.18.18-PM.png" alt="" title="Screen shot 2011-04-01 at 2.18.18 PM" width="413" height="37" class="alignnone size-full wp-image-1066" /></a></p>
<p>Let&#8217;s pretend for a second that you are coding as3 for the first time. You heard that there are filters, but you don&#8217;t know what sort. In this case you need to open your manual and see the filters-section and save the names of all filters into your already overloaded brains. Or at least the first words of them. This leads you to jump back and forward with the manual during your development. For example you would like to add a shadow to image. So you might try to type something like Shad and ask code hint for some guidance. What do you get? Shader this and that&#8230; Where&#8217;s the shadow filter??? After some clicking you find from your manual that the correct word is DropShadowFilter.</p>
<p>Instead all this could be solved with extremely simple naming solution = <strong>FilterShadowDrop</strong>. In this case you could just type Filter and the code hint would serve you a list of all filters at the lib and there could even be different sort of Shadows.</p>
<p>So the idea is to name your classes with type first method. Here&#8217;s an example of lib that contains Frisbee&#8217;s:</p>
<p><a href="http://www.simppa.fi/blog/wp-content/uploads/2011/04/Screen-shot-2011-04-01-at-2.12.59-PM.png"><img src="http://www.simppa.fi/blog/wp-content/uploads/2011/04/Screen-shot-2011-04-01-at-2.12.59-PM.png" alt="" title="Screen shot 2011-04-01 at 2.12.59 PM" width="622" height="148" class="alignnone size-full wp-image-1062" /></a></p>
<p>This is why I&#8217;ve named classes at evoCunningParticleEngine as follows:</p>
<p><a href="http://www.simppa.fi/blog/wp-content/uploads/2011/04/Screen-shot-2011-04-01-at-2.20.46-PM.png"><img src="http://www.simppa.fi/blog/wp-content/uploads/2011/04/Screen-shot-2011-04-01-at-2.20.46-PM.png" alt="" title="Screen shot 2011-04-01 at 2.20.46 PM" width="282" height="340" class="alignnone size-full wp-image-1068" /></a></p>
<p>And this is exactly why command-type classes are named with C-letter at front:</p>
<p><a href="http://www.simppa.fi/blog/wp-content/uploads/2011/04/Screen-shot-2011-04-01-at-2.14.54-PM.png"><img src="http://www.simppa.fi/blog/wp-content/uploads/2011/04/Screen-shot-2011-04-01-at-2.14.54-PM.png" alt="" title="Screen shot 2011-04-01 at 2.14.54 PM" width="398" height="67" class="alignnone size-full wp-image-1063" /></a></p>
<p>I don&#8217;t see why code should be clear English when instead it could be just clear code with good design patterns and named so that it&#8217;s intuitive to use. I can sure you that with this kind of naming the manual paddling will decrease fundamentally. </p>
<p>Or do you disagree?  Am I missing something here?</p>
]]></content:encoded>
			<wfw:commentRss>http://www.simppa.fi/blog/way-we-name-our-classes/feed/</wfw:commentRss>
		<slash:comments>13</slash:comments>
		</item>
		<item>
		<title>Victory at Assembly, opensourced evoCunningParticleEngine and some bad news</title>
		<link>http://www.simppa.fi/blog/victory-at-assembly-opensourced-evocunningparticleengine-and-some-bad-news/</link>
		<comments>http://www.simppa.fi/blog/victory-at-assembly-opensourced-evocunningparticleengine-and-some-bad-news/#comments</comments>
		<pubDate>Mon, 09 Aug 2010 07:40:16 +0000</pubDate>
		<dc:creator>simo</dc:creator>
				<category><![CDATA[AS3.0]]></category>
		<category><![CDATA[demoscene]]></category>
		<category><![CDATA[English]]></category>
		<category><![CDATA[evoCunningParticleEngine]]></category>
		<category><![CDATA[evoSync]]></category>
		<category><![CDATA[evoTinyEngine]]></category>
		<category><![CDATA[flash]]></category>
		<category><![CDATA[source]]></category>
		<category><![CDATA[tips]]></category>

		<guid isPermaLink="false">http://www.simppa.fi/blog/?p=905</guid>
		<description><![CDATA[After 4-5 months of twiddle it payed off and we won again at Assembly. You can checkout the outcome in realtime by clicking the picture or view it in HD at Youtube. Here&#8217;s also the link to the info file and link to pouet of course. As I mentioned earlier I invited David Lenaerts to [...]]]></description>
			<content:encoded><![CDATA[<p><a href="http://www.simppa.fi/asm10/spiralout/"><img src="http://www.simppa.fi/blog/wp-content/uploads/2010/08/screen_simppafi_spo.jpg" alt="" title="Evoflash - Spiral Out" width="605" height="340" class="alignnone size-full wp-image-907" /></a><br />
After 4-5 months of twiddle it payed off and we won again at Assembly. You can checkout the outcome in realtime by clicking the picture or view it in <a href="http://www.youtube.com/watch?v=64LmkYV4KrQ">HD at Youtube</a>. <a href="http://www.simppa.fi/asm10/spiralout/evo-spo.nfo.txt">Here&#8217;s also the link to the info file</a> and <a href="http://www.pouet.net/prod.php?which=55593">link to pouet of course</a>.</p>
<p>As I mentioned earlier I invited <a href="http://www.derschmale.com/">David Lenaerts</a> to help with the demo. All those fancy Away3dLite stuff with shadows and reflections came by his hands. Awesome!</p>
<p>I also compiled the whole shit through <a href="http://blog.joa-ebert.com/">Joa Ebert&#8217;s Apparat</a>. It did speed up it a bit.</p>
<p>I also had a presentation at Assembly. I talked about my flash art and introduced the evoTinyEngine, evoCunningParticleEngine and evoSync-tool. I haven&#8217;t found the recording of the speech yet but here are some of the links I had there.</p>
<p> &#8211; <a href="http://evocunningparticleengine.googlecode.com/">evoCunningParticleEngine at googlecode</a><br />
 &#8211; <a href="http://evotinyengine.googlecode.com/"> evoTinyEngine at googlecode</a><br />
 &#8211; <a href="http://dl.dropbox.com/u/5754229/evoSync.air">download the evoSync air app</a></p>
<p>You can also <a href="http://www.simppa.fi/talk/asm10/asm10_simppa.pdf">download the presentation in pdf format</a>.</p>
<p>Then the bad news. I had an accident last Friday. I fall down from the fence and my wedding ring got stuck at the top of the fence.<br />
The ring peel off all the skin, muscles and stuff out of my finger. The main tragedy about it was that it also ruined my fingers blood vessels and the finger had to be amputated. So I won&#8217;t be coding new experiments for a while now I guess. I also need to learn how to type fast with 9 fingers. I will recover eventually, but it&#8217;ll take some time and hard work.</p>
<p>I&#8217;ll post more info about the particle engine later when it won&#8217;t hurt so much to type.</p>
<p>p.s. We also did <a href="http://www.simppa.fi/asm10/4k/sof/">this little demo</a> with Jalava to show that 4k intro can be done with Flash. It&#8217;s not too fancy but it proofs the concept :)</p>
]]></content:encoded>
			<wfw:commentRss>http://www.simppa.fi/blog/victory-at-assembly-opensourced-evocunningparticleengine-and-some-bad-news/feed/</wfw:commentRss>
		<slash:comments>12</slash:comments>
		</item>
		<item>
		<title>The fastest way to Z-sort and handle objects in AS3</title>
		<link>http://www.simppa.fi/blog/the-fastest-way-to-z-sort-and-handle-objects-in-as3/</link>
		<comments>http://www.simppa.fi/blog/the-fastest-way-to-z-sort-and-handle-objects-in-as3/#comments</comments>
		<pubDate>Sun, 06 Dec 2009 12:34:35 +0000</pubDate>
		<dc:creator>simo</dc:creator>
				<category><![CDATA[AS3.0]]></category>
		<category><![CDATA[English]]></category>
		<category><![CDATA[flash]]></category>
		<category><![CDATA[tips]]></category>

		<guid isPermaLink="false">http://www.simppa.fi/blog/?p=534</guid>
		<description><![CDATA[(Warning! this will be technical mumbojumbo) In real time computer graphics one thing has given headaches to artist for years: Z-sorting (iow. Z-buffering). Everything goes great until you need to sort objects on screen. It simply eats your CPU. In AS3 this is a huge bottle neck. Yeah the drawing is rather slow but sorting [...]]]></description>
			<content:encoded><![CDATA[<p><img src="http://www.simppa.fi/experimental/as3/2009/zsorts/screenshot.png" alt="z sort" /><br />
(Warning! this will be technical mumbojumbo)</p>
<p>In real time computer graphics one thing has given headaches to artist for years: Z-sorting (iow. <a href="http://en.wikipedia.org/wiki/Z-buffering">Z-buffering</a>). Everything goes great until you need to sort objects on screen. It simply eats your CPU. In AS3 this is a huge bottle neck. Yeah the drawing is rather slow but sorting is even more slow. If the challenge is demanding you just need to be equally smart.</p>
<p>As you may have noticed in my works the z-sorting doesn&#8217;t seems to be very big issue. For example the <a href="http://www.simppa.fi/experimental/as3/2009/cunningparticle/gameoflife3d/d/">GameOfLife3D</a> rolls 13824 particles and does dozen other stuff as well. In worst case just the sort can take up to 40ms in every frame.</p>
<p>When creating an engine of 3D the handling and z-sorting of objects should not thought as separated blocks. To gain performance every piece need to work together. The perfect symbiosis has to be found to serve all step of the system.<br />
<span id="more-534"></span><br />
I build a test that sort list of objects that have X,Y,Z -coordinates and parameter i. Task is to z-sort objects and set i to z. In every test coordinates are set to same to have fair results. I added all z-sort methods I could find.<br />
Here are average results with 100000 objects (click on them to stop the process):</p>
<p><a href="http://www.simppa.fi/experimental/as3/2009/zsorts/vector_sort.swf">Vector native sort-method + for-loop: 327ms</a><br />
<a href="http://www.simppa.fi/experimental/as3/2009/zsorts/vector_shellshort_a.swf">Vector shellShort-method + for-loop: 207ms</a><br />
<a href="http://www.simppa.fi/experimental/as3/2009/zsorts/arraysort.swf">Array native sort-method + for-loop: 328ms</a><br />
<a href="http://www.simppa.fi/experimental/as3/2009/zsorts/arraysorton.swf">Array native sortOn-method + for-loop: 54ms</a><br />
<a href="http://www.simppa.fi/experimental/as3/2009/zsorts/jedivoodoo.swf">Jedi+Voodoo sorting and handle method: 4ms</a></p>
<p><strong>Cut the bullshit and tell us how!</strong></p>
<p><a href="http://lab.polygonal.de/about/">Michael Baczynski</a> introduced this code back in 2007 and I think it&#8217;s extremely weird that it hasn&#8217;t been noticed more widely. I was convinced about the power of linked lists after reading his <a href="http://lab.polygonal.de/2007/11/26/data-structures-more-on-linked-lists/">post</a> and been using them ever since. I build the evo3d and evoCunningParticleEngine based on doubly-LinkedLists. He also shows a very elegant method for sorting called <a href="http://en.wikipedia.org/wiki/Insertion_sort">InsertionSort</a> and boy it&#8217;s fast when used right.</p>
<p>The beauty of it is that it doesn&#8217;t do anything unnecessary. Here&#8217;s the lines I use on test:</p>
<div class="codesnip-container" >
<div class="actionscript codesnip" style="font-family:monospace;"><span class="kw2">var</span> f:Particle3D = first;<br />
<span class="kw2">var</span> n:Particle3D, j:Particle3D, p:Particle3D, c:Particle3D;<br />
c = f.<span class="me1">next</span>;<br />
<span class="kw1">while</span><span class="br0">&#40;</span>c<span class="br0">&#41;</span> <span class="br0">&#123;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; n = c.<span class="me1">next</span>;<br />
&nbsp; &nbsp; &nbsp; &nbsp; p = c.<span class="me1">prev</span>;<br />
&nbsp; &nbsp; &nbsp; &nbsp; <span class="kw1">if</span> <span class="br0">&#40;</span>c.<span class="me1">z</span> <span class="sy0">&gt;</span> p.<span class="me1">z</span><span class="br0">&#41;</span> <br />
&nbsp; &nbsp; &nbsp; &nbsp; <span class="br0">&#123;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; j = p;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span class="kw1">while</span><span class="br0">&#40;</span>j.<span class="me1">prev</span><span class="br0">&#41;</span> <br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span class="br0">&#123;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span class="kw1">if</span> <span class="br0">&#40;</span>c.<span class="me1">z</span> <span class="sy0">&gt;</span> j.<span class="me1">prev</span>.<span class="me1">z</span><span class="br0">&#41;</span> <br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span class="br0">&#123;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; j = j.<span class="me1">prev</span>;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span class="br0">&#125;</span><span class="kw1">else</span><span class="br0">&#123;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span class="kw1">break</span>;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span class="br0">&#125;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span class="br0">&#125;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; n ? <span class="br0">&#40;</span>p.<span class="me1">next</span> = n, <span class="br0">&#40;</span>n.<span class="me1">prev</span> = p<span class="br0">&#41;</span><span class="br0">&#41;</span> : p.<span class="me1">next</span> = <span class="kw2">null</span>;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span class="br0">&#40;</span>j == f<span class="br0">&#41;</span> ? <span class="br0">&#40;</span>c.<span class="me1">prev</span> = <span class="kw2">null</span>, <span class="br0">&#40;</span>c.<span class="me1">next</span> = j<span class="br0">&#41;</span>, <span class="br0">&#40;</span>j.<span class="me1">prev</span> = c<span class="br0">&#41;</span>, <span class="br0">&#40;</span>f = c<span class="br0">&#41;</span><span class="br0">&#41;</span> : <span class="br0">&#40;</span>c.<span class="me1">prev</span> = j.<span class="me1">prev</span>, <span class="br0">&#40;</span>j.<span class="me1">prev</span>.<span class="me1">next</span> = c<span class="br0">&#41;</span>, <span class="br0">&#40;</span>c.<span class="me1">next</span> = j<span class="br0">&#41;</span>, <span class="br0">&#40;</span>j.<span class="me1">prev</span> = c<span class="br0">&#41;</span><span class="br0">&#41;</span>;<br />
&nbsp; &nbsp; &nbsp; &nbsp; <span class="br0">&#125;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; c = n;<br />
<span class="br0">&#125;</span></div>
</div>
<p>As you can see if the objects are in order there&#8217;s only one comparison and everything happens inside linkedlist while loop that is the fastest way to loop in as3. Also the benefit of this is that it provides the first object in linkedlist and it can be used to loop again in linkedlist while loop.</p>
<div class="codesnip-container" >
<div class="actionscript codesnip" style="font-family:monospace;"><span class="kw1">while</span><span class="br0">&#40;</span>first<span class="br0">&#41;</span><br />
<span class="br0">&#123;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; first = first.<span class="me1">next</span>;<br />
<span class="br0">&#125;</span></div>
</div>
<p>There is a <strong>but</strong> on this method. If objects are completely mixed this insertion sorting is by far the slowest. That&#8217;s why list has to semi ordered in the first run. This is not a problem in 3d when you are moving using camera and objects doesn&#8217;t swap too much. All the models should be preordered by other methods for the first time. After that insertion sort will take the rest and give maximum performance.</p>
<p>Yeah I know the test isn&#8217;t very good since all objects are in order all ready :) Anyway the linkedlist + insertion sorting is the fastest there is since it only swap those that need to be swapped and does it inside the fastest loop possible.<br />
You can check out <a href="http://www.simppa.fi/experimental/as3/2009/zsorts/src/">the sources</a> here and try for your self.<br />
If you find a faster way to do this I would really appreciate if you let me know how.</p>
<p>&#8212; UPDATE 06:32pm 8.12.2009 &#8212;<br />
<a href="http://www.infiniteturtles.co.uk/blog/about">Rob Bateman</a> responded on this topic by <a href="http://www.infiniteturtles.co.uk/blog/fast-sorting-in-as3">explaining his method on Z-sorting</a>.<br />
<a href="http://en.wikipedia.org/wiki/Radix_sort">Radix Sort</a> is something I didn&#8217;t even knew exist until now :) A must read post.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.simppa.fi/blog/the-fastest-way-to-z-sort-and-handle-objects-in-as3/feed/</wfw:commentRss>
		<slash:comments>14</slash:comments>
		</item>
		<item>
		<title>Extremely Fast Line Algorithm AS3 Optimized</title>
		<link>http://www.simppa.fi/blog/extremely-fast-line-algorithm-as3-optimized/</link>
		<comments>http://www.simppa.fi/blog/extremely-fast-line-algorithm-as3-optimized/#comments</comments>
		<pubDate>Thu, 26 Nov 2009 14:43:15 +0000</pubDate>
		<dc:creator>simo</dc:creator>
				<category><![CDATA[AS3.0]]></category>
		<category><![CDATA[English]]></category>
		<category><![CDATA[flash]]></category>
		<category><![CDATA[tips]]></category>

		<guid isPermaLink="false">http://www.simppa.fi/blog/?p=521</guid>
		<description><![CDATA[Time to time a developer has to ask from Self: &#8220;is this really the fastest way to do it?&#8221; After some investigation in most cases the result is &#8220;no it wasn&#8217;t&#8221;. Here&#8217;s an example: I have used (a little modified version of) the Andre Michelle&#8217;s port from Bresenhams line algorithm and always thought it would [...]]]></description>
			<content:encoded><![CDATA[<p>Time to time a developer has to ask from <a href="http://en.wikipedia.org/wiki/Self">Self</a>: &#8220;is this really the fastest way to do it?&#8221;<br />
After some investigation in most cases the result is &#8220;no it wasn&#8217;t&#8221;. Here&#8217;s an example:</p>
<p>I have used (a little modified version of) the <a href="http://blog.andre-michelle.com/2006/as3-bresenhams-line-algorithm/">Andre Michelle&#8217;s port from Bresenhams</a> line algorithm and always thought it would be the fastest way to draw a line on BitmapData in Flash.</p>
<p>I was playing with lines and asked my self the previous question. After some Googling I found this <a href="http://www.edepot.com/algorithm.html">Extremely Fast Line Algorithm (EFLA)</a> written by Po-Han Lin. I gave it a try and ported it to as3. By default it was way faster then the Bresenhams version, but after some AS3 specific optimizations it came out TWO times faster and here it is for you:</p>
<div class="codesnip-container" >
<div class="actionscript codesnip" style="font-family:monospace;"><span class="kw3">private</span> <span class="kw2">function</span> efla<span class="br0">&#40;</span>x:<span class="kw3">int</span>, y:<span class="kw3">int</span>, x2:<span class="kw3">int</span>, y2:<span class="kw3">int</span>, <span class="kw3">color</span>:uint<span class="br0">&#41;</span>:<span class="kw3">void</span><br />
<span class="br0">&#123;</span><br />
&nbsp; <span class="kw2">var</span> shortLen:<span class="kw3">int</span> = y2-y;<br />
&nbsp; <span class="kw2">var</span> longLen:<span class="kw3">int</span> = x2-x;</p>
<p>&nbsp; <span class="kw1">if</span><span class="br0">&#40;</span><span class="br0">&#40;</span>shortLen ^ <span class="br0">&#40;</span>shortLen <span class="sy0">&gt;&gt;</span> 31<span class="br0">&#41;</span><span class="br0">&#41;</span> &#8211; <span class="br0">&#40;</span>shortLen <span class="sy0">&gt;&gt;</span> 31<span class="br0">&#41;</span> <span class="sy0">&gt;</span> <span class="br0">&#40;</span>longLen ^ <span class="br0">&#40;</span>longLen <span class="sy0">&gt;&gt;</span> 31<span class="br0">&#41;</span><span class="br0">&#41;</span> &#8211; <span class="br0">&#40;</span>longLen <span class="sy0">&gt;&gt;</span> 31<span class="br0">&#41;</span><span class="br0">&#41;</span><br />
&nbsp; <span class="br0">&#123;</span><br />
&nbsp; shortLen ^= longLen;<br />
&nbsp; longLen ^= shortLen;<br />
&nbsp; shortLen ^= longLen;</p>
<p>&nbsp; <span class="kw2">var</span> yLonger:<span class="kw3">Boolean</span> = <span class="kw2">true</span>;<br />
&nbsp; <span class="br0">&#125;</span><br />
&nbsp; <span class="kw1">else</span><br />
&nbsp;<span class="br0">&#123;</span><br />
&nbsp; yLonger = <span class="kw2">false</span>;<br />
&nbsp;<span class="br0">&#125;</span></p>
<p>&nbsp; <span class="kw2">var</span> inc:<span class="kw3">int</span> = longLen <span class="sy0">&lt;</span> 0 ? -1 : <span class="nu0">1</span>;</p>
<p>&nbsp; <span class="kw2">var</span> multDiff:<span class="kw3">Number</span> = longLen == 0 ? shortLen : shortLen <span class="sy0">/</span> longLen;</p>
<p>&nbsp; <span class="kw1">if</span> <span class="br0">&#40;</span>yLonger<span class="br0">&#41;</span> <br />
&nbsp; <span class="br0">&#123;</span><br />
&nbsp; &nbsp; <span class="kw1">for</span> <span class="br0">&#40;</span><span class="kw2">var</span> i:<span class="kw3">int</span> = <span class="nu0">0</span>; i <span class="sy0">!</span>= longLen; i += inc<span class="br0">&#41;</span> <br />
&nbsp; &nbsp; <span class="br0">&#123;</span><br />
&nbsp; &nbsp; &nbsp; <span class="kw3">this</span>.<span class="me1">bit</span>.<span class="me1">setPixel</span><span class="br0">&#40;</span>x + i<span class="sy0">*</span>multDiff, y+i, <span class="kw3">color</span><span class="br0">&#41;</span>;<br />
&nbsp; &nbsp; <span class="br0">&#125;</span><br />
&nbsp; <span class="br0">&#125;</span> <br />
&nbsp; <span class="kw1">else</span> <br />
&nbsp; <span class="br0">&#123;</span><br />
&nbsp; &nbsp; <span class="kw1">for</span> <span class="br0">&#40;</span>i = <span class="nu0">0</span>; i <span class="sy0">!</span>= longLen; i += inc<span class="br0">&#41;</span> <br />
&nbsp; &nbsp; <span class="br0">&#123;</span><br />
&nbsp; &nbsp; &nbsp; <span class="kw3">this</span>.<span class="me1">bit</span>.<span class="me1">setPixel</span><span class="br0">&#40;</span>x+i, y+i<span class="sy0">*</span>multDiff, <span class="kw3">color</span><span class="br0">&#41;</span>;<br />
&nbsp; &nbsp; <span class="br0">&#125;</span><br />
&nbsp; <span class="br0">&#125;</span><br />
<span class="br0">&#125;</span></div>
</div>
]]></content:encoded>
			<wfw:commentRss>http://www.simppa.fi/blog/extremely-fast-line-algorithm-as3-optimized/feed/</wfw:commentRss>
		<slash:comments>24</slash:comments>
		</item>
	</channel>
</rss>

