<?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>Barryvan</title>
	<atom:link href="http://www.barryvan.com.au/feed/" rel="self" type="application/rss+xml" />
	<link>http://www.barryvan.com.au</link>
	<description>Music, Programming, Design</description>
	<lastBuildDate>Mon, 23 Aug 2010 04:12:48 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.0.1</generator>
		<item>
		<title>Theme update (again!)</title>
		<link>http://www.barryvan.com.au/2010/08/theme-update-again/</link>
		<comments>http://www.barryvan.com.au/2010/08/theme-update-again/#comments</comments>
		<pubDate>Mon, 23 Aug 2010 04:12:48 +0000</pubDate>
		<dc:creator>Barry van Oudtshoorn</dc:creator>
				<category><![CDATA[Announcements]]></category>
		<category><![CDATA[CSS]]></category>
		<category><![CDATA[HTML]]></category>
		<category><![CDATA[Web design]]></category>

		<guid isPermaLink="false">http://www.barryvan.com.au/?p=474</guid>
		<description><![CDATA[And so, for the third time this year, I&#8217;ve completely re-themed this site. Taking a very different tack from the last theme, I&#8217;ve tried to keep this one as simple as possible, with just a few subtle touches here and there to add interest. The palette is more subdued, which hopefully means that reading the [...]]]></description>
			<content:encoded><![CDATA[<p>And so, for the third time this year, I&#8217;ve completely re-themed this site. Taking a very different tack from the last theme, I&#8217;ve tried to keep this one as simple as possible, with just a few subtle touches here and there to add interest. The palette is more subdued, which hopefully means that reading the text is a more pleasant experience. I&#8217;ve also done away with the multi-column body text in favour of a fixed-width design.</p>
<p>At the same time, though, I have endeavoured to use some of the new features available in modern web browsers &#8212; gradients, shadows, transitions, generated content, and so on. I&#8217;m fairly happy with the result &#8212; I think it&#8217;s a clean, unobtrusive theme that&#8217;s not too in your face. Feedback and criticism welcome! <img src='http://www.barryvan.com.au/wp-includes/images/smilies/icon_biggrin.gif' alt=':D' class='wp-smiley' /> </p>
]]></content:encoded>
			<wfw:commentRss>http://www.barryvan.com.au/2010/08/theme-update-again/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
		<item>
		<title>Paired sort in JavaScript</title>
		<link>http://www.barryvan.com.au/2010/08/paired-sort-in-javascript/</link>
		<comments>http://www.barryvan.com.au/2010/08/paired-sort-in-javascript/#comments</comments>
		<pubDate>Thu, 19 Aug 2010 01:42:06 +0000</pubDate>
		<dc:creator>Barry van Oudtshoorn</dc:creator>
				<category><![CDATA[Javascript]]></category>
		<category><![CDATA[MooTools]]></category>
		<category><![CDATA[Programming]]></category>

		<guid isPermaLink="false">http://www.barryvan.com.au/?p=467</guid>
		<description><![CDATA[Sometimes, you&#8217;ll have two arrays of associated data, and you&#8217;ll need to sort them. You can&#8217;t just call sort() on both arrays, because that will potentially break the associations between them. What you need is a way to sort one of the arrays, and shuffle the elements of the second array to match. Here&#8217;s a [...]]]></description>
			<content:encoded><![CDATA[<p>Sometimes, you&#8217;ll have two arrays of associated data, and you&#8217;ll need to sort them. You can&#8217;t just call sort() on both arrays, because that will potentially break the associations between them. What you need is a way to sort one of the arrays, and shuffle the elements of the second array to match. Here&#8217;s a simple MooTools function that does just that (using quicksort):</p>
<pre class="brush: javascript">Array.implement({
	pairedSort: function(other, reverse) {
		if (this.length === other.length) {
			for (var i = 0, len = this.length; i &lt; len; i++) {
				var curr = this[i];
				var currOth = other[i];
				var j = i - 1;
				while ((j &gt;= 0) &amp;&amp; (this[j] &gt; curr)) {
					this[j + 1] = this[j];
					other[j + 1] = other[j];
					j--;
				}
				this[j + 1] = curr;
				other[j + 1] = currOth;
			}
		}
		if (reverse) {
			this.reverse();
			other.reverse();
		}
		return this;
	}
});</pre>
<p>Using this function is quite straightforward:</p>
<pre class="brush: javascript">var alpha = [3,2,1,6,5,4];
var beta = [1,2,3,4,5,6];
alpha.pairedSort(beta);
// alpha == [1,2,3,4,5,6]
// beta == [3,2,1,6,5,4]</pre>
<p>When would this actually be useful? Let&#8217;s say you&#8217;ve got an object which maps numeric assessment scores to an alphabetic grade:</p>
<pre class="brush: javascript">var mapping = {
  &#039;A&#039;: 80,
  &#039;B&#039;: 60,
  &#039;C&#039;: 40,
  &#039;D&#039;: 20,
  &#039;E&#039;: 0
}</pre>
<p>Unfortunately, objects in JavaScript have no intrinsic order on their keys &#8212; this is because they&#8217;re essentially just hashmaps. What we need to do to be able to make use of these data, then, is create an array of keys, and one of values, and then sort them. The pairedSort() function allows us to do this easily. (In fact, it&#8217;s for this exact application that I wrote the method!)</p>
]]></content:encoded>
			<wfw:commentRss>http://www.barryvan.com.au/2010/08/paired-sort-in-javascript/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
		<item>
		<title>JS1K: Swarms</title>
		<link>http://www.barryvan.com.au/2010/08/js1k-swarms/</link>
		<comments>http://www.barryvan.com.au/2010/08/js1k-swarms/#comments</comments>
		<pubDate>Fri, 13 Aug 2010 03:35:04 +0000</pubDate>
		<dc:creator>Barry van Oudtshoorn</dc:creator>
				<category><![CDATA[Javascript]]></category>
		<category><![CDATA[Programming]]></category>

		<guid isPermaLink="false">http://www.barryvan.com.au/?p=458</guid>
		<description><![CDATA[In the spirit of the demoscene, the JS1K competition is designed to make people push their boundaries. The competition requires entrants to write an interesting, appealing demo in JavaScript, using no more than 1024 characters (hence the name). Of course, I had to have a shot at it. (See the result!) I decided to revisit [...]]]></description>
			<content:encoded><![CDATA[<p>In the spirit of the <a href="http://en.wikipedia.org/wiki/Demoscene">demoscene</a>, the JS1K competition is designed to make people push their boundaries. The competition requires entrants to write an interesting, appealing <a href="http://en.wikipedia.org/wiki/Demo_%28computer_programming%29">demo</a> in JavaScript, using no more than 1024 characters (hence the name).</p>
<p>Of course, I had to have a shot at it. (<a href="http://js1k.com/demo/270">See the result!</a>) I decided to revisit one of my favourite toy projects: my swarms. What I came up with is this (linebreaks added for convenience):</p>
<pre class="brush: javascript">a=Math,b=a.random,c=[],j=document.getElementById(&quot;c&quot;),k=j.getContext(&quot;2d&quot;),m=window,n=(W=m.innerWidth)/2,q=(H=m.innerHeight)/2,r=M=1;function s(o,p,u,v){k.fillStyle=o;k.beginPath();k.arc(p,u,v,0,a.PI*2,0);k.closePath();k.fill()}function t(o,p){for(g=40;g--;)if(!c[g]){c[g]={x:o||n,y:p||q,d:o?b()*4-2:0,e:p?b()*4-2:0,b:1,a:0,c:b()&gt;.5};return}}with(j.style){position=&quot;fixed&quot;;top=left=0}j.width=W;j.height=H;for(f=40;f--;)c[f]=0;for(f=9;f--;)t(); m.setInterval(function(){k.fillStyle=&quot;rgba(9,9,9,.2)&quot;;k.fillRect(0,0,W,H);for(f=40;f--;)if(d=c[f])if(d.a&gt;1E3)c[f]=0;else{l=d.a/1E3;h=l*7;d.d+=b()*.1*(n-d.x&gt;1?1:n-d.x&lt;-1?-1:n-d.x);d.e+=b()*.1*(q-d.y&gt;1?1:q-d.y&lt;-1?-1:q-d.y);d.x+=d.d;d.y+=d.e;d.a++;i=d.c?&quot;rgba(49,153,255,&quot;:&quot;rgba(255,49,166,&quot;;h=1-l;s(i+h+&quot;)&quot;,d.x,d.y,1+l*12);s(i+h/2+&quot;)&quot;,d.x,d.y,1+l*16);d.b&amp;&amp;d.b--;if(d.b==0&amp;&amp;d.a&gt;250&amp;&amp;d.a&lt;750&amp;&amp;b()&gt;.9)for(g=40;g--&amp;&amp;!d.b;)if((e=c[g])&amp;&amp;e!=d&amp;&amp;e.a&gt;=d.a){i=a.sqrt(d.x-e.x,d.y-e.y);if(i&gt;-5&amp;&amp;i&lt;5&amp;&amp;d.c!=e.c){t(d.x, d.y);d.b=e.b=10}}}r=n&gt;W||n&lt;0?-r:r;M=q&gt;H||q&lt;0?-M:M;n+=r;q+=M},40);</pre>
<p>You can see the submission <a href="http://js1k.com/demo/270">here: http://js1k.com/demo/270</a>. To reduce the size, I first coded tightly, ran the uncompressed code through Google&#8217;s <a href="http://code.google.com/p/closure-compiler/">Closure Compiler</a>, then hand-tweaked the result to save a few more bytes. I&#8217;m quite pleased with the result! For the curious, the full, uncompressed, commented source is below:</p>
<pre class="brush: javascript">/* SWARMS (v1.7)
 * by Barry van Oudtshoorn (www.barryvan.com.au)
 * A re-implementation of http://www.barryvan.com.au/demos/swarms/swarms.html,
 * which in turn is a reimplementation of a Processing script that I wrote.
 *
 * Male and female particles move around a central point, gradually aging.
 * When they reach maturity, they may interact with a particle of the opposite
 * sex to spawn a new particle. As they grow old, they become larger and slower
 * until they eventually die.
 *
 * Revisions (really, these version numbers are all but meaningless!)
 * 1.0 (1023B)
 *     - Initial code.
 * 1.5 (1017B)
 *     - Moved to Closure compiler to reduce size
 *     - Some slight tweaks to particle movement
 *     - Canvas now positioned to get rid of annoying border (try fullscreen!)
 * 1.7 (1011B)
 *     - The swarm centre now moves around (simple bouncing). This allows the
 *         particles to pick up a bit more speed, and move in more interesting ways;
 *         where before they tended to just &#039;bubble&#039; in the middle of the screen,
 *         the swarm, as an entity, now appears more fluid and organic.
 *     - Bugfix to spawning: particles now actually have to be near to each other
 *         in BOTH axes to spawn, and both particles have to be of suitable age. This
 *         prevents billions of particles from spawning from a single one.
 *     - Reduced the total number of particles for aesthetic reasons
 *     - Did some more &quot;by-hand&quot; optimisations after running it through the closure
 *         compiler, like removing global variable declarations when I&#039;m not
 *         instantiating the variables there and then and removing the leading 0 on
 *         decimal values to conserve precious bytes. With each revision, despite
 *         adding functionality each time, the size is going down!
 *
 * Copyright 2010 Barry van Oudtshoorn.
 */

var z = function(a, b, c) { // Normalise a to between b and c
    return (a / (c - b));
},
h = function(a, b, c) { // Limx a to between b and c
    return (a &gt; b ? b : (a &lt; c ? c : a));
},
// I strip out all of the uninitialised declarations after compilation;
// they&#039;re globals anyway. I know it&#039;s not stylish, but it saves bytes!
r,s, // Particles that we&#039;re currently interested in
i,j, // Iterators
u,d, // Working variables
m = Math, // Alias
v = m.random, // Alias
p = [], // The particles
e = document.getElementById(&#039;c&#039;), // The canvas element
t = e.getContext(&#039;2d&#039;), // The context
n, // The normalised age of a particle
Q = window, // Alias
X = (W = Q.innerWidth)/2, // The swarm&#039;s COG
Y = (H = Q.innerHeight)/2,
N = M = 1, // The components of the velocity of the swarm&#039;s COG
q = function(a, b, c, f) { // Draw a blob
    t.fillStyle = a;
    t.beginPath();
    t.arc(b, c, f, 0, m.PI*2, 0);
    t.closePath();
    t.fill();
},

x = function() { // Global iterator
    //t.globalCompositeOperation = &#039;source-over&#039;; // This is prettier, but &quot;globalCompositeOperation&quot; takes too many bytes!
    t.fillStyle = &#039;rgba(9,9,9,.2)&#039;;
    t.fillRect(0,0,W,H);
    //t.globalCompositeOperation = &#039;lighter&#039;;

    for (i = 40; i--;) { // Loop over all of the particles
        if (r = p[i]) {
            if (r.a &gt; 1E3) {
                p[i] = 0; // Kill off old particles; use 0 because it&#039;s shorter than false, null, or using delete.
            } else {
                // Move the particle
                n = z(r.a, 0, 1E3);
                u = n * 7;
                r.X += v() * .1 * h(X - r.x, 1, -1); // Update the particle&#039;s velocity.
                r.Y += v() * .1 * h(Y - r.y, 1, -1);
                r.x += r.X; // Update the particle&#039;s coordinates based on its velocity.
                r.y += r.Y;
                r.a++; // Increment the particle&#039;s age

                // Draw the particle

                d = r.s ? &#039;rgba(49,153,255,&#039; : &#039;rgba(255,49,166,&#039;; // The colour of the particle
                u = 1 - n; // The opacity of the particle; n is the normalised age
                q(d + u + &#039;)&#039;, r.x, r.y, 1 + n * 12); // Draw the primary particle blob
                q(d + (u/2) + &#039;)&#039;, r.x, r.y, 1 + n * 16); // We draw a lighter, larger blob for a &#039;glow&#039; effect

                r.f &amp;&amp; r.f--; // If we&#039;ve spawned, decrement the cooldown.

                if (r.f == 0 &amp;&amp; r.a &gt; 250 &amp;&amp; r.a &lt; 750 &amp;&amp; v() &gt; 0.9) { // If we&#039;re the right age, check if we can spawn!
                    for (j = 40; j-- &amp;&amp; !r.f;) { // We have to loop over the particles again, and see if we&#039;re close enough to spawn.
                        if ((s = p[j]) &amp;&amp; s != r &amp;&amp; s.a &gt;= r.a) {
                            d = m.sqrt(r.x - s.x, r.y - s.y); // Two if statements to avoid this calculation if possible
                            if (d &gt; -5 &amp;&amp; d &lt; 5 &amp;&amp; r.s != s.s) { // Collision detection? What&#039;s that?
                                y(r.x, r.y); // Spawn a new particle!
                                r.f = s.f = 10; // Enforce the spawning cooldown
                            }
                        }
                    }
                }
            }
        }
    }

    // Bounce the swarm&#039;s COG around the canvas
    N = (X &gt; W || X &lt; 0 ? -N : N);
    M = (Y &gt; H || Y &lt; 0 ? -M : M);
    X += N;
    Y += M;
},

// Spawn a new particle. If sx and sy are defined, they will be its initial
// coordinates; otherwise, we just the COG. If sx and sy are defined, we also
// give the particle a random velocity; this means that they&#039;re &#039;flung out&#039;
// from their parents; at startup, though, we want them all nicely bunched.
y = function(sx,sy) {
    for (j = 40; j--;) {
        if (!p[j]) {
            p[j] = {
                x: sx || X, // The particle&#039;s coords
                y: sy || Y,
                X: sx ? v() * 4 - 2: 0, // The particles velocity
                Y: sy ? v() * 4 - 2 : 0,
                f: 1, // Cooldown after spawning
                a: 0, // The age of the particle
                s: v() &gt; .5 // The sex of the particle
            }
            return;
        }
    }
};

// Make the canvas fill the entire screen
with (e.style) {
    position = &#039;fixed&#039;;
    top = left = 0;
}
e.width = W; // Set the canvas width and height
e.height = H;

for (i = 40; i--;) p[i] = 0; // Populate initial particles
for (i = 9; i--;) y(); // Spawn eight particles. A number &lt; 10 saves a byte!

Q.setInterval(x, 40); // Make it go. </pre>
]]></content:encoded>
			<wfw:commentRss>http://www.barryvan.com.au/2010/08/js1k-swarms/feed/</wfw:commentRss>
		<slash:comments>5</slash:comments>
		</item>
		<item>
		<title>How sweetly doth</title>
		<link>http://www.barryvan.com.au/2010/08/how-sweetly-doth/</link>
		<comments>http://www.barryvan.com.au/2010/08/how-sweetly-doth/#comments</comments>
		<pubDate>Mon, 09 Aug 2010 10:08:45 +0000</pubDate>
		<dc:creator>Barry van Oudtshoorn</dc:creator>
				<category><![CDATA[Personal]]></category>

		<guid isPermaLink="false">http://www.barryvan.com.au/?p=454</guid>
		<description><![CDATA[How sweetly doth the crocodile enrobe his cunning nose with cummerbunds of pearly white and ribands made of rose! He carefully adorns it at the breaking of each day; and bitterly doth mourn it when a riband goes astray. And O! the subtle reptile, whilst at rest and whilst at play, ensures his nose is [...]]]></description>
			<content:encoded><![CDATA[<p>How sweetly doth the crocodile<br />
enrobe his cunning nose<br />
with cummerbunds of pearly white<br />
and ribands made of rose!</p>
<p>He carefully adorns it<br />
at the breaking of each day;<br />
and bitterly doth mourn it<br />
when a riband goes astray.</p>
<p>And O! the subtle reptile,<br />
whilst at rest and whilst at play,<br />
ensures his nose is toasty warm,<br />
and beautiful, and gay.</p>
<p>And though tenderly ensuring<br />
that his cummerbund is fix&#8217;d<br />
with pins and twine and sealing wax,<br />
his reception, it is mixed:</p>
<p>For though his nose is twisted &#8217;round<br />
with cummerbunds and stuff,<br />
the fishes in the fishpond say<br />
“His teeth are sharp enough!”</p>
]]></content:encoded>
			<wfw:commentRss>http://www.barryvan.com.au/2010/08/how-sweetly-doth/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
		<item>
		<title>iOS 4</title>
		<link>http://www.barryvan.com.au/2010/06/ios-4/</link>
		<comments>http://www.barryvan.com.au/2010/06/ios-4/#comments</comments>
		<pubDate>Tue, 22 Jun 2010 23:25:16 +0000</pubDate>
		<dc:creator>Barry van Oudtshoorn</dc:creator>
				<category><![CDATA[Apple]]></category>
		<category><![CDATA[Rants]]></category>

		<guid isPermaLink="false">http://www.barryvan.com.au/?p=451</guid>
		<description><![CDATA[I&#8217;ve been living with Apple&#8217;s new OS for about a day now, and the conclusion I&#8217;ve come to is that Apple dropped the ball. There are so many minor frustrations, as well as a few big ones, that the whole experience is at best annoying, and at worst unbearable. The new iOS isn&#8217;t all bad. [...]]]></description>
			<content:encoded><![CDATA[<p>I&#8217;ve been living with Apple&#8217;s new OS for about a day now, and the conclusion I&#8217;ve come to is that Apple dropped the ball. There are so many minor frustrations, as well as a few big ones, that the whole experience is at best annoying, and at worst unbearable.</p>
<p>The new iOS isn&#8217;t all bad. The animations feel snappier, Springboard is prettier, and it&#8217;s got the slick Apple feel which everyone so desperately wants to emulate. The big one, of course, is multitasking, and that I think they got right.</p>
<p>But then there are the problems. Apps crash with neither rhyme nor reason: the iPod app won&#8217;t even startup properly for me anymore. Google Sync is kaput (although I think Google should take some of the blame for that). The new folders, whilst useful, are, to be charitable, ugly. It all feels as though it was released without going through proper testing, let alone going through the spit-and-polish phase.</p>
<p>I was looking forward to this update. I thought that, like all the iOS versions before it, it would Just Work<sup>TM</sup>. I hope that when they patch iOS 4, they don&#8217;t introduce any new features: there&#8217;s just too much that needs to be fixed.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.barryvan.com.au/2010/06/ios-4/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Work</title>
		<link>http://www.barryvan.com.au/2010/05/work/</link>
		<comments>http://www.barryvan.com.au/2010/05/work/#comments</comments>
		<pubDate>Fri, 14 May 2010 10:28:10 +0000</pubDate>
		<dc:creator>Barry van Oudtshoorn</dc:creator>
				<category><![CDATA[Rants]]></category>
		<category><![CDATA[Work]]></category>

		<guid isPermaLink="false">http://www.barryvan.com.au/?p=447</guid>
		<description><![CDATA[I&#8217;m a software developer, working for SEQTA Software. We develop software for the education sector; basically, we aim to let teachers just get on with teaching, rather than having to faff around with a myriad different poorly-designed systems. I&#8217;m responsible for most of the front-end development of our two flagship products, Teachers&#8217; Assistant and SEQTA [...]]]></description>
			<content:encoded><![CDATA[<p>I&#8217;m a software developer, working for <a href="http://www.seqta.com.au">SEQTA Software</a>. We develop software for the education sector; basically, we aim to let teachers just get on with teaching, rather than having to faff around with a myriad different poorly-designed systems. I&#8217;m responsible for most of the front-end development of our two flagship products, <a href="http://www.seqta.com.au/teachers-assistant">Teachers&#8217; Assistant</a> and <a href="http://www.seqta.com.au/coneqt">SEQTA Coneqt</a>. Recently, I also redesigned the <a href="http://www.seqta.com.au">company website</a>.</p>
<p>Why am I bothering to tell you this? Because I enjoy what I do. I get to develop software that&#8217;s genuinely useful, that people actually appreciate, and that has concrete benefits. Oh, and I also get to play with all of the latest and most interesting new browser developments. One of the things I enjoy most about my job is getting out to sites and training people one-on-one. I love seeing people get caught up in what&#8217;s possible, and I particularly appreciate it when they come up with new ideas &#8212; ideas which can sometimes become central features.</p>
<p>I know, I know, this sounds a lot like I&#8217;m just banging on about work to earn brownie points. But the really weird thing is, it&#8217;s the truth. Yes, I&#8217;m young and idealistic. But then, I think that I&#8217;m work in a young and pretty-nearly ideal job.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.barryvan.com.au/2010/05/work/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Generative Music</title>
		<link>http://www.barryvan.com.au/2010/03/generative-music/</link>
		<comments>http://www.barryvan.com.au/2010/03/generative-music/#comments</comments>
		<pubDate>Sun, 21 Mar 2010 08:08:11 +0000</pubDate>
		<dc:creator>Barry van Oudtshoorn</dc:creator>
				<category><![CDATA[Ambient]]></category>
		<category><![CDATA[Chillout]]></category>
		<category><![CDATA[HTML]]></category>
		<category><![CDATA[Javascript]]></category>
		<category><![CDATA[MooTools]]></category>
		<category><![CDATA[Music]]></category>
		<category><![CDATA[Programming]]></category>
		<category><![CDATA[Projects]]></category>
		<category><![CDATA[Web design]]></category>

		<guid isPermaLink="false">http://www.barryvan.com.au/?p=443</guid>
		<description><![CDATA[Continuing my HTML5 and canvas experiments, I&#8217;ve put together a generative music system. Essentially, a series of particles move across a field, occasionally triggering sounds &#8212; the sound triggered depends on their location in the field. There is, of course, a little bit more to it than that. Under the hood, I&#8217;ve got a series [...]]]></description>
			<content:encoded><![CDATA[<p>Continuing my HTML5 and canvas experiments, I&#8217;ve put together a generative music system. Essentially, a series of particles move across a field, occasionally triggering sounds &#8212; the sound triggered depends on their location in the field.</p>
<p>There is, of course, a little bit more to it than that. Under the hood, I&#8217;ve got a series of HTML5 Audio objects that are used to provide polyphonic audio using a simple round-robin algorithm (I encoded the audio in OGG, so you&#8217;ll need to use an OGG-friendly browser, like <a href="http://www.getfirefox.com">Firefox</a>). The particles are much simpler than those in my <a href="/2010/03/canvas-swarms/">previous canvas dalliance</a>, in that they don&#8217;t swarm, and their motion is more linear.</p>
<div class="screenshots">
<a href="/demos/generative.html"><br/><br />
<img alt="Generative Audio Screenshot" src="/wp-content/uploads/2010/03/generative.png" class="aligncenter size-full"/><br/><br />
View (and hear!) it live<br/><br />
</a>
</div>
]]></content:encoded>
			<wfw:commentRss>http://www.barryvan.com.au/2010/03/generative-music/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
		<item>
		<title>Canvas Swarms</title>
		<link>http://www.barryvan.com.au/2010/03/canvas-swarms/</link>
		<comments>http://www.barryvan.com.au/2010/03/canvas-swarms/#comments</comments>
		<pubDate>Thu, 18 Mar 2010 00:27:18 +0000</pubDate>
		<dc:creator>Barry van Oudtshoorn</dc:creator>
				<category><![CDATA[HTML]]></category>
		<category><![CDATA[Javascript]]></category>
		<category><![CDATA[MooTools]]></category>
		<category><![CDATA[Processing]]></category>
		<category><![CDATA[Programming]]></category>
		<category><![CDATA[Web design]]></category>

		<guid isPermaLink="false">http://www.barryvan.com.au/?p=440</guid>
		<description><![CDATA[I&#8217;ve been meaning to start playing with the HTML5 &#60;canvas&#62; element for a while now, and yesterday I took the opportunity. I translated a Processing sketch I made a while ago into JavaScript (with a few minor enhancements). View it live Essentially, 1 to 3 swarms of particles move around the canvas, reproducing when the [...]]]></description>
			<content:encoded><![CDATA[<p>I&#8217;ve been meaning to start playing with the HTML5 &lt;canvas&gt; element for a while now, and yesterday I took the opportunity. I translated a Processing sketch I made a while ago into JavaScript (with a few minor enhancements).</p>
<div class="screenshots">
<a href="/demos/swarms/swarms.html"><br />
<img class="aligncenter size-full" src="/demos/swarms/swarms.png" alt="Swarms Screenshot"/><br />
View it live<br />
</a>
</div>
<p>Essentially, 1 to 3 swarms of particles move around the canvas, reproducing when the conditions are just right, and dying of old age. Quite simple, but the patterns produced can be really quite pretty.</p>
<p>One interesting thing that I discovered whilst doing this is that you can&#8217;t pass around a canvas&#8217; context at the instantiation of a MooTools class &#8212; it complains about wrapped natives. That&#8217;s why, if you like in the source JavaScript, you&#8217;ll see me pass the actual context around to various functions. I&#8217;d be interested in hearing if anyone has a workaround for this, because this is, well, a bit clunky.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.barryvan.com.au/2010/03/canvas-swarms/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>HTML: IE file submission</title>
		<link>http://www.barryvan.com.au/2010/02/html-ie-file-submission/</link>
		<comments>http://www.barryvan.com.au/2010/02/html-ie-file-submission/#comments</comments>
		<pubDate>Tue, 23 Feb 2010 07:57:22 +0000</pubDate>
		<dc:creator>Barry van Oudtshoorn</dc:creator>
				<category><![CDATA[HTML]]></category>
		<category><![CDATA[Javascript]]></category>
		<category><![CDATA[Programming]]></category>
		<category><![CDATA[Web design]]></category>

		<guid isPermaLink="false">http://www.barryvan.com.au/?p=437</guid>
		<description><![CDATA[I&#8217;ve been bumping up against an interesting bug in Internet Explorer recently, and, having just found the solution, thought I&#8217;d share it with you. The problem is that in Internet Explorer (tested 7 &#038; 8), when your document is in quirks mode, uploading a file sometimes just sends through the file name, without the actual [...]]]></description>
			<content:encoded><![CDATA[<p>I&#8217;ve been bumping up against an interesting bug in Internet Explorer recently, and, having just found the solution, thought I&#8217;d share it with you.</p>
<p>The problem is that in Internet Explorer (tested 7 &#038; 8), when your document is in quirks mode, uploading a file sometimes just sends through the file name, without the actual body of the request. Put the document into standards mode, and it all works. It should be noted that this is when you&#8217;re dynamically setting up the elements used with JavaScript.</p>
<p>The cause? In quirks mode, the <em>enctype</em> attribute isn&#8217;t supported. So whilst setting &#8220;encType&#8221; on the form element to the correct &#8220;multipart/form-data&#8221; will indeed set this attribute, it won&#8217;t actually cause the upload to include the file. Instead, you need to set the <em>encoding</em> attribute to this value, too. It certainly doesn&#8217;t help that the MSDN article on the &lt;input type=&#8221;file&#8221;&gt; element tells you to set &#8220;enctype&#8221;, but makes no mention of &#8220;encoding&#8221;.</p>
<ul>
<li><a href="http://msdn.microsoft.com/en-us/library/ms533744(VS.85).aspx">MSDN: &#8216;Encoding&#8217; property</a></li>
<li><a href="http://msdn.microsoft.com/en-us/library/cc304100%28VS.85%29.aspx">MSDN: &#8216;Enctype&#8217; property</a></li>
<li><a href="http://msdn.microsoft.com/en-us/library/ms535263%28VS.85%29.aspx">MSDN: &lt;input type=&#8221;file&#8221;&gt; element</a></li>
</ul>
<p>I couldn&#8217;t find any reference to this problem on the intertubes (although maybe I just didn&#8217;t look hard enough), so hopefully this will help someone.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.barryvan.com.au/2010/02/html-ie-file-submission/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Javascript: Print a single element</title>
		<link>http://www.barryvan.com.au/2010/02/javascript-print-a-single-element/</link>
		<comments>http://www.barryvan.com.au/2010/02/javascript-print-a-single-element/#comments</comments>
		<pubDate>Tue, 16 Feb 2010 08:18:47 +0000</pubDate>
		<dc:creator>Barry van Oudtshoorn</dc:creator>
				<category><![CDATA[Javascript]]></category>
		<category><![CDATA[MooTools]]></category>
		<category><![CDATA[Programming]]></category>
		<category><![CDATA[Web design]]></category>

		<guid isPermaLink="false">http://www.barryvan.com.au/?p=434</guid>
		<description><![CDATA[Sometimes, you&#8217;ll want to allow users the ability to print only a part of your page; for example, a table but not the various links around the page. It&#8217;s possible to use a printing stylesheet, but this can cause severe headaches when you need different parts printed at different times. Really, we want to be [...]]]></description>
			<content:encoded><![CDATA[<p>Sometimes, you&#8217;ll want to allow users the ability to print only a part of your page; for example, a table but not the various links around the page. It&#8217;s possible to use a printing stylesheet, but this can cause severe headaches when you need different parts printed at different times. Really, we want to be able to just say <strong>element.printElement()</strong>, and have it just work. That&#8217;s what the MooTools function below does. It&#8217;s loosely based around the concepts outlined at <a href="http://www.bennadel.com/blog/1591-Ask-Ben-Print-Part-Of-A-Web-Page-With-jQuery.htm">this website</a>.</p>
<pre class="brush: javascript">Element.implement({
	printElement: function() {
		var strName = &#039;printer-&#039; + (new Date()).getTime(),
		styles = $$(&#039;link[type=text/css]&#039;).clone(),
		title = document.title,
		that = this,
		iframe = new IFrame({
			name: strName,
			styles: {
				width: 1,
				height: 1,
				position: &#039;absolute&#039;,
				left: -9999
			},
			events: {
				load: function() {
					var doc = this.contentDocument || window.frames[strName].document;
					doc.title = title;
					$(doc.body).adopt(styles, that.clone());
					this.contentWindow.focus(); // IE requires us to focus before printing, or the parent prints.
					this.contentWindow.print();
				}
			}
		}).inject($(document.body));
		iframe.dispose.delay(15000); // Destroy the iframe in 15s so that it doesn&#039;t hang around.
	}
});</pre>
]]></content:encoded>
			<wfw:commentRss>http://www.barryvan.com.au/2010/02/javascript-print-a-single-element/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
	</channel>
</rss>
