<?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>nooshu &#187; JavaScript Archives </title>
	<atom:link href="http://nooshu.com/category/javascript/feed" rel="self" type="application/rss+xml" />
	<link>http://nooshu.com</link>
	<description>Kneeling on the shoulders of giants</description>
	<lastBuildDate>Fri, 20 Jan 2012 11:38:04 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.3.1</generator>
		<item>
		<title>Plotting the Lorenz Attractor using three.js</title>
		<link>http://nooshu.com/plotting-the-lorenz-attractor-using-three-js?utm_source=rss&#038;utm_medium=rss&#038;utm_campaign=plotting-the-lorenz-attractor-using-three-js</link>
		<comments>http://nooshu.com/plotting-the-lorenz-attractor-using-three-js#comments</comments>
		<pubDate>Thu, 15 Dec 2011 14:53:24 +0000</pubDate>
		<dc:creator>Matt</dc:creator>
				<category><![CDATA[Experiments]]></category>
		<category><![CDATA[Inspiration]]></category>
		<category><![CDATA[JavaScript]]></category>
		<category><![CDATA[Three.js]]></category>
		<category><![CDATA[chaos]]></category>
		<category><![CDATA[lorenz]]></category>
		<category><![CDATA[plot]]></category>

		<guid isPermaLink="false">http://nooshu.com/?p=2058</guid>
		<description><![CDATA[The Lorenz equations are a cornerstone in Chaos theory. The "butterfly effect" is how it is known in popular culture. I little experiment plotting the Lorenz Attractor using three.js.]]></description>
			<content:encoded><![CDATA[<p>It&#8217;s been a while since I dabbled with <a href="https://github.com/mrdoob/three.js">three.js</a>. There have been a few API changes, so it&#8217;s slightly different from what I remember. That being said it&#8217;s still as fun to use, and there are even a few <a href="http://threejs.org/io/s/">API docs</a> available (not sure if they are fully up to date though)! I happened to be reading an article on Chaos Theory and the &#8220;butterfly effect&#8221; which mentioned a lovely set of equations; the <a href="http://en.wikipedia.org/wiki/Lorenz_attractor#Equations">Lorenz Equations</a>, also known as the Lorenz oscillator. So I decided to investigate further. Here they are in all their glory:</p>
<p><img src='http://s0.wp.com/latex.php?latex=%5Cbegin%7Baligned%7D%5Cdot%7Bx%7D+%26+%3D+%5Csigma%28y-x%29+%5C%5C+%5Cdot%7By%7D+%26+%3D+%5Crho+x+-+y+-+xz+%5C%5C+%5Cdot%7Bz%7D+%26+%3D+-%5Cbeta+z+%2B+xy+%5Cend%7Baligned%7D&#038;bg=D7DBCD&#038;fg=000&#038;s=1' alt='&#92;begin{aligned}&#92;dot{x} &amp; = &#92;sigma(y-x) &#92;&#92; &#92;dot{y} &amp; = &#92;rho x - y - xz &#92;&#92; &#92;dot{z} &amp; = -&#92;beta z + xy &#92;end{aligned}' title='&#92;begin{aligned}&#92;dot{x} &amp; = &#92;sigma(y-x) &#92;&#92; &#92;dot{y} &amp; = &#92;rho x - y - xz &#92;&#92; &#92;dot{z} &amp; = -&#92;beta z + xy &#92;end{aligned}' class='latex' /></p>
<p>So what exactly is the Lorenz oscillator? Well to quote from Wikipedia &#8220;The Lorenz oscillator is a 3-dimensional dynamical system that exhibits chaotic flow, noted for its figure eight shape.&#8221;. What this really boils down to is how even very small change in the equations initial conditions (x, y and z) causes large changes over time, in a complex and non-repeating pattern. There&#8217;s a famous title of a talk given in 1972 by Philip Merilees:</p>
<blockquote><p>Does the flap of a butterfly’s wings in Brazil set off a tornado in Texas?</p></blockquote>
<p>The butterfly flapping its wings introduces slight changes to the initial conditions, creating a chain of events that lead to a tornado in Texas. The Lorenz butterfly is a graphical way of showing these changes over time on a much smaller scale.</p>
<p>I&#8217;ve <a href="http://dl.dropbox.com/u/7851949/lorenz-attractor/index.html">created a demo</a> that allows you to change variables related to the Lorenz butterfly and observe the effect it has on the system.</p>
<div id="attachment_2075" class="wp-caption alignnone" style="width: 528px"><a href="http://dl.dropbox.com/u/7851949/lorenz-attractor/index.html"><img src="http://nooshu.com/wp-content/uploads/2011/12/lorenz-examples.jpg" alt="Example of my Lorenz attractor demo in action" title="lorenz-examples" width="518" height="501" class="size-full wp-image-2075" /></a><p class="wp-caption-text">Adjust the demo variables to see how the Lorenz butterfly changes.</p></div>
<p>There are a few variables you can play to change how the Lorenz attractor is rendered:</p>
<ul>
<li><strong>rhoValue</strong>: Called the Rayleigh number. Rho of value 28 shows chaotic behavior. Other values show periodic orbits.</li>
<li><strong>showAxis</strong>: Allows you to turn the x, y, z (red, green, blue) axis on for reference.</li>
<li><strong>randomStart</strong>: Picks a random initial conditions, rather than 0, 0, 0.</li>
<li><strong>totalTime</strong>: The total time (or number of iterations performed) when generating the graph. Higher numbers equals more lines and increases the render time.</li>
<li><strong>timeIncriment</strong>: The accuracy of the graph depends on the number of points plotted. A lower number creates a smoother graph but increases render time.</li>
<li><strong>colorModifier</strong>: Simply changes the colo(u)r. Pointless but pretty!</li>
</ul>
<p>While rendering a larger number of points, I noticed the browser lock-up for a second or so. This was because the points were being calculated on the browsers UI thread. Luckily modern browsers support thread like message passing in the form of the <a href="http://www.html5rocks.com/en/tutorials/workers/basics/">Web Workers API</a>. By offloading the point calculation to its own thread (<a href="http://dl.dropbox.com/u/7851949/lorenz-attractor/js/lorenzPoints.js">lorenzPoints.js</a>), I was able to stop the nasty UI freeze. Unfortunately you are fairly limited with what you can pass back and forth between workers. It was possible to generate the three.js geometry in the worker thread thanks to the importScripts() method. I tried passing the three.js geometry back to the browser but all the methods were stripped out, leading to lots of errors (JSON issues). In the end I dropped back to calculating the points in the worker, pushing them into an array and generating the geometry on the main browser thread. </p>
<p>It was good fun dabbling with three.js, Web Workers and dat.gui again. Now on to my next project&#8230; View the demo <a href="http://dl.dropbox.com/u/7851949/lorenz-attractor/index.html">here</a>.</p>
]]></content:encoded>
			<wfw:commentRss>http://nooshu.com/plotting-the-lorenz-attractor-using-three-js/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Remote Loading HTML5 Elements with jQuery</title>
		<link>http://nooshu.com/remote-loading-html5-elements-with-jquery?utm_source=rss&#038;utm_medium=rss&#038;utm_campaign=remote-loading-html5-elements-with-jquery</link>
		<comments>http://nooshu.com/remote-loading-html5-elements-with-jquery#comments</comments>
		<pubDate>Fri, 18 Nov 2011 10:31:28 +0000</pubDate>
		<dc:creator>Matt</dc:creator>
				<category><![CDATA[Browsers]]></category>
		<category><![CDATA[HTML]]></category>
		<category><![CDATA[jQuery]]></category>
		<category><![CDATA[html5]]></category>
		<category><![CDATA[ie]]></category>

		<guid isPermaLink="false">http://nooshu.com/?p=1946</guid>
		<description><![CDATA[Working with Internet Explorer is never easy. jQuery takes some of the pain out of it, but not always!]]></description>
			<content:encoded><![CDATA[<p>I ran into a rather annoying problem a few months ago while developing my <a href="http://solostrightnow.com/">travel blog</a>; the problem of course was involving Internet Explorer. I&#8217;m used to working with WordPress as I use it all the time, but I wanted to get away from the standard pagination you find on a blog. So I decided to use jQuery 1.6.4 to pull in articles from other pages (blogname.com/page/2, blogname.com/page/3 etc). Now this is all fairly simple using the handy jQuery .load() method; point it to a URL, pull in the page, pick the bits you need and reinsert into the page. Simple! Unfortunately once I got a prototype working in &#8216;good&#8217; browsers, IE8 and below was having non of it!</p>
<p>After a little head scratching to work out what was failing, I worked out it was because I was using HTML5 elements such as &#8216;article&#8217;, &#8216;header&#8217; and &#8216;footer&#8217;. There was no problem displaying them on the page, as I&#8217;d used Remy Sharps excellent <a href="http://remysharp.com/2009/01/07/html5-enabling-script/">HTML5 Shiv script</a>. It only failed when trying to pull in these &#8216;new&#8217; elements via Ajax.</p>
<p><strong>Note</strong>: Before you read on you&#8217;ll be happy to hear that this issue no longer occurs in <a href="http://blog.jquery.com/2011/11/03/jquery-1-7-released/">jQuery 1.7.0</a>. Horray! </p>
<p>If you can&#8217;t upgrade, for whatever reason, I hashed together a <a href="http://dl.dropbox.com/u/7851949/html5-load-method/index.html">little work-around</a> for browsers IE8 and below, so read on. I admit the work around isn&#8217;t pretty, but it works. I tried for a few hours to get IE8- to recognise the &#8216;new&#8217; elements after an Ajax request, but to no avail. Eventually I had to wrap the HTML5 tags in a div using conditionals:</p>
<div class="codecolorer-container html4strict default customCodeColor" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;width:435px;"><table cellspacing="0" cellpadding="0"><tbody><tr><td style="padding:5px;text-align:center;color:#888888;background-color:#EEEEEE;border-right: 1px solid #9F9F9F;font: normal 12px/1.4em Monaco, Lucida Console, monospace;"><div>1<br />2<br />3<br />4<br />5<br />6<br />7<br />8<br />9<br />10<br />11<br />12<br />13<br /></div></td><td><div class="html4strict codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap"><span style="color: #808080; font-style: italic;">&lt;!--[if lt IE 9]&gt;&lt;div id=&quot;ieHackContainer&quot;&gt;&lt;![endif]--&gt;</span><br />
<br />
<span style="color: #009900;">&lt;article <span style="color: #000066;">id</span><span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;html5Content&quot;</span>&gt;</span><br />
&nbsp; &nbsp; <span style="color: #009900;">&lt;header&gt;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #009900;">&lt;<span style="color: #000000; font-weight: bold;">h2</span>&gt;</span>H2 wrapped in a header element<span style="color: #009900;">&lt;<span style="color: #66cc66;">/</span><span style="color: #000000; font-weight: bold;">h2</span>&gt;</span><br />
&nbsp; &nbsp; <span style="color: #009900;">&lt;<span style="color: #66cc66;">/</span>header&gt;</span><br />
&nbsp; &nbsp; <span style="color: #808080; font-style: italic;">&lt;!-- Other HTML here... --&gt;</span><br />
&nbsp; &nbsp; <span style="color: #009900;">&lt;footer&gt;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #009900;">&lt;<span style="color: #000000; font-weight: bold;">p</span>&gt;</span>This is the footer element<span style="color: #009900;">&lt;<span style="color: #66cc66;">/</span><span style="color: #000000; font-weight: bold;">p</span>&gt;</span><br />
&nbsp; &nbsp; <span style="color: #009900;">&lt;<span style="color: #66cc66;">/</span>footer&gt;</span><br />
<span style="color: #009900;">&lt;<span style="color: #66cc66;">/</span>article&gt;</span><br />
<br />
<span style="color: #808080; font-style: italic;">&lt;!--[if lt IE 9]&gt;&lt;/div&gt;&lt;![endif]--&gt;</span></div></td></tr></tbody></table></div>
<p>The div is added for browsers IE8 and below, you can then use it as a hook to pull in the elements inside the div. I was hoping that wrapping the HTML5 elements in a standard div would be the end of it, I&#8217;m afraid not. The .load() method still didn&#8217;t work, IE just ignored the elements it didn&#8217;t recognise. I used jQuerys much more customisable .ajax() method to fix the issue in IE6, 7 and 8:</p>
<div class="codecolorer-container javascript default customCodeColor" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;width:435px;height:300px;"><table cellspacing="0" cellpadding="0"><tbody><tr><td style="padding:5px;text-align:center;color:#888888;background-color:#EEEEEE;border-right: 1px solid #9F9F9F;font: normal 12px/1.4em Monaco, Lucida Console, monospace;"><div>1<br />2<br />3<br />4<br />5<br />6<br />7<br />8<br />9<br />10<br />11<br />12<br />13<br />14<br />15<br />16<br />17<br />18<br />19<br />20<br />21<br />22<br />23<br />24<br />25<br /></div></td><td><div class="javascript codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap"><span style="color: #006600; font-style: italic;">//IE8- work around to load HTML5 elements into a page</span><br />
$<span style="color: #009900;">&#40;</span><span style="color: #3366CC;">&quot;#loadHTML5LinkOld&quot;</span><span style="color: #009900;">&#41;</span>.<span style="color: #660066;">click</span><span style="color: #009900;">&#40;</span><span style="color: #003366; font-weight: bold;">function</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#123;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; $.<span style="color: #660066;">ajax</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#123;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; url<span style="color: #339933;">:</span> <span style="color: #3366CC;">&quot;page_to_load.html&quot;</span><span style="color: #339933;">,</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; cache<span style="color: #339933;">:</span> <span style="color: #003366; font-weight: bold;">false</span><span style="color: #339933;">,</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; success<span style="color: #339933;">:</span> <span style="color: #003366; font-weight: bold;">function</span><span style="color: #009900;">&#40;</span>html<span style="color: #009900;">&#41;</span><span style="color: #009900;">&#123;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #003366; font-weight: bold;">var</span> HTML<span style="color: #339933;">;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #006600; font-style: italic;">//Clear before load</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; $<span style="color: #009900;">&#40;</span><span style="color: #3366CC;">&quot;#html5LoadHolder&quot;</span><span style="color: #009900;">&#41;</span>.<span style="color: #660066;">empty</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #006600; font-style: italic;">//IE: Look for the hacky wrapper before insertion</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; HTML <span style="color: #339933;">=</span> $<span style="color: #009900;">&#40;</span>html<span style="color: #009900;">&#41;</span>.<span style="color: #660066;">filter</span><span style="color: #009900;">&#40;</span><span style="color: #3366CC;">&quot;div#ieHackContainer&quot;</span><span style="color: #009900;">&#41;</span>.<span style="color: #660066;">html</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #006600; font-style: italic;">//If HTML var is empty assume using newer browsers</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #000066; font-weight: bold;">if</span><span style="color: #009900;">&#40;</span><span style="color: #339933;">!</span>HTML<span style="color: #009900;">&#41;</span><span style="color: #009900;">&#123;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; HTML <span style="color: #339933;">=</span> $<span style="color: #009900;">&#40;</span>html<span style="color: #009900;">&#41;</span>.<span style="color: #660066;">filter</span><span style="color: #009900;">&#40;</span><span style="color: #3366CC;">&quot;#html5Content&quot;</span><span style="color: #009900;">&#41;</span>.<span style="color: #660066;">html</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #009900;">&#125;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #006600; font-style: italic;">//Append to page</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; $<span style="color: #009900;">&#40;</span><span style="color: #3366CC;">&quot;#html5LoadHolder&quot;</span><span style="color: #009900;">&#41;</span>.<span style="color: #660066;">append</span><span style="color: #009900;">&#40;</span>HTML<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #009900;">&#125;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #009900;">&#125;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #000066; font-weight: bold;">return</span> <span style="color: #003366; font-weight: bold;">false</span><span style="color: #339933;">;</span><br />
<span style="color: #009900;">&#125;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span></div></td></tr></tbody></table></div>
<p>This method works in all browsers I&#8217;ve tested in as I&#8217;ve added a fall back (or should that be forward?) for newer browsers. The solution isn&#8217;t ideal (I really hate the conditional comments), but older versions of IE aren&#8217;t going away any time soon, and it works. Maybe there&#8217;s a more obvious solution that I missed? Leave a comment if there is, I&#8217;d love to know!</p>
<p>You can see a working example <a href="http://dl.dropbox.com/u/7851949/html5-load-method/index.html">here</a>. The page I&#8217;m loading from is <a href="http://dl.dropbox.com/u/7851949/html5-load-method/page_to_load.html">here</a> and the JavaScript in full <a href="http://dl.dropbox.com/u/7851949/html5-load-method/js/html5test.js">here</a>.</p>
]]></content:encoded>
			<wfw:commentRss>http://nooshu.com/remote-loading-html5-elements-with-jquery/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>dat.gui &#8211; controller library for JavaScript</title>
		<link>http://nooshu.com/dat-gui-controller-library-for-javascript?utm_source=rss&#038;utm_medium=rss&#038;utm_campaign=dat-gui-controller-library-for-javascript</link>
		<comments>http://nooshu.com/dat-gui-controller-library-for-javascript#comments</comments>
		<pubDate>Wed, 16 Nov 2011 02:14:45 +0000</pubDate>
		<dc:creator>Matt</dc:creator>
				<category><![CDATA[Experiments]]></category>
		<category><![CDATA[Interesting]]></category>
		<category><![CDATA[JavaScript]]></category>
		<category><![CDATA[Vanilla JavaScript]]></category>
		<category><![CDATA[controller]]></category>
		<category><![CDATA[euler]]></category>
		<category><![CDATA[library]]></category>

		<guid isPermaLink="false">http://nooshu.com/?p=1933</guid>
		<description><![CDATA[Building a demo in JavaScript? Then you really need to start using the dat.gui library. It takes the hassle out of controlling your variables. ]]></description>
			<content:encoded><![CDATA[<p>Very recently I&#8217;ve been looking at some awesome JavaScript experiments and have noticed they are all using the same GUI. Now I fully admit I had a little &#8216;blonde&#8217; moment as I assumed it was just a style everyone had adopted; developers being &#8216;one of the cool kids&#8217;, that type of thing. It turns out I was wrong, and it finally clicked. All the experiments have started using a little controller library called <a href="http://code.google.com/p/dat-gui/">dat.gui</a>.</p>
<p>After it appeared on <a href="http://workshop.chromeexperiments.com/">Google&#8217;s workshop</a> (along with three.js), I thought it was about time I had a play with this neat little library. Luckily there&#8217;s an excellent set of documentation and <a href="http://workshop.chromeexperiments.com/examples/gui/#1--Basic-Usage">working examples</a> available so you can dive right in. Here&#8217;s a code example of how to get started:</p>
<div class="codecolorer-container javascript default customCodeColor" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;width:435px;height:300px;"><table cellspacing="0" cellpadding="0"><tbody><tr><td style="padding:5px;text-align:center;color:#888888;background-color:#EEEEEE;border-right: 1px solid #9F9F9F;font: normal 12px/1.4em Monaco, Lucida Console, monospace;"><div>1<br />2<br />3<br />4<br />5<br />6<br />7<br />8<br />9<br />10<br />11<br />12<br />13<br />14<br />15<br />16<br />17<br />18<br />19<br />20<br />21<br />22<br />23<br />24<br />25<br />26<br /></div></td><td><div class="javascript codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap"><span style="color: #006600; font-style: italic;">//Define the controller function</span><br />
<span style="color: #003366; font-weight: bold;">var</span> FresnelControls <span style="color: #339933;">=</span> <span style="color: #003366; font-weight: bold;">function</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span><br />
&nbsp; &nbsp; <span style="color: #000066; font-weight: bold;">this</span>.<span style="color: #660066;">movingParticles</span> <span style="color: #339933;">=</span> <span style="color: #CC0000;">5000</span><span style="color: #339933;">;</span><br />
&nbsp; &nbsp; <span style="color: #000066; font-weight: bold;">this</span>.<span style="color: #660066;">seedColor</span> <span style="color: #339933;">=</span> <span style="color: #3366CC;">&quot;#ff0098&quot;</span><span style="color: #339933;">;</span><br />
<span style="color: #009900;">&#125;</span><span style="color: #339933;">;</span><br />
<br />
<span style="color: #006600; font-style: italic;">//Create the Dat.gui controls</span><br />
<span style="color: #003366; font-weight: bold;">var</span> fc <span style="color: #339933;">=</span> <span style="color: #003366; font-weight: bold;">new</span> FresnelControls<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span><br />
<br />
<span style="color: #006600; font-style: italic;">//Create the GUI</span><br />
<span style="color: #003366; font-weight: bold;">var</span> gui <span style="color: #339933;">=</span> <span style="color: #003366; font-weight: bold;">new</span> dat.<span style="color: #660066;">GUI</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span><br />
<br />
<span style="color: #006600; font-style: italic;">//Add 2 folders</span><br />
<span style="color: #003366; font-weight: bold;">var</span> f1 <span style="color: #339933;">=</span> gui.<span style="color: #660066;">addFolder</span><span style="color: #009900;">&#40;</span><span style="color: #3366CC;">'Particle Dynamics'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span><br />
<span style="color: #003366; font-weight: bold;">var</span> f2 <span style="color: #339933;">=</span> gui.<span style="color: #660066;">addFolder</span><span style="color: #009900;">&#40;</span><span style="color: #3366CC;">'Particle Colours'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <br />
<span style="color: #006600; font-style: italic;">//Add the moving particles controller to folder 1</span><br />
f1.<span style="color: #660066;">add</span><span style="color: #009900;">&#40;</span>fc<span style="color: #339933;">,</span> <span style="color: #3366CC;">'movingParticles'</span><span style="color: #339933;">,</span> <span style="color: #CC0000;">0</span><span style="color: #339933;">,</span> <span style="color: #CC0000;">5000</span><span style="color: #009900;">&#41;</span>.<span style="color: #660066;">step</span><span style="color: #009900;">&#40;</span><span style="color: #CC0000;">1</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span><br />
<br />
<span style="color: #006600; font-style: italic;">//Add the colour controller, store in a var to attach events</span><br />
<span style="color: #003366; font-weight: bold;">var</span> seedColor <span style="color: #339933;">=</span> f2.<span style="color: #660066;">addColor</span><span style="color: #009900;">&#40;</span>fc<span style="color: #339933;">,</span> <span style="color: #3366CC;">'seedColor'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span><br />
<br />
<span style="color: #006600; font-style: italic;">//Colour change event</span><br />
seedColor.<span style="color: #660066;">onChange</span><span style="color: #009900;">&#40;</span><span style="color: #003366; font-weight: bold;">function</span><span style="color: #009900;">&#40;</span>value<span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span><br />
&nbsp; &nbsp; <span style="color: #006600; font-style: italic;">//Do something on color change...</span><br />
<span style="color: #009900;">&#125;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span></div></td></tr></tbody></table></div>
<p>I decided to dig out an <a href="http://nooshu.com/animating-the-euler-spiral">old demo</a> I created last year and adapt it to use dat.gui. Originally I used jQuery + jQuery UI to control the JavaScript variables. It worked well, but it really added page weight (jQuery + UI came to over 90Kb); not great when you are only using it for the sliders. </p>
<p>Following the documentation you start off simple and progressively add more of the dat.gui functionality. You can see my adapted demo <a href="http://dl.dropbox.com/u/7851949/euler-dat/index.html">here</a>. The dat.gui code is highlighted if you want to see how it was set up.</p>
<div id="attachment_1936" class="wp-caption alignnone" style="width: 528px"><a href="http://dl.dropbox.com/u/7851949/euler-dat/index.html"><img src="http://nooshu.com/wp-content/uploads/2011/11/datgui-518x205.jpg" alt="Dat.gui in action on the Euler Spiral demo I created." title="datgui" width="518" height="205" class="size-medium wp-image-1936" /></a><p class="wp-caption-text">You can see dat.gui in action on my modified Euler Spiral demo.</p></div>
<p>Dat.gui really has some excellent features available. I was able to make use of the colour picker, presets and folder functionality; but there&#8217;s a whole host of others I didn&#8217;t, such as the <a href="http://workshop.chromeexperiments.com/examples/gui/#8--Custom-Placement">custom placement</a> and <a href="http://workshop.chromeexperiments.com/examples/gui/#9--Updating-the-Display-Automatically">updating the display automatically</a>. Personally I love the presets functionality; supply the GUI with a little bit of JSON and away you go!</p>
<p>As always, a big thank you goes out to the Data Arts Team in Google’s Creative Lab for creating such a useful little library! One I will be using in every demo I create from now on.</p>
]]></content:encoded>
			<wfw:commentRss>http://nooshu.com/dat-gui-controller-library-for-javascript/feed</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>A little bit of MicroJS</title>
		<link>http://nooshu.com/a-little-bit-of-microjs?utm_source=rss&#038;utm_medium=rss&#038;utm_campaign=a-little-bit-of-microjs</link>
		<comments>http://nooshu.com/a-little-bit-of-microjs#comments</comments>
		<pubDate>Sun, 29 May 2011 18:12:10 +0000</pubDate>
		<dc:creator>Matt</dc:creator>
				<category><![CDATA[Interesting]]></category>
		<category><![CDATA[JavaScript]]></category>
		<category><![CDATA[Vanilla JavaScript]]></category>
		<category><![CDATA[code]]></category>
		<category><![CDATA[library]]></category>
		<category><![CDATA[small]]></category>

		<guid isPermaLink="false">http://nooshu.com/?p=1732</guid>
		<description><![CDATA[For some projects you may not need a fully featured JavaScript library. But what are the alternatives?]]></description>
			<content:encoded><![CDATA[<p>Recently there was a flurry of talk around a little something called MicroJS, mainly thanks to a website of the same name created by <a href="http://mir.aculo.us/">Thomas Fuchs</a>, author of the <a href="http://script.aculo.us/">script.aculo.us</a> user interface library. I&#8217;m not sure if Thomas coined the term &#8220;MicroJS&#8221; or if it&#8217;s been in use for a while, but it describes the micro-framework methodology perfectly. So what is a micro-framework? The best way to answer that is to first ask what is a JavaScript framework?</p>
<p>JavaScript frameworks have been around since around 2005 (looking at the Prototype and jQuery history); their purpose is to allow developers to easily add interactivity to a page by creating a JavaScript abstraction layer to build from. The library takes care of any cross browser issues and quirks, allowing developers to focus on the &#8220;cool&#8221; stuff, building websites. As a developer I can&#8217;t thank all the library authors enough; without them my working life would be so much more stressful (and my hair would be even grayer than it is now!).</p>
<p>Once you know what a JavaScript framework is, it doesn&#8217;t take a genius to guess what a micro-framework is. Where as a full framework will have many tools (methods) a developer can use, a micro-framework only focuses on a very specific set of functions. I like the knife analogy: a full-framework like Dojo would be a Swiss Army knife where as a micro-framework could be considered a small pen knife. So which do you use in a project? This completely depends on the project in hand. I&#8217;ve put together a small list of pros and cons for each (let me know if you have any others):</p>
<h3>Full Framework</h3>
<ul>
<li><strong>Pros</strong></li>
<li>Extensive set of features to cater for most eventualities.</li>
<li>Consistent API across features.</li>
<li>Large user base with lots of community support.</li>
<li>Huge number of working examples available.</li>
<li>Many developers to fix bugs and add additional functionality.</li>
<li>Single point of reference of documentation.</li>
</ul>
<ul>
<li><strong>Cons</strong></li>
<li>Large code base could be very daunting to new users.</li>
<li>Large page footprint.</li>
<li>Many features of the library may not be needed.</li>
</ul>
<h3>Micro-Framework</h3>
<ul>
<li><strong>Pros</strong></li>
<li>Small page weight, usually less than 5K.</li>
<li>Small set of features so very quick to pick up and use.</li>
<li>Main focus on a very specific set of functionality.</li>
<li>No feature creep or excess code.</li>
<li>Use the right tool for the right job.</li>
</ul>
<ul>
<li><strong>Cons</strong></li>
<li>Small number of developers, bugs and issues may take a while to be fixed.</li>
<li>Development of the framework may stop completely.</li>
<li>May be very little support from the author and the community.</li>
<li>Fellow developers in your team may not be familiar with the framework.</li>
<li>Mixing micro-frameworks could conflict if badly coded.</li>
<li>Multiple frameworks could mean multiple HTTP requests.</li>
<li>Multiple points of reference for API docs.</li>
<li>Multiple frameworks could lead to an overlap in functionality.</li>
</ul>
<p>Many of the cons for micro-frameworks stem from using more than one at a time, but if you only plan on using one then they can be ignored.</p>
<p>Micro-frameworks caught my eye recently due to a couple of small projects I&#8217;d been working on. The projects all used vanilla JavaScript as there was no need for a helper library. I later realised I needed to attach a few events and manipulate the DOM but I wanted to avoid including jQuery in the project as I only needed a small fraction of its functionality. Luckily the MicroJS website came to the rescue.</p>
<p>The examples below are taken from <a href="https://github.com/ded/qwery">Query</a>, <a href="https://github.com/ded/bonzo">Bonzo</a>, <a href="https://github.com/kbjr/Events.js">Events.js</a> and <a href="https://github.com/fat/bean">Bean</a>. As you can see the usage for each is pretty self-explanatory with lots more functionality is available from each library&#8217;s website. If you&#8217;re a jQuery user the syntax will look <a href="http://www.dustindiaz.com/qwery">very familiar</a>.</p>
<p><strong>CSS selector and DOM utility</strong></p>
<div class="codecolorer-container javascript default customCodeColor" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;width:435px;"><table cellspacing="0" cellpadding="0"><tbody><tr><td style="padding:5px;text-align:center;color:#888888;background-color:#EEEEEE;border-right: 1px solid #9F9F9F;font: normal 12px/1.4em Monaco, Lucida Console, monospace;"><div>1<br />2<br />3<br />4<br />5<br />6<br />7<br />8<br />9<br />10<br />11<br />12<br />13<br />14<br />15<br />16<br />17<br />18<br />19<br /></div></td><td><div class="javascript codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap"><span style="color: #006600; font-style: italic;">/*<br />
Query - Dustin Diaz<br />
https://github.com/ded/qwery<br />
CSS selector engine<br />
*/</span><br />
query<span style="color: #009900;">&#40;</span><span style="color: #3366CC;">&quot;#myid&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span><br />
query<span style="color: #009900;">&#40;</span><span style="color: #3366CC;">&quot;.myclass&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span><br />
query<span style="color: #009900;">&#40;</span><span style="color: #3366CC;">&quot;#myid .myclass div a&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span><br />
query<span style="color: #009900;">&#40;</span><span style="color: #3366CC;">&quot;a, div, strong&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span><br />
<br />
<span style="color: #006600; font-style: italic;">/*<br />
Query Paired with Bonzo - Dustin Diaz<br />
https://github.com/ded/bonzo<br />
DOM utility<br />
*/</span><br />
query<span style="color: #009900;">&#40;</span><span style="color: #3366CC;">&quot;#myid&quot;</span><span style="color: #009900;">&#41;</span>.<span style="color: #660066;">show</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span><br />
query<span style="color: #009900;">&#40;</span><span style="color: #3366CC;">&quot;.myclass&quot;</span><span style="color: #009900;">&#41;</span>.<span style="color: #660066;">offset</span><span style="color: #009900;">&#40;</span><span style="color: #CC0000;">50</span><span style="color: #339933;">,</span> <span style="color: #CC0000;">100</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span><br />
query<span style="color: #009900;">&#40;</span><span style="color: #3366CC;">&quot;#myid .myclass div a&quot;</span><span style="color: #009900;">&#41;</span>.<span style="color: #660066;">addClass</span><span style="color: #009900;">&#40;</span><span style="color: #3366CC;">&quot;anchorClass&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span><br />
query<span style="color: #009900;">&#40;</span><span style="color: #3366CC;">&quot;a, div, strong&quot;</span><span style="color: #009900;">&#41;</span>.<span style="color: #660066;">remove</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span></div></td></tr></tbody></table></div>
<p><strong>Events</strong></p>
<div class="codecolorer-container javascript default customCodeColor" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;width:435px;height:300px;"><table cellspacing="0" cellpadding="0"><tbody><tr><td style="padding:5px;text-align:center;color:#888888;background-color:#EEEEEE;border-right: 1px solid #9F9F9F;font: normal 12px/1.4em Monaco, Lucida Console, monospace;"><div>1<br />2<br />3<br />4<br />5<br />6<br />7<br />8<br />9<br />10<br />11<br />12<br />13<br />14<br />15<br />16<br />17<br />18<br />19<br />20<br />21<br />22<br />23<br />24<br />25<br />26<br />27<br />28<br />29<br />30<br />31<br />32<br />33<br />34<br />35<br /></div></td><td><div class="javascript codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap"><span style="color: #006600; font-style: italic;">/*<br />
Events.js - James Brumond<br />
https://github.com/kbjr/Events.js<br />
Event handler library<br />
*/</span><br />
Events.<span style="color: #660066;">bind</span><span style="color: #009900;">&#40;</span>window<span style="color: #339933;">,</span> <span style="color: #3366CC;">'load'</span><span style="color: #339933;">,</span> <span style="color: #003366; font-weight: bold;">function</span><span style="color: #009900;">&#40;</span>e<span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span><br />
&nbsp; &nbsp; <span style="color: #006600; font-style: italic;">//Page loaded, do something</span><br />
<span style="color: #009900;">&#125;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span><br />
<span style="color: #006600; font-style: italic;">//Invoke the page load event</span><br />
Events.<span style="color: #660066;">invoke</span><span style="color: #009900;">&#40;</span>window<span style="color: #339933;">,</span> <span style="color: #3366CC;">'load'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span><br />
<span style="color: #006600; font-style: italic;">//Mouse click event</span><br />
Events.<span style="color: #660066;">bind</span><span style="color: #009900;">&#40;</span>selectedElements<span style="color: #339933;">,</span> <span style="color: #3366CC;">'click'</span><span style="color: #339933;">,</span> <span style="color: #003366; font-weight: bold;">function</span><span style="color: #009900;">&#40;</span>e<span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span><br />
&nbsp; &nbsp; <span style="color: #006600; font-style: italic;">//Mouse has been clicked</span><br />
<span style="color: #009900;">&#125;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span><br />
<span style="color: #006600; font-style: italic;">//Very handy keystroke event</span><br />
Events.<span style="color: #660066;">bind</span><span style="color: #009900;">&#40;</span>document<span style="color: #339933;">,</span> <span style="color: #3366CC;">'keystroke.Ctrl+Shift+Alt+S'</span><span style="color: #339933;">,</span> <span style="color: #003366; font-weight: bold;">function</span><span style="color: #009900;">&#40;</span>e<span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span><br />
&nbsp; &nbsp; saveMySlices<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span><br />
<span style="color: #009900;">&#125;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span><br />
<br />
<span style="color: #006600; font-style: italic;">/*<br />
Bean - Dustin Diaz<br />
https://github.com/fat/bean<br />
Event handler library<br />
*/</span><br />
bean.<span style="color: #660066;">add</span><span style="color: #009900;">&#40;</span>selectedElements<span style="color: #339933;">,</span> <span style="color: #3366CC;">'click'</span><span style="color: #339933;">,</span> <span style="color: #003366; font-weight: bold;">function</span> <span style="color: #009900;">&#40;</span>e<span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span><br />
&nbsp; &nbsp; <span style="color: #006600; font-style: italic;">//Mouse has been clicked</span><br />
<span style="color: #009900;">&#125;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span><br />
<span style="color: #006600; font-style: italic;">//DOM has loaded</span><br />
bean.<span style="color: #660066;">add</span><span style="color: #009900;">&#40;</span>document<span style="color: #339933;">,</span> <span style="color: #3366CC;">'DOMContentLoaded'</span><span style="color: #339933;">,</span> <span style="color: #003366; font-weight: bold;">function</span><span style="color: #009900;">&#40;</span>e<span style="color: #009900;">&#41;</span><span style="color: #009900;">&#123;</span><br />
&nbsp; &nbsp; <span style="color: #006600; font-style: italic;">//Page loaded, do something</span><br />
<span style="color: #009900;">&#125;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span><br />
<span style="color: #006600; font-style: italic;">//Invoke an event on an element</span><br />
bean.<span style="color: #660066;">fire</span><span style="color: #009900;">&#40;</span>selectedElement<span style="color: #339933;">,</span> <span style="color: #3366CC;">'click'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span><br />
<span style="color: #006600; font-style: italic;">//Remove the event from an element</span><br />
bean.<span style="color: #660066;">remove</span><span style="color: #009900;">&#40;</span>selectedElement<span style="color: #339933;">,</span> <span style="color: #3366CC;">'click'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span></div></td></tr></tbody></table></div>
<p>I&#8217;ll be trying out a few more of these micro-frameworks for my personal projects in the future as the ability to select only the functionality you need really appeals to me. Are there any other micro-frameworks you&#8217;ve used that you&#8217;d recommend? Leave me a comment and I&#8217;ll check them out.</p>
<p><strong>Update</strong>: It just so happens that a handy library website has emerged inspired by the MicroJS website called <a href="http://www.everyjs.com/">EveryJS</a>. The website lists all library&#8217;s rather than just micro versions. Not all are listed but I&#8217;m sure they will be added soon so it&#8217;s one to keep your eye on.</p>
]]></content:encoded>
			<wfw:commentRss>http://nooshu.com/a-little-bit-of-microjs/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Fun with Space Invaders and Parallax scrolling</title>
		<link>http://nooshu.com/fun-with-space-invaders-and-parallax-scrolling?utm_source=rss&#038;utm_medium=rss&#038;utm_campaign=fun-with-space-invaders-and-parallax-scrolling</link>
		<comments>http://nooshu.com/fun-with-space-invaders-and-parallax-scrolling#comments</comments>
		<pubDate>Wed, 25 May 2011 23:25:47 +0000</pubDate>
		<dc:creator>Matt</dc:creator>
				<category><![CDATA[Canvas]]></category>
		<category><![CDATA[Experiments]]></category>
		<category><![CDATA[JavaScript]]></category>
		<category><![CDATA[aliens]]></category>

		<guid isPermaLink="false">http://nooshu.com/?p=1723</guid>
		<description><![CDATA[Loving the HTML5 Canvas element. Having fun with the parallax effect and a few aliens.]]></description>
			<content:encoded><![CDATA[<p>Back when I was a young wippersnapper (many moons ago) one of my good friends had a <a href="http://en.wikipedia.org/wiki/Mega_Drive">Sega Mega Drive</a>. As with any new console it was on every kids Christmas list but compared to the current generation of games consoles it looks very primitive. The games were immense fun and you didn&#8217;t need an instruction manual to play them. Two of my favourite games were <a href="http://en.wikipedia.org/wiki/Golden_Axe">Golden Axe</a> and <a href="http://en.wikipedia.org/wiki/Sonic_the_Hedgehog_(video_game)">Sonic the Hedgehog</a>. Sonic the Hedgehog used a technique called <a href="http://en.wikipedia.org/wiki/Parallax_scrolling">Parallax scrolling</a>; this is where background images move slower than &#8220;closer&#8221; foreground images giving the illusion of depth in a 2D plane.</p>
<p>I&#8217;m quite late to the web parallax party as the effect was recreated and popularised back in 2008. I first remember seeing it being used by the holding page for Clearleft&#8217;s <a href="http://silverbackapp.com/">Silverback application</a>, but it may have appeared elsewhere before that. Three years on the web is a long time and technology has moved on, so I set myself a little project to recreate the effect using the HTML5 canvas element.</p>
<div id="attachment_1724" class="wp-caption alignnone" style="width: 528px"><a href="http://dl.dropbox.com/u/7851949/space-invaders/index.html"><img src="http://nooshu.com/wp-content/uploads/2011/05/space-invader-parallax.gif" alt="Parallax scrolling using a Space Invaders alien" title="space-invader-parallax" width="518" height="357" class="size-full wp-image-1724" /></a><p class="wp-caption-text">Move your mouse to see the Parallax scrolling effect.</p></div>
<p>To demonstrate the effect I used a few graphics from another iconic retro game: <a href="http://en.wikipedia.org/wiki/Space_Invaders">Space Invaders</a>. As you move the mouse the scary alien separates into its constituent pixels. The foreground pixels move faster than the background pixels creating a slight parallax effect. You have three aliens to choose from: Dave, Julian and Brian, which I&#8217;ve named for no particular reason. I think the names quite suit them. I&#8217;ve also added a little randomness to the demo in how they are generated, which you can see by reloading the page.</p>
<p>Hooray for retro games and <a href="http://dl.dropbox.com/u/7851949/space-invaders/index.html">pointless demo&#8217;s</a>! :) </p>
]]></content:encoded>
			<wfw:commentRss>http://nooshu.com/fun-with-space-invaders-and-parallax-scrolling/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Antimatter 3D Graph Plotter and a little animation</title>
		<link>http://nooshu.com/antimatter-3d-graph-plotter-and-a-little-animation?utm_source=rss&#038;utm_medium=rss&#038;utm_campaign=antimatter-3d-graph-plotter-and-a-little-animation</link>
		<comments>http://nooshu.com/antimatter-3d-graph-plotter-and-a-little-animation#comments</comments>
		<pubDate>Tue, 17 May 2011 08:32:35 +0000</pubDate>
		<dc:creator>Matt</dc:creator>
				<category><![CDATA[Experiments]]></category>
		<category><![CDATA[Inspiration]]></category>
		<category><![CDATA[JavaScript]]></category>
		<category><![CDATA[Three.js]]></category>
		<category><![CDATA[graph]]></category>
		<category><![CDATA[maths]]></category>
		<category><![CDATA[plotter]]></category>
		<category><![CDATA[three.js]]></category>

		<guid isPermaLink="false">http://nooshu.com/?p=1691</guid>
		<description><![CDATA[Three.js is a powerful 3D library. Graph plotter and a little bit of experimentation is good fun!]]></description>
			<content:encoded><![CDATA[<p>Last year I stumbled upon this <a href="http://antimatter15.com/wp/2010/05/simple-javascript-3d-function-plotter/">blog post</a> by <a href="http://twitter.com/#!/antimatter15">@antimatter15</a> who added a little three line modification to mr.doobs <a href="http://mrdoob.github.com/three.js/examples/canvas_particles_floor.html">particle floor demo</a> and created a graph plotter in three.js. Unfortunately as three.js has developed and evolved the API has changed; in doing so it broke the graphing demo. I left a message asking if there was a fix on Antimatters blog but got no response. So I decided to update the code and fix it for the latest version of <a href="https://github.com/mrdoob/three.js/">three.js</a>; once updated for the latest API it ran as expected.</p>
<div id="attachment_1694" class="wp-caption alignnone" style="width: 528px"><a href="http://dl.dropbox.com/u/7851949/plotter/index.html?cos(sqrt(sq(x)+sq(y)))/3"><img src="http://nooshu.com/wp-content/uploads/2011/05/antimatter-graph-plotter.gif" alt="3D graph plotter using three.js" title="antimatter-graph-plotter" width="518" height="312" class="size-full wp-image-1694" /></a><p class="wp-caption-text">Antimatter15 graph plotter updated for latest version of three.js.</p></div>
<p>You pass the equation you wish to plot via a URL parameter and out the other pops a pretty 3D graph. Here are a couple of examples taken from the <a href="http://antimatter15.com/wp/2010/05/simple-javascript-3d-function-plotter/">original blog post</a>:</p>
<ul>
<li><a href="http://dl.dropbox.com/u/7851949/plotter/index.html?sin(sqrt(sq(x)+sq(y)))/5">sin(sqrt(sq(x)+sq(y)))/5</a></li>
<li><a href="http://dl.dropbox.com/u/7851949/plotter/index.html?sin(sqrt(sq(x)+sq(y)))/sqrt(sq(x)+sq(y))">sin(sqrt(sq(x)+sq(y)))/sqrt(sq(x)+sq(y))</a></li>
</ul>
<p>In updating the code I thought I&#8217;d have a little play myself and see if I could add a bit of motion to the graphs just for the fun of it. I&#8217;ve created a version of my own which you can <a href="http://dl.dropbox.com/u/7851949/animated-plotter/index.html">view here</a>.</p>
<div id="attachment_1700" class="wp-caption alignnone" style="width: 528px"><a href="http://dl.dropbox.com/u/7851949/animated-plotter/index.html"><img src="http://nooshu.com/wp-content/uploads/2011/05/animated-plotter.gif" alt="Graphing multiple for formula using JavaScript and three.js" title="animated-plotter" width="518" height="215" class="size-full wp-image-1700" /></a><p class="wp-caption-text">Modified version allows you to add more than one formula to plot.</p></div>
<p>In my version you no longer pass the formula you wish to plot via a URL parameter, you add it via the panel on the right hand side. You can add and remove as many equations as you wish and the demo will cycle between them. To do so update the right hand panel then click the &#8220;Plot new formula(e)&#8221; button. The equation that is currently being plotted is highlighted in grey and available mathematical functions listed below.</p>
<p>With a little bit of trial end error you can create some interesting effects. There may not be much practical use for the experiment but I enjoyed putting it together with a little help from mr.doob and antimatter15 :)</p>
]]></content:encoded>
			<wfw:commentRss>http://nooshu.com/antimatter-3d-graph-plotter-and-a-little-animation/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Debug Axes in three.js</title>
		<link>http://nooshu.com/debug-axes-in-three-js?utm_source=rss&#038;utm_medium=rss&#038;utm_campaign=debug-axes-in-three-js</link>
		<comments>http://nooshu.com/debug-axes-in-three-js#comments</comments>
		<pubDate>Sun, 15 May 2011 14:51:31 +0000</pubDate>
		<dc:creator>Matt</dc:creator>
				<category><![CDATA[Experiments]]></category>
		<category><![CDATA[JavaScript]]></category>
		<category><![CDATA[Three.js]]></category>
		<category><![CDATA[debug]]></category>
		<category><![CDATA[three.js]]></category>

		<guid isPermaLink="false">http://nooshu.com/?p=1681</guid>
		<description><![CDATA[Orientate yourself in your three.js with this little bit of JavaScript code. Not the most exciting experiment but I find it very useful!]]></description>
			<content:encoded><![CDATA[<p><strong>Update</strong>: The code I had previously stopped working with the latest three.js API. I&#8217;ve updated and improved the code for the latest API.</p>
<p>I&#8217;ve been working on a couple of small projects using three.js recently; An issue I always seem to have when working with 3D is knowing the current orientation. To help me out I&#8217;ve put together a small snippet of JavaScript.</p>
<div id="attachment_1683" class="wp-caption alignnone" style="width: 528px"><a href="http://dl.dropbox.com/u/7851949/debug-axes/index.html"><img src="http://nooshu.com/wp-content/uploads/2011/05/debug-axis.gif" alt="Creating a set of axis in three.js" title="debug-axes" width="518" height="352" class="size-full wp-image-1683" /></a><p class="wp-caption-text">{x: red, y: green, z: blue} It&#039;s not much to look at but the axes can be very useful.</p></div>
<p>The point where the lines cross is 0,0,0 as you&#8217;d expect, you can adjust the length of the line by changing the axisLength variable. I&#8217;ve uploaded a <a href="http://dl.dropbox.com/u/7851949/debug-axes/index.html">small demo</a> so you can see the code used or copy / paste below:</p>
<div class="codecolorer-container javascript default customCodeColor" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;width:435px;height:300px;"><table cellspacing="0" cellpadding="0"><tbody><tr><td style="padding:5px;text-align:center;color:#888888;background-color:#EEEEEE;border-right: 1px solid #9F9F9F;font: normal 12px/1.4em Monaco, Lucida Console, monospace;"><div>1<br />2<br />3<br />4<br />5<br />6<br />7<br />8<br />9<br />10<br />11<br />12<br />13<br />14<br />15<br />16<br />17<br />18<br />19<br />20<br />21<br />22<br /></div></td><td><div class="javascript codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap"><span style="color: #003366; font-weight: bold;">var</span> debugaxis <span style="color: #339933;">=</span> <span style="color: #003366; font-weight: bold;">function</span><span style="color: #009900;">&#40;</span>axisLength<span style="color: #009900;">&#41;</span><span style="color: #009900;">&#123;</span><br />
&nbsp; &nbsp; <span style="color: #006600; font-style: italic;">//Shorten the vertex function</span><br />
&nbsp; &nbsp; <span style="color: #003366; font-weight: bold;">function</span> v<span style="color: #009900;">&#40;</span>x<span style="color: #339933;">,</span>y<span style="color: #339933;">,</span>z<span style="color: #009900;">&#41;</span><span style="color: #009900;">&#123;</span> <br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #000066; font-weight: bold;">return</span> <span style="color: #003366; font-weight: bold;">new</span> THREE.<span style="color: #660066;">Vertex</span><span style="color: #009900;">&#40;</span><span style="color: #003366; font-weight: bold;">new</span> THREE.<span style="color: #660066;">Vector3</span><span style="color: #009900;">&#40;</span>x<span style="color: #339933;">,</span>y<span style="color: #339933;">,</span>z<span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span> <br />
&nbsp; &nbsp; <span style="color: #009900;">&#125;</span><br />
&nbsp; &nbsp; <br />
&nbsp; &nbsp; <span style="color: #006600; font-style: italic;">//Create axis (point1, point2, colour)</span><br />
&nbsp; &nbsp; <span style="color: #003366; font-weight: bold;">function</span> createAxis<span style="color: #009900;">&#40;</span>p1<span style="color: #339933;">,</span> p2<span style="color: #339933;">,</span> color<span style="color: #009900;">&#41;</span><span style="color: #009900;">&#123;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #003366; font-weight: bold;">var</span> line<span style="color: #339933;">,</span> lineGeometry <span style="color: #339933;">=</span> <span style="color: #003366; font-weight: bold;">new</span> THREE.<span style="color: #660066;">Geometry</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">,</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; lineMat <span style="color: #339933;">=</span> <span style="color: #003366; font-weight: bold;">new</span> THREE.<span style="color: #660066;">LineBasicMaterial</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#123;</span>color<span style="color: #339933;">:</span> color<span style="color: #339933;">,</span> lineWidth<span style="color: #339933;">:</span> <span style="color: #CC0000;">1</span><span style="color: #009900;">&#125;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; lineGeometry.<span style="color: #660066;">vertices</span>.<span style="color: #660066;">push</span><span style="color: #009900;">&#40;</span>p1<span style="color: #339933;">,</span> p2<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; line <span style="color: #339933;">=</span> <span style="color: #003366; font-weight: bold;">new</span> THREE.<span style="color: #660066;">Line</span><span style="color: #009900;">&#40;</span>lineGeometry<span style="color: #339933;">,</span> lineMat<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; scene.<span style="color: #660066;">add</span><span style="color: #009900;">&#40;</span>line<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span><br />
&nbsp; &nbsp; <span style="color: #009900;">&#125;</span><br />
&nbsp; &nbsp; <br />
&nbsp; &nbsp; createAxis<span style="color: #009900;">&#40;</span>v<span style="color: #009900;">&#40;</span><span style="color: #339933;">-</span>axisLength<span style="color: #339933;">,</span> <span style="color: #CC0000;">0</span><span style="color: #339933;">,</span> <span style="color: #CC0000;">0</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">,</span> v<span style="color: #009900;">&#40;</span>axisLength<span style="color: #339933;">,</span> <span style="color: #CC0000;">0</span><span style="color: #339933;">,</span> <span style="color: #CC0000;">0</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">,</span> 0xFF0000<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span><br />
&nbsp; &nbsp; createAxis<span style="color: #009900;">&#40;</span>v<span style="color: #009900;">&#40;</span><span style="color: #CC0000;">0</span><span style="color: #339933;">,</span> <span style="color: #339933;">-</span>axisLength<span style="color: #339933;">,</span> <span style="color: #CC0000;">0</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">,</span> v<span style="color: #009900;">&#40;</span><span style="color: #CC0000;">0</span><span style="color: #339933;">,</span> axisLength<span style="color: #339933;">,</span> <span style="color: #CC0000;">0</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">,</span> 0x00FF00<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span><br />
&nbsp; &nbsp; createAxis<span style="color: #009900;">&#40;</span>v<span style="color: #009900;">&#40;</span><span style="color: #CC0000;">0</span><span style="color: #339933;">,</span> <span style="color: #CC0000;">0</span><span style="color: #339933;">,</span> <span style="color: #339933;">-</span>axisLength<span style="color: #009900;">&#41;</span><span style="color: #339933;">,</span> v<span style="color: #009900;">&#40;</span><span style="color: #CC0000;">0</span><span style="color: #339933;">,</span> <span style="color: #CC0000;">0</span><span style="color: #339933;">,</span> axisLength<span style="color: #009900;">&#41;</span><span style="color: #339933;">,</span> 0x0000FF<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span><br />
<span style="color: #009900;">&#125;</span><span style="color: #339933;">;</span><br />
<br />
<span style="color: #006600; font-style: italic;">//To use enter the axis length</span><br />
debugaxis<span style="color: #009900;">&#40;</span><span style="color: #CC0000;">100</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span></div></td></tr></tbody></table></div>
<p>It&#8217;s not much to look at, but it can certainly help you get your bearing when starting a new project (or when things aren&#8217;t working!). Hopefully you find it useful.</p>
]]></content:encoded>
			<wfw:commentRss>http://nooshu.com/debug-axes-in-three-js/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>The Sieve of Eratosthenes</title>
		<link>http://nooshu.com/the-sieve-of-eratosthenes?utm_source=rss&#038;utm_medium=rss&#038;utm_campaign=the-sieve-of-eratosthenes</link>
		<comments>http://nooshu.com/the-sieve-of-eratosthenes#comments</comments>
		<pubDate>Thu, 12 May 2011 15:19:05 +0000</pubDate>
		<dc:creator>Matt</dc:creator>
				<category><![CDATA[Experiments]]></category>
		<category><![CDATA[HTML]]></category>
		<category><![CDATA[Interesting]]></category>
		<category><![CDATA[JavaScript]]></category>
		<category><![CDATA[maths]]></category>

		<guid isPermaLink="false">http://nooshu.com/?p=1670</guid>
		<description><![CDATA[Having fun with a little bit of prime hunting and JavaScript. Maths geek for the win!]]></description>
			<content:encoded><![CDATA[<p>I recently read <a href="http://www.amazon.co.uk/Prime-Obsession-Bernhard-Greatest-Mathematics/dp/0452285259">Prime Obsession by John Derbyshire</a>; a book all about prime numbers and one of the worlds greatest Mathematicians: <a href="http://en.wikipedia.org/wiki/Bernhard_Riemann">Bernhard Riemann</a>. The books main focus is on the <a href="http://en.wikipedia.org/wiki/Riemann_hypothesis">Riemann Hypothesis</a> which states that:</p>
<blockquote><p>The real part of any non-trivial zero of the Riemann zeta function is 1/2.</p></blockquote>
<p>I&#8217;d love to say that after reading the book I understand the Maths behind it but alas I do not. That&#8217;s not surprising though as it&#8217;s a problem that has yet to be solved, 159 years after Riemann paper on &#8220;On the Number of Primes Less Than a Given Magnitude&#8221;. It doesn&#8217;t look like it&#8217;s going to be solved any time soon either! If you&#8217;re interested it&#8217;s one of the Clay Mathematics Institutes <a href="http://en.wikipedia.org/wiki/Millennium_Prize_Problems">Millennium Prize Problems</a> in which you can earn yourself US$1,000,000.</p>
<p>While reading Prime Obsession it mentioned an interesting method for finding prime numbers called &#8220;Sieve of Eratosthenes&#8221; (pronounced air-a-TAWS-the-nEEss). Eratosthenes was a librarian at the great library of Alexandria around 230 B.C.E. It&#8217;s quite obvious how the method works once you know it, and easy to see why it&#8217;s called a sieve. The method goes like this:</p>
<ol>
<li>Write a list of numbers in which you wish to identify the primes, say 2 &#8211; 100 (exclude 1 as it isn&#8217;t required)</li>
<li>Take the first number 2. Leaving 2 intact, remove every second number.</li>
<li>Move onto the next number 3. Leave 3 intact and remove every third number</li>
<li>Take the next number 5. Leave 5 intact and take away every fifth number</li>
<li>Repeat until you get to the end of your list</li>
</ol>
<p>The end result is the set of prime numbers up to your given number. Essentially all you are doing is removing any number that is divisible by the 1st, 2nd&#8230; Nth number. Clever stuff!</p>
<p>As a little side project I decided to implement this method using JavaScript, displaying the result in the browser. You can view the <a href="http://dl.dropbox.com/u/7851949/sieve/index.html">demo here</a>. For fun I created two implementations, one relying heavily on the DOM, the other only using arrays. As you&#8217;d expect the DOM method is slow; looping through large tables multiple times doesn&#8217;t make for a quick execution time. The second method using a single JavaScript array is much quicker. I&#8217;ve added a stats panel to the right hand side of the page so it&#8217;s possible to compare results from both methods over different input values.</p>
<p>I&#8217;ve added a limit to the number you can enter into the input box (5000), I don&#8217;t want anyone blaming me for crashing their browser by entering 10 million! :) Feel free to copy the demo if you want to see what happens at higher values.</p>
<div id="attachment_1672" class="wp-caption alignnone" style="width: 528px"><a href="http://nooshu.com/wp-content/uploads/2011/05/sieve.gif"><img src="http://nooshu.com/wp-content/uploads/2011/05/sieve-518x255.gif" alt="Sieve of Eratosthenes using JavaScript" title="sieve" width="518" height="255" class="size-medium wp-image-1672" /></a><p class="wp-caption-text">The sieve in action showing prime numbers up to 500.</p></div>
<p>Thanks goes to John Resig for his very handy <a href="http://ejohn.org/blog/javascript-array-remove/">Array Remove method</a>.It made removing non-primes from the numbers array very simple indeed.</p>
<p>Prime Obsession is a superb book but a word of warning, it contains a lot of higher level Mathematics, so may not be to everyone&#8217;s taste. It certainly made my brain hurt at times; not always what you need on that 8am commute to work! <a href="http://dl.dropbox.com/u/7851949/sieve/index.html">View the demo</a>.</p>
]]></content:encoded>
			<wfw:commentRss>http://nooshu.com/the-sieve-of-eratosthenes/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Creating 3D trees with some #CreativeJS</title>
		<link>http://nooshu.com/creating-3d-trees-with-some-creativejs?utm_source=rss&#038;utm_medium=rss&#038;utm_campaign=creating-3d-trees-with-some-creativejs</link>
		<comments>http://nooshu.com/creating-3d-trees-with-some-creativejs#comments</comments>
		<pubDate>Mon, 09 May 2011 15:15:06 +0000</pubDate>
		<dc:creator>Matt</dc:creator>
				<category><![CDATA[Canvas]]></category>
		<category><![CDATA[Experiments]]></category>
		<category><![CDATA[Interesting]]></category>
		<category><![CDATA[JavaScript]]></category>
		<category><![CDATA[Three.js]]></category>
		<category><![CDATA[3d]]></category>
		<category><![CDATA[three.js]]></category>
		<category><![CDATA[tree]]></category>

		<guid isPermaLink="false">http://nooshu.com/?p=1654</guid>
		<description><![CDATA[Everyone love trees. What about a few virtual trees created using some JavaScript goodness?]]></description>
			<content:encoded><![CDATA[<div id="attachment_1655" class="wp-caption alignnone" style="width: 528px"><a href="http://dl.dropbox.com/u/7851949/treejs/index.html"><img src="http://nooshu.com/wp-content/uploads/2011/05/threejs-trees.gif" alt="Random trees created using three.js and some creative JavaScript" title="threejs-trees" width="518" height="449" class="size-full wp-image-1655" /></a><p class="wp-caption-text">Trees generated at random using some CreateiveJS and Three.js.</p></div>
<p>Over a month has passed since my last blog post and much has happened. We&#8217;ve had a wedding, a funeral at sea (maybe in bad taste!) and I&#8217;ve gone full-time freelance (yay!). I&#8217;ve had a little more time to work on a couple of personal projects so I&#8217;ve finished one that I started way back in January.</p>
<p>I had the pleasure of attending a <a href="http://sebleedelisle.com/2011/02/creativejs-experiments/">Creative JavaScript course</a> in Brighton, UK, hosted by <a href="http://sebleedelisle.com/">Seb Lee-Delisle</a>; a two-day course that covered a wealth of topics from Vanilla JavaScript to Three.js. If you&#8217;re looking for some inspiration I highly recommend looking out for one of Seb&#8217;s courses. Great fun and you get to meet some really nice people. <strong>Quick tip:</strong> You may want to brush up on a little <a href="http://en.wikipedia.org/wiki/Trigonometry">Trigonometry</a> before you go as it&#8217;s used numerous times. I knew that A-Level Mathematics course would come in useful one day :).</p>
<p>Seb produced a demo in Canvas that created &#8216;trees&#8217; and it really caught my eye. The trees were in 2D so as I&#8217;ve had a bit of experience with <a href="https://github.com/mrdoob/three.js/">Three.js</a> I decided to create a 3D version! I&#8217;m quite happy with the result although I&#8217;ve had to restrict the number of branches rendered due to the lack of dedicated graphics card in my laptop; I get about 1fps when stopping at a branch length value of 10 (line 211) :(</p>
<p><a href="http://dl.dropbox.com/u/7851949/treejs/index.html">The demo</a> also allowed me to use the new request animation frame API which vendors have added to aid animations in browsers. The main advantage of using it is if you have the animation running in a tab that isn&#8217;t visible, the browser will know to stop the animation! Using the old setTimeout method, the animation still runs in the background and uses up precious CPU, memory and battery power (especially on a laptop). As with most new browser features the API isn&#8217;t set in stone (yet) but luckily Paul Irish has <a href="http://paulirish.com/2011/requestanimationframe-for-smart-animating/">created a polyfill</a> that falls back to setTimeout in older browsers. </p>
<p>View the <a href="http://dl.dropbox.com/u/7851949/treejs/index.html">demo here</a>; reload for different trees. JavaScript finally seems to be coming of age!</p>
<p><strong>Update:</strong> Original credit goes to Jean-No with his <a href="http://www.openprocessing.org/portal/?userID=997">amazing OpenProcessing work</a>! I&#8217;ll be bookmarking that link, some stunning work there. Thanks to Seb for pointing out who to credit :)</p>
]]></content:encoded>
			<wfw:commentRss>http://nooshu.com/creating-3d-trees-with-some-creativejs/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>The developing WebGL demoscene</title>
		<link>http://nooshu.com/the-developing-webgl-demoscene?utm_source=rss&#038;utm_medium=rss&#038;utm_campaign=the-developing-webgl-demoscene</link>
		<comments>http://nooshu.com/the-developing-webgl-demoscene#comments</comments>
		<pubDate>Mon, 07 Mar 2011 00:36:43 +0000</pubDate>
		<dc:creator>Matt</dc:creator>
				<category><![CDATA[Browsers]]></category>
		<category><![CDATA[Canvas]]></category>
		<category><![CDATA[Inspiration]]></category>
		<category><![CDATA[Interesting]]></category>
		<category><![CDATA[JavaScript]]></category>
		<category><![CDATA[Ramblings]]></category>
		<category><![CDATA[demoscene]]></category>
		<category><![CDATA[webgl]]></category>

		<guid isPermaLink="false">http://nooshu.com/?p=1614</guid>
		<description><![CDATA[Cool graphics in the browser, the demoscene has woken up to WebGL. Bring on the amazing demos!]]></description>
			<content:encoded><![CDATA[<p>One of my key memories from playing a friends <a href="http://en.wikipedia.org/wiki/Amiga">Amiga</a> oh so many years ago (apart from <a href="http://en.wikipedia.org/wiki/Cannon_Fodder">Cannon Fodder</a>) is the cool intro demos created by the <a href="http://www.scene.org/">demoscene</a>. These were usually found on, <em>cough</em>, slightly dodgy versions of games that were &#8220;acquired&#8221; from various sources :)</p>
<p>What&#8217;s always amazed me about these demos is the amount of space the programmers had to play with and the hardware available at the time; both extremely limited. While the space and hardware limitations are no longer an issue, people are still developing these amazing demos. One reason for this is due to an exciting area in Web Development that&#8217;s currently flourishing: <a href="http://en.wikipedia.org/wiki/WebGL">WebGL</a>. The <a href="http://www.khronos.org/news/press/releases/khronos-releases-final-webgl-1.0-specification">technical specification</a> was finalised last week and developers have started to take notice of this very powerful visual programming language. Developing demos in the browser environment is a new limitation and programmers are looking at WebGL to push the boundaries.</p>
<div id="attachment_1616" class="wp-caption alignnone" style="width: 528px"><a href="http://nooshu.com/wp-content/uploads/2011/03/full-webgl-demo.jpg"><img src="http://nooshu.com/wp-content/uploads/2011/03/full-webgl-demo-518x518.jpg" alt="The demoscene in action via WebGL" title="full-webgl-demo" width="518" height="518" class="size-medium wp-image-1616" /></a><p class="wp-caption-text">WebGL port of &quot;glass&quot;, an old 64kb demo from 2000. </p></div>
<p>The <a href="http://possan.se/junk/webglass/index.html">demo above</a> has been converted into WebGL by a very talented programmer called <a href="http://possan.se/">Per-Olov Jernberg</a> (Possan). You can even take a look at the <a href="https://github.com/possan/webglass">source on Github</a> if your that way inclined! You can view the original from April 2000 <a href="http://pouet.net/prod.php?which=94">here</a>.</p>
<p>With modern browsers like Chrome, Firefox 4 and <a href="http://my.opera.com/chooseopera/blog/2011/03/03/a-sneak-preview-of-our-upcoming-webgl-demo">now Opera</a> adding WebGL support and improving their JavaScript engines, there&#8217;s never been a better time for Web Developers to get involved in this new demoscene. All that&#8217;s needed is some JavaScript, Canvas and a little creativity. I genuinely look forward to seeing all the old school programmers diving into WebGL. I personally know very little about this new language so I&#8217;ll be able to learn so much by doing a quick &#8220;view source&#8221;.</p>
<p>There&#8217;s already a WebGL competition in progress called <a href="http://gl64k.com/">gl64k</a> where programmers have to create an interesting visual demo with only 64k (65,536 bytes) at their disposal. Awesome stuff will be emerging from this new technology in the next couple of years and I for one can&#8217;t wait to see what!</p>
]]></content:encoded>
			<wfw:commentRss>http://nooshu.com/the-developing-webgl-demoscene/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>

