<?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>mostly a codeBlog &#187; Bitmap</title>
	<atom:link href="http://www.rickigregersen.com/tag/bitmap/feed/" rel="self" type="application/rss+xml" />
	<link>http://www.rickigregersen.com</link>
	<description>whatever I am currently programming... and I truly digress</description>
	<lastBuildDate>Mon, 21 Jun 2010 15:40:35 +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>SporeTree</title>
		<link>http://www.rickigregersen.com/2009/08/11/sporetree/</link>
		<comments>http://www.rickigregersen.com/2009/08/11/sporetree/#comments</comments>
		<pubDate>Tue, 11 Aug 2009 21:21:02 +0000</pubDate>
		<dc:creator>Ricki</dc:creator>
				<category><![CDATA[ActionScript 3.0]]></category>
		<category><![CDATA[ActionScript3]]></category>
		<category><![CDATA[Flash]]></category>
		<category><![CDATA[actionscript]]></category>
		<category><![CDATA[algorithm]]></category>
		<category><![CDATA[AS3]]></category>
		<category><![CDATA[Bitmap]]></category>
		<category><![CDATA[fun]]></category>
		<category><![CDATA[recursive]]></category>
		<category><![CDATA[spore]]></category>
		<category><![CDATA[tree]]></category>

		<guid isPermaLink="false">http://www.rickigregersen.com/?p=193</guid>
		<description><![CDATA[This time the spores turned into a tree. It is by no means perfect, the branches does not move upwards with the stem as it should, were this a real orange colored scary spore tree. This was just some &#8220;while Im doing nothing, let&#8217;s put whatever in the &#8216;fun&#8217; category&#8221; but if anyone would like [...]]]></description>
			<content:encoded><![CDATA[<p>This time the <a href="http://www.rickigregersen.com/?paged=2">spores</a> turned into a tree. It is by no means perfect, the branches does not move upwards with the stem as it should, were this a real orange colored scary spore tree.</p>
<p>This was just some &#8220;while Im doing nothing, let&#8217;s put whatever in the &#8216;fun&#8217; category&#8221; <img src='http://www.rickigregersen.com/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' />  but if anyone would like the code, throw me a comment and I&#8217;ll send it off. I is uncommented and messy.</p>
<p><object width="512" height="750" data="http://www.rickigregersen.com/wp-content/uploads/BitmapSporeGrowingTree.swf" type="application/x-shockwave-flash"><param name="quality" value="high" /><param name="scale" value="exactfit" /><param name="salign" value="l" /><param name="wmode" value="transparent" /><param name="src" value="http://www.rickigregersen.com/wp-content/uploads/BitmapSporeGrowingTree.swf" /></object></h4>
]]></content:encoded>
			<wfw:commentRss>http://www.rickigregersen.com/2009/08/11/sporetree/feed/</wfw:commentRss>
		<slash:comments>5</slash:comments>
		</item>
		<item>
		<title>Processing Tentacles</title>
		<link>http://www.rickigregersen.com/2009/08/08/processing-tentacles/</link>
		<comments>http://www.rickigregersen.com/2009/08/08/processing-tentacles/#comments</comments>
		<pubDate>Sat, 08 Aug 2009 16:16:38 +0000</pubDate>
		<dc:creator>Ricki</dc:creator>
				<category><![CDATA[Particle]]></category>
		<category><![CDATA[Processing]]></category>
		<category><![CDATA[algorithm]]></category>
		<category><![CDATA[Bitmap]]></category>
		<category><![CDATA[fun]]></category>
		<category><![CDATA[Java]]></category>

		<guid isPermaLink="false">http://www.rickigregersen.com/?p=185</guid>
		<description><![CDATA[I just did a quick port to processing, important to notice that these classes are &#8220;as is&#8221;, but still, the speed of Java compared to Flash is&#8230; well lets just say the gap isn&#8217;t quite gone yet EDIT: forgot some int/float math that made the tentacles look bulky&#8230; better now. Example and code here:]]></description>
			<content:encoded><![CDATA[<p>I just did a quick port to processing, important to notice that these classes are &#8220;as is&#8221;, but still, the speed of Java compared to Flash is&#8230; well lets just say the gap isn&#8217;t quite gone yet <img src='http://www.rickigregersen.com/wp-includes/images/smilies/icon_wink.gif' alt=';)' class='wp-smiley' /> </p>
<p>EDIT: forgot some int/float math that made the tentacles look bulky&#8230; better now.<br />
<a href="http://www.rickigregersen.com/wp-content/uploads/applet/index.html">Example and code here:</a></p>
]]></content:encoded>
			<wfw:commentRss>http://www.rickigregersen.com/2009/08/08/processing-tentacles/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Homegrown Tentacles</title>
		<link>http://www.rickigregersen.com/2009/08/06/homegrown-tentacles/</link>
		<comments>http://www.rickigregersen.com/2009/08/06/homegrown-tentacles/#comments</comments>
		<pubDate>Thu, 06 Aug 2009 18:03:40 +0000</pubDate>
		<dc:creator>Ricki</dc:creator>
				<category><![CDATA[ActionScript 3.0]]></category>
		<category><![CDATA[ActionScript3]]></category>
		<category><![CDATA[Flash]]></category>
		<category><![CDATA[Particle]]></category>
		<category><![CDATA[algorithm]]></category>
		<category><![CDATA[AS3]]></category>
		<category><![CDATA[Bitmap]]></category>
		<category><![CDATA[Filters]]></category>
		<category><![CDATA[flash builder 4]]></category>
		<category><![CDATA[fun]]></category>

		<guid isPermaLink="false">http://www.rickigregersen.com/?p=173</guid>
		<description><![CDATA[I had been scurrying about over on the Soulwire blog, again, and looking at the tentacles. I did some experiments of my own, but the tentacles never came out right, not organic enough. I wrote Justin and asked him how he did it and he was really cool about helping out with a code example [...]]]></description>
			<content:encoded><![CDATA[<p>I had been scurrying about over on the Soulwire blog, again, and looking at the tentacles. I did some experiments of<br />
my own, but the tentacles never came out right, not organic enough. I wrote Justin and asked him how he did it and he was really cool about helping out with a code example of how he did that part.</p>
<p>The Soulwire Tentacles was an experiment in PixelBender speed and usability, so he makes it look as if the tentacles are really growing, i.e. starts out small and each &#8220;joint&#8221; grows as the tentacles grows. Mine is just a look into the random-organic way they grow. Also I was trying to see what kinds of speed I would get by using the Bitmap approach.</p>
<p>Here are the <a href="http://blog.soulwire.co.uk/flash/actionscript-3/pixel-bender-growing-tentacles/">Soulwire Tentacles</a></p>
<p>And here are my Tentacles&#8230; that came out wrong&#8230; <img src='http://www.rickigregersen.com/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' /> </p>
<p><object width="512" height="512" data="http://www.rickigregersen.com/wp-content/uploads/BitmapSpore.swf" type="application/x-shockwave-flash"><param name="quality" value="high" /><param name="scale" value="exactfit" /><param name="salign" value="l" /><param name="wmode" value="transparent" /><param name="src" value="http://www.rickigregersen.com/wp-content/uploads/BitmapSpore.swf" /></object></h4>
<p>The code:</p>
<pre lang="actionscript">
/**
*
 * @BitmapSpore.as	:	inspired by http://blog.soulwire.co.uk/flash/actionscript-3/pixel-bender-growing-tentacles/
 * @Date  08/06-09
 * @Ricki Gregersen
*/

package
{
	import flash.display.Bitmap;
	import flash.display.BitmapData;
	import flash.display.Sprite;
	import flash.events.Event;
	import flash.filters.BlurFilter;
	import flash.geom.ColorTransform;
	import flash.geom.Point;

	[SWF( width="512", height = "512", backgroundColor = "0x222222", frameRate = "30" )]

	public class BitmapSpore extends Sprite
	{
		private static var fading : ColorTransform = new ColorTransform( 1, 1, 1, 0.99999 );
		private static var _blur : BlurFilter = new BlurFilter( 1, 1, 2 );

		private var _bmd:BitmapData;
		private var _bmp:Bitmap;
		private var _container:Sprite;

		public function BitmapSpore()
		{
			_bmd = new BitmapData( 512, 512, true, 0x222222 );
			_bmp = new Bitmap( _bmd );
			addChild( _bmp );
			var s:Spore;
			addChild( _container = new Sprite() );
			for( var i:int = 0; i < 500; i++ )
			{
				s = new Spore( 256, 256, range( 0.01, 0.05 ), range( 2.0, 3.0 ), range( 0.2, 1.0 ));
				s.scaleX = s.scaleY = Math.random() * 2;
				_container.addChild( s );
			}
			addEventListener( Event.ENTER_FRAME, update );
		}

		private function update( event:Event ):void
		{
			var n:int = _container.numChildren;
			var s:Spore;

			for( var i:int = 0; i < n; i++ )
			{
				s = Spore( _container.getChildAt( i ));
				s.move();
				s.x = s.loc.x;
				s.y = s.loc.y;
			}
			_bmp.filters = [  _blur ];
			_bmd.colorTransform( _bmd.rect, fading );
			_bmd.draw( _container );
		}

		private function range(min:Number, max:Number = NaN):Number
		{
			if(isNaN(max)) {max = min; min = 0}
				return min + (Math.random() * (max - min));
		} 

	}
}
	import flash.geom.Point;
	import flash.display.Shape;

	class Spore extends Shape
	{
		public var loc:Point;

		private var angStep:Number;
		private var posStep:Number;
		private var curl:Number;
		private var n:Number = 0;
		private var a:Number = Math.random() * Math.PI * 2;

		function Spore( xPos:Number, yPos:Number, aStep:Number, pStep:Number, c:Number )
		{
			loc = new Point( xPos, yPos );
			angStep = aStep;
			posStep = pStep;
			curl = c;
			graphics.lineStyle( 0, 0x222222, 0.7 );
			graphics.beginFill( 0xFF6600, 0.7 );
			graphics.drawCircle( 0, 0, 5 );
			graphics.endFill();
		}
		public function move():void
		{
			n += Math.random() * (angStep - -angStep) + -angStep;
			n *= 0.9 + curl * 0.1;
			a += n;
			loc.x += Math.cos( a ) * posStep;
			loc.y += Math.sin( a ) * posStep;
			this.scaleX = this.scaleY *= 0.98;
			var s:Number = this.scaleX = this.scaleY;
			if( s < 0.1 )
			{
				loc.x = loc.y = 256;
				this.scaleX = this.scaleY = Math.random() * 2;
			}
		}
	}
</pre>
]]></content:encoded>
			<wfw:commentRss>http://www.rickigregersen.com/2009/08/06/homegrown-tentacles/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
	</channel>
</rss>
