<?xml version="1.0" encoding="UTF-8"?><rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	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/"
		>
<channel>
	<title>Comments on: Extremely Fast Line Algorithm AS3 Optimized</title>
	<atom:link href="http://www.simppa.fi/blog/extremely-fast-line-algorithm-as3-optimized/feed/" rel="self" type="application/rss+xml" />
	<link>http://www.simppa.fi/blog/extremely-fast-line-algorithm-as3-optimized/</link>
	<description>minä kaikkeudessa.</description>
	<lastBuildDate>Mon, 06 Feb 2012 21:49:12 +0000</lastBuildDate>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.3.1</generator>
	<item>
		<title>By: hugo</title>
		<link>http://www.simppa.fi/blog/extremely-fast-line-algorithm-as3-optimized/comment-page-1/#comment-24287</link>
		<dc:creator>hugo</dc:creator>
		<pubDate>Thu, 06 Jan 2011 10:29:51 +0000</pubDate>
		<guid isPermaLink="false">http://www.simppa.fi/blog/?p=521#comment-24287</guid>
		<description>i get a syntax error in this line here?!:

if((shortLen ^ (shortLen &gt;&gt; 31)) – (shortLen &gt;&gt; 31) &gt; (longLen ^ (longLen &gt;&gt; 31)) – (longLen &gt;&gt; 31))

