<?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"
	>

<channel>
	<title>webroo.org &#187; Javascript</title>
	<atom:link href="http://webroo.org/category/javascript/feed/" rel="self" type="application/rss+xml" />
	<link>http://webroo.org</link>
	<description>Matt Sweetman :: Flex &#38; Actionscript Development</description>
	<pubDate>Tue, 08 Jun 2010 10:15:26 +0000</pubDate>
	<generator>http://wordpress.org/?v=2.6.3</generator>
	<language>en</language>
			<item>
		<title>Experimenting with Processing.js</title>
		<link>http://webroo.org/2010/05/03/experimenting-with-processingjs/</link>
		<comments>http://webroo.org/2010/05/03/experimenting-with-processingjs/#comments</comments>
		<pubDate>Mon, 03 May 2010 20:23:35 +0000</pubDate>
		<dc:creator>Matt Sweetman</dc:creator>
		
		<category><![CDATA[Javascript]]></category>

		<guid isPermaLink="false">http://webroo.org/?p=198</guid>
		<description><![CDATA[I eventually got round to trying out Processing.js - the javascript implementation of the original Processing. You can see the result below in a little experiment called Fireflies.
Fireflies
(View in Google Chrome/Firefox)
I actually ported this from a javascript experiment I did around the same time as the snowfall one. I thought it would be a good [...]]]></description>
			<content:encoded><![CDATA[<p>I eventually got round to trying out <a href="http://processingjs.org/">Processing.js</a> - the javascript implementation of the original Processing. You can see the result below in a little experiment called Fireflies.</p>
<p><a href="http://webroo.org/media/fireflies/index.html"><img src="http://webroo.org/images/fireflies.jpg" alt="Fireflies" />Fireflies</a><br />
(View in Google Chrome/Firefox)</p>
<p>I actually ported this from a javascript experiment I did around the same time as the snowfall one. I thought it would be a good idea to see how regular JS performed alongside Processing.js. You can check out the <a href="http://webroo.org/media/fireflies/fireflies-js.html">regular javascript version</a> for comparison. I tried to ensure they both looked identical and were coded as similarly as possible. The verdict is that they both perform smoothly, but Processing.js seems to require about 20% more CPU than regular JS, for what reason I don&#8217;t quite know. I haven&#8217;t looked into the Processing source code to see what&#8217;s going on. Processing has a neater syntax and less overall code, and it even sorted out scoping issues I had in the regular version, so it wins on that front.</p>
<p>I&#8217;d be interested to use it some more, although I&#8217;m unsure of what benefits it offers over regular JS. The syntax is certainly nicer, but the typed variables tempt me with the facade of proper OO - it&#8217;s ultimately converted to javascript so I know it doesn&#8217;t offer any practical advantage. I think it would require further investigation to see the real benefits.</p>
<p>Oh, I hit a couple of hurdles early on that had me stumped for ages. The beginners guide to Processing.js is lacking some vital information, so if you&#8217;re stuck on how to actually set up it in your HTML page then follow the points below:</p>
<p><span id="more-198"></span></p>
<ol>
<li>Add the processing.xx.min.js in a script tag.</li>
<li>Add init.js in the same manner, which can be found in the examples zip on the Processing.js website.</li>
<li>Ensure your processing script tag and Canvas object are in the same container, and the script tag is above the canvas.</li>
<li>Be sure to have a setup() method and set the canvas size with size()</li>
</ol>
<p>Check out the source code in the Firefly experiment if you want to see exactly how this is done.</p>
]]></content:encoded>
			<wfw:commentRss>http://webroo.org/2010/05/03/experimenting-with-processingjs/feed/</wfw:commentRss>
		</item>
		<item>
		<title>HTML 5 Canvas vs Flash</title>
		<link>http://webroo.org/2010/01/17/html-5-canvas-vs-flash/</link>
		<comments>http://webroo.org/2010/01/17/html-5-canvas-vs-flash/#comments</comments>
		<pubDate>Sun, 17 Jan 2010 16:11:26 +0000</pubDate>
		<dc:creator>Matt Sweetman</dc:creator>
		
		<category><![CDATA[Actionscript]]></category>

		<category><![CDATA[Flash]]></category>

		<category><![CDATA[Javascript]]></category>

		<guid isPermaLink="false">http://webroo.org/?p=136</guid>
		<description><![CDATA[Over the holidays I gave myself a break from Actionscript and took a look at the HTML 5 Canvas object. It&#8217;s been a while since I programmed any javascript, and AJAX technologies seem to be the popular choice for web apps these days (goodbye Flex!). I decided to port over an old Actionscript 1 experiment [...]]]></description>
			<content:encoded><![CDATA[<p>Over the holidays I gave myself a break from Actionscript and took a look at the HTML 5 Canvas object. It&#8217;s been a while since I programmed any javascript, and AJAX technologies seem to be the popular choice for web apps these days (goodbye Flex!). I decided to port over an old Actionscript 1 experiment to see how the two technologies performed alongside each other, the results can be seen below.</p>
<p><img src="http://webroo.org/images/snow1.jpg" width="130" height="130" alt="Snowfall image" /><a href="http://webroo.org/media/snowfall/canvassnowfall.html">Canvas Snowfall</a></p>
<p><a href="http://webroo.org/media/snowfall/flashsnowfall.html">Flash Snowfall</a></p>
<p>You&#8217;ll need a modern browser to view the canvas version (eg: Firefox/Chrome/Opera/etc). View the source of the Canvas version for the javascript.</p>
<p>As you can see they look pretty much identical, the differences primarily lie in performance. The Flash version can handle more than twice the number of snowflakes before the frame rate drops. This may be down to the a fundamental difference between Canvas and Flash: Canvas is a rasterised bitmap object, whereas Flash is a vector animation tool. When you draw shapes in Canvas you&#8217;re drawing directly onto a bitmap, the shape can no longer be moved or scaled and is &#8216;baked&#8217; into the image. In some ways it&#8217;s similar to the BitmapData object in Flash. Because of this animation is far easier to accomplish in Flash and I had to adapt parts of the original code to work with the Canvas concept.</p>
<p><span id="more-136"></span>Javascript and AS1 share a lot in similarity as programming languages so porting the code was relatively easy. The Canvas object also has a similar API to the Graphics object in Flash. I&#8217;ll admit Javascript is not my favourite language, by a long shot, the lack of strict typing is difficult to return to after years of AS3, and in more complex scripts nested closures can get messy. It is however fast to program, which can come in very handy when prototyping and experimenting with ideas.</p>
<p>It may be worth investigating <a href="http://processingjs.org/">Processing</a>, a framework for the Canvas object written by John Resig, the guy behind JQuery.</p>
]]></content:encoded>
			<wfw:commentRss>http://webroo.org/2010/01/17/html-5-canvas-vs-flash/feed/</wfw:commentRss>
		</item>
	</channel>
</rss>
