<?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>lab.joelGillman.com &#187; Uncategorized</title>
	<atom:link href="http://lab.joelgillman.com/archives/category/uncategorized/feed" rel="self" type="application/rss+xml" />
	<link>http://lab.joelgillman.com</link>
	<description>Sketches, Code Bites and Toys</description>
	<lastBuildDate>Thu, 05 Nov 2009 23:19:57 +0000</lastBuildDate>
	<generator>http://wordpress.org/?v=2.9.1</generator>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
			<item>
		<title>Pseudo Work (fwork)</title>
		<link>http://lab.joelgillman.com/archives/159_pseudo-work</link>
		<comments>http://lab.joelgillman.com/archives/159_pseudo-work#comments</comments>
		<pubDate>Thu, 05 Nov 2009 22:16:30 +0000</pubDate>
		<dc:creator>joel gillman</dc:creator>
				<category><![CDATA[Uncategorized]]></category>
		<category><![CDATA[bash]]></category>
		<category><![CDATA[clock]]></category>
		<category><![CDATA[code]]></category>
		<category><![CDATA[processing]]></category>
		<category><![CDATA[source control]]></category>
		<category><![CDATA[test]]></category>

		<guid isPermaLink="false">http://lab.joelgillman.com/?p=159</guid>
		<description><![CDATA[This script takes a text file (any text file should) and displays it one line at a time with short delays in between.  In other words, you can run this script to make it look like your computer is actually doing something worthwhile.
I had searched around the internet a few times but never really [...]]]></description>
			<content:encoded><![CDATA[<p>This script takes a text file (any text file should) and displays it one line at a time with short delays in between.  In other words, you can run this script to make it <em>look</em> like your computer is actually doing something worthwhile.</p>
<p>I had searched around the internet a few times but never really found anything like this, but that doesn&#8217;t mean it doesn&#8217;t look.  Maybe I&#8217;m just a bad internet searcher.  <a href="http://lab.joelgillman.com/archives/159_pseudo-work">Script after the jump</a>. <span id="more-159"></span></p>
<p><br/></p>
<div class="codecolorer-container bash " style="overflow:auto;white-space:nowrap;width:435px"><div class="bash codecolorer" style="font-family:Monaco,Lucida Console,monospace"><span class="co0">#!/bin/bash</span><br />
<br />
<span class="co0">#####################################################</span><br />
<span class="co0"># Pseudo Work (fwork) Script - by Joel Gillman 2009</span><br />
<span class="co0"># lab.joelgillman.com/archives/159_pseudo-work</span><br />
<span class="co0"># </span><br />
<span class="co0"># Please feel free to edit and change this as you</span><br />
<span class="co0"># &nbsp;like! If &nbsp;you do make any edits I would be curious</span><br />
<span class="co0"># &nbsp;to see what you've done so drop me a line!</span><br />
<span class="co0"># </span><br />
<span class="co0"># DISCLAIMER</span><br />
<span class="co0"># I am in no way a bash scripting expert. Most of what</span><br />
<span class="co0"># &nbsp;I write is copy and paste and trial and error.</span><br />
<span class="co0"># &nbsp;While this script shouldn't hurt anything in your</span><br />
<span class="co0"># &nbsp;system don't hold me responsible if it does! Use</span><br />
<span class="co0"># &nbsp;at your own risk.</span><br />
<span class="co0">#####################################################</span><br />
<br />
<br />
<span class="co0">## test if file (default or otherwise)</span><br />
<span class="kw1">if</span> <span class="br0">&#91;</span> <span class="st0">&quot;$1&quot;</span> = <span class="st_h">''</span> <span class="br0">&#93;</span>; <span class="kw1">then</span><br />
&nbsp; &nbsp; <span class="re2">filename</span>=<span class="st0">&quot;<span class="es2">$HOME</span>/garbage.txt&quot;</span><br />
&nbsp; &nbsp; <span class="kw1">if</span> <span class="br0">&#91;</span> <span class="re5">-e</span> <span class="re1">$filename</span> <span class="br0">&#93;</span>; <span class="kw1">then</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span class="kw2">sleep</span> <span class="nu0">0</span><br />
&nbsp; &nbsp; <span class="kw1">else</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span class="kw3">echo</span> <span class="st0">&quot;No file specified and default file '~/garbage.txt' not found.&quot;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span class="kw3">exit</span><br />
&nbsp; &nbsp; <span class="kw1">fi</span><br />
<span class="kw1">elif</span> <span class="br0">&#91;</span> <span class="re5">-e</span> $<span class="nu0">1</span> <span class="br0">&#93;</span>; <span class="kw1">then</span><br />
&nbsp; &nbsp; <span class="re2">filename</span>=$<span class="nu0">1</span><br />
<span class="kw1">else</span><br />
&nbsp; &nbsp; <span class="kw3">echo</span> <span class="st0">&quot;No file found at $1&quot;</span><br />
&nbsp; &nbsp; <span class="kw3">exit</span><br />
<span class="kw1">fi</span><br />
<br />
<span class="co0">## execute fakeness</span><br />
<span class="kw1">while</span> <span class="kw2">read</span> p; <span class="kw1">do</span><br />
&nbsp; &nbsp; <span class="kw1">if</span> <span class="br0">&#91;</span> <span class="st0">&quot;<span class="es4">$(($RANDOM % 10)</span>)&quot;</span> <span class="re5">-eq</span> <span class="nu0">1</span> <span class="br0">&#93;</span>; <span class="kw1">then</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span class="kw3">let</span> <span class="st0">&quot;R1 = (<span class="es2">$RANDOM</span> % 2)&quot;</span><br />
&nbsp; &nbsp; <span class="kw1">elif</span> <span class="br0">&#91;</span> <span class="st0">&quot;<span class="es4">$(($RANDOM % 50)</span>)&quot;</span> <span class="re5">-eq</span> <span class="nu0">1</span> <span class="br0">&#93;</span>; <span class="kw1">then</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span class="kw3">let</span> <span class="st0">&quot;R1 = (<span class="es2">$RANDOM</span> % 20)&quot;</span><br />
&nbsp; &nbsp; <span class="kw1">else</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span class="kw3">let</span> <span class="st0">&quot;R1 = 0&quot;</span><br />
&nbsp; &nbsp; <span class="kw1">fi</span><br />
&nbsp; &nbsp; <br />
&nbsp; &nbsp; <span class="kw3">let</span> <span class="st0">&quot;R2 = (<span class="es2">$RANDOM</span> % 10)&quot;</span><br />
&nbsp; &nbsp; <span class="kw3">echo</span> <span class="re1">$p</span><br />
&nbsp; &nbsp; <span class="kw2">sleep</span> <span class="re1">$R1</span>.<span class="re1">$R2</span><br />
<span class="kw1">done</span> <span class="sy0">&lt;</span> <span class="re1">$filename</span></div></div>
<p><a href="http://lab.joelgillman.com/thepress/wp-content/uploads/2009/11/fwork.zip">Download a zip&#8217;d version of the script</a>.<br />
You can <a href="http://lab.joelgillman.com/thepress/wp-content/uploads/2009/11/garbage.txt">download the (2.5MB) text file</a> I&#8217;ve been using.</p>
<p>Let me know what you think!  Any improvements or suggestions would be greatly appreciated.</p>
]]></content:encoded>
			<wfw:commentRss>http://lab.joelgillman.com/archives/159_pseudo-work/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>TWenty One</title>
		<link>http://lab.joelgillman.com/archives/150_twenty-one</link>
		<comments>http://lab.joelgillman.com/archives/150_twenty-one#comments</comments>
		<pubDate>Thu, 20 Aug 2009 23:17:20 +0000</pubDate>
		<dc:creator>joel gillman</dc:creator>
				<category><![CDATA[Uncategorized]]></category>

		<guid isPermaLink="false">http://lab.joelgillman.com/?p=150</guid>
		<description><![CDATA[I threw this together in an hour or two.  I&#8217;ll post the code if anyone likes, but it&#8217;s really just a sketch so it&#8217;s embarrassingly messy and uncommented.  It&#8217;s inspired by the font &#8220;TWenty One&#8221; by SMeltery which is &#8220;is a French font factory founded in 2002 by Jack Usine&#8221;
There&#8217;s also a larger [...]]]></description>
			<content:encoded><![CDATA[<p>I threw this together in an hour or two.  I&#8217;ll post the code if anyone likes, but it&#8217;s really just a sketch so it&#8217;s embarrassingly messy and uncommented.  It&#8217;s inspired by the font &#8220;<a href="http://www.smeltery.net/fonts/twenty-one">TWenty One</a>&#8221; by <a href="http://www.smeltery.net/">SMeltery</a> which is &#8220;is a French font factory founded in 2002 by Jack Usine&#8221;<span id="more-150"></span></p>
<p>There&#8217;s also a <a href="/thepress/wp-content/uploads/2009/08/round_blocks_big.swf">larger version</a> for your creation pleasure.</p>
<p>Don&#8217;t forget to hit &#8220;s&#8221; to save out a jpeg of what you made!<br />
<object width="470" height="314"><param name="movie" value="/thepress/wp-content/uploads/2009/08/round_blocks_small.swf"><embed src="/thepress/wp-content/uploads/2009/08/round_blocks_small.swf" width="470" height="314"></embed></object></p>
]]></content:encoded>
			<wfw:commentRss>http://lab.joelgillman.com/archives/150_twenty-one/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>iSightCapture, now with more SSH!</title>
		<link>http://lab.joelgillman.com/archives/130_isightcapture-now-with-more-ssh</link>
		<comments>http://lab.joelgillman.com/archives/130_isightcapture-now-with-more-ssh#comments</comments>
		<pubDate>Thu, 30 Apr 2009 18:28:50 +0000</pubDate>
		<dc:creator>joel gillman</dc:creator>
				<category><![CDATA[Uncategorized]]></category>
		<category><![CDATA[automation]]></category>
		<category><![CDATA[bash]]></category>
		<category><![CDATA[isight]]></category>
		<category><![CDATA[scp]]></category>
		<category><![CDATA[screencapture]]></category>
		<category><![CDATA[script]]></category>
		<category><![CDATA[shell]]></category>
		<category><![CDATA[ssh]]></category>
		<category><![CDATA[ssh-keys]]></category>
		<category><![CDATA[terminal]]></category>

		<guid isPermaLink="false">http://lab.joelgillman.com/?p=130</guid>
		<description><![CDATA[I think this kind of thing is pretty awesome.  Take a picture from your iSight.  Take a screencapture.  Upload them both to a remote server. WHY DOESN&#8217;T EVERYONE WANT TO DO THIS?!  Maybe you do, now you can (hopefully).
Firstly, props to Dylan O&#8217;Donnell, who wrote the original script.  I was [...]]]></description>
			<content:encoded><![CDATA[<p>I think this kind of thing is pretty awesome.  Take a picture from your iSight.  Take a screencapture.  Upload them both to a remote server. WHY DOESN&#8217;T EVERYONE WANT TO DO THIS?!  Maybe you do, now you can (hopefully).<span id="more-130"></span></p>
<p>Firstly, props to Dylan O&#8217;Donnell, who wrote the original script.  I was personally unsatisfied with FTP because it&#8217;s insecure and I always run into technical troubles with it. Probably because I never took the time to learn what I was doing with FTP via command line&#8230; But I favor SCP for my file transferring needs.<br/><br/></p>
<p>I also added a screen cap functionality because there&#8217;s all kinds of cool things you can do with that down the line.  Time-lapse animation, security, you name it!<br/><br/></p>
<p>If you want the iSight captures to work you must download and install <a href='http://lab.joelgillman.com/thepress/wp-content/uploads/2009/04/isightcapture.zip'>isightcapture</a>! I&#8217;ve installed it to /usr/sbin/ and hardcoded the script to look there. If you don&#8217;t know what you&#8217;re doing, I suggest you do the same.<br/><br/></p>
<p><strong>&#8220;Installing&#8221; isightcapture (assuming it&#8217;s unzipped and on your desktop):</strong></p>
<div class="codecolorer-container bash " style="overflow:auto;white-space:nowrap;width:435px"><div class="bash codecolorer" style="font-family:Monaco,Lucida Console,monospace">user$ <span class="kw2">sudo</span> <span class="kw2">cp</span> ~<span class="sy0">/</span>Desktop<span class="sy0">/</span>isightcapture <span class="sy0">/</span>usr<span class="sy0">/</span>sbin<span class="sy0">/</span></div></div>
<p>Quick rundown of what&#8217;s happening here:<br />
- Grab the date and time info and prepare the filenames (YearMonthDayHourMinuteSecond)<br />
- Take a picture with the iSight, save it to a folder (~/Documents/pics/)<br />
- Take a screencap, save it to the same folder (~/Documents/pics/)<br />
- Resize all of the jpgs in the pics folder so they&#8217;re no more than 800px in any dimention<br />
- Check to see if the computer has a network connection, if it does upload the files to a remote server (via scp) and delete the local images. If there&#8217;s no connection, do nothing (images will try to upload next time the script is run)</p>
<p>In order for this to work <strong><em>you must have SSH Keys setup with the server you are connecting to</em></strong>. If you don&#8217;t it will not work.  If you google &#8220;ssh keys&#8221; there are a million ways to do it but this is the site that actually got it working on my modern mac: <a href="http://www.webficient.com/2007/11/16/mac-and-ssh-keys">http://www.webficient.com/2007/11/16/mac-and-ssh-keys</a><br/><br/></p>
<p>Here&#8217;s a quick and dirty run down of how to do that, but I&#8217;m just copying from <a href="http://www.webficient.com/2007/11/16/mac-and-ssh-keys">Phil&#8217;s post</a> so don&#8217;t blame me if it doesn&#8217;t work for you :)<br/><br/></p>
<p>Generate the ssh key (obviously replace the CAPS stuff with your info). When asked for a passphrase just hit enter, this will make an empty passphrase which, I admit, is very insecure but it&#8217;s better than nothing and the script won&#8217;t work with a passphrase :( :</p>
<div class="codecolorer-container bash " style="overflow:auto;white-space:nowrap;width:435px"><div class="bash codecolorer" style="font-family:Monaco,Lucida Console,monospace">user$ <span class="kw2">ssh-keygen</span> <span class="re5">-t</span> rsa <span class="re5">-f</span> ~<span class="sy0">/</span>.ssh<span class="sy0">/</span>id_rsa</div></div>
<p>If you&#8217;ve never used SSH to make an outgoing connect on the machine you are connecting to you will also need to create the ssh folder on that machine and make it so only your user can read it:</p>
<div class="codecolorer-container bash " style="overflow:auto;white-space:nowrap;width:435px"><div class="bash codecolorer" style="font-family:Monaco,Lucida Console,monospace">user$ <span class="kw2">ssh</span> USER<span class="sy0">@</span>YOUR.SERVER.COM <span class="st_h">'mkdir ~/.ssh;chmod 700 ~/.ssh'</span></div></div>
<p>Now copy your public key (id_rsa.pub) to the server you&#8217;re connecting to (I always name the copy on the server &#8220;temp_pub_key&#8221; so I know exactly what file I need):</p>
<div class="codecolorer-container bash " style="overflow:auto;white-space:nowrap;width:435px"><div class="bash codecolorer" style="font-family:Monaco,Lucida Console,monospace">user$ <span class="kw2">scp</span> ~<span class="sy0">/</span>.ssh<span class="sy0">/</span>id_rsa.pub USER<span class="sy0">@</span>YOUR.SERVER.COM:~<span class="sy0">/</span>.ssh<span class="sy0">/</span>temp_pub_key</div></div>
<p>Now connect to the remote server and navigate to ~/.ssh/</p>
<div class="codecolorer-container bash " style="overflow:auto;white-space:nowrap;width:435px"><div class="bash codecolorer" style="font-family:Monaco,Lucida Console,monospace">remote-user$ <span class="kw3">cd</span> ~<span class="sy0">/</span>.ssh<span class="sy0">/</span></div></div>
<p>On the server, check to see if the file &#8220;authorized_keys&#8221; exists, if it doesn&#8217;t rename your &#8220;temp_pub_key&#8221; to &#8220;authorized_keys:</p>
<div class="codecolorer-container bash " style="overflow:auto;white-space:nowrap;width:435px"><div class="bash codecolorer" style="font-family:Monaco,Lucida Console,monospace">remote-user$ <span class="kw2">mv</span> temp_pub_key authorized_keys</div></div>
<p>If &#8220;authorized_keys&#8221; already exists then you want to add your public key to the end of the file:</p>
<div class="codecolorer-container bash " style="overflow:auto;white-space:nowrap;width:435px"><div class="bash codecolorer" style="font-family:Monaco,Lucida Console,monospace">remote-user$ <span class="kw2">cat</span> temp_pub_key <span class="sy0">&amp;</span>gt;<span class="sy0">&amp;</span>gt; authorized_keys</div></div>
<p>If &#8220;authorized_keys&#8221; didn&#8217;t already exists, you&#8217;ll also have to set the permissions of the authorized_keys file:</p>
<div class="codecolorer-container bash " style="overflow:auto;white-space:nowrap;width:435px"><div class="bash codecolorer" style="font-family:Monaco,Lucida Console,monospace"><span class="kw2">ssh</span> USER<span class="sy0">@</span>YOUR.SERVER.COM <span class="st_h">'chmod 644 ~/.ssh/authorized_keys2'</span></div></div>
<p>Here is the automation script originally written by Dylan O&#8217;Donnell with my tweaks and editing for SSH and screencaps.</p>
<div class="codecolorer-container bash " style="overflow:auto;white-space:nowrap;width:435px;height:300px"><div class="bash codecolorer" style="font-family:Monaco,Lucida Console,monospace"><span class="co0">#!/bin/bash</span><br />
<span class="co0">#</span><br />
<span class="co0"># Original iSight Auto Upload Script - by Dylan O'Donnell 2006</span><br />
<span class="co0"># Edited for ssh and made more awesome by Joel Gillman 2009 </span><br />
<span class="co0">#####################################################</span><br />
<span class="co0"># Edit CAPITALS with appropriate details </span><br />
<span class="co0"># &nbsp;Notes : You must have ssh-keys setup with the server you are </span><br />
<span class="co0"># &nbsp; &nbsp; &nbsp; &nbsp;: uploading to before hand. Otherwise this will not work.</span><br />
<span class="co0"># &nbsp; &nbsp; &nbsp; &nbsp;:</span><br />
<span class="co0"># &nbsp; &nbsp; &nbsp; &nbsp;: Try here for tutorial on ssh-keys (worked for me)</span><br />
<span class="co0"># &nbsp; &nbsp; &nbsp; &nbsp;: &nbsp;http://www.webficient.com/2007/11/16/mac-and-ssh-keys</span><br />
<span class="co0">#</span><br />
<span class="co0">#####################################################</span><br />
<br />
<span class="co0"># Generate filename based on date stamp</span><br />
<span class="re2">picture</span>=$<span class="br0">&#40;</span><span class="kw2">date</span> +<span class="sy0">%</span>y<span class="sy0">%</span>m<span class="sy0">%</span>d<span class="sy0">%</span>H<span class="sy0">%</span>M<span class="sy0">%</span>S<span class="br0">&#41;</span>_pic.jpg;<br />
<span class="re2"><span class="kw2">screen</span></span>=$<span class="br0">&#40;</span><span class="kw2">date</span> +<span class="sy0">%</span>y<span class="sy0">%</span>m<span class="sy0">%</span>d<span class="sy0">%</span>H<span class="sy0">%</span>M<span class="sy0">%</span>S<span class="br0">&#41;</span>_scr.jpg;<br />
<br />
<span class="co0"># Take iSight Photo and store with datestamp filename</span><br />
<span class="sy0">/</span>usr<span class="sy0">/</span>sbin<span class="sy0">/</span>isightcapture <span class="re5">-w</span> <span class="nu0">640</span> <span class="re5">-h</span> <span class="nu0">480</span> <span class="re5">-t</span> jpg <span class="sy0">/</span>Users<span class="sy0">/</span>USERNAME<span class="sy0">/</span>Documents<span class="sy0">/</span>pics<span class="sy0">/</span><span class="re1">$picture</span>;<br />
<br />
<span class="co0"># Take screen capture</span><br />
<span class="sy0">/</span>usr<span class="sy0">/</span>sbin<span class="sy0">/</span>screencapture <span class="re5">-C</span> <span class="re5">-m</span> <span class="re5">-t</span> jpg <span class="re5">-x</span> <span class="sy0">/</span>Users<span class="sy0">/</span>USERNAME<span class="sy0">/</span>Documents<span class="sy0">/</span>pics<span class="sy0">/</span><span class="re1">$screen</span>;<br />
<br />
<span class="co0">#resize the pictures so they're not too big</span><br />
<span class="sy0">/</span>usr<span class="sy0">/</span>bin<span class="sy0">/</span>sips <span class="re5">--resampleHeightWidthMax</span> <span class="nu0">800</span> <span class="sy0">/</span>Users<span class="sy0">/</span>USERNAME<span class="sy0">/</span>Documents<span class="sy0">/</span>pics<span class="sy0">/*</span>.jpg<br />
<br />
<span class="co0"># Generate semaphore for connectivity by pinging NASA</span><br />
<span class="re2">isconnected</span>=$<span class="br0">&#40;</span><span class="kw2">ping</span> <span class="re5">-c</span> <span class="nu0">1</span> www.nasa.gov <span class="sy0">|</span> <span class="kw2">grep</span> <span class="nu0">64</span> <span class="sy0">|</span> <span class="kw2">wc</span> <span class="sy0">|</span> <span class="kw2">awk</span> <span class="st_h">'{print $1}'</span><span class="br0">&#41;</span>;<br />
<br />
<span class="co0"># Wait a few seconds to see if it's connected.</span><br />
<span class="kw2">sleep</span> <span class="nu0">3</span>;<br />
<br />
<span class="co0"># If connected...</span><br />
<span class="kw1">if</span> <span class="br0">&#91;</span> <span class="st0">&quot;<span class="es2">$isconnected</span>&quot;</span> <span class="re5">-eq</span> <span class="st0">&quot;1&quot;</span> <span class="br0">&#93;</span>; <span class="kw1">then</span> <br />
<br />
&nbsp; &nbsp; <span class="sy0">/</span>usr<span class="sy0">/</span>bin<span class="sy0">/</span><span class="kw2">scp</span> <span class="sy0">/</span>Users<span class="sy0">/</span>USERNAME<span class="sy0">/</span>Documents<span class="sy0">/</span>pics<span class="sy0">/*</span> USERNAME<span class="sy0">@</span>YOUR.SERVER.COM:<span class="st0">&quot;REMOTE/PATH&quot;</span>;<br />
<br />
&nbsp; &nbsp; <span class="co0"># Wait a few seconds, just to make sure everything is clear and complete</span><br />
&nbsp; &nbsp; <span class="kw2">sleep</span> <span class="nu0">4</span>;<br />
<br />
&nbsp; &nbsp; <span class="co0"># delete local images</span><br />
&nbsp; &nbsp; <span class="kw2">rm</span> <span class="re5">-f</span> <span class="sy0">/</span>Users<span class="sy0">/</span>USERNAME<span class="sy0">/</span>Documents<span class="sy0">/</span>pics<span class="sy0">/*</span>.jpg;<br />
<br />
<span class="kw1">else</span> <br />
&nbsp; &nbsp; <span class="co0"># If not connected.. leave captures there until next time. </span><br />
&nbsp; &nbsp; <span class="kw3">echo</span> <span class="st0">&quot;No Connection, Image not transferred or deleted.&quot;</span>;<br />
<span class="kw1">fi</span></div></div>
]]></content:encoded>
			<wfw:commentRss>http://lab.joelgillman.com/archives/130_isightcapture-now-with-more-ssh/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>SVN For Newbies</title>
		<link>http://lab.joelgillman.com/archives/103_svn-for-newbies</link>
		<comments>http://lab.joelgillman.com/archives/103_svn-for-newbies#comments</comments>
		<pubDate>Thu, 05 Feb 2009 16:06:05 +0000</pubDate>
		<dc:creator>joel gillman</dc:creator>
				<category><![CDATA[Uncategorized]]></category>
		<category><![CDATA[learning]]></category>
		<category><![CDATA[source control]]></category>
		<category><![CDATA[SVN]]></category>
		<category><![CDATA[terminal]]></category>

		<guid isPermaLink="false">http://lab.joelgillman.com/?p=103</guid>
		<description><![CDATA[SVN is confusing, or at least it can be for people who don&#8217;t know their way around the Terminal or aren&#8217;t exactly sure what SVN is. I was confused by it for a long time and I&#8217;m decently technologically inclined. (+1 spelling) This article is intended for those who are forced to use SVN against [...]]]></description>
			<content:encoded><![CDATA[<p><a href="http://subversion.tigris.org/">SVN is confusing</a>, or at least it can be for people who don&#8217;t know their way around the Terminal or <a href="http://en.wikipedia.org/wiki/Subversion_(software)">aren&#8217;t exactly sure what SVN is</a>. I was confused by it for a long time and I&#8217;m decently technologically inclined. (+1 spelling) This article is intended for those who are forced to use SVN against their will and I will be very explicit and redundant about what is happening and why.</p>
<p>SVN can be learned!<br/>&nbsp;<br />
You too can learn to love it!<br/>&nbsp;<span id="more-103"></span></p>
<p>Some technical information first, I&#8217;m writing on a mac and I use SVN on a mac. If you ALSO are on a mac, you&#8217;ll need to have the latest Developer Tools installed. They&#8217;re not installed by default so if you haven&#8217;t done this already you should do that now. If you&#8217;ve lost the install CD that came with your computer you can grab it <a href="http://developer.apple.com/technology/xcode.html">here</a> for free (it&#8217;s a <stroke>big</stroke> HUGE download). You probably won&#8217;t use 90% of the stuff that it installs, but there&#8217;s some background stuff going on that you&#8217;ll need (SVN for example).<br/>&nbsp;</p>
<p>Check to see if SVN is installed, open Terminal (Applications > Utilities) and type &#8220;svn&#8221;.</p>
<div class="codecolorer-container bash " style="overflow:auto;white-space:nowrap;width:435px"><div class="bash codecolorer" style="font-family:Monaco,Lucida Console,monospace">$ <span class="kw2">svn</span><br />
Type <span class="st_h">'svn help'</span> <span class="kw1">for</span> usage.</div></div>
<p>If you see something similar, it worked! If not, sorry, try Google.</p>
<p>OKAY, install done. There are <a href="http://www.syncrosvnclient.com/">several</a> <a href="http://versionsapp.com/">graphical</a> <a href="http://www.lachoseinteractive.net/en/community/subversion/svnx/features/?sid=099cc11e3657867741478a20916b43b4">interfaces</a> <a href="http://odetoapple.com/2006/svn-plugin-for-finder/">for</a> <a href="http://www.panic.com/coda/">SVN</a> but I&#8217;ve found that none of them can really compare to the command line interface (someone will hate me for saying that). Even if you use a GUI for SVN, sometimes something will break and the program won&#8217;t be able to fix it.<br/>&nbsp;</p>
<p>First I&#8217;ll cover some Terminal basics to help you get around.<br/>&nbsp;</p>
<p>How to change directories (folders):</p>
<div class="codecolorer-container bash " style="overflow:auto;white-space:nowrap;width:435px"><div class="bash codecolorer" style="font-family:Monaco,Lucida Console,monospace">$ <span class="kw3">cd</span> <span class="sy0">/</span>the<span class="sy0">/</span>directory<span class="sy0">/</span>you<span class="sy0">/</span>want<span class="sy0">/</span></div></div>
<p>cd, which probably stands for &#8220;change directory&#8221; is how you&#8217;re going to get around. If you&#8217;re in the terminal, you&#8217;re using cd all the time.</p>
<p>This following commands will take you to the root (<em>Macintosh HD</em>), your home folder (<em>/Users/yourname/</em>), and up one folder, respectively.</p>
<div class="codecolorer-container bash " style="overflow:auto;white-space:nowrap;width:435px"><div class="bash codecolorer" style="font-family:Monaco,Lucida Console,monospace">$ <span class="kw3">cd</span> <span class="sy0">/</span><br />
$ <span class="kw3">cd</span> ~<span class="sy0">/</span><br />
$ <span class="kw3">cd</span> ..</div></div>
<p>&nbsp;</p>
<p>Want to see what other folders/files are in the directory you&#8217;re in?</p>
<div class="codecolorer-container bash " style="overflow:auto;white-space:nowrap;width:435px"><div class="bash codecolorer" style="font-family:Monaco,Lucida Console,monospace">$ <span class="kw2">ls</span></div></div>
<p>If you get lost you can use &#8220;pwd&#8221; which will return the current directory that you are in. (Print Working Directory)</p>
<div class="codecolorer-container bash " style="overflow:auto;white-space:nowrap;width:435px"><div class="bash codecolorer" style="font-family:Monaco,Lucida Console,monospace">$ <span class="kw3">pwd</span></div></div>
<p>&nbsp;</p>
<p>Cluttered screen? Try this:</p>
<div class="codecolorer-container bash " style="overflow:auto;white-space:nowrap;width:435px"><div class="bash codecolorer" style="font-family:Monaco,Lucida Console,monospace">$ <span class="kw2">clear</span></div></div>
<p>Okay, that should be enough to get you scooting around nicely. Let&#8217;s get into some SVN goodness! So first you&#8217;re probably going to want to &#8220;checkout&#8221; a copy of the repository (or repo as I will call it from now on). First cd into the directory where you&#8217;d like your local copy to be. I usually checkout to <em>~/myUserName/Sites/</em> because I&#8217;m usually working with websites, but you can put yours wherever you like. Then get the URL to the repo. You&#8217;ll probably get this from the IT guys or from someone sitting next to you. The following will checkout the repo &#8220;superImportantProject&#8221; which will put a folder called &#8220;superImportantProject&#8221; in whatever directory you&#8217;re currently in.</p>
<div class="codecolorer-container bash " style="overflow:auto;white-space:nowrap;width:435px"><div class="bash codecolorer" style="font-family:Monaco,Lucida Console,monospace"><span class="kw2">svn</span> checkout http:<span class="sy0">//</span>svn.companywebsite.com<span class="sy0">/</span><span class="kw2">svn</span><span class="sy0">/</span>lgn<span class="sy0">/</span>trunk<span class="sy0">/</span>superImportantProject</div></div>
<p>At this point, assuming you typed the url in correctly, you&#8217;ll see a bunch of text start to appear on your screen. If it&#8217;s going slow enough you can see each file that it&#8217;s downloading to your computer. Magic! You&#8217;ll know it&#8217;s done when you&#8217;ve been returned to the prompt. So you just downloaded a bunch of files to your computer, la-dee-dah. Now&#8217;s when you do your thing and jump into the folder, edit a bunch of copy, add some new images, delete some redundant files.</p>
<p>Great! All done for now, finished what you needed? Cool, now it&#8217;s time to CHECK IN YOUR CHANGES! First, before checking in your changes you want to see if anyone else has made changes to the repo while you&#8217;ve been working.</p>
<div class="codecolorer-container bash " style="overflow:auto;white-space:nowrap;width:435px"><div class="bash codecolorer" style="font-family:Monaco,Lucida Console,monospace">$ <span class="kw2">svn</span> update</div></div>
<p>&nbsp;</p>
<p>Hold your breath while it checks &#8211; with any luck no one has made any changes, or at least no changes that have to do with your files. If no changes have been made you&#8217;ll see something like this:</p>
<div class="codecolorer-container bash " style="overflow:auto;white-space:nowrap;width:435px"><div class="bash codecolorer" style="font-family:Monaco,Lucida Console,monospace">At revision 764.</div></div>
<p>&nbsp;</p>
<p>If changes <em>have</em> been made you&#8217;ll see something like:</p>
<div class="codecolorer-container text " style="overflow:auto;white-space:nowrap;width:435px"><div class="text codecolorer" style="font-family:Monaco,Lucida Console,monospace">A &nbsp; &nbsp; &nbsp;public/mainpage.html<br />
D &nbsp; &nbsp; &nbsp;public/fullpage.swf<br />
A &nbsp; &nbsp; &nbsp;public/index.html<br />
A &nbsp; &nbsp; &nbsp;public/thank_you.html<br />
A &nbsp; &nbsp; &nbsp;public/why_use_svn.html<br />
A &nbsp; &nbsp; &nbsp;public/images/sweetpic.jpg<br />
U &nbsp; &nbsp; &nbsp;public/images/yourmom.jpg<br />
U &nbsp; &nbsp; &nbsp;public/images/lolz.gif<br />
Updated to revision 765.</div></div>
<p>The letters before each file tell you what is happening to that file. A for added, D for deleted, U for updated.  If you, god forbid, see a C, that means conflict.  If you see that, you&#8217;re fucked.  Well&#8230;at least you are until you read the part where I talk about that.  But that&#8217;s later!</p>
<p>Okay, so you didn&#8217;t see the dreaded C of conflict. On to the next step. Double check to see what files you&#8217;ve changed/added:</p>
<div class="codecolorer-container bash " style="overflow:auto;white-space:nowrap;width:435px"><div class="bash codecolorer" style="font-family:Monaco,Lucida Console,monospace">$ <span class="kw2">svn</span> status</div></div>
<p>&nbsp;</p>
<p>Now a list of all the files you changed, added and deleted will be displayed.  Mine looks like this:</p>
<div class="codecolorer-container bash " style="overflow:auto;white-space:nowrap;width:435px"><div class="bash codecolorer" style="font-family:Monaco,Lucida Console,monospace">M &nbsp; &nbsp; &nbsp;index.php<br />
M &nbsp; &nbsp; &nbsp;footer.php<br />
? &nbsp; &nbsp; &nbsp;images<span class="sy0">/</span>my_logo.jpg<br />
? &nbsp; &nbsp; &nbsp;images<span class="sy0">/</span>sweet_image_4.gif<br />
<span class="sy0">!</span> &nbsp; &nbsp; &nbsp;redundant.html</div></div>
<p>Woah, what&#8217;s all that crap mean?  M means that you modified a file (most common).  A ? means that file isn&#8217;t under version control (it&#8217;s not in entered into svn yet).  The ! means that a file is missing.</p>
<p>Well let&#8217;s add those ? files into svn first because those are pretty important for my project.</p>
<div class="codecolorer-container bash " style="overflow:auto;white-space:nowrap;width:435px"><div class="bash codecolorer" style="font-family:Monaco,Lucida Console,monospace">$ <span class="kw2">svn</span> add images<span class="sy0">/</span>my_logo.jpg<br />
$ <span class="kw2">svn</span> add images<span class="sy0">/</span>sweet_image_4.gif</div></div>
<p>&nbsp;</p>
<p>Or you can string the files together (separated by a space) and add a bunch of files at the same time:</p>
<div class="codecolorer-container bash " style="overflow:auto;white-space:nowrap;width:435px"><div class="bash codecolorer" style="font-family:Monaco,Lucida Console,monospace">$ <span class="kw2">svn</span> add images<span class="sy0">/</span>my_logo.jpg images<span class="sy0">/</span>sweet_image_4.gif</div></div>
<p>&nbsp;</p>
<p>Now run &#8217;svn status&#8217; again:</p>
<div class="codecolorer-container bash " style="overflow:auto;white-space:nowrap;width:435px"><div class="bash codecolorer" style="font-family:Monaco,Lucida Console,monospace">$ <span class="kw2">svn</span> status<br />
M &nbsp; &nbsp; &nbsp;index.php<br />
M &nbsp; &nbsp; &nbsp;footer.php<br />
A &nbsp; &nbsp; &nbsp;images<span class="sy0">/</span>my_logo.jpg<br />
A &nbsp; &nbsp; &nbsp;images<span class="sy0">/</span>sweet_image_4.gif<br />
<span class="sy0">!</span> &nbsp; &nbsp; &nbsp;redundant.html</div></div>
<p>&nbsp;</p>
<p>Cool, we&#8217;ve got the A of added so those files are ready to go.  Now about that missing file (!).  Did you really mean to delete it?  Does it need to be deleted?  Is anyone going to miss this file?  Think about that for a bit because if you delete that file out of the repository you&#8217;re deleting it for everyone else, too.  Still want to get it out of there?  Okay, but be careful with this one.</p>
<div class="codecolorer-container bash " style="overflow:auto;white-space:nowrap;width:435px"><div class="bash codecolorer" style="font-family:Monaco,Lucida Console,monospace">$ <span class="kw2">svn</span> remove redundant.html</div></div>
<p>&nbsp;</p>
<p>Almost too easy, right? &#8217;svn status&#8217; one more time before we commit just to make doubly sure.</p>
<div class="codecolorer-container bash " style="overflow:auto;white-space:nowrap;width:435px"><div class="bash codecolorer" style="font-family:Monaco,Lucida Console,monospace">$ <span class="kw2">svn</span> status<br />
M &nbsp; &nbsp; &nbsp;index.php<br />
M &nbsp; &nbsp; &nbsp;footer.php<br />
A &nbsp; &nbsp; &nbsp;images<span class="sy0">/</span>my_logo.jpg<br />
A &nbsp; &nbsp; &nbsp;images<span class="sy0">/</span>sweet_image_4.gif<br />
D &nbsp; &nbsp; &nbsp;redundant.html</div></div>
<p>Awesome, all the files we changed know what they&#8217;re doing now.  It should be said at this time that it&#8217;s okay to leave files unadded and missing (? and !) but they will be ignored when you commit to the repository.</p>
<p>Time to commit:</p>
<div class="codecolorer-container bash " style="overflow:auto;white-space:nowrap;width:435px"><div class="bash codecolorer" style="font-family:Monaco,Lucida Console,monospace">$ <span class="kw2">svn</span> commit <span class="re5">-m</span> <span class="st0">&quot;Changed header copy. Added new images to homepage.&quot;</span></div></div>
<p>The -m in there is an &#8220;option&#8221;.  You&#8217;re telling the command &#8217;svn commit&#8217; to look for a message with your commit.  The commit command won&#8217;t work without a message so you&#8217;ll always need to do that.  The actual message can be as explicit or as vague as you like, just know that the message is logged and can be helpful later if you need to go back and find changes you had made in the past.</p>
<p>Hey, congrats!  You know all the basics of svn to get you through the day!<br/>&nbsp;</p>
<p>This next bit holds some basic tricks to clear up any problems you might have as you flounder your way around svn.<br/>&nbsp;</p>
<p><strong>Crap.  I deleted a file that I didn&#8217;t mean to, how can I get it back?!</strong><br />
Well if you deleted the file locally and didn&#8217;t delete it with &#8217;svn remove&#8217; that&#8217;s easy!  Just run &#8217;svn update&#8217; and you&#8217;ll grab any new files along with any you might be missing. If you deleted it with &#8217;svn remove&#8217; then WHAT THE HELL?!  What were you thinking?!  Fuck, just keep reading for now.</p>
<p><strong>Crap. I&#8217;m getting the dreaded C of conflict.</strong><br />
Oh no!  When this happens svn makes a bunch of crazy-ass files.  Let&#8217;s just say your file was called &#8220;example.html&#8221; because I&#8217;m not feeling very creative right now.  Now you&#8217;ve got:</p>
<div class="codecolorer-container bash " style="overflow:auto;white-space:nowrap;width:435px"><div class="bash codecolorer" style="font-family:Monaco,Lucida Console,monospace">example.html<br />
example.html.mine<br />
example.html.r767<br />
example.html.r768</div></div>
<p>If you were to take a look in the example.html file right now you&#8217;d potentially see a bunch of weird code that isn&#8217;t yours.  The file that has all of your changes in it is now called &#8220;example.html.mine&#8221;.  The other two files (r767 and r768) are the revision you were editing from (r767) and the latest revision that&#8217;s in the repository (r768).  The easiest way out of this is to decide what version is the right one.</p>
<ul>
<li>Your co-worker has been working there for years and is way smarter than you, so just assume what they did it is right.  Turn to page 768.  Er, go with revision r768.</li>
<li>Your co-worker is worthless which is why you were hired, your changes are right.  Go with your copy (.mine).</li>
<li>Both of you are idiots so let&#8217;s just start over and let the senior devs deal with it. Go with the old revision (.r767).</li>
</ul>
<p>Whatever you decide, you&#8217;ve got to copy the file you want to go with over the original file then tell svn you&#8217;ve resolved the problem.  My co-worker&#8217;s changes are usually right so I&#8217;ll just go with his:</p>
<div class="codecolorer-container bash " style="overflow:auto;white-space:nowrap;width:435px"><div class="bash codecolorer" style="font-family:Monaco,Lucida Console,monospace">$ <span class="kw2">cp</span> example.html.r768 example.html<br />
$ <span class="kw2">svn</span> resolved example.html<br />
Resolved conflicted state of <span class="st_h">'example.html'</span></div></div>
<p>The &#8216;cp&#8217; command is used to copy file A to file B.</p>
<p>That should cover you for awhile&#8230; Once you get the hang of this stuff you shouldn&#8217;t have too much of a problem learning the rest yourself.  If not, I&#8217;m still here!</p>
]]></content:encoded>
			<wfw:commentRss>http://lab.joelgillman.com/archives/103_svn-for-newbies/feed</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
		<item>
		<title>Map Function</title>
		<link>http://lab.joelgillman.com/archives/87_map-function</link>
		<comments>http://lab.joelgillman.com/archives/87_map-function#comments</comments>
		<pubDate>Mon, 29 Sep 2008 22:39:41 +0000</pubDate>
		<dc:creator>joel gillman</dc:creator>
				<category><![CDATA[Uncategorized]]></category>
		<category><![CDATA[actionscript]]></category>
		<category><![CDATA[AS3]]></category>
		<category><![CDATA[flash]]></category>
		<category><![CDATA[function]]></category>
		<category><![CDATA[map]]></category>
		<category><![CDATA[normalize]]></category>
		<category><![CDATA[processing]]></category>

		<guid isPermaLink="false">http://lab.joelgillman.com/?p=87</guid>
		<description><![CDATA[If you&#8217;ve ever used Processing you&#8217;ve probably used the &#8216;map&#8217; function.  From the Processing Reference section it reads: &#8220;Re-maps a number from one range to another.&#8221;
Unfortunately the function doesn&#8217;t exist in Flash, so I rewrote it.  Why is this function useful?  Lets say your mouse can move within the bounds of your [...]]]></description>
			<content:encoded><![CDATA[<p>If you&#8217;ve ever used <a href="http://www.processing.org/">Processing</a> you&#8217;ve probably used the &#8216;map&#8217; function.  From the Processing Reference section it <a href="http://processing.org/reference/map_.html">reads</a>: &#8220;Re-maps a number from one range to another.&#8221;</p>
<p><span id="more-87"></span>Unfortunately the function doesn&#8217;t exist in Flash, so I rewrote it.  Why is this function useful?  Lets say your mouse can move within the bounds of your stage from 0 to 550 pixels along its x-axis.  You want a box to move back and forth from 100 to 200 pixels according to the position of the mouse.  So when your mouse is halfway across the stage your box should be halfway between 100 and 200 pixels.  You would simply use:</p>
<div class="codecolorer-container actionscript3 " style="overflow:auto;white-space:nowrap;width:435px"><div class="actionscript3 codecolorer" style="font-family:Monaco,Lucida Console,monospace">myBox.<span class="kw7">x</span> = <span class="kw7">map</span><span class="br0">&#40;</span><span class="kw7">mouseX</span>, <span class="nu0">0</span>, <span class="nu0">550</span>, <span class="nu0">100</span>, <span class="nu0">200</span><span class="br0">&#41;</span>;</div></div>
<p>Easy as that!</p>
<p>Usage:<br />
map(value, low1, high1, low2, high2);<br />
<em>low2 and high2 default to 0 and 1, respectively so you don&#8217;t have to put them in if you just want to normalize your value.</em></p>
<div class="codecolorer-container actionscript3 " style="overflow:auto;white-space:nowrap;width:435px"><div class="actionscript3 codecolorer" style="font-family:Monaco,Lucida Console,monospace"><span class="kw3">function</span> <span class="kw7">map</span><span class="br0">&#40;</span><span class="kw7">value</span><span class="sy0">:</span><a href="http://www.google.com/search?q=number%20inurl:http://livedocs.adobe.com/flex/201/langref/%20inurl:number.html&amp;filter=0&amp;num=100&amp;btnI=lucky"><span class="kw5">Number</span></a>,<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;low1<span class="sy0">:</span><a href="http://www.google.com/search?q=number%20inurl:http://livedocs.adobe.com/flex/201/langref/%20inurl:number.html&amp;filter=0&amp;num=100&amp;btnI=lucky"><span class="kw5">Number</span></a>,<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;high1<span class="sy0">:</span><a href="http://www.google.com/search?q=number%20inurl:http://livedocs.adobe.com/flex/201/langref/%20inurl:number.html&amp;filter=0&amp;num=100&amp;btnI=lucky"><span class="kw5">Number</span></a>,<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;low2<span class="sy0">:</span><a href="http://www.google.com/search?q=number%20inurl:http://livedocs.adobe.com/flex/201/langref/%20inurl:number.html&amp;filter=0&amp;num=100&amp;btnI=lucky"><span class="kw5">Number</span></a> = <span class="nu0">0</span>,<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;high2<span class="sy0">:</span><a href="http://www.google.com/search?q=number%20inurl:http://livedocs.adobe.com/flex/201/langref/%20inurl:number.html&amp;filter=0&amp;num=100&amp;btnI=lucky"><span class="kw5">Number</span></a> = <span class="nu0">1</span><span class="br0">&#41;</span><span class="sy0">:</span><a href="http://www.google.com/search?q=number%20inurl:http://livedocs.adobe.com/flex/201/langref/%20inurl:number.html&amp;filter=0&amp;num=100&amp;btnI=lucky"><span class="kw5">Number</span></a> <span class="br0">&#123;</span><br />
&nbsp; &nbsp; <span class="co1">//if the value and the 1st range low are equal to</span><br />
&nbsp; &nbsp; <span class="co1">// the new value must be low2</span><br />
&nbsp; &nbsp; <span class="kw1">if</span> <span class="br0">&#40;</span><span class="kw7">value</span> == low1<span class="br0">&#41;</span> <span class="br0">&#123;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span class="kw1">return</span> low2;<br />
&nbsp; &nbsp; <span class="br0">&#125;</span><br />
&nbsp; &nbsp; <br />
&nbsp; &nbsp; <span class="co1">//normalize both sets to a 0-? range</span><br />
&nbsp; &nbsp; <span class="kw2">var</span> range1 = high1 <span class="sy0">-</span> low1;<br />
&nbsp; &nbsp; <span class="kw2">var</span> range2 = high2 <span class="sy0">-</span> low2;<br />
&nbsp; &nbsp; <br />
&nbsp; &nbsp; <span class="co1">//normalize the value to the new normalized range</span><br />
&nbsp; &nbsp; <span class="kw2">var</span> result = <span class="kw7">value</span> <span class="sy0">-</span> low1;<br />
&nbsp; &nbsp; <br />
&nbsp; &nbsp; <span class="co1">//define the range as a percentage (0.0 to 1.0)</span><br />
&nbsp; &nbsp; <span class="kw2">var</span> ratio = result <span class="sy0">/</span> range1;<br />
&nbsp; &nbsp; <br />
&nbsp; &nbsp; <span class="co1">//find the value in the new normalized-range</span><br />
&nbsp; &nbsp; result = ratio <span class="sy0">*</span> range2;<br />
&nbsp; &nbsp; <br />
&nbsp; &nbsp; <span class="co1">//un-normalize the value in the new range</span><br />
&nbsp; &nbsp; result <span class="sy0">+</span>= low2;<br />
&nbsp; &nbsp; <br />
&nbsp; &nbsp; <span class="kw1">return</span> result;<br />
<span class="br0">&#125;</span></div></div>
<p>And super compressed (less readable, less space, works the same):</p>
<div class="codecolorer-container actionscript3 " style="overflow:auto;white-space:nowrap;width:435px"><div class="actionscript3 codecolorer" style="font-family:Monaco,Lucida Console,monospace"><span class="kw3">function</span> <span class="kw7">map</span><span class="br0">&#40;</span>v<span class="sy0">:</span><a href="http://www.google.com/search?q=number%20inurl:http://livedocs.adobe.com/flex/201/langref/%20inurl:number.html&amp;filter=0&amp;num=100&amp;btnI=lucky"><span class="kw5">Number</span></a>, a<span class="sy0">:</span><a href="http://www.google.com/search?q=number%20inurl:http://livedocs.adobe.com/flex/201/langref/%20inurl:number.html&amp;filter=0&amp;num=100&amp;btnI=lucky"><span class="kw5">Number</span></a>, <span class="kw7">b</span><span class="sy0">:</span><a href="http://www.google.com/search?q=number%20inurl:http://livedocs.adobe.com/flex/201/langref/%20inurl:number.html&amp;filter=0&amp;num=100&amp;btnI=lucky"><span class="kw5">Number</span></a>, <span class="kw7">x</span><span class="sy0">:</span><a href="http://www.google.com/search?q=number%20inurl:http://livedocs.adobe.com/flex/201/langref/%20inurl:number.html&amp;filter=0&amp;num=100&amp;btnI=lucky"><span class="kw5">Number</span></a> = <span class="nu0">0</span>, <span class="kw7">y</span><span class="sy0">:</span><a href="http://www.google.com/search?q=number%20inurl:http://livedocs.adobe.com/flex/201/langref/%20inurl:number.html&amp;filter=0&amp;num=100&amp;btnI=lucky"><span class="kw5">Number</span></a> = <span class="nu0">1</span><span class="br0">&#41;</span><span class="sy0">:</span><a href="http://www.google.com/search?q=number%20inurl:http://livedocs.adobe.com/flex/201/langref/%20inurl:number.html&amp;filter=0&amp;num=100&amp;btnI=lucky"><span class="kw5">Number</span></a> <span class="br0">&#123;</span><br />
&nbsp; &nbsp; <span class="kw1">return</span> <span class="br0">&#40;</span>v == a<span class="br0">&#41;</span> <span class="sy0">?</span> <span class="kw7">x</span> <span class="sy0">:</span> <span class="br0">&#40;</span>v <span class="sy0">-</span> a<span class="br0">&#41;</span> <span class="sy0">*</span> <span class="br0">&#40;</span><span class="kw7">y</span> <span class="sy0">-</span> <span class="kw7">x</span><span class="br0">&#41;</span> <span class="sy0">/</span> <span class="br0">&#40;</span><span class="kw7">b</span> <span class="sy0">-</span> a<span class="br0">&#41;</span> <span class="sy0">+</span> <span class="kw7">x</span>;<br />
<span class="br0">&#125;</span></div></div>
]]></content:encoded>
			<wfw:commentRss>http://lab.joelgillman.com/archives/87_map-function/feed</wfw:commentRss>
		<slash:comments>5</slash:comments>
		</item>
		<item>
		<title>Why You Should Embed Your Fonts</title>
		<link>http://lab.joelgillman.com/archives/73_why-you-should-embed-your-fonts</link>
		<comments>http://lab.joelgillman.com/archives/73_why-you-should-embed-your-fonts#comments</comments>
		<pubDate>Mon, 22 Sep 2008 22:52:36 +0000</pubDate>
		<dc:creator>joel gillman</dc:creator>
				<category><![CDATA[Uncategorized]]></category>

		<guid isPermaLink="false">http://lab.joelgillman.com/?p=73</guid>
		<description><![CDATA[I think this should go without saying, but not everyone knows how to do this.  First I randomly downloaded a font from dafont.com to make sure that I would be using a font that 99% of people didn&#8217;t have.  If you check out the Flash below you can see that the top text [...]]]></description>
			<content:encoded><![CDATA[<p>I think this should go without saying, but not everyone knows how to do this.  First I randomly downloaded a font from <a href="http://www.dafont.com/">dafont.com</a> to make sure that I would be using a font that 99% of people didn&#8217;t have.  If you check out the Flash below you can see that the top text field is using some crazy bitmap-esque font.  The text field on the bottom is actually using the same font but since I created it on the stage by hand (rather than dynamically with my code) it is probably displaying Times New Roman.  Or some other default serif typeface.  The the source code for a commented explanation.<br />
<span id="more-73"></span></p>
<div id="flashcontent"></div>
<p><script type="text/javascript">
		var flashvars = {};
		var params = {};
		params.menu = "false";
		var attributes = {};
		swfobject.embedSWF("http://lab.joelgillman.com/thepress/wp-content/uploads/2008/09/embed_font01.swf", "flashcontent", "450", "400", "9.0.0", false, flashvars, params, attributes);
	</script></p>
<p>AS3 Code:</p>
<div class="codecolorer-container actionscript3 " style="overflow:auto;white-space:nowrap;width:435px"><div class="actionscript3 codecolorer" style="font-family:Monaco,Lucida Console,monospace"><span class="kw1">import</span> <span class="kw6">flash.display</span>.<a href="http://www.google.com/search?q=sprite%20inurl:http://livedocs.adobe.com/flex/201/langref/%20inurl:sprite.html&amp;filter=0&amp;num=100&amp;btnI=lucky"><span class="kw5">Sprite</span></a>;<br />
<br />
<span class="kw1">import</span> <span class="kw6">flash.text</span>.<a href="http://www.google.com/search?q=antialiastype%20inurl:http://livedocs.adobe.com/flex/201/langref/%20inurl:antialiastype.html&amp;filter=0&amp;num=100&amp;btnI=lucky"><span class="kw5">AntiAliasType</span></a>;<br />
<span class="kw1">import</span> <span class="kw6">flash.text</span>.<a href="http://www.google.com/search?q=font%20inurl:http://livedocs.adobe.com/flex/201/langref/%20inurl:font.html&amp;filter=0&amp;num=100&amp;btnI=lucky"><span class="kw5">Font</span></a>;<br />
<span class="kw1">import</span> <span class="kw6">flash.text</span>.<a href="http://www.google.com/search?q=fontstyle%20inurl:http://livedocs.adobe.com/flex/201/langref/%20inurl:fontstyle.html&amp;filter=0&amp;num=100&amp;btnI=lucky"><span class="kw5">FontStyle</span></a>;<br />
<span class="kw1">import</span> <span class="kw6">flash.text</span>.<a href="http://www.google.com/search?q=fonttype%20inurl:http://livedocs.adobe.com/flex/201/langref/%20inurl:fonttype.html&amp;filter=0&amp;num=100&amp;btnI=lucky"><span class="kw5">FontType</span></a>;<br />
<span class="kw1">import</span> <span class="kw6">flash.text</span>.<a href="http://www.google.com/search?q=textfield%20inurl:http://livedocs.adobe.com/flex/201/langref/%20inurl:textfield.html&amp;filter=0&amp;num=100&amp;btnI=lucky"><span class="kw5">TextField</span></a>;<br />
<span class="kw1">import</span> <span class="kw6">flash.text</span>.<a href="http://www.google.com/search?q=textformat%20inurl:http://livedocs.adobe.com/flex/201/langref/%20inurl:textformat.html&amp;filter=0&amp;num=100&amp;btnI=lucky"><span class="kw5">TextFormat</span></a>;<br />
<span class="kw1">import</span> <span class="kw6">flash.text</span>.<a href="http://www.google.com/search?q=textformatalign%20inurl:http://livedocs.adobe.com/flex/201/langref/%20inurl:textformatalign.html&amp;filter=0&amp;num=100&amp;btnI=lucky"><span class="kw5">TextFormatAlign</span></a>;<br />
<span class="kw1">import</span> <span class="kw6">flash.text</span>.<a href="http://www.google.com/search?q=textrenderer%20inurl:http://livedocs.adobe.com/flex/201/langref/%20inurl:textrenderer.html&amp;filter=0&amp;num=100&amp;btnI=lucky"><span class="kw5">TextRenderer</span></a>;<br />
<br />
<br />
<span class="kw2">var</span> format<span class="sy0">:</span><a href="http://www.google.com/search?q=textformat%20inurl:http://livedocs.adobe.com/flex/201/langref/%20inurl:textformat.html&amp;filter=0&amp;num=100&amp;btnI=lucky"><span class="kw5">TextFormat</span></a> = <span class="kw1">new</span> <a href="http://www.google.com/search?q=textformat%20inurl:http://livedocs.adobe.com/flex/201/langref/%20inurl:textformat.html&amp;filter=0&amp;num=100&amp;btnI=lucky"><span class="kw5">TextFormat</span></a><span class="br0">&#40;</span><span class="br0">&#41;</span>;<br />
<span class="kw2">var</span> <span class="kw7">font</span><span class="sy0">:</span><a href="http://www.google.com/search?q=font%20inurl:http://livedocs.adobe.com/flex/201/langref/%20inurl:font.html&amp;filter=0&amp;num=100&amp;btnI=lucky"><span class="kw5">Font</span></a> &nbsp; &nbsp; &nbsp; &nbsp; = <span class="kw1">new</span> bitmapRegular36<span class="br0">&#40;</span><span class="br0">&#41;</span>; <span class="co1">//use the linkage name for the font in the library</span><br />
<span class="kw2">var</span> <span class="kw7">size</span><span class="sy0">:</span><a href="http://www.google.com/search?q=number%20inurl:http://livedocs.adobe.com/flex/201/langref/%20inurl:number.html&amp;filter=0&amp;num=100&amp;btnI=lucky"><span class="kw5">Number</span></a> &nbsp; &nbsp; &nbsp; = <span class="nu0">36</span>;<br />
<br />
<br />
<span class="kw3">function</span> <span class="kw7">init</span><span class="br0">&#40;</span><span class="br0">&#41;</span><span class="sy0">:</span><span class="kw1">void</span> <span class="br0">&#123;</span><br />
&nbsp; &nbsp; format = makeTextFormat<span class="br0">&#40;</span><span class="kw7">size</span>, <span class="kw7">font</span><span class="br0">&#41;</span>;<br />
&nbsp; &nbsp; makeTextField<span class="br0">&#40;</span><span class="st0">&quot;This ridiculous font is dynamicly embedded.&quot;</span>, format<span class="br0">&#41;</span>;<br />
<span class="br0">&#125;</span><br />
<br />
<span class="kw3">function</span> makeTextFormat<span class="br0">&#40;</span>__size<span class="sy0">:</span><a href="http://www.google.com/search?q=number%20inurl:http://livedocs.adobe.com/flex/201/langref/%20inurl:number.html&amp;filter=0&amp;num=100&amp;btnI=lucky"><span class="kw5">Number</span></a>, __font<span class="sy0">:</span><a href="http://www.google.com/search?q=font%20inurl:http://livedocs.adobe.com/flex/201/langref/%20inurl:font.html&amp;filter=0&amp;num=100&amp;btnI=lucky"><span class="kw5">Font</span></a><span class="br0">&#41;</span><span class="sy0">:</span><a href="http://www.google.com/search?q=textformat%20inurl:http://livedocs.adobe.com/flex/201/langref/%20inurl:textformat.html&amp;filter=0&amp;num=100&amp;btnI=lucky"><span class="kw5">TextFormat</span></a> <span class="br0">&#123;</span><br />
&nbsp; &nbsp; <span class="kw2">var</span> result<span class="sy0">:</span><a href="http://www.google.com/search?q=textformat%20inurl:http://livedocs.adobe.com/flex/201/langref/%20inurl:textformat.html&amp;filter=0&amp;num=100&amp;btnI=lucky"><span class="kw5">TextFormat</span></a> = <span class="kw1">new</span> <a href="http://www.google.com/search?q=textformat%20inurl:http://livedocs.adobe.com/flex/201/langref/%20inurl:textformat.html&amp;filter=0&amp;num=100&amp;btnI=lucky"><span class="kw5">TextFormat</span></a><span class="br0">&#40;</span><span class="br0">&#41;</span>;<br />
&nbsp; &nbsp; result.<span class="kw7">font</span> &nbsp; &nbsp; = __font.<span class="kw7">fontName</span>;<br />
&nbsp; &nbsp; result.<span class="kw7">size</span> &nbsp; &nbsp; = __size;<br />
&nbsp; &nbsp; result.<span class="kw7">kerning</span> &nbsp;= <span class="kw1">true</span>; <span class="co1">//not availible for non-embedded fonts</span><br />
&nbsp; &nbsp; <br />
&nbsp; &nbsp; <span class="kw1">return</span> result;<br />
&nbsp;<span class="br0">&#125;</span><br />
<br />
<span class="kw3">function</span> makeTextField<span class="br0">&#40;</span>_inputText<span class="sy0">:</span><a href="http://www.google.com/search?q=string%20inurl:http://livedocs.adobe.com/flex/201/langref/%20inurl:string.html&amp;filter=0&amp;num=100&amp;btnI=lucky"><span class="kw5">String</span></a>, __format<span class="sy0">:</span><a href="http://www.google.com/search?q=textformat%20inurl:http://livedocs.adobe.com/flex/201/langref/%20inurl:textformat.html&amp;filter=0&amp;num=100&amp;btnI=lucky"><span class="kw5">TextFormat</span></a>, __x<span class="sy0">:</span><a href="http://www.google.com/search?q=number%20inurl:http://livedocs.adobe.com/flex/201/langref/%20inurl:number.html&amp;filter=0&amp;num=100&amp;btnI=lucky"><span class="kw5">Number</span></a> = <span class="nu0">0</span>, __y<span class="sy0">:</span><a href="http://www.google.com/search?q=number%20inurl:http://livedocs.adobe.com/flex/201/langref/%20inurl:number.html&amp;filter=0&amp;num=100&amp;btnI=lucky"><span class="kw5">Number</span></a> = <span class="nu0">0</span><span class="br0">&#41;</span><span class="sy0">:</span><span class="kw1">void</span> <span class="br0">&#123;</span><br />
&nbsp; &nbsp; <span class="kw2">var</span> tf<span class="sy0">:</span><a href="http://www.google.com/search?q=textfield%20inurl:http://livedocs.adobe.com/flex/201/langref/%20inurl:textfield.html&amp;filter=0&amp;num=100&amp;btnI=lucky"><span class="kw5">TextField</span></a> = <span class="kw1">new</span> <a href="http://www.google.com/search?q=textfield%20inurl:http://livedocs.adobe.com/flex/201/langref/%20inurl:textfield.html&amp;filter=0&amp;num=100&amp;btnI=lucky"><span class="kw5">TextField</span></a><span class="br0">&#40;</span><span class="br0">&#41;</span>;<br />
&nbsp; &nbsp; tf.<span class="kw7">x</span> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;= __x;<br />
&nbsp; &nbsp; tf.<span class="kw7">y</span> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;= __y;<br />
&nbsp; &nbsp; tf.<span class="kw7">width</span> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;= <span class="nu0">450</span>;<br />
&nbsp; &nbsp; tf.<span class="kw7">height</span> &nbsp; &nbsp; &nbsp; &nbsp; = <span class="nu0">200</span>;<br />
&nbsp; &nbsp; tf.<span class="kw7">type</span> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; = <a href="http://www.google.com/search?q=textfieldtype%20inurl:http://livedocs.adobe.com/flex/201/langref/%20inurl:textfieldtype.html&amp;filter=0&amp;num=100&amp;btnI=lucky"><span class="kw5">TextFieldType</span></a>.<span class="kw8">INPUT</span>;<br />
&nbsp; &nbsp; tf.<span class="kw7">wordWrap</span> &nbsp; &nbsp; &nbsp; = <span class="kw1">true</span>;<br />
&nbsp; &nbsp; tf.<span class="kw7">multiline</span> &nbsp; &nbsp; &nbsp;= <span class="kw1">true</span>;<br />
&nbsp; &nbsp; tf.<span class="kw7">selectable</span> &nbsp; &nbsp; = <span class="kw1">true</span>;<br />
&nbsp; &nbsp; tf.<span class="kw7">embedFonts</span> &nbsp; &nbsp; = <span class="kw1">true</span>;<br />
&nbsp; &nbsp; tf.<span class="kw7">antiAliasType</span> &nbsp;= <a href="http://www.google.com/search?q=antialiastype%20inurl:http://livedocs.adobe.com/flex/201/langref/%20inurl:antialiastype.html&amp;filter=0&amp;num=100&amp;btnI=lucky"><span class="kw5">AntiAliasType</span></a>.<span class="kw8">ADVANCED</span>; <span class="co1">//not availible for non-embedded fonts</span><br />
&nbsp; &nbsp; tf.<span class="kw7">gridFitType</span> &nbsp; &nbsp;= <a href="http://www.google.com/search?q=gridfittype%20inurl:http://livedocs.adobe.com/flex/201/langref/%20inurl:gridfittype.html&amp;filter=0&amp;num=100&amp;btnI=lucky"><span class="kw5">GridFitType</span></a>.<span class="kw8">PIXEL</span>; <span class="co1">//not availible for non-embedded fonts</span><br />
&nbsp; &nbsp; tf.<span class="kw7">text</span> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; = _inputText;<br />
&nbsp; &nbsp; <br />
&nbsp; &nbsp; <span class="co1">//as a general rule, set the textFormat last</span><br />
&nbsp; &nbsp; tf.<span class="kw7">setTextFormat</span><span class="br0">&#40;</span>__format<span class="br0">&#41;</span>;<br />
&nbsp; &nbsp; <br />
&nbsp; &nbsp; <span class="kw7">addChild</span><span class="br0">&#40;</span>tf<span class="br0">&#41;</span>;<br />
<span class="br0">&#125;</span><br />
<br />
<span class="co1">//start</span><br />
<span class="kw7">init</span><span class="br0">&#40;</span><span class="br0">&#41;</span>;</div></div>
<p>Download the <a href="http://lab.joelgillman.com/thepress/wp-content/uploads/2008/09/embedded_font_demo.zip">source</a>.</p>
<p>Original font by <a href="http://www.dafont.com/sam-derrick.d1882">Sam Derrick</a>.</p>
]]></content:encoded>
			<wfw:commentRss>http://lab.joelgillman.com/archives/73_why-you-should-embed-your-fonts/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>False 3D in Flash: Displacement Maps</title>
		<link>http://lab.joelgillman.com/archives/30_false-3d-in-flash-displacement-maps</link>
		<comments>http://lab.joelgillman.com/archives/30_false-3d-in-flash-displacement-maps#comments</comments>
		<pubDate>Wed, 17 Sep 2008 21:53:48 +0000</pubDate>
		<dc:creator>joel gillman</dc:creator>
				<category><![CDATA[Uncategorized]]></category>
		<category><![CDATA[AS3]]></category>
		<category><![CDATA[displacement mapping]]></category>
		<category><![CDATA[flash]]></category>
		<category><![CDATA[photoshop]]></category>
		<category><![CDATA[source code]]></category>

		<guid isPermaLink="false">http://lab.joelgillman.com/?p=30</guid>
		<description><![CDATA[After seeing a post on the Puny Blog about displacement maps I became interested in how they did it.  Unfortunately there wasn&#8217;t any source code so I&#8217;ve replicated the effect from scratch.
Turns out displacement maps are really hard to wrap your head around, so I&#8217;ll try to explain it very carefully and slowly.

I feel [...]]]></description>
			<content:encoded><![CDATA[<p>After seeing a <a href="http://www.punyblog.com/2008/08/displacement-map-filter.html">post</a> on the Puny Blog about displacement maps I became interested in how they did it.  Unfortunately there wasn&#8217;t any source code so I&#8217;ve replicated the effect from scratch.<br />
Turns out displacement maps are really hard to wrap your head around, so I&#8217;ll try to explain it very carefully and slowly.<br />
<span id="more-30"></span><br />
I feel that Wikipedia is always a good place to start:</p>
<blockquote><p><b>Displacement mapping</b> is an alternative computer graphics technique in contrast to <a href="/wiki/Bump_mapping" title="Bump mapping">bump mapping</a>, <a href="/wiki/Normal_mapping" title="Normal mapping">normal mapping</a>, and <a href="/wiki/Parallax_mapping" title="Parallax mapping">parallax mapping</a>, using a (<a href="/wiki/Procedural_texture" title="Procedural texture">procedural</a>-) <a href="/wiki/Texture_mapping" title="Texture mapping">texture-</a> or <a href="/wiki/Heightmap" title="Heightmap">height map</a> to cause an effect where the actual geometric position of points over the textured surface are <i>displaced</i>, often along the <a href="/wiki/Locally" title="Locally" class="mw-redirect">local</a> <a href="/wiki/Surface_normal" title="Surface normal">surface normal</a>, according to the value the texture function evaluates to at each point on the surface. It gives surfaces a great sense of depth and detail, permitting in particular self-occlusion, self-shadowing and silhouettes; on the other hand, it is the most costly of this class of techniques owing to the large amount of additional geometry.</p></blockquote>
<p>Displacement maps are commonly used in 3D programs to make complicated geometry using simple 2D images.  In those programs it actually morphs objects in a 3D-space (along a z-axis).  But in our (so far) 2D flash world, it&#8217;s easier to think of the displacement maps as <a href="http://www.edwardsamuels.com/illustratedstory/chapter%204/goo%20-%20mona%20lisa.jpg">distortion</a>.  In plain English, you distort an image using a separate gray scale image.</p>
<p>I&#8217;m a visual thinker so I drew it out in my sketch book first:<br />
<img src="http://lab.joelgillman.com/thepress/wp-content/uploads/2008/09/displacement_breakthrough.png" alt="" title="displacement_breakthrough" width="450" height="275" class="alignnone size-full wp-image-35" /><br />
This is the distortion I wanted to achieve.  If you can&#8217;t read my chicken scratch it says, &#8220;x: -30 to 0 to +30&#8243;.  Meaning that if every square were for 5 pixels, at the grid&#8217;s most distorted point the bottom-left point would be offset by -30 pixels along it&#8217;s &#8216;x&#8217; axis while the bottom-right point is offset by +30 pixels.  The bottom-middle is not offset along the &#8216;x&#8217; axis.</p>
<p><img src="http://lab.joelgillman.com/thepress/wp-content/uploads/2008/09/photoshop_channles.png" alt="" title="photoshop_channels" width="222" height="180" class="alignright size-full wp-image-48" />After drawing out and writing down what would happen to each pixel, translating it into a gradient was pretty easy.  A gray scale image consists of 255 levels, 0 being black and 255 being white.  If you&#8217;re reading this you probably already know that.  You also know that any digital image is made up of three channels: Red, green and blue.  In Photoshop, you can see these channels individually by opening the channels window.  This will be important, or at least handy to know later.  SO, converting those levels into hex you get 00 (black, -30px offset), 80 (middle gray, 0 offset) and FF (white, +30 offset).</p>
<p>I didn&#8217;t want the whole image to be distorted, so part of the image needed to remain unchanged.  This is where the middle-gray comes in.  The gray fades in from the bottom to about a third of the way up the image and from there it is the same even color all the way up.<br />
<img src="http://lab.joelgillman.com/thepress/wp-content/uploads/2008/09/displacement02.png" alt="" title="My second, more successful attempt" width="450" height="327" class="alignnone size-full wp-image-35" /></p>
<p>If you break it out into channels you get this:<br />
<img src="http://lab.joelgillman.com/thepress/wp-content/uploads/2008/09/displacement02_breakout.png" alt="" title="Channel breakout of the displacement map" width="450" height="327" class="alignnone size-full wp-image-35" /><br />
For this example I am only using the RED and BLUE channels (though since the BLUE and GREEN are the same in this case, they are interchangeable).  The BLUE channel goes from black to gray meaning that pixels will be moved in a negative direction, this is the first part of the skewed illusion.  The second, and most important part, comes from the RED channel.  Starting with the most extreme black (00) and fading to the most extreme red (FF), we get our most extreme distortion. Cowabunga!<br />
From there, as we move up, the image fades more and more to middle-gray creating less and less distortion until there is no distortion at all.</p>
<p>At first I used a picture of some pretty flowers to test the distortion, but I realized that with a real photo, it wasn&#8217;t very obvious what had actually been morphed.  I ditched it for a good ol&#8217; grid.  The grid makes it ridiculously easy to tell what&#8217;s been morphed, plus it looks like a cool Tron-esque world.<br />
<img src="http://lab.joelgillman.com/thepress/wp-content/uploads/2008/09/grid.jpg" alt="" title="Grid to be displaced" width="450" height="327" class="alignnone size-full wp-image-35" /></p>
<hr class="space"/>
<p>Check out the <a href="http://lab.joelgillman.com/thepress/wp-content/uploads/2008/09/false3d_demo.html">working demo</a>. (click to turn the distortion on and off)</p>
<hr class="space"/>
<p><a href="http://lab.joelgillman.com/thepress/wp-content/uploads/2008/09/false3d_demo.zip">Download the source</a>.  All code is EXPLICITLY commented.</p>
<hr class="space"/>
<p>A few sites that I found helpful:
<ul>
<li><a href="http://objectpainters.com/blog/2007/01/09/getting-the-displacement-you-need/">Getting the Displacement Your Need</a></li>
<li><a href="http://www.terrypaton.com/as3-bitmap-displacement/">AS3 Bitmap Displacement</a></li>
<li><a href="http://www.emanueleferonato.com/2007/12/03/understanding-flash-displacement-map-filter/">Understanding Flash Displacement Map Filter</a></li>
</ul>
<hr class="space"/>
<p>After all of that the one thing that I still don&#8217;t get is <em>why</em> when the image is distorted why it looks so crappy.  I&#8217;ve tried using different image formats (jpeg vs png) and I&#8217;ve even dynamically drawn in a vector grid, but it still give me that pixelly crap.  Anyone have an answer? (<a href="#comment-2087">Philipp does!</a>)</p>
<p>So it&#8217;s cleaner looking now, but there&#8217;s still some monster pixelation going on.  Anyone know how to .smoothing=true for a displacement map?  Displacement maps need bitmapData and I don&#8217;t think you can do too much to that in the way of smoothing&#8230;</p>
]]></content:encoded>
			<wfw:commentRss>http://lab.joelgillman.com/archives/30_false-3d-in-flash-displacement-maps/feed</wfw:commentRss>
		<slash:comments>5</slash:comments>
		</item>
		<item>
		<title>Sun Chips</title>
		<link>http://lab.joelgillman.com/archives/29_sun-chips</link>
		<comments>http://lab.joelgillman.com/archives/29_sun-chips#comments</comments>
		<pubDate>Wed, 16 Apr 2008 03:05:01 +0000</pubDate>
		<dc:creator>joel gillman</dc:creator>
				<category><![CDATA[Uncategorized]]></category>
		<category><![CDATA[colony]]></category>
		<category><![CDATA[creatures]]></category>
		<category><![CDATA[energy]]></category>
		<category><![CDATA[light energy]]></category>
		<category><![CDATA[movement]]></category>
		<category><![CDATA[moving guys]]></category>
		<category><![CDATA[ReacTable]]></category>
		<category><![CDATA[sun]]></category>
		<category><![CDATA[sun chips]]></category>
		<category><![CDATA[time and money]]></category>

		<guid isPermaLink="false">http://lab.joelgillman.com/archives/29_sun-chips</guid>
		<description><![CDATA[I had been doing an interactive chess table using the ReacTable software, but that whole project was nothing but problems. It ended up needing more time and money than I had available. One day I&#8217;ll finish it&#8230;
This video is a test run of my new senior project. This goes back to my projects last semester [...]]]></description>
			<content:encoded><![CDATA[<p>I had been doing an interactive chess table using the <a href="http://reactable.iua.upf.edu/">ReacTable</a> software, but that whole project was nothing but problems. It ended up needing more time and money than I had available. One day I&#8217;ll finish it&#8230;</p>
<p>This video is a test run of my <em>new</em> senior project. This goes back to my projects last semester when I was using <strong>little to no computers</strong>.  I know, scary.</p>
<p><em>This</em> project consists of solar powered creatures who collect light energy and then use the energy to make a movement.  There are only two in this video as I&#8217;m in the process of making more so they can live in a small and bright colony of happy moving guys.</p>
<p><span id="more-29"></span><br />
<object type="application/x-shockwave-flash" width="480" height="320" data="http://www.vimeo.com/moogaloop.swf?clip_id=903949&amp;server=www.vimeo.com&amp;fullscreen=1&amp;show_title=0&amp;show_byline=0&amp;show_portrait=0&amp;color=ff0179"><param name="quality" value="best" /><param name="allowfullscreen" value="true" /><param name="scale" value="showAll" /><param name="movie" value="http://www.vimeo.com/moogaloop.swf?clip_id=903949&amp;server=www.vimeo.com&amp;fullscreen=1&amp;show_title=0&amp;show_byline=0&amp;show_portrait=0&amp;color=ff0179" /></object><br /><a href="http://www.vimeo.com/903949/l:embed_903949">Sun Chips &#8211; Test Run 01</a> from <a href="http://www.vimeo.com/jgillman/l:embed_903949">Joel Gillman</a> on <a href="http://vimeo.com/l:embed_903949">Vimeo</a>.</p>
]]></content:encoded>
			<wfw:commentRss>http://lab.joelgillman.com/archives/29_sun-chips/feed</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
		<item>
		<title>Emitters</title>
		<link>http://lab.joelgillman.com/archives/28_emitters</link>
		<comments>http://lab.joelgillman.com/archives/28_emitters#comments</comments>
		<pubDate>Fri, 07 Mar 2008 07:48:49 +0000</pubDate>
		<dc:creator>joel gillman</dc:creator>
				<category><![CDATA[Uncategorized]]></category>
		<category><![CDATA[emitter]]></category>
		<category><![CDATA[particles]]></category>
		<category><![CDATA[processing]]></category>
		<category><![CDATA[star field]]></category>
		<category><![CDATA[video]]></category>
		<category><![CDATA[Vimeo]]></category>

		<guid isPermaLink="false">http://lab.joelgillman.com/archives/28_emitters</guid>
		<description><![CDATA[For a project I needed to learn how to make an emitter (for particles).  Specifically and emitter object that can be called several times so that there can be several unique emitters.  I have made something similar before but it works more efficiently now.  Videos only.
Mouse Emitter from Joel Gillman on Vimeo.
Emitter [...]]]></description>
			<content:encoded><![CDATA[<p>For a project I needed to learn how to make an emitter (for particles).  Specifically and emitter object that can be called several times so that there can be several unique emitters.  I have made <a href="http://lab.joelgillman.com/archives/15_spawn-object">something</a> similar before but it works more efficiently now.  Videos only.<span id="more-28"></span></p>
<p><object type="application/x-shockwave-flash" width="500" height="333" data="http://www.vimeo.com/moogaloop.swf?clip_id=755681&amp;server=www.vimeo.com&amp;fullscreen=1&amp;show_title=0&amp;show_byline=0&amp;show_portrait=0&amp;color=ff333d"><param name="quality" value="best" /><param name="allowfullscreen" value="true" /><param name="scale" value="showAll" /><param name="movie" value="http://www.vimeo.com/moogaloop.swf?clip_id=755681&amp;server=www.vimeo.com&amp;fullscreen=1&amp;show_title=0&amp;show_byline=0&amp;show_portrait=0&amp;color=ff333d" /></object><br /><a href="http://www.vimeo.com/755681/l:embed_755681">Mouse Emitter</a> from <a href="http://www.vimeo.com/jgillman/l:embed_755681">Joel Gillman</a> on <a href="http://vimeo.com/l:embed_755681">Vimeo</a>.</p>
<p><object type="application/x-shockwave-flash" width="500" height="333" data="http://www.vimeo.com/moogaloop.swf?clip_id=760824&amp;server=www.vimeo.com&amp;fullscreen=1&amp;show_title=0&amp;show_byline=0&amp;show_portrait=0&amp;color=ff333d"><param name="quality" value="best" /><param name="allowfullscreen" value="true" /><param name="scale" value="showAll" /><param name="movie" value="http://www.vimeo.com/moogaloop.swf?clip_id=760824&amp;server=www.vimeo.com&amp;fullscreen=1&amp;show_title=0&amp;show_byline=0&amp;show_portrait=0&amp;color=ff333d" /></object><br /><a href="http://www.vimeo.com/760824/l:embed_760824">Emitter &#8211; Star Field</a> from <a href="http://www.vimeo.com/jgillman/l:embed_760824">Joel Gillman</a> on <a href="http://vimeo.com/l:embed_760824">Vimeo</a>.</p>
]]></content:encoded>
			<wfw:commentRss>http://lab.joelgillman.com/archives/28_emitters/feed</wfw:commentRss>
		<slash:comments>3</slash:comments>
		</item>
		<item>
		<title>Chess Clock</title>
		<link>http://lab.joelgillman.com/archives/27_chess-clock</link>
		<comments>http://lab.joelgillman.com/archives/27_chess-clock#comments</comments>
		<pubDate>Sun, 02 Mar 2008 21:43:28 +0000</pubDate>
		<dc:creator>joel gillman</dc:creator>
				<category><![CDATA[Uncategorized]]></category>
		<category><![CDATA[Chess]]></category>
		<category><![CDATA[clock]]></category>
		<category><![CDATA[modes]]></category>
		<category><![CDATA[processing]]></category>
		<category><![CDATA[program]]></category>

		<guid isPermaLink="false">http://lab.joelgillman.com/archives/27_chess-clock</guid>
		<description><![CDATA[A friend and I have been playing Chess recently (neither of us are very good) and we decided we could use a chess clock to make the games faster and more stressful.  We decided to make a game of it and see who could program a rudimentary (but working) chess clock.  Here&#8217;s mine.
10 [...]]]></description>
			<content:encoded><![CDATA[<p>A friend and I have been playing Chess recently (neither of us are very good) and we decided we could use a chess clock to make the games faster and more stressful.  We decided to make a game of it and see who could program a rudimentary (but working) chess clock.  Here&#8217;s mine.<span id="more-27"></span></p>
<p><em>10 minutes per player is the default.<br />
&#8216;r&#8217; to reset<br />
&#8217;space&#8217; to switch players<br />
&#8216;p&#8217; to pause</em><br />
<applet class="span-12" code="ClockCounter" archive="http://lab.joelgillman.com/thepress/wp-content/uploads/2008/03/clockcounter.jar" width="400" height="200"></applet></p>
<p><a href="http://lab.joelgillman.com/thepress/wp-content/uploads/2008/03/clockcounter.pde">Source 1</a> <a href="http://lab.joelgillman.com/thepress/wp-content/uploads/2008/03/draw_clock.pde">2</a> and <a href="http://lab.joelgillman.com/thepress/wp-content/uploads/2008/03/chess_keyboard.pde">3</a></p>
]]></content:encoded>
			<wfw:commentRss>http://lab.joelgillman.com/archives/27_chess-clock/feed</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
	</channel>
</rss>