why? thx!</description>
		<content:encoded><![CDATA[<p>i get a syntax error in this line here?!:</p>
<p>if((shortLen ^ (shortLen &gt;&gt; 31)) – (shortLen &gt;&gt; 31) &gt; (longLen ^ (longLen &gt;&gt; 31)) – (longLen &gt;&gt; 31))</p>
<p>why? thx!</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: simo</title>
		<link>http://www.simppa.fi/blog/extremely-fast-line-algorithm-as3-optimized/comment-page-1/#comment-23722</link>
		<dc:creator>simo</dc:creator>
		<pubDate>Fri, 15 Oct 2010 06:37:18 +0000</pubDate>
		<guid isPermaLink="false">http://www.simppa.fi/blog/?p=521#comment-23722</guid>
		<description>Mads ny, thanks for sharing! Very useful stuff. I would merge them into new line method to get the performance to max. Respect.</description>
		<content:encoded><![CDATA[<p>Mads ny, thanks for sharing! Very useful stuff. I would merge them into new line method to get the performance to max. Respect.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Mads ny</title>
		<link>http://www.simppa.fi/blog/extremely-fast-line-algorithm-as3-optimized/comment-page-1/#comment-23718</link>
		<dc:creator>Mads ny</dc:creator>
		<pubDate>Thu, 14 Oct 2010 18:40:54 +0000</pubDate>
		<guid isPermaLink="false">http://www.simppa.fi/blog/?p=521#comment-23718</guid>
		<description>GREAT GREAT line drawer funct, and great blog+work by the way.
If you like me, need transparenty with your like drawing, then here&#039;s a great color blending function for ya.

private function blendColors(col1:uint, col2:uint):uint{
		var aT:uint = col1 &gt;&gt;&gt; 24;
    		var rT:uint = (col1 &gt;&gt;&gt; 16 &amp; 0xFF) * (aT/0xFF);
    		var gT:uint = (col1 &gt;&gt;&gt; 8 &amp; 0xFF) * (aT/0xFF);
    		var bT:uint = (col1  &amp; 0xFF) * (aT/0xFF);
    		var aB:uint = col2 &gt;&gt;&gt; 24;
    		var rB:uint = (col2 &gt;&gt;&gt; 16 &amp; 0xFF) * (aB/0xFF);
    		var gB:uint = (col2 &gt;&gt;&gt; 8 &amp; 0xFF) * (aB/0xFF);
   		var bB:uint = (col2  &amp; 0xFF) * (aB /0xFF);
    		var alpValue:Number = (0xFF - aT)/0xFF;
    		var aN:uint = Math.min(aB + aT, 0xFF);
    		var rN:uint = Math.min(rB * alpValue + rT, 0xFF);
   		var gN:uint = Math.min(gB * alpValue + gT, 0xFF);
   		var bN:uint = Math.min(bB * alpValue + bT, 0xFF);
   		return(aN &lt;&lt; 24 &#124; rN &lt;&lt; 16 &#124; gN &lt;&lt; 8 &#124; bN);
}

To use. update the efla&#039;s pixel drawing section like this.

if (yLonger)
            {
                for (var i:int = 0; i != longLen; i += inc)
                {
		var tcol:uint = blendColors(  color,  bmd.getPixel32(x + i*multDiff, y+i));
		bmd.setPixel32(x + i*multDiff, y+i, tcol)
                }
            }
            else
            {
                for (i = 0; i != longLen; i += inc)
                {
		var tcol:uint = blendColors(   color, bmd.getPixel32(x+i, y+i*multDiff));
                bmd.setPixel32(x+i, y+i*multDiff, tcol);
                }
            }

and voila, pixels blend when they draw on top of each other with transparency, off remember to set you BitmapData object to transparency, i have mine like this
new BitmapData(X, Y, true);

Hope this could help anyone :)</description>
		<content:encoded><![CDATA[<p>GREAT GREAT line drawer funct, and great blog+work by the way.<br />
If you like me, need transparenty with your like drawing, then here&#8217;s a great color blending function for ya.</p>
<p>private function blendColors(col1:uint, col2:uint):uint{<br />
		var aT:uint = col1 &gt;&gt;&gt; 24;<br />
    		var rT:uint = (col1 &gt;&gt;&gt; 16 &amp; 0xFF) * (aT/0xFF);<br />
    		var gT:uint = (col1 &gt;&gt;&gt; 8 &amp; 0xFF) * (aT/0xFF);<br />
    		var bT:uint = (col1  &amp; 0xFF) * (aT/0xFF);<br />
    		var aB:uint = col2 &gt;&gt;&gt; 24;<br />
    		var rB:uint = (col2 &gt;&gt;&gt; 16 &amp; 0xFF) * (aB/0xFF);<br />
    		var gB:uint = (col2 &gt;&gt;&gt; 8 &amp; 0xFF) * (aB/0xFF);<br />
   		var bB:uint = (col2  &amp; 0xFF) * (aB /0xFF);<br />
    		var alpValue:Number = (0xFF &#8211; aT)/0xFF;<br />
    		var aN:uint = Math.min(aB + aT, 0xFF);<br />
    		var rN:uint = Math.min(rB * alpValue + rT, 0xFF);<br />
   		var gN:uint = Math.min(gB * alpValue + gT, 0xFF);<br />
   		var bN:uint = Math.min(bB * alpValue + bT, 0xFF);<br />
   		return(aN &lt;&lt; 24 | rN &lt;&lt; 16 | gN &lt;&lt; 8 | bN);<br />
}</p>
<p>To use. update the efla&#039;s pixel drawing section like this.</p>
<p>if (yLonger)<br />
            {<br />
                for (var i:int = 0; i != longLen; i += inc)<br />
                {<br />
		var tcol:uint = blendColors(  color,  bmd.getPixel32(x + i*multDiff, y+i));<br />
		bmd.setPixel32(x + i*multDiff, y+i, tcol)<br />
                }<br />
            }<br />
            else<br />
            {<br />
                for (i = 0; i != longLen; i += inc)<br />
                {<br />
		var tcol:uint = blendColors(   color, bmd.getPixel32(x+i, y+i*multDiff));<br />
                bmd.setPixel32(x+i, y+i*multDiff, tcol);<br />
                }<br />
            }</p>
<p>and voila, pixels blend when they draw on top of each other with transparency, off remember to set you BitmapData object to transparency, i have mine like this<br />
new BitmapData(X, Y, true);</p>
<p>Hope this could help anyone :)</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Lauri V.</title>
		<link>http://www.simppa.fi/blog/extremely-fast-line-algorithm-as3-optimized/comment-page-1/#comment-23573</link>
		<dc:creator>Lauri V.</dc:creator>
		<pubDate>Wed, 09 Jun 2010 19:27:41 +0000</pubDate>
		<guid isPermaLink="false">http://www.simppa.fi/blog/?p=521#comment-23573</guid>
		<description>Actually i spoke too soon again - i wonder if Michael Abrash&#039;s &quot;run-length sliced Bresenham&#039;s line drawing algorithm&quot; is even faster than fixed point DDA (Han-Po&#039;s implementation). I was estimating the amount of CPU cycles per pixel for both methods and it might even be that mr. Abrash&#039;s code runs 2/3 faster... I do not know though, i haven&#039;t tested/measured it.

For details please see http://downloads.gamedev.net/pdf/gpbb/gpbb36.pdf .</description>
		<content:encoded><![CDATA[<p>Actually i spoke too soon again &#8211; i wonder if Michael Abrash&#8217;s &#8220;run-length sliced Bresenham&#8217;s line drawing algorithm&#8221; is even faster than fixed point DDA (Han-Po&#8217;s implementation). I was estimating the amount of CPU cycles per pixel for both methods and it might even be that mr. Abrash&#8217;s code runs 2/3 faster&#8230; I do not know though, i haven&#8217;t tested/measured it.</p>
<p>For details please see <a href="http://downloads.gamedev.net/pdf/gpbb/gpbb36.pdf" rel="nofollow">http://downloads.gamedev.net/pdf/gpbb/gpbb36.pdf</a> .</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: simo</title>
		<link>http://www.simppa.fi/blog/extremely-fast-line-algorithm-as3-optimized/comment-page-1/#comment-23558</link>
		<dc:creator>simo</dc:creator>
		<pubDate>Fri, 04 Jun 2010 10:35:08 +0000</pubDate>
		<guid isPermaLink="false">http://www.simppa.fi/blog/?p=521#comment-23558</guid>
		<description>ohh, shame :( Would have been nice to find even faster solution.</description>
		<content:encoded><![CDATA[<p>ohh, shame :( Would have been nice to find even faster solution.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Lauri V.</title>
		<link>http://www.simppa.fi/blog/extremely-fast-line-algorithm-as3-optimized/comment-page-1/#comment-23555</link>
		<dc:creator>Lauri V.</dc:creator>
		<pubDate>Wed, 02 Jun 2010 18:12:37 +0000</pubDate>
		<guid isPermaLink="false">http://www.simppa.fi/blog/?p=521#comment-23555</guid>
		<description>I&#039;m sorry for my too fast judgement - Breseham&#039;s line drawing algorithm isn&#039;t fastest on modern 32-bit hardware. Fixed point DDA is the fastest and Han-Po&#039;s algorithm is actually nothing more than a fixed point optimized DDA line drawing algorithm with a new, fancy name.

So, Simo, you&#039;ve got the fastest algorithm already. :)</description>
		<content:encoded><![CDATA[<p>I&#8217;m sorry for my too fast judgement &#8211; Breseham&#8217;s line drawing algorithm isn&#8217;t fastest on modern 32-bit hardware. Fixed point DDA is the fastest and Han-Po&#8217;s algorithm is actually nothing more than a fixed point optimized DDA line drawing algorithm with a new, fancy name.</p>
<p>So, Simo, you&#8217;ve got the fastest algorithm already. :)</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: simo</title>
		<link>http://www.simppa.fi/blog/extremely-fast-line-algorithm-as3-optimized/comment-page-1/#comment-23551</link>
		<dc:creator>simo</dc:creator>
		<pubDate>Tue, 01 Jun 2010 10:35:54 +0000</pubDate>
		<guid isPermaLink="false">http://www.simppa.fi/blog/?p=521#comment-23551</guid>
		<description>Good for you, Lauri.
How about sharing your method?</description>
		<content:encoded><![CDATA[<p>Good for you, Lauri.<br />
How about sharing your method?</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Lauri V.</title>
		<link>http://www.simppa.fi/blog/extremely-fast-line-algorithm-as3-optimized/comment-page-1/#comment-23541</link>
		<dc:creator>Lauri V.</dc:creator>
		<pubDate>Sat, 29 May 2010 10:14:28 +0000</pubDate>
		<guid isPermaLink="false">http://www.simppa.fi/blog/?p=521#comment-23541</guid>
		<description>This agorithm is the naivest possible.
I brewed the same code back in 2003 when i was just starting graphics programming. I had no interests to do reserch on line drawing and thus i didn&#039;t know any other ways to do it. I had no interests for benchmarking and thus i never knew it was so fast.

Basically Bresenham Line Algorithm could be optimized with nested loops to get rid of the inner branch. In the case where dx &gt; dy the inner loop itself could be replaced with horizontal line drawing code i.e. memset() making it blazing fast!

I think the root of Han-Po&#039;s results is unevenly distributed level optimizing among line drawing algorithms making his implemetation seem fastest.</description>
		<content:encoded><![CDATA[<p>This agorithm is the naivest possible.<br />
I brewed the same code back in 2003 when i was just starting graphics programming. I had no interests to do reserch on line drawing and thus i didn&#8217;t know any other ways to do it. I had no interests for benchmarking and thus i never knew it was so fast.</p>
<p>Basically Bresenham Line Algorithm could be optimized with nested loops to get rid of the inner branch. In the case where dx &gt; dy the inner loop itself could be replaced with horizontal line drawing code i.e. memset() making it blazing fast!</p>
<p>I think the root of Han-Po&#8217;s results is unevenly distributed level optimizing among line drawing algorithms making his implemetation seem fastest.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: simo</title>
		<link>http://www.simppa.fi/blog/extremely-fast-line-algorithm-as3-optimized/comment-page-1/#comment-23461</link>
		<dc:creator>simo</dc:creator>
		<pubDate>Wed, 24 Mar 2010 12:45:10 +0000</pubDate>
		<guid isPermaLink="false">http://www.simppa.fi/blog/?p=521#comment-23461</guid>
		<description>auch dave! create a new Rectangle() object into class and use it on every loop cycle:

rect.x = x-(size/2) + i * multDiff;
rect.y = y-(size/2) + i;
rect.width = rect.height = size;
bitmapData.fillRect(rect,color);

much faster.</description>
		<content:encoded><![CDATA[<p>auch dave! create a new Rectangle() object into class and use it on every loop cycle:</p>
<p>rect.x = x-(size/2) + i * multDiff;<br />
rect.y = y-(size/2) + i;<br />
rect.width = rect.height = size;<br />
bitmapData.fillRect(rect,color);</p>
<p>much faster.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: dave</title>
		<link>http://www.simppa.fi/blog/extremely-fast-line-algorithm-as3-optimized/comment-page-1/#comment-23458</link>
		<dc:creator>dave</dc:creator>
		<pubDate>Sun, 21 Mar 2010 00:03:41 +0000</pubDate>
		<guid isPermaLink="false">http://www.simppa.fi/blog/?p=521#comment-23458</guid>
		<description>great thanks, worked perfectly for me:

bitmapData.fillRect(new Rectangle(x-(size/2) + i * multDiff, y-(size/2) + i, size, size),color);</description>
		<content:encoded><![CDATA[<p>great thanks, worked perfectly for me:</p>
<p>bitmapData.fillRect(new Rectangle(x-(size/2) + i * multDiff, y-(size/2) + i, size, size),color);</p>
]]></content:encoded>
	</item>
</channel>
</rss>

