<?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>Nathaniel Johnston &#187; Javascript</title>
	<atom:link href="http://www.nathanieljohnston.com/index.php/tag/javascript/feed/" rel="self" type="application/rss+xml" />
	<link>http://www.nathanieljohnston.com</link>
	<description>A blog of recreational math and coding</description>
	<lastBuildDate>Tue, 18 May 2010 12:49:57 +0000</lastBuildDate>
	<generator>http://wordpress.org/?v=2.8.4</generator>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
			<item>
		<title>A Case for Canvas</title>
		<link>http://www.nathanieljohnston.com/index.php/2008/10/a-case-for-canvas/</link>
		<comments>http://www.nathanieljohnston.com/index.php/2008/10/a-case-for-canvas/#comments</comments>
		<pubDate>Fri, 31 Oct 2008 00:00:57 +0000</pubDate>
		<dc:creator>Nathaniel</dc:creator>
				<category><![CDATA[Uncategorized]]></category>
		<category><![CDATA[Coding]]></category>
		<category><![CDATA[Javascript]]></category>

		<guid isPermaLink="false">http://www.nathanieljohnston.com/?p=47</guid>
		<description><![CDATA[I recently came across this page, which shows a rudimentary rotating 3D cube made entirely of javascript.  Since I&#8217;m a code geek I of course thought it deserved a kudo or two, but it got me thinking; why isn&#8217;t the canvas tag more widely used (or supported natively in Internet Explorer)? For those of [...]]]></description>
			<content:encoded><![CDATA[<p>I recently came across <a href="http://maettig.com/code/javascript/3d_dots.html" target="_new">this page</a>, which shows a rudimentary rotating 3D cube made entirely of javascript.  Since I&#8217;m a code geek I of course thought it deserved a kudo or two, but it got me thinking; why isn&#8217;t the canvas tag more widely used (or supported natively in Internet Explorer)? For those of you who don&#8217;t know what the canvas tag is, it&#8217;s essentially an environment for drawing things on the fly in web pages, without having to use a plug-in like Flash. It is probably something that is easiest to appreciate through some examples, so I present to you the following simple comparison of what can be done with javascript alone versus javascript plus the canvas tag (scroll your mouse over the cubes to rotate them):</p>
<p><strong>Javascript Only:</strong><br />
<center><iframe src="http://www.nathanieljohnston.com/cubes/JS.html" mce_src="http://www.nathanieljohnston.com/cubes/JS.html" width="350" height="350" scrolling="no" border="0" frameborder="0"></iframe></center></p>
<p><strong>Javascript and the Canvas Tag:</strong><br />
<center><iframe src="http://www.nathanieljohnston.com/cubes/canvasA.html" mce_src="http://www.nathanieljohnston.com/cubes/cubeA.html" width="350" height="350" scrolling="no" border="0" frameborder="0"></iframe></center></p>
<p>The top cube makes use of 18 images (for drawing the lines via the trick described <a href="http://www.p01.org/articles/DHTML_techniques/Drawing_lines_in_JavaScript/" target="_new">here</a>) and about 1.0kB of javascript code. The bottom cube is animated using 509 bytes of javascript code in conjunction with the canvas tag. That&#8217;s it &#8212; no auxilliary images or plug-ins of any kind.</p>
<p>Personally, I think that&#8217;s pretty awesome, and I wish that the usage of the canvas tag would leave the realm of the tech demo. People need to realize its potential and start really using it. It&#8217;s supported in all major current browsers (OK, you have to do <a href="http://excanvas.sourceforge.net/" target="_new">some trickery</a> to get it to work in Internet Explorer, but it still requires no work on the part of the end-user) and it does things that simply can not be done otherwise without loading a plug-in like Flash. Consider the following variation of the 3D rotating cube:</p>
<p><strong>Colour Cube via Canvas Tag:</strong><br />
<center><iframe src="http://www.nathanieljohnston.com/cubes/canvasB.html" mce_src="http://www.nathanieljohnston.com/cubes/canvasB.html" width="350" height="350" scrolling="no" border="0" frameborder="0"></iframe></center></p>
<p>I believe that it&#8217;s flat-out impossible to replicate the above coloured cube using only CSS and javascript without the canvas tag, but even if it is <em>possible</em>, it certainly won&#8217;t be easy or scalable &#8212; the canvas tag is both.</p>
<p><span class="sub_header_text"><strong>Related Links</strong></span></p>
<ul>
<li><a href="https://developer.mozilla.org/en/Canvas_tutorial" target="_new"><strong>Canvas Tutorial</strong></a> - A tutorial provided by Mozilla for using the canvas tag.</li>
</ul>
]]></content:encoded>
			<wfw:commentRss>http://www.nathanieljohnston.com/index.php/2008/10/a-case-for-canvas/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
	</channel>
</rss>
