<?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>Zach Archer Blog &#187; Flash</title>
	<atom:link href="http://blog.zacharcher.com/category/flash/feed/" rel="self" type="application/rss+xml" />
	<link>http://blog.zacharcher.com</link>
	<description>This blog is GO!</description>
	<lastBuildDate>Fri, 09 Jul 2010 23:02:45 +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>Aquatic Sound Generator in Flash</title>
		<link>http://blog.zacharcher.com/2010/06/16/aquatic-sound-generator/</link>
		<comments>http://blog.zacharcher.com/2010/06/16/aquatic-sound-generator/#comments</comments>
		<pubDate>Wed, 16 Jun 2010 18:07:48 +0000</pubDate>
		<dc:creator>Zach</dc:creator>
				<category><![CDATA[Flash]]></category>
		<category><![CDATA[Music]]></category>
		<category><![CDATA[Synth]]></category>
		<category><![CDATA[aquasound]]></category>
		<category><![CDATA[audio]]></category>
		<category><![CDATA[formant]]></category>
		<category><![CDATA[fs1r]]></category>
		<category><![CDATA[generative]]></category>

		<guid isPermaLink="false">http://blog.zacharcher.com/?p=219</guid>
		<description><![CDATA[Here's something from the vaults. Aquasound was built with these requirements in mind: Generate sounds that aquatic animals might make Sounds can be "combined" somehow Sounds can emote This was never used in production. I wonder if I could turn this into something? Like a paid iPhone app? ;) Double-click the envelopes to add/remove control [...]]]></description>
			<content:encoded><![CDATA[<p><a href="http://zacharcher.com/lab/aquasound/aquasound.swf"><img class="aligncenter" title="Aquasound" src="http://zacharcher.com/lab/aquasound/aquasound_pic.png" alt="" width="432" height="405" /></a></p>
<p>Here's something from the vaults. Aquasound was built with these requirements in mind:</p>
<ul>
<li>Generate sounds that aquatic animals might make</li>
<li>Sounds can be "combined" somehow</li>
<li>Sounds can emote</li>
</ul>
<p>This was never used in production. I wonder if I could turn this into something? Like a paid iPhone app? ;)</p>
<p>Double-click the envelopes to add/remove control points. Drag lines up &amp; down to change their curviture. The best feature is the "Combine With" dropdown, which splices the current sound with your selection. Also the "Emote" menu will play sounds with different expression.</p>
<p>The audio algorithm is reverse-engineered from <a href="http://blog.zacharcher.com/2009/01/05/synth-review-the-head-exploding-fs1r/">my beloved FS1R</a>. I generated formants in two ways (toggle the "Tonal" checkbox to hear both), the "atonal" version is closer to ring modulation than actual formants. It's more fun if you don't understand what the controls are doing, but if you insist: Pitch controls the overall pitch of the sound. Freq controls the center frequency of the formant (like a bandpass filter). LFOFreq and LFOWeight control a low-frequency sine wave, which can be applied to other controls via their "___LFOAmt" curves. Amp is amplitude, Width is formant width (think: width of the bandpass filter), Skirt adds distortion. Each voice has two formant generators, check "Formant Active" to enable them.</p>
<p>May all your bloops and crackles be happy ones!</p>
<div class='bookmarkify'><a name='bookmarkify'></a><div class='linkbuttons'><a href='http://del.icio.us/post?url=http://blog.zacharcher.com/2010/06/16/aquatic-sound-generator/&amp;title=Aquatic Sound Generator in Flash' title='Save to del.icio.us' onclick='target="_blank";' rel='nofollow'><img src='http://blog.zacharcher.com/wp-content/plugins/bookmarkify/delicious.png' style='width:16px; height:16px;' alt='[del.icio.us] ' /></a> <a href='http://digg.com/submit?phase=2&amp;url=http://blog.zacharcher.com/2010/06/16/aquatic-sound-generator/&amp;title=Aquatic Sound Generator in Flash' title='Digg It!' onclick='target="_blank";' rel='nofollow'><img src='http://blog.zacharcher.com/wp-content/plugins/bookmarkify/digg.png' style='width:16px; height:16px;' alt='[Digg] ' /></a> <a href='http://reddit.com/submit?url=http://blog.zacharcher.com/2010/06/16/aquatic-sound-generator/&amp;title=Aquatic Sound Generator in Flash' title='Reddit' onclick='target="_blank";' rel='nofollow'><img src='http://blog.zacharcher.com/wp-content/plugins/bookmarkify/reddit.png' style='width:16px; height:16px;' alt='[Reddit] ' /></a> <a href='http://twitter.com/home/?status=Aquatic Sound Generator in Flash+http://blog.zacharcher.com/2010/06/16/aquatic-sound-generator/' title='Save to Twitter' onclick='target="_blank";' rel='nofollow'><img src='http://blog.zacharcher.com/wp-content/plugins/bookmarkify/twitter.png' style='width:16px; height:16px;' alt='[Twitter] ' /></a> <a href='http://www.feedburner.com/fb/a/emailFlare?itemTitle=Aquatic Sound Generator in Flash&amp;uri=http://blog.zacharcher.com/2010/06/16/aquatic-sound-generator/&amp;loc=en_US' title='Email this to a friend' onclick='target="_blank";' rel='nofollow'><img src='http://blog.zacharcher.com/wp-content/plugins/bookmarkify/email.png' style='width:16px; height:16px;' alt='[Email] ' /></a>  <a title='See more bookmark and sharing options...' href='http://blog.zacharcher.com/2010/06/16/aquatic-sound-generator/#bookmarkify' rel='nofollow'><small>More&nbsp;&raquo;</small></a></div></div>]]></content:encoded>
			<wfw:commentRss>http://blog.zacharcher.com/2010/06/16/aquatic-sound-generator/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
		<item>
		<title>Strange Attractors in Flash</title>
		<link>http://blog.zacharcher.com/2009/12/12/strange-attractors-in-flash/</link>
		<comments>http://blog.zacharcher.com/2009/12/12/strange-attractors-in-flash/#comments</comments>
		<pubDate>Sun, 13 Dec 2009 00:10:16 +0000</pubDate>
		<dc:creator>Zach</dc:creator>
				<category><![CDATA[Flash]]></category>
		<category><![CDATA[Graphics]]></category>
		<category><![CDATA[fractal]]></category>
		<category><![CDATA[strange attractor]]></category>

		<guid isPermaLink="false">http://blog.zacharcher.com/?p=184</guid>
		<description><![CDATA[Have you seen (or played) the demo for Polynomial, the space shooter? Quick! Watch the video: I spent a couple hours generating strange attractors in Flash, just a simple 2D version for now. Click to play: Click the black region to generate new polynomial coefficients and redraw. You will have to click many times to [...]]]></description>
			<content:encoded><![CDATA[<p>Have you seen (or played) the demo for <a href="http://dmytry.pandromeda.com/games/index.html">Polynomial</a>, the space shooter? Quick! Watch the video:</p>
<p><object width="560" height="340"><param name="movie" value="http://www.youtube.com/v/2Q6RaOgmanc&#038;hl=en_US&#038;fs=1&#038;"></param><param name="allowFullScreen" value="true"></param><param name="allowscriptaccess" value="always"></param><embed src="http://www.youtube.com/v/2Q6RaOgmanc&#038;hl=en_US&#038;fs=1&#038;" type="application/x-shockwave-flash" allowscriptaccess="always" allowfullscreen="true" width="560" height="340"></embed></object></p>
<p>I spent a couple hours generating strange attractors in Flash, just a simple 2D version for now. Click to play:<br />
<a href="http://zacharcher.com/lab/20091212_strange_attractor/StrangeAttractor.html"><br />
<img src="http://zacharcher.com/lab/20091212_strange_attractor/attractor_image.png" alt="Here Be Strange Attractors" /></a></p>
<p>Click the black region to generate new polynomial coefficients and redraw. <strong>You will have to click many times to generate something interesting</strong>. That's the nature of fractals, I'm afraid. Some coefficients are automatically thrown out if the drawing exceeds a certain size. Unfortunately, the inverse is not true: the code isn't smart enough to trash any drawings that shrink to microscopic size.</p>
<p>I believe that you can stabilize any coefficients by scaling the values of each coefficient, gradually nudging them larger/smaller until the drawing is stable. I'll try this when I get more time. I've been gung-ho on my first proper iPhone app, trying to finish it before Christmas! Stay tuned...</p>
<p>Also, <a href="http://zacharcher.com/lab/20091212_strange_attractor/strange_attractor.zip">here's the source code for the strange attractor harness</a>! Enjoy.</p>
<div class='bookmarkify'><a name='bookmarkify'></a><div class='linkbuttons'><a href='http://del.icio.us/post?url=http://blog.zacharcher.com/2009/12/12/strange-attractors-in-flash/&amp;title=Strange Attractors in Flash' title='Save to del.icio.us' onclick='target="_blank";' rel='nofollow'><img src='http://blog.zacharcher.com/wp-content/plugins/bookmarkify/delicious.png' style='width:16px; height:16px;' alt='[del.icio.us] ' /></a> <a href='http://digg.com/submit?phase=2&amp;url=http://blog.zacharcher.com/2009/12/12/strange-attractors-in-flash/&amp;title=Strange Attractors in Flash' title='Digg It!' onclick='target="_blank";' rel='nofollow'><img src='http://blog.zacharcher.com/wp-content/plugins/bookmarkify/digg.png' style='width:16px; height:16px;' alt='[Digg] ' /></a> <a href='http://reddit.com/submit?url=http://blog.zacharcher.com/2009/12/12/strange-attractors-in-flash/&amp;title=Strange Attractors in Flash' title='Reddit' onclick='target="_blank";' rel='nofollow'><img src='http://blog.zacharcher.com/wp-content/plugins/bookmarkify/reddit.png' style='width:16px; height:16px;' alt='[Reddit] ' /></a> <a href='http://twitter.com/home/?status=Strange Attractors in Flash+http://blog.zacharcher.com/2009/12/12/strange-attractors-in-flash/' title='Save to Twitter' onclick='target="_blank";' rel='nofollow'><img src='http://blog.zacharcher.com/wp-content/plugins/bookmarkify/twitter.png' style='width:16px; height:16px;' alt='[Twitter] ' /></a> <a href='http://www.feedburner.com/fb/a/emailFlare?itemTitle=Strange Attractors in Flash&amp;uri=http://blog.zacharcher.com/2009/12/12/strange-attractors-in-flash/&amp;loc=en_US' title='Email this to a friend' onclick='target="_blank";' rel='nofollow'><img src='http://blog.zacharcher.com/wp-content/plugins/bookmarkify/email.png' style='width:16px; height:16px;' alt='[Email] ' /></a>  <a title='See more bookmark and sharing options...' href='http://blog.zacharcher.com/2009/12/12/strange-attractors-in-flash/#bookmarkify' rel='nofollow'><small>More&nbsp;&raquo;</small></a></div></div>]]></content:encoded>
			<wfw:commentRss>http://blog.zacharcher.com/2009/12/12/strange-attractors-in-flash/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Flash 3D: A change of heart?</title>
		<link>http://blog.zacharcher.com/2009/09/04/flash-3d-a-change-of-heart/</link>
		<comments>http://blog.zacharcher.com/2009/09/04/flash-3d-a-change-of-heart/#comments</comments>
		<pubDate>Fri, 04 Sep 2009 10:31:40 +0000</pubDate>
		<dc:creator>Zach</dc:creator>
				<category><![CDATA[Flash]]></category>
		<category><![CDATA[Games]]></category>
		<category><![CDATA[3d]]></category>
		<category><![CDATA[away3d]]></category>
		<category><![CDATA[game]]></category>

		<guid isPermaLink="false">http://blog.zacharcher.com/?p=173</guid>
		<description><![CDATA[Yesterday, I posted a damning critique of Flash's native 3D. Today I noticed that if you right-click on yesterday's SWF and show the redraw regions, you can see that it's redrawing the contents of the entire stage, even though I put the scene in a scrollRect. Is it seriously rendering a scene that's thousands of [...]]]></description>
			<content:encoded><![CDATA[<p>Yesterday, I posted <a href="http://blog.zacharcher.com/2009/09/03/flash-3d-makes-me-sad/">a damning critique of Flash's native 3D</a>.</p>
<p>Today I noticed that if you right-click on <a href="http://zacharcher.com/lab/20090831_3d/09b_touch_to_glow.swf">yesterday's SWF</a> and show the redraw regions, you can see that it's redrawing the contents of the entire stage, even though I put the scene in a scrollRect. Is it seriously rendering a scene that's thousands of pixels wide before displaying it ?!?!?!? Oh, no. No they DIDN'T.</p>
<p>Today I ported the scene to the <a href="http://away3d.com/">Away3D</a> rendering engine. Here's the result:</p>
<p style="text-align: center;"><a href="http://zacharcher.com/lab/20090831_3d/10_away3d_follow.swf"><img class="aligncenter" title="Away3D screenshot" src="http://zacharcher.com/lab/20090831_3d/p/10_screenshot.png" alt="" width="453" height="339" /></a></p>
<p>It's beautiful, and provides access to low-level drawing routines, light sources, normal maps, ... It was speedy at first, then slowed down considerably when I added the glowing floors. (Each glow is 16+ triangles right now, for various reasons including: I can't render objects in my own custom order.) This makes <a href="http://zacharcher.com/lab/20090831_3d/09test.html">yesterday's version look performant</a>, I'm reluctant to admit.</p>
<p>Possible next steps:</p>
<ul>
<li>Reduce the native 3D rendering area, see if performance improves?</li>
<li>Grow beyond Flash, embrace the future and try <a href="http://unity3d.com/">Unity 3D</a>?</li>
<li>Dump this project, finish that iPhone game I started, make a million dollars in 2 weeks?</li>
</ul>
<div class='bookmarkify'><a name='bookmarkify'></a><div class='linkbuttons'><a href='http://del.icio.us/post?url=http://blog.zacharcher.com/2009/09/04/flash-3d-a-change-of-heart/&amp;title=Flash 3D: A change of heart?' title='Save to del.icio.us' onclick='target="_blank";' rel='nofollow'><img src='http://blog.zacharcher.com/wp-content/plugins/bookmarkify/delicious.png' style='width:16px; height:16px;' alt='[del.icio.us] ' /></a> <a href='http://digg.com/submit?phase=2&amp;url=http://blog.zacharcher.com/2009/09/04/flash-3d-a-change-of-heart/&amp;title=Flash 3D: A change of heart?' title='Digg It!' onclick='target="_blank";' rel='nofollow'><img src='http://blog.zacharcher.com/wp-content/plugins/bookmarkify/digg.png' style='width:16px; height:16px;' alt='[Digg] ' /></a> <a href='http://reddit.com/submit?url=http://blog.zacharcher.com/2009/09/04/flash-3d-a-change-of-heart/&amp;title=Flash 3D: A change of heart?' title='Reddit' onclick='target="_blank";' rel='nofollow'><img src='http://blog.zacharcher.com/wp-content/plugins/bookmarkify/reddit.png' style='width:16px; height:16px;' alt='[Reddit] ' /></a> <a href='http://twitter.com/home/?status=Flash 3D: A change of heart?+http://blog.zacharcher.com/2009/09/04/flash-3d-a-change-of-heart/' title='Save to Twitter' onclick='target="_blank";' rel='nofollow'><img src='http://blog.zacharcher.com/wp-content/plugins/bookmarkify/twitter.png' style='width:16px; height:16px;' alt='[Twitter] ' /></a> <a href='http://www.feedburner.com/fb/a/emailFlare?itemTitle=Flash 3D: A change of heart?&amp;uri=http://blog.zacharcher.com/2009/09/04/flash-3d-a-change-of-heart/&amp;loc=en_US' title='Email this to a friend' onclick='target="_blank";' rel='nofollow'><img src='http://blog.zacharcher.com/wp-content/plugins/bookmarkify/email.png' style='width:16px; height:16px;' alt='[Email] ' /></a>  <a title='See more bookmark and sharing options...' href='http://blog.zacharcher.com/2009/09/04/flash-3d-a-change-of-heart/#bookmarkify' rel='nofollow'><small>More&nbsp;&raquo;</small></a></div></div>]]></content:encoded>
			<wfw:commentRss>http://blog.zacharcher.com/2009/09/04/flash-3d-a-change-of-heart/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Flash 3D makes me sad</title>
		<link>http://blog.zacharcher.com/2009/09/03/flash-3d-makes-me-sad/</link>
		<comments>http://blog.zacharcher.com/2009/09/03/flash-3d-makes-me-sad/#comments</comments>
		<pubDate>Thu, 03 Sep 2009 11:43:05 +0000</pubDate>
		<dc:creator>Zach</dc:creator>
				<category><![CDATA[Flash]]></category>
		<category><![CDATA[Games]]></category>
		<category><![CDATA[3d]]></category>

		<guid isPermaLink="false">http://blog.zacharcher.com/?p=164</guid>
		<description><![CDATA[I've been dabbling with Flash 10's native 3D support. Try my engine: Click to set the focus. Use the arrow keys to move. Touch blocks to illuminate. I'm disappointed with two things: 1). How much time is required to create a 3D engine, even a grid-based one like mine. I've been wrestling this project for [...]]]></description>
			<content:encoded><![CDATA[<p>I've been dabbling with Flash 10's native 3D support. Try my engine:</p>
<p><a href="http://zacharcher.com/lab/20090831_3d/09b_touch_to_glow.swf"><img class="aligncenter" title="Blue LEDs" src="http://zacharcher.com/lab/20090831_3d/p/09_screenshot.png" alt="" width="428" height="324" /></a></p>
<p>Click to set the focus. Use the arrow keys to move. Touch blocks to illuminate.</p>
<p>I'm disappointed with two things:</p>
<p>1). How much time is required to create a 3D engine, even a grid-based one like mine. I've been wrestling this project for 4+ hours every day, for a week. I feel like I must be lagging behind, but there are ten thousand things that will go wrong when developing in 3D. The paradigm is uniquely punishing, there are always edge cases where some polygons aren't drawn correctly. This project hasn't been a joy.</p>
<p>Also:</p>
<p>2). <strong>Flash's native 3D is not suited for a high-performance application like this one.</strong> It would be fine if I was only spinning a few DisplayObjects in space. However, the scene above displays up to 125 Bitmaps simultaneously. (Light all 25 bulbs (3 Bitmaps each), stand in the corner facing them, and the 25-segment walls.) 125 Bitmaps would be child's play in OpenGL. But after you light a few blocks, Flash Player chokes pretty hard.</p>
<p><a href="http://zacharcher.com/lab/20090831_3d/09c_glow_blendmode.swf">Here's another version that uses a BlendMode on the lightbulbs</a>. It looks great, but its performance is even less acceptable.</p>
<p><a href="http://zacharcher.com/lab/20090831_3d/02.swf">Here's an early version that uses my own 3D computations, and the Graphics API</a>. Also it has a limited field of view, which I widened for the latest builds. The performance is surprisingly high. I abandoned my custom 3D <a href="http://zacharcher.com/lab/20090831_3d/04.swf">when I reached this point</a>; drawing lines around each cube face was expensive, so I switched to Bitmaps, and the native 3D.</p>
<p>The cube faces are set to width &amp; height of 100. However, the bitmaps are higher resolution, a 200x200 region is shown. They're being downsampled at 100x100 before they're rendered, not by my choice.</p>
<p>At runtime, I get periodic warnings like these:</p>
<blockquote><p>Warning: 3D DisplayObject will not render.  Its dimensions (8238, 1628) are too large to be drawn.</p></blockquote>
<p>What?! How is this happening? I swear that any blocks behind the camera are being removed from the Stage. (Actually, this is difficult to verify. If I shrink the scene, Flash magically applies the 3D perspective with a weird projection, and distorts everything in Lovecraftian dimensions.) Please, Adobe, tell me that you're not rendering the scene at 8000 pixels wide, then scaling it down to my 700x400 window, frame after frame?</p>
<p>Also note that you, the developer, are responsible for drawing the DisplayObjects in the correct depth order (farthest to nearest), Flash doesn't handle it automatically. This is known as "<a href="http://en.wikipedia.org/wiki/2.5D">2.5D</a>", and it's wildly inconvenient.</p>
<p>So, I'm pretty disappointed with Flash 10's native 3D. Even with my limited 3D experience, I dislike how it renders the scene (<a href="http://summitprojectsflashblog.wordpress.com/2009/05/19/flash-10-cs4-native-3d-blurry/">I'm not alone in this</a>) and the performance is obviously sub-par. This technology will not bring 3D games to the web, it <em>cannot</em>.</p>
<p>I need to decide whether to endure its shortcomings for 4 more weeks, or if I should abandon this project altogether. There are moments when you realize you've outgrown something you used to love, and this may be one of mine.</p>
<div class='bookmarkify'><a name='bookmarkify'></a><div class='linkbuttons'><a href='http://del.icio.us/post?url=http://blog.zacharcher.com/2009/09/03/flash-3d-makes-me-sad/&amp;title=Flash 3D makes me sad' title='Save to del.icio.us' onclick='target="_blank";' rel='nofollow'><img src='http://blog.zacharcher.com/wp-content/plugins/bookmarkify/delicious.png' style='width:16px; height:16px;' alt='[del.icio.us] ' /></a> <a href='http://digg.com/submit?phase=2&amp;url=http://blog.zacharcher.com/2009/09/03/flash-3d-makes-me-sad/&amp;title=Flash 3D makes me sad' title='Digg It!' onclick='target="_blank";' rel='nofollow'><img src='http://blog.zacharcher.com/wp-content/plugins/bookmarkify/digg.png' style='width:16px; height:16px;' alt='[Digg] ' /></a> <a href='http://reddit.com/submit?url=http://blog.zacharcher.com/2009/09/03/flash-3d-makes-me-sad/&amp;title=Flash 3D makes me sad' title='Reddit' onclick='target="_blank";' rel='nofollow'><img src='http://blog.zacharcher.com/wp-content/plugins/bookmarkify/reddit.png' style='width:16px; height:16px;' alt='[Reddit] ' /></a> <a href='http://twitter.com/home/?status=Flash 3D makes me sad+http://blog.zacharcher.com/2009/09/03/flash-3d-makes-me-sad/' title='Save to Twitter' onclick='target="_blank";' rel='nofollow'><img src='http://blog.zacharcher.com/wp-content/plugins/bookmarkify/twitter.png' style='width:16px; height:16px;' alt='[Twitter] ' /></a> <a href='http://www.feedburner.com/fb/a/emailFlare?itemTitle=Flash 3D makes me sad&amp;uri=http://blog.zacharcher.com/2009/09/03/flash-3d-makes-me-sad/&amp;loc=en_US' title='Email this to a friend' onclick='target="_blank";' rel='nofollow'><img src='http://blog.zacharcher.com/wp-content/plugins/bookmarkify/email.png' style='width:16px; height:16px;' alt='[Email] ' /></a>  <a title='See more bookmark and sharing options...' href='http://blog.zacharcher.com/2009/09/03/flash-3d-makes-me-sad/#bookmarkify' rel='nofollow'><small>More&nbsp;&raquo;</small></a></div></div>]]></content:encoded>
			<wfw:commentRss>http://blog.zacharcher.com/2009/09/03/flash-3d-makes-me-sad/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Synthetic Speech in Flash</title>
		<link>http://blog.zacharcher.com/2009/08/27/synthetic-speech-in-flash/</link>
		<comments>http://blog.zacharcher.com/2009/08/27/synthetic-speech-in-flash/#comments</comments>
		<pubDate>Thu, 27 Aug 2009 10:46:44 +0000</pubDate>
		<dc:creator>Zach</dc:creator>
				<category><![CDATA[Flash]]></category>
		<category><![CDATA[Synth]]></category>
		<category><![CDATA[audio]]></category>
		<category><![CDATA[linear predictive coding]]></category>
		<category><![CDATA[lpc]]></category>
		<category><![CDATA[speech]]></category>
		<category><![CDATA[synthesis]]></category>

		<guid isPermaLink="false">http://blog.zacharcher.com/?p=161</guid>
		<description><![CDATA[EDIT: I made an iPhone version, "Metal Mouth", with lots of features. Here it is on YouTube and the iTunes Store! Recently, I learned about Linear Predictive Coding ("LPC"). This technique is used in classic arcade games (such as Gauntlet) and the Speak &#38; Spell to synthesize speech. Here's my first attempt at LPC speech [...]]]></description>
			<content:encoded><![CDATA[<p><em><strong>EDIT:</strong> I made an iPhone version, "Metal Mouth", with lots of features. Here it is on <a href="http://www.youtube.com/watch?v=g2NwVMjrY2o">YouTube</a> and the <a href="http://itunes.apple.com/us/app/metal-mouth/id348741365?mt=8">iTunes Store</a>!</em></p>
<p>Recently, I learned about <a href="http://en.wikipedia.org/wiki/Linear_predictive_coding">Linear Predictive Coding ("LPC")</a>. This technique is used in classic arcade games (such as <em>Gauntlet</em>) and the <em>Speak &amp; Spell</em> to synthesize speech.</p>
<p>Here's my first attempt at LPC speech in Flash: (click &amp; explore)</p>
<p><a href="http://zacharcher.com/lab/20090827_lpc_speech/LPCsynth.swf"><img class="aligncenter" title="LPC harness" src="http://zacharcher.com/lab/20090827_lpc_speech/lpc_harness.png" alt="" width="236" height="254" /></a></p>
<p>It's great, except for one tiny problem: It sounds horrific. Can you feel the cold, robotic love? This voice will stalk your nightmares.</p>
<p>The phonemes were derived from an unrehearsed recording of my voice. I'm confident that it can be improved. Note that direct LPC encodings of my voice, <a href="http://zacharcher.com/lab/20090827_lpc_speech/zach_voice_test.mp3">such as this one</a>, sound more acceptable.</p>
<p><em><strong>EDIT:</strong> I made an iPhone version, "Metal Mouth", with lots of features. Here it is on <a href="http://www.youtube.com/watch?v=g2NwVMjrY2o">YouTube</a> and the <a href="http://itunes.apple.com/us/app/metal-mouth/id348741365?mt=8">iTunes Store</a>!</em></p>
<div class='bookmarkify'><a name='bookmarkify'></a><div class='linkbuttons'><a href='http://del.icio.us/post?url=http://blog.zacharcher.com/2009/08/27/synthetic-speech-in-flash/&amp;title=Synthetic Speech in Flash' title='Save to del.icio.us' onclick='target="_blank";' rel='nofollow'><img src='http://blog.zacharcher.com/wp-content/plugins/bookmarkify/delicious.png' style='width:16px; height:16px;' alt='[del.icio.us] ' /></a> <a href='http://digg.com/submit?phase=2&amp;url=http://blog.zacharcher.com/2009/08/27/synthetic-speech-in-flash/&amp;title=Synthetic Speech in Flash' title='Digg It!' onclick='target="_blank";' rel='nofollow'><img src='http://blog.zacharcher.com/wp-content/plugins/bookmarkify/digg.png' style='width:16px; height:16px;' alt='[Digg] ' /></a> <a href='http://reddit.com/submit?url=http://blog.zacharcher.com/2009/08/27/synthetic-speech-in-flash/&amp;title=Synthetic Speech in Flash' title='Reddit' onclick='target="_blank";' rel='nofollow'><img src='http://blog.zacharcher.com/wp-content/plugins/bookmarkify/reddit.png' style='width:16px; height:16px;' alt='[Reddit] ' /></a> <a href='http://twitter.com/home/?status=Synthetic Speech in Flash+http://blog.zacharcher.com/2009/08/27/synthetic-speech-in-flash/' title='Save to Twitter' onclick='target="_blank";' rel='nofollow'><img src='http://blog.zacharcher.com/wp-content/plugins/bookmarkify/twitter.png' style='width:16px; height:16px;' alt='[Twitter] ' /></a> <a href='http://www.feedburner.com/fb/a/emailFlare?itemTitle=Synthetic Speech in Flash&amp;uri=http://blog.zacharcher.com/2009/08/27/synthetic-speech-in-flash/&amp;loc=en_US' title='Email this to a friend' onclick='target="_blank";' rel='nofollow'><img src='http://blog.zacharcher.com/wp-content/plugins/bookmarkify/email.png' style='width:16px; height:16px;' alt='[Email] ' /></a>  <a title='See more bookmark and sharing options...' href='http://blog.zacharcher.com/2009/08/27/synthetic-speech-in-flash/#bookmarkify' rel='nofollow'><small>More&nbsp;&raquo;</small></a></div></div>]]></content:encoded>
			<wfw:commentRss>http://blog.zacharcher.com/2009/08/27/synthetic-speech-in-flash/feed/</wfw:commentRss>
		<slash:comments>7</slash:comments>
<enclosure url="http://zacharcher.com/lab/20090827_lpc_speech/zach_voice_test.mp3" length="264600" type="audio/mpeg" />
		</item>
		<item>
		<title>Toaster Bro alpha: 10 days later</title>
		<link>http://blog.zacharcher.com/2009/03/20/toaster-bro-alpha-10-days-later/</link>
		<comments>http://blog.zacharcher.com/2009/03/20/toaster-bro-alpha-10-days-later/#comments</comments>
		<pubDate>Fri, 20 Mar 2009 08:23:54 +0000</pubDate>
		<dc:creator>Zach</dc:creator>
				<category><![CDATA[Flash]]></category>
		<category><![CDATA[Games]]></category>
		<category><![CDATA[gamedev]]></category>
		<category><![CDATA[nes]]></category>
		<category><![CDATA[process]]></category>
		<category><![CDATA[schedule]]></category>
		<category><![CDATA[toaster bro]]></category>

		<guid isPermaLink="false">http://blog.zacharcher.com/?p=148</guid>
		<description><![CDATA[Did I mention my new game, "Toaster Bro"? Play Toaster Bro alpha version 1! (You will need Flash Player 10.) Ten days have elapsed since I shared this version with friends (who are unwittingly being used as play testers). It's time for a "wrap-up" meeting, because I want to examine what went wrong/right, and instead [...]]]></description>
			<content:encoded><![CDATA[<p>Did I mention my new game, "Toaster Bro"? <a href="http://zacharcher.com/lab/toaster_bro/20090309_alpha_1/ToasterBro_0.1alpha.swf">Play Toaster Bro alpha version 1!</a></p>
<p><a href="http://zacharcher.com/lab/toaster_bro/20090309_alpha_1/ToasterBro_0.1alpha.swf"><img src="http://zacharcher.com/lab/toaster_bro/20090309_alpha_1/p/instructions.png" alt="" /></a></p>
<p>(You will need Flash Player 10.)</p>
<p>Ten days have elapsed since I shared this version with friends (who are unwittingly being used as play testers). It's time for a "wrap-up" meeting, because I want to examine what went wrong/right, and instead of a meeting it's a blog post:</p>
<p><span id="more-148"></span>The <a href="http://blog.zacharcher.com/2008/07/12/tile-engine-is-go/">tile engine has existed for half a year</a>. Toaster Bro began its life as "Roomhack", one of the pet projects <a href="http://blog.sixsided.org/">Miles</a> and I dreamed up -- could we create a game that was <a href="http://en.wikipedia.org/wiki/Turing_complete">Turing complete</a>? In the tradition of <a href="http://en.wikipedia.org/wiki/Robot_Odyssey">Robot Odyssey</a>, we wanted to create an experience that was both programmable and entertaining.</p>
<p>During the development of <a href="http://jayisgames.com/archives/2008/01/space_kitteh.php">Space Kitty</a>, we used its script engine to change the rules of the game at runtime. Once, we configured a cat to act as an "attack cat", which chased (and kicked) the player. We discovered new modes of gameplay -- how long can you say aloft? Can you slingshot yourself around a dense star? (Ultimately, we ran out of time before we could make the Kitty-verse bigger. We're currently discussing a Space Kitty sequel.)</p>
<p>The script engine whet our appetite -- what if the player could modify the rules of <em>the game itself</em>? What happens to the gameplay? Can it remain challenging and fun? We talked about this for days, weeks... Hashing out ideas for an "ultimate" hacker game. I think we're still talking about it.</p>
<p>I imagined such a game would resemble a dark, apocalyptic 3/4 view basement crawl, reminiscent of:</p>
<p><img src="http://i232.photobucket.com/albums/ee231/PapillonReel/Link%20to%20the%20Past%20Part%207/LegendofZelda-ALinktothePast149.png" alt="" /></p>
<p>So I built the tile engine. The plot &amp; aesthetic of the game were still unknown. Tavvv challenged me to invent a "missing" console from the NES-SNES era, devise hardware specs for it, and develop the game in accordance to the hardware specs. Constraints fuel creativity, right? I settled on SNES-era hardware, with a custom color engine, and improved sound. Television artifacts &amp; blur could be exaggerated to make the game creepier; bosses would have extra blur and distortions, so you couldn't get a clear image of them. <em>The lurking horror.</em> This concept was eventually dropped, once I realized that I'm not ready to develop a Turing-complete game... <em>yet</em>. I'll come back to this project in the future, I'm sure.</p>
<p>"The tile game" evolved into a shooter, much like Smash TV but with a heavy-handed political bent. That still didn't feel right, even with "a spider-tank with Richard Nixon's head" in tow. In the middle of this confusion, we realized that putting hackable terminals in a tile-based game detracted from the appeal of both. Is there a way to allow hacking, within the context of a tile engine? From this fray emerged the Toaster Bro mechanic. I rolled a quick proof-of-concept. It seemed like we were on to something.</p>
<p>Then the game sat in stasis for a few months, while I worked and tended to life. I wanted to finish one solid level, and I imagined a 4-week timeline:</p>
<ul>
<li><strong>Week 1: Engine Malarky.</strong> Moving between rooms, easier wire drawing, electricity &amp; fire shouldn't hurt you, remove crufty code.</li>
<li><strong>Week 2: Levels &amp; Art.</strong>. Finalize the plot &amp; characters, somewhat. Replace stand-in art with "real" art. On-screen text. Create a bunch of rooms.</li>
<li><strong>Week 3: Audio, splash screen, boss fight, begin testing.</strong></li>
<li><strong>Week 4: Music, ???</strong></li>
</ul>
<p>This seemed like a good plan. Work began, but here's how things really went down:</p>
<p><strong>Week 1:</strong> Plugged lots of holes in the engine, but a single week wasn't enough to tackle everything. There are major structural implications when you modify your game's core. Still no way to change blocks at runtime, yet. I need a scripting engine, but I want one with <a href="http://en.wikipedia.org/wiki/Infix_notation">infix notation</a> (Space Kitty used various <a href="http://en.wikipedia.org/wiki/Reverse_Polish_notation">postfix notation</a> languages, before Miles settled on an implementation of the <a href="http://en.wikipedia.org/wiki/PostScript">PostScript language</a> I think? It made my brain bleed.) I didn't allot time for creating a scripting engine, but clearly there was a need for it.</p>
<p><strong>Week 2:</strong> I'm not sure how the 8-bit NES aesthetic won out, but I liked it because it entailed <em>fewer artistic decisions</em>. The aesthetic had an entire era of gaming backing it. This seemed like a wise choice, because I'm not an accomplished artist, nor designer. I'm partially colorblind, in fact. Could I still cobble together pixel art?</p>
<p>I bought a Wacom tablet and books on animation, hoping to produce an acceptable look &amp; feel. By the way, nearly every graphic in the game has been redrawn at least once. You should have seen the original sideways animation for Toaster Bro, it took a few tries to make him look non-crippled.</p>
<p>So I had a decent lead on the art, but bugs kept popping up. Fundamental pieces of the puzzle were still missing (no scripting engine, no on-screen text, player can't die).</p>
<p><strong>Week 3:</strong> I caught a bad cold, so I spent most of this week supine on the couch. I forced the "game" on a few people, and collected their feedback. All the responses were valuable, and people raised issues that I hadn't considered. One tester said he couldn't view the entire window, he was on a MacBook with its standard (small) screen. Oops! Sorry about that... I reduced the console's "pixel" size.</p>
<p>The upshot of being sick was having lots of quiet time, during which I (slowly, groggily) puzzled out the scripting engine. Here's what the scripting language looks like now, this is extracted from the first room on the Dark Chocolate level:</p>
<pre><code>function clubDoor_electricity {
	i.isDoorOpen = true;
	call o.setBlock '__' 7 4; // empty space
	call o.setBlock '__' 7 5;
	call o.playSound 'doorOpen';
	call o.emotePlayer 'happy' 75;
}

function clubDoor_stop {
	if(i.isDoorOpen == true) {
		i.isDoorOpen = false;
		call o.setBlock '$L' 7 4; // lock
		call o.setBlock '$L' 7 5;
		call o.playSound 'doorClose';
		call o.emotePlayer 'sad' 75;
	}
}</code></pre>
<p>The interpreter supports a large syntax, including: loops, switch/case statements, tons of operators, enterFrame yields, userInput yields, recursion ... You get the idea. Variables are always referenced through a few specific objects, right now these are: <strong>t</strong>hread, <strong>i</strong>nterpreter, <strong>o</strong>wner (this is the Room that created the Interpreter instance), <strong>l</strong>evel, and <strong>g</strong>lobal (or <strong>g</strong>ame). (These are all dynamic objects except for <strong>o</strong>wner.) The script engine is decoupled from the code, I wrote a harness for it.</p>
<p>Also the <a href="http://blog.zacharcher.com/2009/03/15/8-bit-ntsc-artifacts-using-pixel-bender/">8-bit NTSC artifacts</a> happened during week 3, somehow.</p>
<p>At this point, the game had a mere 3 rooms, all unsightly geometric slogs used for testing. Uh oh.</p>
<p><strong>Week 4:</strong> Still a bit sick, and my real-world work schedule poked its head in, and needed some attention. The list of bugs &amp; issues was huge; 30 items, including toughies like art and program flow.</p>
<p>I forced myself to draw the dreaded sprite animations. Infrequently, this was relaxing and zen-like. But in the wrong state of mind, it was taxing and disheartening. I'm using the <a href="http://blog.zacharcher.com/2007/10/13/understanding-colormatrixfilter/">palette swap trick</a> from Space Kitty, so I stared at grotesque red, green and blue images all day, and felt sorry for myself. Definitely out of my league.</p>
<p>Also I hacked together a level editor using Flex components, accessible through a magic keystroke. It's buggy and non-intuitive, but it's better than editing the room layouts as raw ascii! Here's how the final room in Mom's Kitchen is stored:</p>
<pre><code>[P,d [P,d [P,d [P,d [P,d [f,d ..,d ..,d ..,d ..,d [d,d [P,d [P,d [P,d [P,d [P,d
[P,d [P,d [P,d [P,d [P,d [f,d ..,d ..,a ..,a ..,d [d,d [P,d [P,d [P,d [P,d [P,d
[j,d [P,d [P,d [P,d [P,d [F,d ..,d ..,a ..,a ..,d [D,d [P,d [P,d [P,d [P,d [k,d
[J,d [h,d [h,d [h,d [h,d [i,d ..,d ..,d ..,d ..,d [g,d [h,d [h,d [h,d [h,d [K,d
[f,d ..;n ..;o ..;o ..;o ..;o ..;o ..;o ..;o ..;o ..;o ..;o ..;o ..;o ..;p [d,d
[f,d ..;q ..,d ..,d ..,d ..,d ..,d ..,d ..,d ..,d ..,d ..,d ..,d ..,d ..;q [d,d
[f,d ..;q ..,d ..,a ..,a ..,a #a,a #a,a #a,a #a,a ..,a ..,a ..,a ..,d ..;q [d,d
[f,d ..;q ..,d ..,a ..,a ..,a #a,a #a,a #t,a #a,a ..,a ..,a ..,a ..,d ..;q [d,d
[f,d ..;q ..,d ..,a ..,a ..,a __,a ..,a ..,a ..,a ..,a ..,a ..,a ..,d ..;q [d,d
[F,d ..;q __,d __,d __,d __,d ..,d ..,d ..,d ..,d ..,d ..,d ..,d __,d ..;q [D,d
[i,d ..;r ..;o ..;o ..;o ..;o ..;o ..;o ..;o ..;o ..;o ..;o ..;o ..;o ..;s [g,d</code></pre>
<p>I resolved to ride my bike every day, to avoid getting sick again. So far so good, but now I ride to coffee shops and spend a metric crapload of money dining out of the house. The hidden price of wellness...</p>
<p><strong>Week 5:</strong> The list grew even longer. Lots of bugs, lots of missing features that I didn't consider -- the heart containers, the health bar. Dark Chocolate's level was half done. The entity behaviors were unstable; the damage system was finicky, every Entity required too much configuration to properly interact with others. This needed an overhaul. I'd started thinking about unit testing, which I'd never tried before.</p>
<p>I drew Dark Chocolate, but with no behavioral code, he didn't move. Fun fact: I saw his animation in a dream.</p>
<p><strong>Week 6:</strong> Dark Chocolate's level was finished, mostly. The boss fight took a day and a half to get right. You still couldn't "win" a level. I always joked that the goal was to plug in a toaster. Hmmmmm...</p>
<p><strong>Weeks 7-9:</strong> Sound design, on-screen text, Mom's kitchen (the training level), giant toasters. Redrawing sprites. Bigger croissants (the laser-guards). Spotlights. Refactoring lots of code. The scripting engine is versatile, but not easy to use. In week 7, it was much clunkier than the syntax listed above. There were no <code>switch</code> statements, you had to write a list of consecutive <code>if</code> statements instead.</p>
<p>Days passed. The spit 'n polish phase took <em>forever</em>. I sympathize with whoever said, "your code is always 85% done". It sure felt that way.</p>
<p>Also I finally implemented unit testing. I tried <a href="http://www.asunit.org/">ASUnit</a> first, but it's not very Flash-like; I believe it's a direct port of JUnit (as evidenced by the Java code in its comments). If I'd realized <a href="http://opensource.adobe.com/wiki/display/flexunit/FlexUnit">FlexUnit</a> was still in development, then I would have jumped on it, but... Long story short: I wanted to display failed tests on the stage, and ASUnit made that difficult. So I threw out the ASUnit code, kept my custom TestCase subclasses, and wrote my own Flash-centric versions of a TestRunner and TestCase (they both extend Sprite).</p>
<p>I can compile Toaster Bro in two ways: I have a Main.as class which will compile in the Flash IDE. But there's also a Roomhack.mxml wrapper which creates a "developer" build, integrating the testing framework and level editor. When the developer build is launched, it runs every TestCase. If a TestCase fails, and if it has added children, then it's displayed on the stage, with diagnostic messages &amp; an execution trace. Failed TestCases can be dismissed with a click. I'm not "in love" with unit testing yet, perhaps because writing the tests <em>after</em> the code was tedious. I'm sure it will save my butt in the future, tho.</p>
<p><strong>Week 10:</strong> Toaster Bro alpha is unleashed on the world!</p>
<p>Overall, feedback has been positive. Like Space Kitty, most people want the game to be longer. The negative feedback has been very helpful, pointing out specific problems which aren't obvious to me, since I view the application as a whole now.</p>
<p>So, after writing this gigantic treatise, I figured I'd have some insights on how to improve the process. And you know what? <em>I don't</em>.</p>
<p>Gamasutra had <a href="http://www.gamasutra.com/features/20051026/gabler_pfv.htm">an excellent article on rapid prototyping</a>, and their process echoes what we experienced on Toaster Bro and Space Kitty: Creativity can't be scheduled, and you'll spend a huge chunk of time germinating the idea in your head. We had 2 months to develop Space Kitty; we spent almost exactly 1 month dreaming up the idea. After that, the initial prototype took a day or two, and we were rolling.</p>
<p>With Toaster Bro, nearly half of the "serious" development time went towards polishing the game and making it presentable. This was a surprise, even though most of my interactive work has followed this pattern, too. The functional code is fairly easy to develop, but then you must meet the clients' standards, and hammer the UI to find the rough spots.</p>
<p>Sound effects gave Toaster Bro an air of legitimacy. The difference was like night and day. Without sound effects, it was a shaky graphics demo; with sound effects, it felt <em>alive</em>. Hard to explain unless you've witnessed it.</p>
<p>Testers will comment on all the broken windows they find. I still hear about the missing sound effects in Toaster Bro (and yes, there are plenty!) But that's okay, their feedback is always valuable. Occasionally they'll have solid ideas on how best to <em>fix</em> a broken window, too.</p>
<p>What happens now? I have to produce more levels, art, and script. I'd like to believe that my productivity will ramp up, with so much of the infrastructure and assets completed. Sadly, I don't think it works that way. I have big ideas for the remaining Toaster Bro levels, and these involve intense scripting. The second room of Mom's Kitchen (where Toaster Bro learns how to use a wire, via 4 simple dialogs) is 131 lines of script, and it's still not done -- Mom should rush in and cheer after you activate the toaster, right? I can only imagine the length of the equivalent code in AS3. I want big effects &amp; easter eggs. It will be difficult to develop and test these.</p>
<p>Whatever skills you have, I recommend bringing these into your projects, and emphasizing them, even leaning on them. I produce groovy electronic music, so <a href="http://zacharcher.com/lab/toaster_bro/chiptunes_test/">I made a bunch of chiptunes</a> early on, to help center my thinking. Some aren't useable for Toaster Bro, they're too active -- they have the pace of Mega Man, rather than Zelda. It was good to realize that, it helped shape my thinking.</p>
<p>More to come?...</p>
<div class='bookmarkify'><a name='bookmarkify'></a><div class='linkbuttons'><a href='http://del.icio.us/post?url=http://blog.zacharcher.com/2009/03/20/toaster-bro-alpha-10-days-later/&amp;title=Toaster Bro alpha: 10 days later' title='Save to del.icio.us' onclick='target="_blank";' rel='nofollow'><img src='http://blog.zacharcher.com/wp-content/plugins/bookmarkify/delicious.png' style='width:16px; height:16px;' alt='[del.icio.us] ' /></a> <a href='http://digg.com/submit?phase=2&amp;url=http://blog.zacharcher.com/2009/03/20/toaster-bro-alpha-10-days-later/&amp;title=Toaster Bro alpha: 10 days later' title='Digg It!' onclick='target="_blank";' rel='nofollow'><img src='http://blog.zacharcher.com/wp-content/plugins/bookmarkify/digg.png' style='width:16px; height:16px;' alt='[Digg] ' /></a> <a href='http://reddit.com/submit?url=http://blog.zacharcher.com/2009/03/20/toaster-bro-alpha-10-days-later/&amp;title=Toaster Bro alpha: 10 days later' title='Reddit' onclick='target="_blank";' rel='nofollow'><img src='http://blog.zacharcher.com/wp-content/plugins/bookmarkify/reddit.png' style='width:16px; height:16px;' alt='[Reddit] ' /></a> <a href='http://twitter.com/home/?status=Toaster Bro alpha: 10 days later+http://blog.zacharcher.com/2009/03/20/toaster-bro-alpha-10-days-later/' title='Save to Twitter' onclick='target="_blank";' rel='nofollow'><img src='http://blog.zacharcher.com/wp-content/plugins/bookmarkify/twitter.png' style='width:16px; height:16px;' alt='[Twitter] ' /></a> <a href='http://www.feedburner.com/fb/a/emailFlare?itemTitle=Toaster Bro alpha: 10 days later&amp;uri=http://blog.zacharcher.com/2009/03/20/toaster-bro-alpha-10-days-later/&amp;loc=en_US' title='Email this to a friend' onclick='target="_blank";' rel='nofollow'><img src='http://blog.zacharcher.com/wp-content/plugins/bookmarkify/email.png' style='width:16px; height:16px;' alt='[Email] ' /></a>  <a title='See more bookmark and sharing options...' href='http://blog.zacharcher.com/2009/03/20/toaster-bro-alpha-10-days-later/#bookmarkify' rel='nofollow'><small>More&nbsp;&raquo;</small></a></div></div>]]></content:encoded>
			<wfw:commentRss>http://blog.zacharcher.com/2009/03/20/toaster-bro-alpha-10-days-later/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>8-bit NTSC artifacts using Pixel Bender</title>
		<link>http://blog.zacharcher.com/2009/03/15/8-bit-ntsc-artifacts-using-pixel-bender/</link>
		<comments>http://blog.zacharcher.com/2009/03/15/8-bit-ntsc-artifacts-using-pixel-bender/#comments</comments>
		<pubDate>Mon, 16 Mar 2009 03:27:05 +0000</pubDate>
		<dc:creator>Zach</dc:creator>
				<category><![CDATA[Flash]]></category>
		<category><![CDATA[Games]]></category>
		<category><![CDATA[Graphics]]></category>

		<guid isPermaLink="false">http://blog.zacharcher.com/?p=139</guid>
		<description><![CDATA[By request, here's a quick 'n dirty test harness, and sample code, for NTSC artifacts in the style of the 8-bit Nintendo Entertainment System (NES): Click the animation to change scale &#38; scroll speed. Source code &#38; .fla: nes_ntsc.zip The .pbk code is not optimized yet. The code is fairly explicit, I tried to explain [...]]]></description>
			<content:encoded><![CDATA[<p>By request, here's a quick 'n dirty test harness, and sample code, for NTSC artifacts in the style of the 8-bit Nintendo Entertainment System (NES):</p>
<p><a href="http://zacharcher.com/lab/20090315_nes_ntsc/nes_ntsc_harness.swf"><img class="alignnone" title="NES NTSC screencap" src="http://zacharcher.com/lab/20090315_nes_ntsc/nes_ntsc_screencap.png" alt="" width="301" height="249" /></a></p>
<p>Click the animation to change scale &amp; scroll speed.</p>
<p>Source code &amp; .fla: <a href="http://zacharcher.com/lab/20090315_nes_ntsc/20090315_nes_ntsc.zip">nes_ntsc.zip</a></p>
<p>The .pbk code is not optimized yet. The code is fairly explicit, I tried to explain how it works in the comments. <a href="http://slack.net/~ant/libs/ntsc.html">Blargg's pages</a> have better explanations tho.</p>
<p>The test harness lets you select two flavors of the effect. The numbers 8 and 12 denote the width of the lowpass window used for applying crosstalk. 12 is more processor-intensive, but will look "smoother", which may not be what you want. The mathematics can be reduced to a few (long) lines, which should reduce processor overhead; I want to do this in the future. <a href="http://blog.zacharcher.com/2008/12/29/fractal-transform-in-pixel-bender/#comments">unic0rn left some nice comments</a> suggesting more routes to optimization.</p>
<p>The filter still needs some tuning. Areas of solid (non-black) color have diagonal stripes in them. I believe that normalizing the strengths of the filters will fix this.</p>
<p>To be continued...</p>
<div class='bookmarkify'><a name='bookmarkify'></a><div class='linkbuttons'><a href='http://del.icio.us/post?url=http://blog.zacharcher.com/2009/03/15/8-bit-ntsc-artifacts-using-pixel-bender/&amp;title=8-bit NTSC artifacts using Pixel Bender' title='Save to del.icio.us' onclick='target="_blank";' rel='nofollow'><img src='http://blog.zacharcher.com/wp-content/plugins/bookmarkify/delicious.png' style='width:16px; height:16px;' alt='[del.icio.us] ' /></a> <a href='http://digg.com/submit?phase=2&amp;url=http://blog.zacharcher.com/2009/03/15/8-bit-ntsc-artifacts-using-pixel-bender/&amp;title=8-bit NTSC artifacts using Pixel Bender' title='Digg It!' onclick='target="_blank";' rel='nofollow'><img src='http://blog.zacharcher.com/wp-content/plugins/bookmarkify/digg.png' style='width:16px; height:16px;' alt='[Digg] ' /></a> <a href='http://reddit.com/submit?url=http://blog.zacharcher.com/2009/03/15/8-bit-ntsc-artifacts-using-pixel-bender/&amp;title=8-bit NTSC artifacts using Pixel Bender' title='Reddit' onclick='target="_blank";' rel='nofollow'><img src='http://blog.zacharcher.com/wp-content/plugins/bookmarkify/reddit.png' style='width:16px; height:16px;' alt='[Reddit] ' /></a> <a href='http://twitter.com/home/?status=8-bit NTSC artifacts using Pixel Bender+http://blog.zacharcher.com/2009/03/15/8-bit-ntsc-artifacts-using-pixel-bender/' title='Save to Twitter' onclick='target="_blank";' rel='nofollow'><img src='http://blog.zacharcher.com/wp-content/plugins/bookmarkify/twitter.png' style='width:16px; height:16px;' alt='[Twitter] ' /></a> <a href='http://www.feedburner.com/fb/a/emailFlare?itemTitle=8-bit NTSC artifacts using Pixel Bender&amp;uri=http://blog.zacharcher.com/2009/03/15/8-bit-ntsc-artifacts-using-pixel-bender/&amp;loc=en_US' title='Email this to a friend' onclick='target="_blank";' rel='nofollow'><img src='http://blog.zacharcher.com/wp-content/plugins/bookmarkify/email.png' style='width:16px; height:16px;' alt='[Email] ' /></a>  <a title='See more bookmark and sharing options...' href='http://blog.zacharcher.com/2009/03/15/8-bit-ntsc-artifacts-using-pixel-bender/#bookmarkify' rel='nofollow'><small>More&nbsp;&raquo;</small></a></div></div>]]></content:encoded>
			<wfw:commentRss>http://blog.zacharcher.com/2009/03/15/8-bit-ntsc-artifacts-using-pixel-bender/feed/</wfw:commentRss>
		<slash:comments>4</slash:comments>
		</item>
		<item>
		<title>Tweetcoding: Round 1 Winners</title>
		<link>http://blog.zacharcher.com/2009/03/13/tweetcoding-round-1-winners/</link>
		<comments>http://blog.zacharcher.com/2009/03/13/tweetcoding-round-1-winners/#comments</comments>
		<pubDate>Sat, 14 Mar 2009 00:43:21 +0000</pubDate>
		<dc:creator>Zach</dc:creator>
				<category><![CDATA[Flash]]></category>
		<category><![CDATA[obfuscation]]></category>
		<category><![CDATA[tweetcoding]]></category>

		<guid isPermaLink="false">http://blog.zacharcher.com/?p=135</guid>
		<description><![CDATA[Hooray, I'm a runner-up in the first Tweetcoding contest. My entry "Ghost Marquee" placed in the top 4. The code extracts certain bits from a string of jibberish, 6 bits at a time; when arranged on a grid, the bits form a message. Also I had 2 notable mentions with Sea Sphere and 3D Sketch. [...]]]></description>
			<content:encoded><![CDATA[<p>Hooray, <a href="http://www.gskinner.com/playpen/tweetcoding_0/">I'm a runner-up in the first Tweetcoding contest</a>. My entry "<a href="http://www.gskinner.com/playpen/tweetcoding_0/tc_1263383494.swf">Ghost Marquee</a>" placed in the top 4. The code extracts certain bits from a string of jibberish, 6 bits at a time; when arranged on a grid, the bits form a message.</p>
<p>Also I had 2 notable mentions with <a href="http://www.gskinner.com/playpen/tweetcoding_0/tc_1264481820.swf">Sea Sphere</a> and <a href="http://www.gskinner.com/playpen/tweetcoding_0/tc_1257410301.swf">3D Sketch</a>. I figured my entry <a href="http://tweetcoding.machine501.com/tc_1260723981.swf">The w00t Quilt</a> would have placed, but perhaps I'm just easily hypnotized...</p>
<p>I think the strongest entry was <a href="http://www.gskinner.com/playpen/tweetcoding_0/tc_1267109791.swf">Diagonal Snake</a> by <a href="http://twitter.com/tomee6">@tomee6</a>, which is (not coincidentally) also one of the winners. Move the mouse to attract the snake; you lose when the snake crosses itself or touches you. There's even a death animation. Amazing.</p>
<p>Here's looking forward to round 2...</p>
<div class='bookmarkify'><a name='bookmarkify'></a><div class='linkbuttons'><a href='http://del.icio.us/post?url=http://blog.zacharcher.com/2009/03/13/tweetcoding-round-1-winners/&amp;title=Tweetcoding: Round 1 Winners' title='Save to del.icio.us' onclick='target="_blank";' rel='nofollow'><img src='http://blog.zacharcher.com/wp-content/plugins/bookmarkify/delicious.png' style='width:16px; height:16px;' alt='[del.icio.us] ' /></a> <a href='http://digg.com/submit?phase=2&amp;url=http://blog.zacharcher.com/2009/03/13/tweetcoding-round-1-winners/&amp;title=Tweetcoding: Round 1 Winners' title='Digg It!' onclick='target="_blank";' rel='nofollow'><img src='http://blog.zacharcher.com/wp-content/plugins/bookmarkify/digg.png' style='width:16px; height:16px;' alt='[Digg] ' /></a> <a href='http://reddit.com/submit?url=http://blog.zacharcher.com/2009/03/13/tweetcoding-round-1-winners/&amp;title=Tweetcoding: Round 1 Winners' title='Reddit' onclick='target="_blank";' rel='nofollow'><img src='http://blog.zacharcher.com/wp-content/plugins/bookmarkify/reddit.png' style='width:16px; height:16px;' alt='[Reddit] ' /></a> <a href='http://twitter.com/home/?status=Tweetcoding: Round 1 Winners+http://blog.zacharcher.com/2009/03/13/tweetcoding-round-1-winners/' title='Save to Twitter' onclick='target="_blank";' rel='nofollow'><img src='http://blog.zacharcher.com/wp-content/plugins/bookmarkify/twitter.png' style='width:16px; height:16px;' alt='[Twitter] ' /></a> <a href='http://www.feedburner.com/fb/a/emailFlare?itemTitle=Tweetcoding: Round 1 Winners&amp;uri=http://blog.zacharcher.com/2009/03/13/tweetcoding-round-1-winners/&amp;loc=en_US' title='Email this to a friend' onclick='target="_blank";' rel='nofollow'><img src='http://blog.zacharcher.com/wp-content/plugins/bookmarkify/email.png' style='width:16px; height:16px;' alt='[Email] ' /></a>  <a title='See more bookmark and sharing options...' href='http://blog.zacharcher.com/2009/03/13/tweetcoding-round-1-winners/#bookmarkify' rel='nofollow'><small>More&nbsp;&raquo;</small></a></div></div>]]></content:encoded>
			<wfw:commentRss>http://blog.zacharcher.com/2009/03/13/tweetcoding-round-1-winners/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Tweetcoding!</title>
		<link>http://blog.zacharcher.com/2009/03/02/tweetcoding/</link>
		<comments>http://blog.zacharcher.com/2009/03/02/tweetcoding/#comments</comments>
		<pubDate>Tue, 03 Mar 2009 05:46:55 +0000</pubDate>
		<dc:creator>Zach</dc:creator>
				<category><![CDATA[Flash]]></category>
		<category><![CDATA[optimization]]></category>
		<category><![CDATA[tweetcoding]]></category>
		<category><![CDATA[twitter]]></category>

		<guid isPermaLink="false">http://blog.zacharcher.com/?p=111</guid>
		<description><![CDATA[The challenge was steep: Build something interesting in Flash, using 140 characters or less. Check out the rules, and the results. Oh man, I was hooked. I admit, I'm suspicious of Twitter's usefulness in the grand scheme of things. You're allowed 140 characters, eh? You can only communicate the big picture; blipverts. Twitter is addictive [...]]]></description>
			<content:encoded><![CDATA[<p>The challenge was steep: Build something interesting in Flash, using 140 characters or less.</p>
<p>Check out <a href="http://gskinner.com/playpen/tweetcoding.html">the rules</a>, and <a href="http://tweetcoding.machine501.com/">the results</a>. Oh man, I was hooked.<br />
<span id="more-111"></span><br />
I admit, I'm suspicious of Twitter's usefulness in the grand scheme of things. You're allowed 140 characters, eh? You can only communicate the big picture; <a href="http://en.wikipedia.org/wiki/Blipvert">blipverts</a>. Twitter is addictive because it doesn't require any commitment -- it takes 10 seconds to "tweet". You can tweet like mad. You can tweet at any moment of the day, even from your phone. You can abuse the Twitter API, and post non-human-readable text (such as tweetcode), which will drive your friends crazy.</p>
<p>Having said that... It was stunning to watch everyone create beauty in the face of the 140-character limit. Constraints fuel creativity. Here's what I came up with:</p>
<ul>
<li><a href="http://tweetcoding.machine501.com/tc_1260723981.swf">The w00t Quilt</a></li>
<li><a href="http://tweetcoding.machine501.com/tc_1257410301.swf">3D Sketch</a></li>
<li><a href="http://tweetcoding.machine501.com/tc_1263383494.swf">Ghost Marquee</a></li>
<li><a href="http://tweetcoding.machine501.com/tc_1264481820.swf">Sea Sphere</a></li>
<li><a href="http://tweetcoding.machine501.com/tc_1268469008.swf">Sound Effects</a>. Move the mouse for FM synthesis. (Caution: kinda loud.)</li>
</ul>
<p>Many people posted entries that blew my mind. Some favorites:</p>
<ul>
<li><a href="http://twitter.com/oskitar">@oskitar</a>: <a href="http://tweetcoding.machine501.com/tc_1250258414.swf">The Day The Earth Stood Still</a></li>
<li><a href="http://twitter.com/og2t">@og2t</a>:<a href="http://tweetcoding.machine501.com/tc_1258007768.swf">My 1st Tweetcode</a></li>
<li><a href="http://twitter.com/flashpadawan">@flashpadawan</a>: <a href="http://tweetcoding.machine501.com/tc_1263655966.swf">3D Particle Emitter</a>. Custom 3D rendering!</li>
<li><a href="http://twitter.com/kalisnik">@kalisnik</a>: <a href="http://tweetcoding.machine501.com/tc_1262904228.swf">Grass in the Wind</a></li>
<li><a href="http://twitter.com/piXelero">@piXelero</a>: <a href="http://tweetcoding.machine501.com/tc_1238049748.swf">Inversemapping</a>, and <a href="http://tweetcoding.machine501.com/tc_1250044251.swf">Tweetcoding With Recursion</a> (probably my favorite examples of beautiful recursion)</li>
<li><a href="http://twitter.com/pantaa">@pantaa</a>: <a href="http://tweetcoding.machine501.com/tc_1236586119.swf">Alien Lifeform</a></li>
<li><a href="http://twitter.com/rmdesign">@rmdesign</a>: <a href="http://tweetcoding.machine501.com/tc_1239657440.swf">Jellycube</a></li>
<li><a href="http://twitter.com/Quasimondo">@Quasimondo</a>: <a href="http://tweetcoding.machine501.com/tc_1227966320.swf">Hyperdrive</a></li>
</ul>
<p>Who am I kidding, I have too many favorites to list. The most interesting aspect was watching  personalities emerge, as people submitted multiple entries.</p>
<p>I'm sure I could have crammed more features in my code; I remembered the comma operator late in the game, which lets you shorten</p>
<pre><code>if(condition){doThis;doThat}</code></pre>
<p>into</p>
<pre><code>if(condition)doThis,doThat</code></pre>
<p>You just saved two whole characters!! Epic savings, there. Now I find myself tightening up my "real" code: using multiple assignment, and increment/decrement operators within expressions. Back when I studied Perl, I feared this: You can cram an entire script onto one line, how clever!.. "Clever" code doesn't seem smart later, when you have to maintain it.</p>
<p>Cheers to <a href="http://www.gskinner.com/blog/">Grant Skinner</a> for developing the contest, and to all the judges who are about to wade through hundreds of entries -- we salute you. Here's looking forward to Tweetcoding: The Sequel!</p>
<div class='bookmarkify'><a name='bookmarkify'></a><div class='linkbuttons'><a href='http://del.icio.us/post?url=http://blog.zacharcher.com/2009/03/02/tweetcoding/&amp;title=Tweetcoding!' title='Save to del.icio.us' onclick='target="_blank";' rel='nofollow'><img src='http://blog.zacharcher.com/wp-content/plugins/bookmarkify/delicious.png' style='width:16px; height:16px;' alt='[del.icio.us] ' /></a> <a href='http://digg.com/submit?phase=2&amp;url=http://blog.zacharcher.com/2009/03/02/tweetcoding/&amp;title=Tweetcoding!' title='Digg It!' onclick='target="_blank";' rel='nofollow'><img src='http://blog.zacharcher.com/wp-content/plugins/bookmarkify/digg.png' style='width:16px; height:16px;' alt='[Digg] ' /></a> <a href='http://reddit.com/submit?url=http://blog.zacharcher.com/2009/03/02/tweetcoding/&amp;title=Tweetcoding!' title='Reddit' onclick='target="_blank";' rel='nofollow'><img src='http://blog.zacharcher.com/wp-content/plugins/bookmarkify/reddit.png' style='width:16px; height:16px;' alt='[Reddit] ' /></a> <a href='http://twitter.com/home/?status=Tweetcoding!+http://blog.zacharcher.com/2009/03/02/tweetcoding/' title='Save to Twitter' onclick='target="_blank";' rel='nofollow'><img src='http://blog.zacharcher.com/wp-content/plugins/bookmarkify/twitter.png' style='width:16px; height:16px;' alt='[Twitter] ' /></a> <a href='http://www.feedburner.com/fb/a/emailFlare?itemTitle=Tweetcoding!&amp;uri=http://blog.zacharcher.com/2009/03/02/tweetcoding/&amp;loc=en_US' title='Email this to a friend' onclick='target="_blank";' rel='nofollow'><img src='http://blog.zacharcher.com/wp-content/plugins/bookmarkify/email.png' style='width:16px; height:16px;' alt='[Email] ' /></a>  <a title='See more bookmark and sharing options...' href='http://blog.zacharcher.com/2009/03/02/tweetcoding/#bookmarkify' rel='nofollow'><small>More&nbsp;&raquo;</small></a></div></div>]]></content:encoded>
			<wfw:commentRss>http://blog.zacharcher.com/2009/03/02/tweetcoding/feed/</wfw:commentRss>
		<slash:comments>3</slash:comments>
		</item>
		<item>
		<title>Fractal Transform, made with Pixel Bender</title>
		<link>http://blog.zacharcher.com/2008/12/29/fractal-transform-in-pixel-bender/</link>
		<comments>http://blog.zacharcher.com/2008/12/29/fractal-transform-in-pixel-bender/#comments</comments>
		<pubDate>Mon, 29 Dec 2008 09:06:11 +0000</pubDate>
		<dc:creator>Zach</dc:creator>
				<category><![CDATA[Flash]]></category>
		<category><![CDATA[Graphics]]></category>
		<category><![CDATA[fractal]]></category>
		<category><![CDATA[julia]]></category>
		<category><![CDATA[pixel bender]]></category>

		<guid isPermaLink="false">http://blog.zacharcher.com/?p=79</guid>
		<description><![CDATA[I made a Pixel Bender filter that performs Julia Set transformations on images. It looks great when it animates, the colors morph and twist like mathematical slime. Try it (Flash Player 10 required): JuliaTile.swf Source code: julia_tile_src.zip. Pixel Bender code is in src/shader/. The default image is Seattle's Space Needle. You can upload custom images. [...]]]></description>
			<content:encoded><![CDATA[<p>I made a Pixel Bender filter that performs Julia Set transformations on images. It looks great when it animates, the colors morph and twist like mathematical slime. Try it (Flash Player 10 required): <a href="http://zacharcher.com/lab/20081229_julia_filter/JuliaTile.swf">JuliaTile.swf<br />
</a></p>
<p><a href="http://zacharcher.com/lab/20081229_julia_filter/JuliaTile.swf"><img class="alignnone" title="Julia Set sample" src="http://zacharcher.com/lab/20081229_julia_filter/julia_sample.png" alt="" width="357" height="393" /></a></p>
<p>Source code: <a href="http://zacharcher.com/lab/20081229_julia_filter/julia_tile_src.zip">julia_tile_src.zip</a>. Pixel Bender code is in <code>src/shader/</code>.<a href="http://zacharcher.com/lab/20081229_julia_filter/julia_tile_src.zip"><br />
</a></p>
<p>The default image is Seattle's Space Needle. You can upload custom images. Very large images may set your processor on fire.</p>
<p><span id="more-79"></span>Parameters: <strong>Iterations</strong> sets how many times the Julia formula is applied per pixel. The iteration increments appear smooth, not stepped, because the code tweens across the destination coordinates of the two nearest iterations. <strong>Complex X&amp;Y</strong> are the real &amp; imaginary values of the transform constant. <strong>Bias X&amp;Y</strong> is something I hacked in, it skews the coordinates in a linear way, becoming more intense with each iteration.</p>
<p>The <strong>Fill Types</strong> are as follows:</p>
<ul>
<li>0: Pixels out of range are transparent; no fill.</li>
<li>1: Repeats the nearest edge pixel.</li>
<li>2: Repeats the source image, mirroring every other copy to create a smooth transition.</li>
<li>3: Repeats the source image without mirroring.</li>
</ul>
<p>The filter needs more features before it's "done", hopefully it's still enjoyable. The Pixel Bender code took about 30 minutes to write; the Flex wrapper took much longer.</p>
<p>Despite its limited feature set, Pixel Bender is pretty cool. My only misgiving is that Pixel Bender's runtime performance is never as good as I hope. I have another filter in the works that mimics NTSC television artifacts, but the performance is abysmal. The code can still be optimized; stay tuned.</p>
<div class='bookmarkify'><a name='bookmarkify'></a><div class='linkbuttons'><a href='http://del.icio.us/post?url=http://blog.zacharcher.com/2008/12/29/fractal-transform-in-pixel-bender/&amp;title=Fractal Transform, made with Pixel Bender' title='Save to del.icio.us' onclick='target="_blank";' rel='nofollow'><img src='http://blog.zacharcher.com/wp-content/plugins/bookmarkify/delicious.png' style='width:16px; height:16px;' alt='[del.icio.us] ' /></a> <a href='http://digg.com/submit?phase=2&amp;url=http://blog.zacharcher.com/2008/12/29/fractal-transform-in-pixel-bender/&amp;title=Fractal Transform, made with Pixel Bender' title='Digg It!' onclick='target="_blank";' rel='nofollow'><img src='http://blog.zacharcher.com/wp-content/plugins/bookmarkify/digg.png' style='width:16px; height:16px;' alt='[Digg] ' /></a> <a href='http://reddit.com/submit?url=http://blog.zacharcher.com/2008/12/29/fractal-transform-in-pixel-bender/&amp;title=Fractal Transform, made with Pixel Bender' title='Reddit' onclick='target="_blank";' rel='nofollow'><img src='http://blog.zacharcher.com/wp-content/plugins/bookmarkify/reddit.png' style='width:16px; height:16px;' alt='[Reddit] ' /></a> <a href='http://twitter.com/home/?status=Fractal Transform, made with Pixel Bender+http://blog.zacharcher.com/2008/12/29/fractal-transform-in-pixel-bender/' title='Save to Twitter' onclick='target="_blank";' rel='nofollow'><img src='http://blog.zacharcher.com/wp-content/plugins/bookmarkify/twitter.png' style='width:16px; height:16px;' alt='[Twitter] ' /></a> <a href='http://www.feedburner.com/fb/a/emailFlare?itemTitle=Fractal Transform, made with Pixel Bender&amp;uri=http://blog.zacharcher.com/2008/12/29/fractal-transform-in-pixel-bender/&amp;loc=en_US' title='Email this to a friend' onclick='target="_blank";' rel='nofollow'><img src='http://blog.zacharcher.com/wp-content/plugins/bookmarkify/email.png' style='width:16px; height:16px;' alt='[Email] ' /></a>  <a title='See more bookmark and sharing options...' href='http://blog.zacharcher.com/2008/12/29/fractal-transform-in-pixel-bender/#bookmarkify' rel='nofollow'><small>More&nbsp;&raquo;</small></a></div></div>]]></content:encoded>
			<wfw:commentRss>http://blog.zacharcher.com/2008/12/29/fractal-transform-in-pixel-bender/feed/</wfw:commentRss>
		<slash:comments>4</slash:comments>
		</item>
		<item>
		<title>Tile engine is go!</title>
		<link>http://blog.zacharcher.com/2008/07/12/tile-engine-is-go/</link>
		<comments>http://blog.zacharcher.com/2008/07/12/tile-engine-is-go/#comments</comments>
		<pubDate>Sat, 12 Jul 2008 10:11:10 +0000</pubDate>
		<dc:creator>Zach</dc:creator>
				<category><![CDATA[Flash]]></category>
		<category><![CDATA[Games]]></category>
		<category><![CDATA[roomhack]]></category>
		<category><![CDATA[tile]]></category>

		<guid isPermaLink="false">http://blog.zacharcher.com/?p=21</guid>
		<description><![CDATA[Homemade tile engine! Click to play. Move: Arrow keys, or WASD Shoot: Mouse button, or IJKL Make sure you grab a weapon in room #2, so you can shoot the orcs. Currently, there are 9 rooms for romping. Not one pixel of the art should be considered "final". Most sprites &#38; tiles have a ColorMatrixFilter [...]]]></description>
			<content:encoded><![CDATA[<p>Homemade tile engine!<a href="http://zacharcher.com/lab/20080711_roomhack/RoomHack.swf"><br />
</a></p>
<p><a href="http://zacharcher.com/lab/20080711_roomhack/RoomHack.swf"><img src="http://zacharcher.com/lab/20080711_roomhack/roomhack_screenshot.png" alt="screenshot" width="324" height="324" /></a></p>
<p><a href="http://zacharcher.com/lab/20080711_roomhack/RoomHack.swf">Click to play</a>.</p>
<ul>
<li>Move: Arrow keys, or WASD</li>
<li>Shoot: Mouse button, or IJKL</li>
</ul>
<p>Make sure you grab a weapon in room #2, so you can shoot the orcs. Currently, there are 9 rooms for romping.</p>
<p>Not one pixel of the art should be considered "final". Most sprites &amp; tiles have a ColorMatrixFilter that "skins" them with four particular colors (see <a href="http://blog.zacharcher.com/2007/10/13/understanding-colormatrixfilter/">my post detailing this technique</a>). In some respects, this is wonderful, as the colors can be randomized, and it's easy to change the palette of an entire room. Unfortunately, to maintain retro look &amp; feel, I chose the <a href="http://en.wikipedia.org/wiki/List_of_videogame_consoles_palettes#Atari_2600">Atari 2600 palette</a>. The dark colors are over-saturated, the pastels are unexciting, and the hue distribution is completely wrong (nearly half the colors could be considered "green"). This will be dealt with.</p>
<p>An <a href="http://blog.zacharcher.com/2008/05/24/flash-10-is-go/">earlier screenshot</a> shows some vector art. Unfortunately, the vectors currently require Flash 10. I've disabled this feature... <em>for now</em>.</p>
<div class='bookmarkify'><a name='bookmarkify'></a><div class='linkbuttons'><a href='http://del.icio.us/post?url=http://blog.zacharcher.com/2008/07/12/tile-engine-is-go/&amp;title=Tile engine is go!' title='Save to del.icio.us' onclick='target="_blank";' rel='nofollow'><img src='http://blog.zacharcher.com/wp-content/plugins/bookmarkify/delicious.png' style='width:16px; height:16px;' alt='[del.icio.us] ' /></a> <a href='http://digg.com/submit?phase=2&amp;url=http://blog.zacharcher.com/2008/07/12/tile-engine-is-go/&amp;title=Tile engine is go!' title='Digg It!' onclick='target="_blank";' rel='nofollow'><img src='http://blog.zacharcher.com/wp-content/plugins/bookmarkify/digg.png' style='width:16px; height:16px;' alt='[Digg] ' /></a> <a href='http://reddit.com/submit?url=http://blog.zacharcher.com/2008/07/12/tile-engine-is-go/&amp;title=Tile engine is go!' title='Reddit' onclick='target="_blank";' rel='nofollow'><img src='http://blog.zacharcher.com/wp-content/plugins/bookmarkify/reddit.png' style='width:16px; height:16px;' alt='[Reddit] ' /></a> <a href='http://twitter.com/home/?status=Tile engine is go!+http://blog.zacharcher.com/2008/07/12/tile-engine-is-go/' title='Save to Twitter' onclick='target="_blank";' rel='nofollow'><img src='http://blog.zacharcher.com/wp-content/plugins/bookmarkify/twitter.png' style='width:16px; height:16px;' alt='[Twitter] ' /></a> <a href='http://www.feedburner.com/fb/a/emailFlare?itemTitle=Tile engine is go!&amp;uri=http://blog.zacharcher.com/2008/07/12/tile-engine-is-go/&amp;loc=en_US' title='Email this to a friend' onclick='target="_blank";' rel='nofollow'><img src='http://blog.zacharcher.com/wp-content/plugins/bookmarkify/email.png' style='width:16px; height:16px;' alt='[Email] ' /></a>  <a title='See more bookmark and sharing options...' href='http://blog.zacharcher.com/2008/07/12/tile-engine-is-go/#bookmarkify' rel='nofollow'><small>More&nbsp;&raquo;</small></a></div></div>]]></content:encoded>
			<wfw:commentRss>http://blog.zacharcher.com/2008/07/12/tile-engine-is-go/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Horacio without glitch effects</title>
		<link>http://blog.zacharcher.com/2008/06/15/horacio-salinas-no-more-glitches/</link>
		<comments>http://blog.zacharcher.com/2008/06/15/horacio-salinas-no-more-glitches/#comments</comments>
		<pubDate>Mon, 16 Jun 2008 00:40:13 +0000</pubDate>
		<dc:creator>Zach</dc:creator>
				<category><![CDATA[Flash]]></category>
		<category><![CDATA[glitch]]></category>
		<category><![CDATA[Horacio Salinas]]></category>

		<guid isPermaLink="false">http://blog.zacharcher.com/?p=19</guid>
		<description><![CDATA[Due to factors beyond our control, FashionBuddha and myself have removed the "glitch" effects from horaciosalinas.net. It's sad, but these things do happen. It's still a great site. You can see the glitch-enabled version here: http://www.fashionbuddha.com/horaciosalinas/ More&#160;&#187;]]></description>
			<content:encoded><![CDATA[<p>Due to factors beyond our control, <a href="http://www.fashionbuddha.com/">FashionBuddha</a> and myself have removed the "glitch" effects from <a href="http://horaciosalinas.net/">horaciosalinas.net</a>. It's sad, but these things do happen. It's still a great site.</p>
<p>You can see the glitch-enabled version here: <a href="http://www.fashionbuddha.com/horaciosalinas/">http://www.fashionbuddha.com/horaciosalinas/</a></p>
<div class='bookmarkify'><a name='bookmarkify'></a><div class='linkbuttons'><a href='http://del.icio.us/post?url=http://blog.zacharcher.com/2008/06/15/horacio-salinas-no-more-glitches/&amp;title=Horacio without glitch effects' title='Save to del.icio.us' onclick='target="_blank";' rel='nofollow'><img src='http://blog.zacharcher.com/wp-content/plugins/bookmarkify/delicious.png' style='width:16px; height:16px;' alt='[del.icio.us] ' /></a> <a href='http://digg.com/submit?phase=2&amp;url=http://blog.zacharcher.com/2008/06/15/horacio-salinas-no-more-glitches/&amp;title=Horacio without glitch effects' title='Digg It!' onclick='target="_blank";' rel='nofollow'><img src='http://blog.zacharcher.com/wp-content/plugins/bookmarkify/digg.png' style='width:16px; height:16px;' alt='[Digg] ' /></a> <a href='http://reddit.com/submit?url=http://blog.zacharcher.com/2008/06/15/horacio-salinas-no-more-glitches/&amp;title=Horacio without glitch effects' title='Reddit' onclick='target="_blank";' rel='nofollow'><img src='http://blog.zacharcher.com/wp-content/plugins/bookmarkify/reddit.png' style='width:16px; height:16px;' alt='[Reddit] ' /></a> <a href='http://twitter.com/home/?status=Horacio without glitch effects+http://blog.zacharcher.com/2008/06/15/horacio-salinas-no-more-glitches/' title='Save to Twitter' onclick='target="_blank";' rel='nofollow'><img src='http://blog.zacharcher.com/wp-content/plugins/bookmarkify/twitter.png' style='width:16px; height:16px;' alt='[Twitter] ' /></a> <a href='http://www.feedburner.com/fb/a/emailFlare?itemTitle=Horacio without glitch effects&amp;uri=http://blog.zacharcher.com/2008/06/15/horacio-salinas-no-more-glitches/&amp;loc=en_US' title='Email this to a friend' onclick='target="_blank";' rel='nofollow'><img src='http://blog.zacharcher.com/wp-content/plugins/bookmarkify/email.png' style='width:16px; height:16px;' alt='[Email] ' /></a>  <a title='See more bookmark and sharing options...' href='http://blog.zacharcher.com/2008/06/15/horacio-salinas-no-more-glitches/#bookmarkify' rel='nofollow'><small>More&nbsp;&raquo;</small></a></div></div>]]></content:encoded>
			<wfw:commentRss>http://blog.zacharcher.com/2008/06/15/horacio-salinas-no-more-glitches/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Reactions to Horacio Salinas</title>
		<link>http://blog.zacharcher.com/2008/05/23/reactions-to-the-horacio-salinas-site/</link>
		<comments>http://blog.zacharcher.com/2008/05/23/reactions-to-the-horacio-salinas-site/#comments</comments>
		<pubDate>Fri, 23 May 2008 10:49:25 +0000</pubDate>
		<dc:creator>Zach</dc:creator>
				<category><![CDATA[Flash]]></category>

		<guid isPermaLink="false">http://blog.zacharcher.com/2008/05/23/reactions-to-the-horacio-salinas-site/</guid>
		<description><![CDATA[I'm talking about http://www.fashionbuddha.com/horaciosalinas/: "The electrical static was very disturbing. I don't think it adds to the photography, but it did add to my anxiety about my own computer enough that I bailed even though I knew it was something on the site. HTH" -- Zani (There is a glitchless version of the site at [...]]]></description>
			<content:encoded><![CDATA[<p>I'm talking about <a href="http://www.fashionbuddha.com/horaciosalinas/">http://www.fashionbuddha.com/horaciosalinas/</a>:</p>
<blockquote><p>"<span class="postbody">The electrical static was very disturbing. I don't think it adds to   the photography, but it did add to my anxiety about my own computer   enough that I bailed even though I knew it was something on the site.   HTH" -- <a href="http://www.gotoandplay.net/forum/viewtopic.php?t=11015">Zani</a></span></p></blockquote>
<p>(There is a glitchless version of the site at <a href="http://horaciosalinas.com">horaciosalinas.com</a>.)</p>
<p>Also... They say imitation is the sincerest form of flattery, so I'm amused that <a href="http://yenisanat.net/horaciosalinas/">yenisanat.net copied the site in its entirety</a> (even the images!) but changed the copyright. I'm glad you appreciate our hard work, Yeni. I feel like I've finally <em>arrived</em>, ya know?</p>
<div class='bookmarkify'><a name='bookmarkify'></a><div class='linkbuttons'><a href='http://del.icio.us/post?url=http://blog.zacharcher.com/2008/05/23/reactions-to-the-horacio-salinas-site/&amp;title=Reactions to Horacio Salinas' title='Save to del.icio.us' onclick='target="_blank";' rel='nofollow'><img src='http://blog.zacharcher.com/wp-content/plugins/bookmarkify/delicious.png' style='width:16px; height:16px;' alt='[del.icio.us] ' /></a> <a href='http://digg.com/submit?phase=2&amp;url=http://blog.zacharcher.com/2008/05/23/reactions-to-the-horacio-salinas-site/&amp;title=Reactions to Horacio Salinas' title='Digg It!' onclick='target="_blank";' rel='nofollow'><img src='http://blog.zacharcher.com/wp-content/plugins/bookmarkify/digg.png' style='width:16px; height:16px;' alt='[Digg] ' /></a> <a href='http://reddit.com/submit?url=http://blog.zacharcher.com/2008/05/23/reactions-to-the-horacio-salinas-site/&amp;title=Reactions to Horacio Salinas' title='Reddit' onclick='target="_blank";' rel='nofollow'><img src='http://blog.zacharcher.com/wp-content/plugins/bookmarkify/reddit.png' style='width:16px; height:16px;' alt='[Reddit] ' /></a> <a href='http://twitter.com/home/?status=Reactions to Horacio Salinas+http://blog.zacharcher.com/2008/05/23/reactions-to-the-horacio-salinas-site/' title='Save to Twitter' onclick='target="_blank";' rel='nofollow'><img src='http://blog.zacharcher.com/wp-content/plugins/bookmarkify/twitter.png' style='width:16px; height:16px;' alt='[Twitter] ' /></a> <a href='http://www.feedburner.com/fb/a/emailFlare?itemTitle=Reactions to Horacio Salinas&amp;uri=http://blog.zacharcher.com/2008/05/23/reactions-to-the-horacio-salinas-site/&amp;loc=en_US' title='Email this to a friend' onclick='target="_blank";' rel='nofollow'><img src='http://blog.zacharcher.com/wp-content/plugins/bookmarkify/email.png' style='width:16px; height:16px;' alt='[Email] ' /></a>  <a title='See more bookmark and sharing options...' href='http://blog.zacharcher.com/2008/05/23/reactions-to-the-horacio-salinas-site/#bookmarkify' rel='nofollow'><small>More&nbsp;&raquo;</small></a></div></div>]]></content:encoded>
			<wfw:commentRss>http://blog.zacharcher.com/2008/05/23/reactions-to-the-horacio-salinas-site/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Real Time JPEG Corruption</title>
		<link>http://blog.zacharcher.com/2008/05/23/real-time-jpeg-corruption/</link>
		<comments>http://blog.zacharcher.com/2008/05/23/real-time-jpeg-corruption/#comments</comments>
		<pubDate>Fri, 23 May 2008 09:37:54 +0000</pubDate>
		<dc:creator>Zach</dc:creator>
				<category><![CDATA[Flash]]></category>

		<guid isPermaLink="false">http://blog.zacharcher.com/2008/05/23/real-time-jpeg-corruption/</guid>
		<description><![CDATA[Here's a new site that I worked on: http://www.fashionbuddha.com/horaciosalinas/ The site seems typical at a first glance, until the glitches kick in... Then you're in for a treat. (You can adjust the glitch rate in the menu.) Here's how the effect works: The concept + design were crafted by Fashionbuddha Studio. They handed me proof-of-concept [...]]]></description>
			<content:encoded><![CDATA[<p>Here's a new site that I worked on:</p>
<p><a title="http://www.fashionbuddha.com/horaciosalinas/" href="http://www.fashionbuddha.com/horaciosalinas/">http://www.fashionbuddha.com/horaciosalinas/</a></p>
<p><a href="http://www.horaciosalinas.net/"><img title="Reserved &amp; Corrupted" src="http://zacharcher.com/lab/20080523_jpeg_corruption/reserved_demo_frame.jpg" alt="Reserved &amp; Corrupted" width="417" height="566" align="absmiddle" /></a></p>
<p>The site seems typical at a first glance, until the glitches kick in... Then you're in for a treat. (You can adjust the glitch rate in the menu.) Here's how the effect works:</p>
<p><span id="more-15"></span>The concept + design were crafted by <a href="http://www.fashionbuddha.com/">Fashionbuddha Studio</a>. They handed me proof-of-concept code that loaded a JPEG, scrambled its bytes, and rendered it to the screen. Corrupted JPEGs look like you'd expect; some are beautiful, with distortions in their colors and textures; some were nasty or unrecognizable. A few wouldn't display at all, but more on that in a minute...</p>
<p>The site uses JPEG corruption as a method of animation. When the site is idle, a photograph will sometimes crackle to life and progressively corrupt itself for several frames. When you click a menu link, you see a similar effect, but it's reversed: the corrupted frames are quickly pre-rendered in memory, and then displayed in reverse order, materializing from the most corrupted frame to the least.</p>
<p>All the corruption effects are performed inside Flash. Use a URLLoader to load an image, then on Event.COMPLETE, you can access the raw JPEG data as a ByteArray:</p>
<p><code>var bytes:ByteArray = e.target.data;</code></p>
<p>You can traverse the ByteArray and change selective bytes, just like editing an Array. (Some people would call this <a href="http://www.getlofi.com/?cat=13">"data bending"</a>.) Then you can display the corrupted image by using the Loader.loadBytes method:</p>
<p><code>_loader.loadBytes( bytes );</code></p>
<p>Matt Rooney of <a href="http://impactresist.net/">Impact Resist</a> helped me with the next phase: sometimes, our corrupted ByteArrays weren't recognized as valid JPEGs, and Flash wouldn't display them. Matt dug into the <a href="http://en.wikipedia.org/wiki/JPEG#Syntax_and_structure">JPEG file structure</a>, and created a class that identified various markers inside the file.</p>
<p>I wrote a <a href="http://zacharcher.com/lab/20080523_jpeg_corruption/ScrambleHarness.swf">quick 'n dirty test harness</a> <em>(warning: contains drugs and boobs) </em>that loads a couple images, and lets you change the value of one byte at one particular position. Using the harness, and the info gleaned from Matt's JPEGInfo class, I determined that there are three "hot zones" where you can garble the data and produce desirable effects:</p>
<ul>
<li><strong>Scan data</strong>. (This is the bulk of the file, containing the image data). These effects are usually relatively weak, and cause horizontal tearing, or sometimes color changes. Applying several corruptions is effective. To see a single corruption effect, drop these values into the harness: [10000/200]</li>
<li><strong>Quantization tables</strong>. These are beautiful effects that can affect the entire image. The first half of the quantization data controls the visual complexity (Fourier constants) and the second half controls the overall color. Try these values: [60/40], [61/40], [64/75],  [125/110]</li>
<li><strong>Huffman lookup tables</strong>. This is the most drastic effect. Try these values: [366/28], [367/28], and explore the surrounding bytes.</li>
</ul>
<p>It took lots of tuning to make the photo corruption look aesthetically "correct" -- not too intense, not too subtle. The final algorithm applies a number of scan data glitches every frame, and sometimes one quantization or Huffman glitch per frame (and always on the first frame, to emphasize that the glitch is occurring). Some byte values aren't safe to inject (or modify): 0, 1 and 255 have special functions in the JPEG file format, so the site avoids those completely.</p>
<p>If you want to scramble your own JPEGs, but don't want to write a whole Flash harness to do it, then you can open JPEGs using a text editor (such as TextMate) and edit the file as text (with unpredictable results). Have fun!</p>
<p><strong>EDIT:</strong> The glitch effects have been removed from horaciosalinas.com, <a href="http://blog.zacharcher.com/2008/06/15/horacio-salinas-no-more-glitches/">see this post for more info</a>.</p>
<div class='bookmarkify'><a name='bookmarkify'></a><div class='linkbuttons'><a href='http://del.icio.us/post?url=http://blog.zacharcher.com/2008/05/23/real-time-jpeg-corruption/&amp;title=Real Time JPEG Corruption' title='Save to del.icio.us' onclick='target="_blank";' rel='nofollow'><img src='http://blog.zacharcher.com/wp-content/plugins/bookmarkify/delicious.png' style='width:16px; height:16px;' alt='[del.icio.us] ' /></a> <a href='http://digg.com/submit?phase=2&amp;url=http://blog.zacharcher.com/2008/05/23/real-time-jpeg-corruption/&amp;title=Real Time JPEG Corruption' title='Digg It!' onclick='target="_blank";' rel='nofollow'><img src='http://blog.zacharcher.com/wp-content/plugins/bookmarkify/digg.png' style='width:16px; height:16px;' alt='[Digg] ' /></a> <a href='http://reddit.com/submit?url=http://blog.zacharcher.com/2008/05/23/real-time-jpeg-corruption/&amp;title=Real Time JPEG Corruption' title='Reddit' onclick='target="_blank";' rel='nofollow'><img src='http://blog.zacharcher.com/wp-content/plugins/bookmarkify/reddit.png' style='width:16px; height:16px;' alt='[Reddit] ' /></a> <a href='http://twitter.com/home/?status=Real Time JPEG Corruption+http://blog.zacharcher.com/2008/05/23/real-time-jpeg-corruption/' title='Save to Twitter' onclick='target="_blank";' rel='nofollow'><img src='http://blog.zacharcher.com/wp-content/plugins/bookmarkify/twitter.png' style='width:16px; height:16px;' alt='[Twitter] ' /></a> <a href='http://www.feedburner.com/fb/a/emailFlare?itemTitle=Real Time JPEG Corruption&amp;uri=http://blog.zacharcher.com/2008/05/23/real-time-jpeg-corruption/&amp;loc=en_US' title='Email this to a friend' onclick='target="_blank";' rel='nofollow'><img src='http://blog.zacharcher.com/wp-content/plugins/bookmarkify/email.png' style='width:16px; height:16px;' alt='[Email] ' /></a>  <a title='See more bookmark and sharing options...' href='http://blog.zacharcher.com/2008/05/23/real-time-jpeg-corruption/#bookmarkify' rel='nofollow'><small>More&nbsp;&raquo;</small></a></div></div>]]></content:encoded>
			<wfw:commentRss>http://blog.zacharcher.com/2008/05/23/real-time-jpeg-corruption/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Understanding the ColorMatrixFilter class!</title>
		<link>http://blog.zacharcher.com/2007/10/13/understanding-colormatrixfilter/</link>
		<comments>http://blog.zacharcher.com/2007/10/13/understanding-colormatrixfilter/#comments</comments>
		<pubDate>Sat, 13 Oct 2007 11:31:12 +0000</pubDate>
		<dc:creator>Zach</dc:creator>
				<category><![CDATA[Flash]]></category>

		<guid isPermaLink="false">http://blog.zacharcher.com/2007/10/13/understanding-colormatrixfilter/</guid>
		<description><![CDATA[I haven't seen many people explore the ColorMatrixFilter class, probably because it appears daunting. I'm happy to report that I comprehend the mysteries of ColorMatrixFilter now, and I thought I'd share a technique we used in our new game, Space Kitty. Before we jump into ColorMatrixFilter, let's ponder a different, and more commonly-used, class first: [...]]]></description>
			<content:encoded><![CDATA[<p>I haven't seen many people explore the <a href="http://livedocs.adobe.com/flash/9.0/ActionScriptLangRefV3/flash/filters/ColorMatrixFilter.html">ColorMatrixFilter</a> class, probably because it appears daunting. I'm happy to report that I comprehend the mysteries of ColorMatrixFilter now, and I thought I'd share a technique we used in our new game, <a href="http://mirror8.cgdc4.fizzlebot.com/?gameID=24">Space Kitty</a>.</p>
<p>Before we jump into ColorMatrixFilter, let's ponder a different, and more commonly-used, class first: <a href="http://livedocs.adobe.com/flash/9.0/ActionScriptLangRefV3/flash/geom/ColorTransform.html">ColorTransform</a> . Using a ColorTransform, you can "tint" any DisplayObject with color. But there's something sneaky you can do, as well -- Notice that ColorTransform gives you two parameters for each of the four color channels: Red, Green, Blue, and Alpha. One parameter is the "multiplier," which takes the input value and (predictably) multiplies this value by a constant. The other is the "offset," which works like addition: adding (or subtracting) another constant from the value. These two functions are applied to <em>all four color channels of each individual pixel</em>. That's how the magic works.</p>
<p><span id="more-14"></span>Allow me to spend a few paragraphs making sure this idea is lodged in your head. Imagine that you have a DisplayObject; one of its pixels has a <strong>red</strong> value of 128 (out of a range of 0-255. So this red is at a medium level.) We don't care about any of the other color data right now; let's just focus on the red.</p>
<p>Let's say you have applied a ColorTransform to this DisplayObject. The ColorTransform has a <strong>redMultiplier</strong> of <strong>0.5</strong>, so our working red value is now 64. (The red value is now somewhat darker.)</p>
<p>But the ColorTransform also has a <strong>redOffset</strong> of <strong>128</strong>, which is then added to the pixel's red value. The final red value is 192, so the output color has a fairly bright red component.</p>
<p>Keep in mind that we aren't considering the green, blue, and alpha channels in the above steps. We're just altering the red value, at this point.</p>
<p>Now for the first round of magic: There's a slick way to colorize a black-and-white image, using a ColorTransform to "map" its black and white values to two destination colors of your choosing. Shades of grey will even be mapped to the spectrum of colors between your chosen destination colors. <a href="http://zacharcher.com/lab/20071013_color_matrix/GradientTest.swf">Here's a quick-and-dirty .swf showing this in action</a>. Every time you click the mouse, the application selects two new destination colors (you can see these values in your trace log) and creates a new ColorTransform that maps the black pixels to one destination color, and the white pixels to the other color. The grey pixels create a smooth blend between the two extremes.</p>
<p>How do we accomplish this? By using simple math. Suppose one of your destination colors has a medium red value (128). Mapping all the <em>black</em> pixels to this red value is the easiest thing in the world. Since black pixels have a red value of 0 (because they have no brightness whatsoever), we can set our redOffset to 128. ...</p>
<p>Stepping through the math: The ColorTransform is about to crunch a black pixel. Since the red value of the pixel is already 0, it doesn't matter what our redMultiplier is. Any number multiplied by zero is 0. Then, our redOffset (128) is added to the working red value.</p>
<p>Imagine doing this with green and blue, as well. Congratulations, you've just mapped your black pixels to any specific color you want.</p>
<p>Once you understand that concept, mapping the white pixels to a different destination color is easy. Suppose our second destination color has a red value of 192. Incoming white pixels will always have the maximum red value, which is 255, right?</p>
<p><em>Since we know our redOffset will add 128 to the final red value, we need to make up the difference between 192 and 128 (64!), using the redMultiplier alone. </em>And since we know our incoming white pixels have red values of 255, we can set our redMultiplier to ... 0.25 . (This is an approximation, for the sake of the example. 64 divided by 255 is 0.2509803 .)</p>
<p>Imagine that the ColorTransform is processing a white pixel; the incoming red value is 255, yes? Our redMultiplier acts first, and multiplies this value by 0.25. The working red value is now (approximately) 64. Then, the redOffset steps in, adds 128, and the final red value becomes the desired 192.</p>
<p>Again, the process for the green and blue channels is similar. Here's some AS2 code that uses this technique, hopefully you can guess that a "ColorObj" is a little object that holds red, green and blue values, ranging from 0 to 255:</p>
<pre><code>import flash.geom.ColorTransform;
import com.zacharcher.color.ColorObj;

class com.zacharcher.color.ColorGradient
{
	public var transform:ColorTransform;

	function ColorGradient( black:ColorObj, white:ColorObj ) {
		transform = new ColorTransform(
			(white.r - black.r) / 256,
			(white.g - black.g) / 256,
			(white.b - black.b) / 256,
			1.0,
			black.r,
			black.g,
			black.b,
			0.0
		);
	}
}</code></pre>
<p>Ok. Let me wrap this up, because it's 4 in the morning here in Portland! For Space Kitty, we wanted each cat to use a different color scheme, but without going to the trouble of creating dozens of MovieClips (one for each cat). We discovered that we can use ColorMatrixFilter to perform the same trick as with ColorTransform, but it's more sophisticated because we can map to 4 (<em>four!</em>) destination colors at once.</p>
<p>First, <a href="http://isometric.sixsided.org/">Miles</a> drew a cat using four specific colors: black, pure red (#ff0000), pure green (#00ff00), and pure blue (#0000ff):</p>
<p><img src="http://zacharcher.com/lab/20071013_color_matrix/kitty_rgb.png" alt="RGB KITTY" /></p>
<p>Then I wrote the code. Here's how ColorMatrixFilter crunches one pixel value, say we start by examining the red component: The value of the red channel is multiplied by a red multiplier (just like ColorTransform), <em>and also three other multipliers (for green, blue and alpha)</em>. The four resulting values are added to four separate output "pools". One pool will become the final red value; one will be the final green value; etc.</p>
<p>Then the incoming green channel is examined, and four different multipliers act on it, adding new values to the four pools. Then the incoming blue channel is evaluated in the same way, and finally the alpha channel is evaluated.</p>
<p>As a finishing touch, there are four additional values which are added to the pools, much like the offsets of the ColorTransform. All that math produces a simple result: four "pool" values, representing the new red, green, blue, and alpha values for one pixel. That's how ColorMatrixFilter works.</p>
<p>And it lets us map four colors, not just two! The technique is just like our ColorTransform technique, except that we don't need to handle the red, green, and blue of the destination color separately. We can handle them all at once, because we have multipliers that splice the color values onto each other: the incoming red channel can affect the green pool, and so on. Here's the AS3 code we used... Our cat MovieClips featured red eyes, so the "redDest" in this code holds the cat's desired eye color:</p>
<pre><code>var matrix:Array = new Array();

// RED RESULT:
matrix = matrix.concat([
	(redDest.r - blackDest.r) / 255.0,
	(greenDest.r - blackDest.r) / 255.0,
	(blueDest.r - blackDest.r) / 255.0,
	0,
	blackDest.r
]);

// GREEN RESULT:
matrix = matrix.concat([
	(redDest.g - blackDest.g) / 255.0,
	(greenDest.g - blackDest.g) / 255.0,
	(blueDest.g - blackDest.g) / 255.0,
	0,
	blackDest.g
]);

// BLUE RESULT:
matrix = matrix.concat([
	(redDest.b - blackDest.b) / 255.0,
	(greenDest.b - blackDest.b) / 255.0,
	(blueDest.b - blackDest.b) / 255.0,
	0,
	blackDest.b
]);				

// ALPHA: for now, do not adjust opacity
matrix = matrix.concat([
	0,
	0,
	0,
	1,
	0
]);

var filter:ColorMatrixFilter = new ColorMatrixFilter( matrix );</code></pre>
<p>And here's how it looks in the game!</p>
<p><img src="http://zacharcher.com/lab/20071013_color_matrix/kitty_color.png" alt="KITTY COLOR" /></p>
<p>I look forward to experimenting with this technique more in the future. You'll notice we didn't perform any magic with the alpha channel, although both ColorTransform and ColorMatrixFilter let you treat alpha in the same way as red, green and blue. So there are still interesting tricks waiting to be discovered!</p>
<div class='bookmarkify'><a name='bookmarkify'></a><div class='linkbuttons'><a href='http://del.icio.us/post?url=http://blog.zacharcher.com/2007/10/13/understanding-colormatrixfilter/&amp;title=Understanding the ColorMatrixFilter class!' title='Save to del.icio.us' onclick='target="_blank";' rel='nofollow'><img src='http://blog.zacharcher.com/wp-content/plugins/bookmarkify/delicious.png' style='width:16px; height:16px;' alt='[del.icio.us] ' /></a> <a href='http://digg.com/submit?phase=2&amp;url=http://blog.zacharcher.com/2007/10/13/understanding-colormatrixfilter/&amp;title=Understanding the ColorMatrixFilter class!' title='Digg It!' onclick='target="_blank";' rel='nofollow'><img src='http://blog.zacharcher.com/wp-content/plugins/bookmarkify/digg.png' style='width:16px; height:16px;' alt='[Digg] ' /></a> <a href='http://reddit.com/submit?url=http://blog.zacharcher.com/2007/10/13/understanding-colormatrixfilter/&amp;title=Understanding the ColorMatrixFilter class!' title='Reddit' onclick='target="_blank";' rel='nofollow'><img src='http://blog.zacharcher.com/wp-content/plugins/bookmarkify/reddit.png' style='width:16px; height:16px;' alt='[Reddit] ' /></a> <a href='http://twitter.com/home/?status=Understanding the ColorMatrixFilter class!+http://blog.zacharcher.com/2007/10/13/understanding-colormatrixfilter/' title='Save to Twitter' onclick='target="_blank";' rel='nofollow'><img src='http://blog.zacharcher.com/wp-content/plugins/bookmarkify/twitter.png' style='width:16px; height:16px;' alt='[Twitter] ' /></a> <a href='http://www.feedburner.com/fb/a/emailFlare?itemTitle=Understanding the ColorMatrixFilter class!&amp;uri=http://blog.zacharcher.com/2007/10/13/understanding-colormatrixfilter/&amp;loc=en_US' title='Email this to a friend' onclick='target="_blank";' rel='nofollow'><img src='http://blog.zacharcher.com/wp-content/plugins/bookmarkify/email.png' style='width:16px; height:16px;' alt='[Email] ' /></a>  <a title='See more bookmark and sharing options...' href='http://blog.zacharcher.com/2007/10/13/understanding-colormatrixfilter/#bookmarkify' rel='nofollow'><small>More&nbsp;&raquo;</small></a></div></div>]]></content:encoded>
			<wfw:commentRss>http://blog.zacharcher.com/2007/10/13/understanding-colormatrixfilter/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>How to Crash Flash</title>
		<link>http://blog.zacharcher.com/2007/10/05/how-to-crash-flash/</link>
		<comments>http://blog.zacharcher.com/2007/10/05/how-to-crash-flash/#comments</comments>
		<pubDate>Fri, 05 Oct 2007 09:03:06 +0000</pubDate>
		<dc:creator>Zach</dc:creator>
				<category><![CDATA[Flash]]></category>
		<category><![CDATA[Games]]></category>

		<guid isPermaLink="false">http://blog.zacharcher.com/?p=13</guid>
		<description><![CDATA[Miles and I submitted our new Flash game to the 4th Jay Is Games competition. In Space Kitteh (pronounced something like "Space Kitty"), the object is to rescue cats in an outer space environment. The physics are a real treat -- it's impossible to "fall" off the landscape. If you get lost, just wait for [...]]]></description>
			<content:encoded><![CDATA[<p><a href="http://isometric.sixsided.org/">Miles</a> and I submitted our new Flash game to the <a href="http://jayisgames.com/archives/2007/08/game_design_competition_4.php">4th Jay Is Games competition</a>. In Space Kitteh (pronounced something like "Space Kitty"), the object is to rescue cats in an outer space environment. The physics are a real treat -- it's impossible to "fall" off the landscape. If you get lost, just wait for the solar system's gravitational pull to drag you home.</p>
<p>It's a lot of fun, but I need to warn you about a serious problem in Space Kitteh. This is a heads-up for users of Windows Flash Player --</p>
<p><strong>Our game will crash your browser.</strong></p>
<p><span id="more-13"></span>And we don't know why. It has something to do with this level:</p>
<p><a href="http://chaz.bdmonkeys.net/shared/p/atomsmasher/20070929_sunlight.png"><img src="http://chaz.bdmonkeys.net/shared/p/atomsmasher/20070929_sunlight.png" height="360" width="458" /></a></p>
<p>Every Windows user who spends a little time on this level reports the same problem: the game crashes hard, and takes down their browser. Sometimes it's after a few seconds, sometimes it's minutes, but eventually, <em>this level will get you</em>.</p>
<p>And the frustrating thing is, we have no idea why. Mac users (including myself) have no problems, PowerPC- or Intel-based. Perhaps it's due to the glut of sun ray shapes in the center of the solar system? Look at the size of those things! Do these <code>malloc</code> huge chunks of memory, and overflow the heap? Who knows. One day, Miles reigned in the rays, so they wouldn't grow to immense proportions, but that didn't remedy the crash. Then he disabled the sun rays completely, and this seemed to work, although the game <em>did</em> crash in another area thereafter. It's all very confusing.</p>
<p>I feel like we're sitting on a time bomb. This is going to ruin our chance of winning a prize. (Not that we entered to win, but it would be nice! We both put serious time and energy into Space Kitteh.) Jay Is Games devotees are going to enjoy some of our hard work, <em>but it crashes</em>, irritatingly so, and you can't win the game.</p>
<p>In addition to this method of crashing Flash, I stumbled on another nuclear exploit that even crashed Flash on my Mac (it took down the Flash CS3 application). Here it is, the purpose of this code is to play a sound after a short delay:</p>
<p><code>var snd:Sound = fetchSoundByName( name );<br />
var timer:Timer = new Timer( delayInSeconds * 1000, 1 );	// seconds =&amp;gt; milliseconds<br />
timer.addEventListener( TimerEvent.TIMER, snd.play );<br />
timer.start();</code></p>
<p>In this example, I'm guessing that the native Sound.play() method barfs because it's not equipped to handle any arguments, such as the TimerEvent it receives? Whatever the cause, enjoy the exploit. Play practical jokes on your friends, and the whole of digg.com, and whatnot.</p>
<p>I doubt we can mend Space Kitteh in time for its debut, which happens in a few days. I don't know what to do, really. We put a lot of love into Space Kitteh, and tried to create a quality experience. And I'm already grieving in anticipation of our (otherwise wonderful) game crashing browsers worldwide.</p>
<p>What would you do?</p>
<div class='bookmarkify'><a name='bookmarkify'></a><div class='linkbuttons'><a href='http://del.icio.us/post?url=http://blog.zacharcher.com/2007/10/05/how-to-crash-flash/&amp;title=How to Crash Flash' title='Save to del.icio.us' onclick='target="_blank";' rel='nofollow'><img src='http://blog.zacharcher.com/wp-content/plugins/bookmarkify/delicious.png' style='width:16px; height:16px;' alt='[del.icio.us] ' /></a> <a href='http://digg.com/submit?phase=2&amp;url=http://blog.zacharcher.com/2007/10/05/how-to-crash-flash/&amp;title=How to Crash Flash' title='Digg It!' onclick='target="_blank";' rel='nofollow'><img src='http://blog.zacharcher.com/wp-content/plugins/bookmarkify/digg.png' style='width:16px; height:16px;' alt='[Digg] ' /></a> <a href='http://reddit.com/submit?url=http://blog.zacharcher.com/2007/10/05/how-to-crash-flash/&amp;title=How to Crash Flash' title='Reddit' onclick='target="_blank";' rel='nofollow'><img src='http://blog.zacharcher.com/wp-content/plugins/bookmarkify/reddit.png' style='width:16px; height:16px;' alt='[Reddit] ' /></a> <a href='http://twitter.com/home/?status=How to Crash Flash+http://blog.zacharcher.com/2007/10/05/how-to-crash-flash/' title='Save to Twitter' onclick='target="_blank";' rel='nofollow'><img src='http://blog.zacharcher.com/wp-content/plugins/bookmarkify/twitter.png' style='width:16px; height:16px;' alt='[Twitter] ' /></a> <a href='http://www.feedburner.com/fb/a/emailFlare?itemTitle=How to Crash Flash&amp;uri=http://blog.zacharcher.com/2007/10/05/how-to-crash-flash/&amp;loc=en_US' title='Email this to a friend' onclick='target="_blank";' rel='nofollow'><img src='http://blog.zacharcher.com/wp-content/plugins/bookmarkify/email.png' style='width:16px; height:16px;' alt='[Email] ' /></a>  <a title='See more bookmark and sharing options...' href='http://blog.zacharcher.com/2007/10/05/how-to-crash-flash/#bookmarkify' rel='nofollow'><small>More&nbsp;&raquo;</small></a></div></div>]]></content:encoded>
			<wfw:commentRss>http://blog.zacharcher.com/2007/10/05/how-to-crash-flash/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>3D Interface</title>
		<link>http://blog.zacharcher.com/2007/07/23/3d-interface/</link>
		<comments>http://blog.zacharcher.com/2007/07/23/3d-interface/#comments</comments>
		<pubDate>Mon, 23 Jul 2007 09:48:14 +0000</pubDate>
		<dc:creator>Zach</dc:creator>
				<category><![CDATA[Flash]]></category>

		<guid isPermaLink="false">http://blog.zacharcher.com/?p=11</guid>
		<description><![CDATA[I read relevant chapters of 3D Graphics Programming, and felt my knowledge expanding; I was able to fix the foreshortening bugs in my 3D engine. Then I added solid surfaces, but added some components to the stage that I wasn't completely happy with. Try the swf. Today I thought about interface design, and performance issues [...]]]></description>
			<content:encoded><![CDATA[<p>I read relevant chapters of <a href="http://www.amazon.com/3D-Graphics-Programming-Beyond-CD-ROM/dp/0672319292/ref=pd_bbs_sr_2/102-4957968-9085748?ie=UTF8&amp;s=books&amp;qid=1185063528&amp;sr=8-2">3D Graphics Programming</a>, and felt my knowledge expanding; I was able to fix the foreshortening bugs in my 3D engine. Then I added solid surfaces, but added some components to the stage that I wasn't completely happy with. <a href="http://zacharcher.com/lab/20070723_button_test/20070223_slow-fo_solids.swf">Try the swf</a>.</p>
<p>Today I thought about interface design, and performance issues (the sluggishness this early in development irks me) so I thought about simplifying the design a bit. Here's where I'm at:</p>
<p><a href="http://zacharcher.com/lab/20070723_button_test/20070723_button_test.swf"><img src="http://zacharcher.com/lab/20070723_button_test/20070723_button_test.png" height="232" width="382" /><br />
</a></p>
<p><a href="http://zacharcher.com/lab/20070723_button_test/20070723_button_test.swf">Play with the swf</a>. The button has a rollover state, but doesn't react when clicked.</p>
<p>MUST ... INCREASE ... PERFORMANCE. Somehow. I have some approaches in mind, but I was hoping to escape the long process of experimentation &amp; optimization. Oh well, stay tuned.</p>
<div class='bookmarkify'><a name='bookmarkify'></a><div class='linkbuttons'><a href='http://del.icio.us/post?url=http://blog.zacharcher.com/2007/07/23/3d-interface/&amp;title=3D Interface' title='Save to del.icio.us' onclick='target="_blank";' rel='nofollow'><img src='http://blog.zacharcher.com/wp-content/plugins/bookmarkify/delicious.png' style='width:16px; height:16px;' alt='[del.icio.us] ' /></a> <a href='http://digg.com/submit?phase=2&amp;url=http://blog.zacharcher.com/2007/07/23/3d-interface/&amp;title=3D Interface' title='Digg It!' onclick='target="_blank";' rel='nofollow'><img src='http://blog.zacharcher.com/wp-content/plugins/bookmarkify/digg.png' style='width:16px; height:16px;' alt='[Digg] ' /></a> <a href='http://reddit.com/submit?url=http://blog.zacharcher.com/2007/07/23/3d-interface/&amp;title=3D Interface' title='Reddit' onclick='target="_blank";' rel='nofollow'><img src='http://blog.zacharcher.com/wp-content/plugins/bookmarkify/reddit.png' style='width:16px; height:16px;' alt='[Reddit] ' /></a> <a href='http://twitter.com/home/?status=3D Interface+http://blog.zacharcher.com/2007/07/23/3d-interface/' title='Save to Twitter' onclick='target="_blank";' rel='nofollow'><img src='http://blog.zacharcher.com/wp-content/plugins/bookmarkify/twitter.png' style='width:16px; height:16px;' alt='[Twitter] ' /></a> <a href='http://www.feedburner.com/fb/a/emailFlare?itemTitle=3D Interface&amp;uri=http://blog.zacharcher.com/2007/07/23/3d-interface/&amp;loc=en_US' title='Email this to a friend' onclick='target="_blank";' rel='nofollow'><img src='http://blog.zacharcher.com/wp-content/plugins/bookmarkify/email.png' style='width:16px; height:16px;' alt='[Email] ' /></a>  <a title='See more bookmark and sharing options...' href='http://blog.zacharcher.com/2007/07/23/3d-interface/#bookmarkify' rel='nofollow'><small>More&nbsp;&raquo;</small></a></div></div>]]></content:encoded>
			<wfw:commentRss>http://blog.zacharcher.com/2007/07/23/3d-interface/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Music of the Spheres</title>
		<link>http://blog.zacharcher.com/2007/07/20/music-of-the-spheres/</link>
		<comments>http://blog.zacharcher.com/2007/07/20/music-of-the-spheres/#comments</comments>
		<pubDate>Fri, 20 Jul 2007 11:36:11 +0000</pubDate>
		<dc:creator>Zach</dc:creator>
				<category><![CDATA[Flash]]></category>

		<guid isPermaLink="false">http://blog.zacharcher.com/?p=10</guid>
		<description><![CDATA[I took a couple weeks off, played a booty bass show and did some other things. Onward! Play with the swf. Move the camera with the mouse; Click the mouse to summon a new message. Creating this graphic demo was not a huge ordeal. I probably spent more time futzing with Subversion than writing code; [...]]]></description>
			<content:encoded><![CDATA[<p>I took a couple weeks off, played a booty bass show and did some other things. Onward!</p>
<p><a href="http://zacharcher.com/lab/20070720_vector_spheres/20070720_vector_spheres.swf"><img src="http://zacharcher.com/lab/20070720_vector_spheres/20070720_vector_spheres.png" height="285" width="452" /> </a></p>
<p><a href="http://zacharcher.com/lab/20070720_vector_spheres/20070720_vector_spheres.swf">Play with the swf.</a> Move the camera with the mouse; Click the mouse to summon a new message.</p>
<p>Creating this graphic demo was not a huge ordeal. I probably spent more time futzing with Subversion than writing code; and by the way, <a href="http://dev.zacharcher.com/svn/zacharcher_com/">this project may evolve into my personal website, so it has its own SVN repository now</a>.</p>
<p>I've pinpointed two interesting problems with my 3D engine: 2D Symbols (such as the letters) do not exhibit foreshortening, yet 3D symbols do. (This is almost a good effect; like a low-fi hack that ends up being more stylistic than a hi-fi equivalent. Maybe I'll conveniently forget about this issue for now...)</p>
<p>And, my Matrix3D class has a buggy method: either multiply() or rotate(). An early version of tonight's .swf turned the cube in space, but it would also re-apply the camera angle to the cube, turning it in crazy unexpected ways. ... TODO.</p>
<p>I just looked at the <a href="http://actionscriptcheatsheet.com/pdf/papervision3dcheatsheet.pdf">PaperVision API (.pdf)</a>, they have a Matrix3D object that is much more advanced than mine. I'm still glad I wrote my own engine, it was fun and I feel more competent with 3D math and matrix operations now.</p>
<p>I removed the glow effects in an attempt to boost performance. I should have whipped up a little FPS counter several posts ago, of course... The performance on my G5 (dual-core 1.8ghz PowerPC) is already less-than-optimal, and there's not a ton of stuff happening on the screen. This worries me a bit.</p>
<div class='bookmarkify'><a name='bookmarkify'></a><div class='linkbuttons'><a href='http://del.icio.us/post?url=http://blog.zacharcher.com/2007/07/20/music-of-the-spheres/&amp;title=Music of the Spheres' title='Save to del.icio.us' onclick='target="_blank";' rel='nofollow'><img src='http://blog.zacharcher.com/wp-content/plugins/bookmarkify/delicious.png' style='width:16px; height:16px;' alt='[del.icio.us] ' /></a> <a href='http://digg.com/submit?phase=2&amp;url=http://blog.zacharcher.com/2007/07/20/music-of-the-spheres/&amp;title=Music of the Spheres' title='Digg It!' onclick='target="_blank";' rel='nofollow'><img src='http://blog.zacharcher.com/wp-content/plugins/bookmarkify/digg.png' style='width:16px; height:16px;' alt='[Digg] ' /></a> <a href='http://reddit.com/submit?url=http://blog.zacharcher.com/2007/07/20/music-of-the-spheres/&amp;title=Music of the Spheres' title='Reddit' onclick='target="_blank";' rel='nofollow'><img src='http://blog.zacharcher.com/wp-content/plugins/bookmarkify/reddit.png' style='width:16px; height:16px;' alt='[Reddit] ' /></a> <a href='http://twitter.com/home/?status=Music of the Spheres+http://blog.zacharcher.com/2007/07/20/music-of-the-spheres/' title='Save to Twitter' onclick='target="_blank";' rel='nofollow'><img src='http://blog.zacharcher.com/wp-content/plugins/bookmarkify/twitter.png' style='width:16px; height:16px;' alt='[Twitter] ' /></a> <a href='http://www.feedburner.com/fb/a/emailFlare?itemTitle=Music of the Spheres&amp;uri=http://blog.zacharcher.com/2007/07/20/music-of-the-spheres/&amp;loc=en_US' title='Email this to a friend' onclick='target="_blank";' rel='nofollow'><img src='http://blog.zacharcher.com/wp-content/plugins/bookmarkify/email.png' style='width:16px; height:16px;' alt='[Email] ' /></a>  <a title='See more bookmark and sharing options...' href='http://blog.zacharcher.com/2007/07/20/music-of-the-spheres/#bookmarkify' rel='nofollow'><small>More&nbsp;&raquo;</small></a></div></div>]]></content:encoded>
			<wfw:commentRss>http://blog.zacharcher.com/2007/07/20/music-of-the-spheres/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Subversion is open!</title>
		<link>http://blog.zacharcher.com/2007/07/04/subversion-is-open/</link>
		<comments>http://blog.zacharcher.com/2007/07/04/subversion-is-open/#comments</comments>
		<pubDate>Wed, 04 Jul 2007 09:35:04 +0000</pubDate>
		<dc:creator>Zach</dc:creator>
				<category><![CDATA[Flash]]></category>

		<guid isPermaLink="false">http://blog.zacharcher.com/?p=9</guid>
		<description><![CDATA[A couple of ya'll wanted to see my code, so I made the repository public! Here: http://dev.zacharcher.com/svn/as2/ Have fun, give me feedback, but for the love of all that is holy, use this code at your own peril... This codebase is growing rapidly, and some classes that work today might have a different interface tomorrow. [...]]]></description>
			<content:encoded><![CDATA[<p>A couple of ya'll wanted to see my code, so I made the repository public! Here:</p>
<p><a href="http://dev.zacharcher.com/svn/as2/">http://dev.zacharcher.com/svn/as2/</a></p>
<p>Have fun, give me feedback, but <em>for the love of all that is holy, use this code at your own peril</em>... This codebase is growing rapidly, and some classes that work today might have a different interface tomorrow.</p>
<div class='bookmarkify'><a name='bookmarkify'></a><div class='linkbuttons'><a href='http://del.icio.us/post?url=http://blog.zacharcher.com/2007/07/04/subversion-is-open/&amp;title=Subversion is open!' title='Save to del.icio.us' onclick='target="_blank";' rel='nofollow'><img src='http://blog.zacharcher.com/wp-content/plugins/bookmarkify/delicious.png' style='width:16px; height:16px;' alt='[del.icio.us] ' /></a> <a href='http://digg.com/submit?phase=2&amp;url=http://blog.zacharcher.com/2007/07/04/subversion-is-open/&amp;title=Subversion is open!' title='Digg It!' onclick='target="_blank";' rel='nofollow'><img src='http://blog.zacharcher.com/wp-content/plugins/bookmarkify/digg.png' style='width:16px; height:16px;' alt='[Digg] ' /></a> <a href='http://reddit.com/submit?url=http://blog.zacharcher.com/2007/07/04/subversion-is-open/&amp;title=Subversion is open!' title='Reddit' onclick='target="_blank";' rel='nofollow'><img src='http://blog.zacharcher.com/wp-content/plugins/bookmarkify/reddit.png' style='width:16px; height:16px;' alt='[Reddit] ' /></a> <a href='http://twitter.com/home/?status=Subversion is open!+http://blog.zacharcher.com/2007/07/04/subversion-is-open/' title='Save to Twitter' onclick='target="_blank";' rel='nofollow'><img src='http://blog.zacharcher.com/wp-content/plugins/bookmarkify/twitter.png' style='width:16px; height:16px;' alt='[Twitter] ' /></a> <a href='http://www.feedburner.com/fb/a/emailFlare?itemTitle=Subversion is open!&amp;uri=http://blog.zacharcher.com/2007/07/04/subversion-is-open/&amp;loc=en_US' title='Email this to a friend' onclick='target="_blank";' rel='nofollow'><img src='http://blog.zacharcher.com/wp-content/plugins/bookmarkify/email.png' style='width:16px; height:16px;' alt='[Email] ' /></a>  <a title='See more bookmark and sharing options...' href='http://blog.zacharcher.com/2007/07/04/subversion-is-open/#bookmarkify' rel='nofollow'><small>More&nbsp;&raquo;</small></a></div></div>]]></content:encoded>
			<wfw:commentRss>http://blog.zacharcher.com/2007/07/04/subversion-is-open/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Intermission in the Third Dimension</title>
		<link>http://blog.zacharcher.com/2007/07/04/intermission-in-the-third-dimension/</link>
		<comments>http://blog.zacharcher.com/2007/07/04/intermission-in-the-third-dimension/#comments</comments>
		<pubDate>Wed, 04 Jul 2007 09:00:00 +0000</pubDate>
		<dc:creator>Zach</dc:creator>
				<category><![CDATA[Flash]]></category>

		<guid isPermaLink="false">http://blog.zacharcher.com/?p=8</guid>
		<description><![CDATA[I spent yesterday and today building a 3D engine for my Vector classes. This turned out to be some of the most difficult math I've ever wrapped my brain around. Here's a screenshot: Play with the .swf. Click the mouse; type some letters; move the mouse for beefy, savory 3D taste. Backspace to clear. You'll [...]]]></description>
			<content:encoded><![CDATA[<p>I spent yesterday and today building a 3D engine for my Vector classes. This turned out to be some of the most difficult math I've ever wrapped my brain around. Here's a screenshot:</p>
<p><img src="http://zacharcher.com/lab/20070704_vector_font_3d/screenshot_3d.png" border="0" height="328" hspace="0" vspace="0" width="442" /></p>
<p><a href="http://zacharcher.com/lab/20070704_vector_font_3d/20070702_vector_font_3d.swf">Play with the .swf</a>. Click the mouse; type some letters; move the mouse for beefy, savory 3D taste. Backspace to clear.</p>
<p>You'll notice that the letters flicker; this is intentional. It's a step towards simulating the "old cathode ray tube" look and feel that I desire.</p>
<p>I'm creating the flicker using one of my favorite tricks: flash.geom.ColorTransform . The line segments (and the glow) are being drawn using random shades of grey (including black and white). The ColorTransform maps black to a new color, and white to another color; in doing so, shades of grey are automatically mapped to color values ranging between the two.</p>
<p>The 3D action is, in a word, <em>complicated</em>. Many websites were consulted; many mathematical formulas were borrowed.</p>
<p>One of the biggest challenges was extending flash.geom.Point to a new class: "Point3D". Also (especially) difficult was extending flash.geom.Matrix to "Matrix3D". Of course, I wanted all my Vector drawing methods to support both 2D and 3D geometry, so there were issues with inheritance and casting. ActionScript 2.0 can't tell you what class an object belongs to (all the classes mentioned in this paragraph evaluate to "Object". Not helpful!) so I had to improvise. The 3D classes return true if you evaluate myObject['is3D'].</p>
<p>Also I added static create() methods to the 3D objects: these accept a Point/Point3D, or a Matrix/Matrix3D, and verifiably return a 3D equivalent of whatever you passed in.</p>
<p>I did this because I had issues with casting. This cast did not work for me, and I don't yet understand why:</p>
<p>var myMatrix3D:Matrix3D = Matrix3D( myMatrix2D );</p>
<p>The 3D algorithm took a day and a half to get right. I relearned <a href="http://en.wikipedia.org/wiki/Matrix_(mathematics)#Matrix_multiplication">matrix multiplication</a> along the way. I was giddy and cheering when it finally worked. This is a major step forward.</p>
<div class='bookmarkify'><a name='bookmarkify'></a><div class='linkbuttons'><a href='http://del.icio.us/post?url=http://blog.zacharcher.com/2007/07/04/intermission-in-the-third-dimension/&amp;title=Intermission in the Third Dimension' title='Save to del.icio.us' onclick='target="_blank";' rel='nofollow'><img src='http://blog.zacharcher.com/wp-content/plugins/bookmarkify/delicious.png' style='width:16px; height:16px;' alt='[del.icio.us] ' /></a> <a href='http://digg.com/submit?phase=2&amp;url=http://blog.zacharcher.com/2007/07/04/intermission-in-the-third-dimension/&amp;title=Intermission in the Third Dimension' title='Digg It!' onclick='target="_blank";' rel='nofollow'><img src='http://blog.zacharcher.com/wp-content/plugins/bookmarkify/digg.png' style='width:16px; height:16px;' alt='[Digg] ' /></a> <a href='http://reddit.com/submit?url=http://blog.zacharcher.com/2007/07/04/intermission-in-the-third-dimension/&amp;title=Intermission in the Third Dimension' title='Reddit' onclick='target="_blank";' rel='nofollow'><img src='http://blog.zacharcher.com/wp-content/plugins/bookmarkify/reddit.png' style='width:16px; height:16px;' alt='[Reddit] ' /></a> <a href='http://twitter.com/home/?status=Intermission in the Third Dimension+http://blog.zacharcher.com/2007/07/04/intermission-in-the-third-dimension/' title='Save to Twitter' onclick='target="_blank";' rel='nofollow'><img src='http://blog.zacharcher.com/wp-content/plugins/bookmarkify/twitter.png' style='width:16px; height:16px;' alt='[Twitter] ' /></a> <a href='http://www.feedburner.com/fb/a/emailFlare?itemTitle=Intermission in the Third Dimension&amp;uri=http://blog.zacharcher.com/2007/07/04/intermission-in-the-third-dimension/&amp;loc=en_US' title='Email this to a friend' onclick='target="_blank";' rel='nofollow'><img src='http://blog.zacharcher.com/wp-content/plugins/bookmarkify/email.png' style='width:16px; height:16px;' alt='[Email] ' /></a>  <a title='See more bookmark and sharing options...' href='http://blog.zacharcher.com/2007/07/04/intermission-in-the-third-dimension/#bookmarkify' rel='nofollow'><small>More&nbsp;&raquo;</small></a></div></div>]]></content:encoded>
			<wfw:commentRss>http://blog.zacharcher.com/2007/07/04/intermission-in-the-third-dimension/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
	</channel>
</rss>
