<?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>Is Good Stuff &#187; javascript</title>
	<atom:link href="http://www.isgoodstuff.com/tag/javascript/feed/" rel="self" type="application/rss+xml" />
	<link>http://www.isgoodstuff.com</link>
	<description>All the good stuff here!</description>
	<lastBuildDate>Thu, 09 Feb 2012 13:46:32 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.2</generator>
		<item>
		<title>HTML5 : FREE Cloud Carousel</title>
		<link>http://www.isgoodstuff.com/2012/02/09/html5-free-cloud-carousel/</link>
		<comments>http://www.isgoodstuff.com/2012/02/09/html5-free-cloud-carousel/#comments</comments>
		<pubDate>Thu, 09 Feb 2012 12:57:37 +0000</pubDate>
		<dc:creator>Alex T.</dc:creator>
				<category><![CDATA[Tech]]></category>
		<category><![CDATA[canvas]]></category>
		<category><![CDATA[HTML5]]></category>
		<category><![CDATA[javascript]]></category>
		<category><![CDATA[Tutorials]]></category>

		<guid isPermaLink="false">http://www.isgoodstuff.com/?p=2191</guid>
		<description><![CDATA[<p><img src="http://www.isgoodstuff.com/wp-content/uploads/et_temp/cloudCarouselCropped2-179245_300x185.png"/></p>New and free interactive HTML5 Canvas Carousel to try out today!]]></description>
			<content:encoded><![CDATA[<p><img src="http://www.isgoodstuff.com/wp-content/uploads/et_temp/cloudCarouselCropped2-179245_300x185.png"/></p><p>Previously I&#8217;ve wrote before about an article about <a href="http://www.isgoodstuff.com/2008/05/28/free-flash-carousel-slideshow/">flash based carousel here</a>. Today I&#8217;m gonna share and write about carousel again, but not the flash version this is html5 canvas combo with jquery version. Check out the beautiful carousel picture below, click to <a href="http://www.isgoodstuff.com/wp-content/demo/CarouselHTML5/" target="_blank">run the demo</a>. It runs smoothly on all major browser and has a cool fallback support in case javascript is turned off. Such a beautiful expression of art written in latest cutting edge tech&#8230;all good!</p>
<p style="text-align: center;"><a href="http://www.isgoodstuff.com/wp-content/demo/CarouselHTML5/" target="_blank"><img class="aligncenter size-full wp-image-2192" title="cloudCarousel" src="http://www.isgoodstuff.com/wp-content/uploads/2012/02/cloudCarousel.png" alt="" width="495" height="342" /></a></p>
<p style="text-align: left;">The carousel above is called <a href="http://www.professorcloud.com/mainsite/carousel.htm" target="_blank">Cloud Carousel</a> written by Prof Cloud. Below are some example on how to implement this carousel.</p>
<p style="text-align: left;">
<p>&nbsp;</p>

<div class="wp_syntax"><table><tr><td class="line_numbers"><pre>1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
</pre></td><td class="code"><pre class="html" style="font-family:monospace;">&lt;head&gt;
 &lt;title&gt;Cloud Carousel&lt;/title&gt;
 &lt;!-- 1. Download and insert the script from Cloud Carousel Website --&gt;
 &lt;script type=&quot;text/javascript&quot; src=&quot;http://ajax.googleapis.com/ajax/libs/jquery/1.4.2/jquery.min.js&quot;&gt;&lt;/script&gt;
 &lt;script type=&quot;text/javaScript&quot; src=&quot;cloud-carousel.1.0.5.min.js&quot;&gt;&lt;/script&gt;
 &lt;script type=&quot;text/javascript&quot;&gt;
  $(document).ready(function(){
		// This initialises carousels on the container elements specified, in this case, carousel1.
		$(&quot;#carousel1&quot;).CloudCarousel(		
			{			
				// Best is half of the width you set in DIV style of carouselID
				xPos: 285,
				// Determines the central height of the pivot point of the carousel itself.
				yPos: 100,
				buttonLeft: $(&quot;#butLeft&quot;),
				buttonRight: $(&quot;#butRight&quot;),
				reflHeight: 56,
				reflGap:2,
			}
		);
	});
&nbsp;
 &lt;/script&gt;
&lt;/head&gt;
&nbsp;
&lt;body&gt;
 &lt;!-- 2. Declare a div with a given carouselID Name, use style to manage the style and height. You can add background also --&gt;
 &lt;!-- 3. Declare class=&quot;cloudcarousel&quot; to all the images sandwitched in between the div tag, these will be the images for the carousel --&gt;
 &lt;div id=&quot;carousel1&quot; style=&quot;width:570px; height:220px; background:#000;overflow:scroll;&quot;&gt;
        &lt;a href=&quot;http://www.watchlearnknow.com&quot;&gt;&lt;img class=&quot;cloudcarousel&quot; src=&quot;images/BlueAppIcon.png&quot; alt=&quot;AppIcon1&quot; width=&quot;58&quot; height =&quot;58&quot;/&gt;&lt;/a&gt;
        &lt;a href=&quot;http://www.wikipedia.com&quot;&gt;&lt;img class=&quot;cloudcarousel&quot; src=&quot;images/GoldAppIcon.png&quot; alt=&quot;AppIcon2&quot; width=&quot;58&quot; height =&quot;58&quot;/&gt;&lt;/a&gt;
	&lt;a href=&quot;http://www.wordpress.com&quot;&gt;&lt;img class=&quot;cloudcarousel&quot; src=&quot;images/GreenAppIcon.png&quot; alt=&quot;AppIcon3&quot; width=&quot;58&quot; height =&quot;58&quot;/&gt;&lt;/a&gt;
	&lt;a href=&quot;http://www.yahoo.com&quot;&gt;&lt;img class=&quot;cloudcarousel&quot; src=&quot;images/OrangeAppIcon.png&quot; alt=&quot;AppIcon4&quot; width=&quot;58&quot; height =&quot;58&quot;/&gt;&lt;/a&gt;
	&lt;a href=&quot;http://www.apple.com&quot;&gt;&lt;img class=&quot;cloudcarousel&quot; src=&quot;images/RedAppIcon.png&quot; alt=&quot;AppIcon5&quot; width=&quot;58&quot; height =&quot;58&quot;/&gt;&lt;/a&gt;
	&lt;a href=&quot;http://www.android.com&quot;&gt;&lt;img class=&quot;cloudcarousel&quot; src=&quot;images/PinkAppIcon.png&quot; alt=&quot;AppIcon6&quot; width=&quot;58&quot; height =&quot;58&quot;/&gt;&lt;/a&gt;
&nbsp;
    &lt;div id=&quot;butLeft&quot; style=&quot;position:relative;top:20px;left:20px;padding:5px;background:#fff;&quot;&gt;&amp;lt;&lt;/div&gt;
    &lt;div id=&quot;butRight&quot; style=&quot;position:relative;top:20px;left:30px;padding:5px;background:#fff;&quot;&gt;&amp;gt;&lt;/div&gt; 
 &lt;/div&gt;
&lt;/body&gt;</pre></td></tr></table></div>

<p>Well that&#8217;s it for today. If you want to take a look on my demo in source file.<br />
<p><strong><a href="http://www.isgoodstuff.com/wp-content/plugins/download-monitor/download.php?id=33">Download Here</a></strong></p></br></p>
]]></content:encoded>
			<wfw:commentRss>http://www.isgoodstuff.com/2012/02/09/html5-free-cloud-carousel/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>HTML5: Keyboard Controls &amp; Update Loop (enterFramer)</title>
		<link>http://www.isgoodstuff.com/2012/01/30/html5-keyboard-controls-update-loop-enterframer/</link>
		<comments>http://www.isgoodstuff.com/2012/01/30/html5-keyboard-controls-update-loop-enterframer/#comments</comments>
		<pubDate>Mon, 30 Jan 2012 01:28:18 +0000</pubDate>
		<dc:creator>Alex T.</dc:creator>
				<category><![CDATA[Tech]]></category>
		<category><![CDATA[canvas]]></category>
		<category><![CDATA[HTML5]]></category>
		<category><![CDATA[javascript]]></category>
		<category><![CDATA[Tutorials]]></category>

		<guid isPermaLink="false">http://www.isgoodstuff.com/?p=2184</guid>
		<description><![CDATA[<p><img src="http://www.isgoodstuff.com/wp-content/uploads/2012/01/html5Image.png"/></p>HTML5 - How to script a simple keyboard control and creating an update loop.]]></description>
			<content:encoded><![CDATA[<p><img src="http://www.isgoodstuff.com/wp-content/uploads/2012/01/html5Image.png"/></p><p style="text-align: justify;">Hiya folks, I&#8217;m back for more html5 goodies. Today i&#8217;m gonna focus more on how to script a simple keyboard control and how we make our update loop (for those coming from AS3 background, this is how we do our enterFrame). Let&#8217;s move on. </p>
<p style="text-align: justify;">Before we start, I would like to emphasize again scripting in html5 has always been with data and render done separately. Meaning, you write objects to contain it&#8217;s x and y value and compute it&#8217;s movement every updateCycle before rendering it into canvas. Check out the <strong><a href="http://www.isgoodstuff.com/wp-content/demo/Tutorial%202/" target="_blank">demo here</a></strong>.</p>
<p style="text-align: center;"><a href="http://www.isgoodstuff.com/wp-content/demo/Tutorial%202/" target="_blank"><img class="aligncenter size-full wp-image-2175" style="margin-top:5px;" title="CanvasUpdateCycle" src="http://www.isgoodstuff.com/wp-content/uploads/2012/01/CanvasUpdateCycle.jpg" alt="" width="486" height="468" /></a></p>
<p style="text-align: justify;">Below is my enterFrame Util js (this is a update loop js). You can use it for all your project. In fact, it also comes with a cool fps counter for benchmarking; all you need to do is to pass in the div id parameter for it&#8217;s output. We use update loop cycle to check in runtime, changes that happen to the objects in canvas, for example, update of movement and etc.</p>
<h4><strong>Enterframe.js</strong></h4>

<div class="wp_syntax"><div class="code"><pre class="javascript" style="font-family:monospace;"><span style="color: #003366; font-weight: bold;">var</span> enterFrame <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>
	<span style="color: #006600; font-style: italic;">// To Use this enterFrame Utility just include into script src.</span>
	<span style="color: #006600; font-style: italic;">// Then, use enterFrame.init( callBackFunction );</span>
	<span style="color: #006600; font-style: italic;">// where callbackFunction is the function that will cycle update.</span>
	<span style="color: #006600; font-style: italic;">// e.g.</span>
&nbsp;
	<span style="color: #006600; font-style: italic;">// enterFrame.init(60, handleEnterFrame);</span>
	<span style="color: #006600; font-style: italic;">// function handleEnterFrame(){</span>
	<span style="color: #006600; font-style: italic;">//      // This function runs at default 60 FrameRate</span>
	<span style="color: #006600; font-style: italic;">//      // You can also use getFPS here since, it requires</span>
	<span style="color: #006600; font-style: italic;">//      // an constant update cycle.</span>
	<span style="color: #006600; font-style: italic;">// }</span>
    <span style="color: #000066; font-weight: bold;">return</span> <span style="color: #009900;">&#123;</span><span style="color: #009900;">&#125;</span><span style="color: #339933;">;</span>
<span style="color: #009900;">&#125;</span>
&nbsp;
enterFrame <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>
	<span style="color: #003366; font-weight: bold;">var</span> myFrameRate <span style="color: #339933;">=</span> <span style="color: #CC0000;">60</span><span style="color: #339933;">;</span>
	<span style="color: #003366; font-weight: bold;">var</span> intervalTime <span style="color: #339933;">=</span> <span style="color: #CC0000;">1000</span><span style="color: #339933;">/</span>myFrameRate<span style="color: #339933;">;</span>
	<span style="color: #003366; font-weight: bold;">var</span> lastTime <span style="color: #339933;">=</span> <span style="color: #003366; font-weight: bold;">new</span> Date<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
	<span style="color: #003366; font-weight: bold;">var</span> frameCount <span style="color: #339933;">=</span> <span style="color: #CC0000;">0</span><span style="color: #339933;">;</span>
	<span style="color: #003366; font-weight: bold;">var</span> intervalTimer<span style="color: #339933;">;</span>
	<span style="color: #003366; font-weight: bold;">var</span> myCallbackFunc<span style="color: #339933;">;</span>
&nbsp;
	<span style="color: #003366; font-weight: bold;">function</span> ENTERFRAME<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#123;</span>
		<span style="color: #000066; font-weight: bold;">return</span> myCallbackFunc.<span style="color: #660066;">call</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
	<span style="color: #009900;">&#125;</span>
&nbsp;
	<span style="color: #003366; font-weight: bold;">function</span> calcFPS<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#123;</span>
		<span style="color: #003366; font-weight: bold;">var</span> nowTime <span style="color: #339933;">=</span> <span style="color: #003366; font-weight: bold;">new</span> Date<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
		<span style="color: #003366; font-weight: bold;">var</span> diffTime <span style="color: #339933;">=</span> Math.<span style="color: #660066;">ceil</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#40;</span>nowTime.<span style="color: #660066;">getTime</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span> <span style="color: #339933;">-</span> lastTime.<span style="color: #660066;">getTime</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
		<span style="color: #003366; font-weight: bold;">var</span> fps <span style="color: #339933;">=</span> myFrameRate<span style="color: #339933;">;</span>
&nbsp;
		<span style="color: #000066; font-weight: bold;">if</span> <span style="color: #009900;">&#40;</span>diffTime <span style="color: #339933;">&amp;</span>gt<span style="color: #339933;">;=</span> <span style="color: #CC0000;">1000</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
			fps <span style="color: #339933;">=</span> frameCount<span style="color: #339933;">;</span>
			frameCount <span style="color: #339933;">=</span> <span style="color: #CC0000;">0.0</span><span style="color: #339933;">;</span>
			lastTime <span style="color: #339933;">=</span> nowTime<span style="color: #339933;">;</span>
		<span style="color: #009900;">&#125;</span>
&nbsp;
		<span style="color: #000066; font-weight: bold;">return</span> frameCount<span style="color: #339933;">++;</span>
	<span style="color: #009900;">&#125;</span>
&nbsp;
	<span style="color: #000066; font-weight: bold;">return</span> <span style="color: #009900;">&#123;</span>
		init<span style="color: #339933;">:</span><span style="color: #003366; font-weight: bold;">function</span><span style="color: #009900;">&#40;</span>arg1<span style="color: #339933;">,</span> arg2<span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
			<span style="color: #000066; font-weight: bold;">if</span><span style="color: #009900;">&#40;</span>arguments.<span style="color: #660066;">length</span> <span style="color: #339933;">===</span> <span style="color: #CC0000;">2</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#123;</span>
				<span style="color: #006600; font-style: italic;">//Arguements checker:if pass in two, use arg1 as framerate override </span>
				<span style="color: #006600; font-style: italic;">// and arg2 as callback function</span>
				<span style="color: #000066; font-weight: bold;">this</span>.<span style="color: #660066;">setFrameRate</span><span style="color: #009900;">&#40;</span> arg1 <span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
				myCallbackFunc <span style="color: #339933;">=</span> arg2<span style="color: #339933;">;</span>
			<span style="color: #009900;">&#125;</span> <span style="color: #000066; font-weight: bold;">else</span> <span style="color: #009900;">&#123;</span>
				<span style="color: #006600; font-style: italic;">//Arguements checker:if pass in only one, use arg1 as callback function</span>
				<span style="color: #000066; font-weight: bold;">this</span>.<span style="color: #660066;">setFrameRate</span><span style="color: #009900;">&#40;</span> <span style="color: #CC0000;">60</span> <span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
				myCallbackFunc <span style="color: #339933;">=</span> arg1<span style="color: #339933;">;</span>
			<span style="color: #009900;">&#125;</span>
&nbsp;
			intervalTimer <span style="color: #339933;">=</span> setInterval<span style="color: #009900;">&#40;</span>ENTERFRAME<span style="color: #339933;">,</span> intervalTime <span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
		<span style="color: #009900;">&#125;</span><span style="color: #339933;">,</span>
&nbsp;
		clear<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>
			clearInterval<span style="color: #009900;">&#40;</span> intervalTimer <span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
		<span style="color: #009900;">&#125;</span><span style="color: #339933;">,</span>
&nbsp;
		setFrameRate<span style="color: #339933;">:</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>
			myFrameRate <span style="color: #339933;">=</span> value<span style="color: #339933;">;</span>
		<span style="color: #009900;">&#125;</span><span style="color: #339933;">,</span>
&nbsp;
		getFPS<span style="color: #339933;">:</span><span style="color: #003366; font-weight: bold;">function</span><span style="color: #009900;">&#40;</span>divName<span style="color: #009900;">&#41;</span><span style="color: #009900;">&#123;</span>
			<span style="color: #006600; font-style: italic;">// Must be used within callback function of EnterFrame.</span>
			<span style="color: #000066; font-weight: bold;">return</span> divName.<span style="color: #660066;">innerHTML</span> <span style="color: #339933;">=</span> <span style="color: #3366CC;">&quot;FPS Counter : &quot;</span> <span style="color: #339933;">+</span> calcFPS<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
		<span style="color: #009900;">&#125;</span>
&nbsp;
	<span style="color: #009900;">&#125;</span>
<span style="color: #009900;">&#125;</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span></pre></div></div>

<p style="text-align: justify;">And let&#8217;s look at the main html and how we intend to use it today alongside with key controls. Always try to located the middle registration point of the object you are about to draw in canvas. It is useful for positioning and animation wise. You also will need to clear the canvas content every update cycle loop (in other words every enterFrame). See codes below.</p>
<h4><strong>index.html</strong></h4>

<div class="wp_syntax"><div class="code"><pre class="html" style="font-family:monospace;">&lt;!DOCTYPE HTML&gt;
&lt;html&gt;
&lt;head&gt;
	&lt;meta http-equiv=&quot;Content-Type&quot; content=&quot;text/html; charset=utf-8&quot;&gt;
	&lt;title&gt;Sample App HTML5 One - Using Canvas and Filters&lt;/title&gt;
	&lt;meta name=&quot;generator&quot; content=&quot;TextMate http://macromates.com/&quot;&gt;
	&lt;meta name=&quot;author&quot; content=&quot;Alex Tam Ming Yen&quot;&gt;
	&lt;LINK href=&quot;default.css&quot; rel=&quot;stylesheet&quot; type=&quot;text/css&quot;&gt;
	&lt;!-- Date: 2011-12-31 --&gt;
	&lt;script src=&quot;lib/enterFrame.js&quot; text=&quot;text/javascript&quot;&gt;&lt;/script&gt;
	&lt;script&gt;
		function triggerReady(){
			var canvas = document.getElementById('canvas');  
			var contxt = canvas.getContext('2d');
			var myBox = new Object();  
&nbsp;
			function startDraw(){
				  var halfCanvasWidth = 480/2;
				  var halfCanvasHeight = 320/2;
				  var middlePointX = halfCanvasWidth - 10;
				  var middlePointY = halfCanvasHeight - 10;
&nbsp;
				  if (canvas.getContext){  
				    contxt.fillStyle = &quot;#fff&quot;;
				    contxt.fillRect(middlePointX,middlePointY,20,20);
				  	myBox.context = contxt;
					myBox.x = middlePointX;
					myBox.y = middlePointY;
					myBox.centerX = 10;
					myBox.centerY = 10;
				  }
			}
&nbsp;
			function clear(){
				contxt.clearRect(0, 0, 480, 320);
			}
&nbsp;
			startDraw();
			enterFrame.init( handleEnterFrame );
			function handleEnterFrame(){
				enterFrame.getFPS(label1);
				document.onkeypress = function(evt){
					var evt  = (evt) ? evt : ((event) ? event : null);
					var node = (evt.target) ? evt.target : ((evt.srcElement) ? evt.srcElement : null);
					// console.log( event.keyCode );
&nbsp;
					switch (event.keyCode) {
						case 32:
						     	clear();
								startDraw();
						break;
&nbsp;
						case 37:
								myBox.x -= 5;
					    break;
&nbsp;
						case 97:
								myBox.x -= 5;
						break;
&nbsp;
						case 38:
								myBox.y -=5;
						break;
&nbsp;
						case 119:
								myBox.y -=5;
						break;
&nbsp;
						case 39:
					    		myBox.x += 5;
					    break;
&nbsp;
						case 100:
								myBox.x += 5;
						break;
&nbsp;
						case 40:
								myBox.y += 5;					
					    break;
&nbsp;
						case 115:
								myBox.y += 5;
						break;
					}
				};
				renderUpdate();
			}
&nbsp;
			function renderUpdate(){
				clear();
				contxt.fillRect(myBox.x,myBox.y,20,20);				
			}
		}
	&lt;/script&gt;
&lt;/head&gt;
&lt;body onload=&quot;triggerReady()&quot;&gt;
	&lt;div class=&quot;titleBar&quot;&gt;
		&lt;h1 class=&quot;label15Arial&quot;&gt;Canvas Update Cycle&lt;h1&gt;
	&lt;/div&gt;
&nbsp;
	&lt;div class=&quot;borderContainer&quot;&gt;&lt;canvas id=&quot;canvas&quot; width=&quot;480&quot; height=&quot;320&quot;&gt;&lt;/canvas&gt;&lt;/div&gt;
	&lt;div class=&quot;controlsContainer&quot;&gt;
		&lt;div id=&quot;label1&quot; class=&quot;label1&quot;&gt;&lt;/div&gt;
	&lt;/div&gt;
&lt;/body&gt;
&lt;/html&gt;</pre></div></div>

<p>Here are the default.css for the html.</p>
<h4><strong>default.css</strong></h4>

<div class="wp_syntax"><div class="code"><pre class="css" style="font-family:monospace;"><span style="color: #808080; font-style: italic;">/**************************** HTML 5 RESET **************************/</span>
html<span style="color: #00AA00;">,</span> body<span style="color: #00AA00;">,</span> div<span style="color: #00AA00;">,</span> span<span style="color: #00AA00;">,</span> applet<span style="color: #00AA00;">,</span> object<span style="color: #00AA00;">,</span> iframe<span style="color: #00AA00;">,</span>
h1<span style="color: #00AA00;">,</span> h2<span style="color: #00AA00;">,</span> h3<span style="color: #00AA00;">,</span> h4<span style="color: #00AA00;">,</span> h5<span style="color: #00AA00;">,</span> h6<span style="color: #00AA00;">,</span> p<span style="color: #00AA00;">,</span> blockquote<span style="color: #00AA00;">,</span> pre<span style="color: #00AA00;">,</span>
a<span style="color: #00AA00;">,</span> abbr<span style="color: #00AA00;">,</span> acronym<span style="color: #00AA00;">,</span> address<span style="color: #00AA00;">,</span> big<span style="color: #00AA00;">,</span> cite<span style="color: #00AA00;">,</span> code<span style="color: #00AA00;">,</span>
del<span style="color: #00AA00;">,</span> dfn<span style="color: #00AA00;">,</span> em<span style="color: #00AA00;">,</span> img<span style="color: #00AA00;">,</span> ins<span style="color: #00AA00;">,</span> kbd<span style="color: #00AA00;">,</span> q<span style="color: #00AA00;">,</span> s<span style="color: #00AA00;">,</span> samp<span style="color: #00AA00;">,</span>
small<span style="color: #00AA00;">,</span> strike<span style="color: #00AA00;">,</span> strong<span style="color: #00AA00;">,</span> sub<span style="color: #00AA00;">,</span> sup<span style="color: #00AA00;">,</span> tt<span style="color: #00AA00;">,</span> var<span style="color: #00AA00;">,</span>
b<span style="color: #00AA00;">,</span> u<span style="color: #00AA00;">,</span> i<span style="color: #00AA00;">,</span> <span style="color: #993333;">center</span><span style="color: #00AA00;">,</span>
dl<span style="color: #00AA00;">,</span> dt<span style="color: #00AA00;">,</span> dd<span style="color: #00AA00;">,</span> ol<span style="color: #00AA00;">,</span> ul<span style="color: #00AA00;">,</span> li<span style="color: #00AA00;">,</span>
fieldset<span style="color: #00AA00;">,</span> form<span style="color: #00AA00;">,</span> label<span style="color: #00AA00;">,</span> legend<span style="color: #00AA00;">,</span>
table<span style="color: #00AA00;">,</span> caption<span style="color: #00AA00;">,</span> tbody<span style="color: #00AA00;">,</span> tfoot<span style="color: #00AA00;">,</span> thead<span style="color: #00AA00;">,</span> tr<span style="color: #00AA00;">,</span> th<span style="color: #00AA00;">,</span> td<span style="color: #00AA00;">,</span>
article<span style="color: #00AA00;">,</span> aside<span style="color: #00AA00;">,</span> canvas<span style="color: #00AA00;">,</span> details<span style="color: #00AA00;">,</span> <span style="color: #993333;">embed</span><span style="color: #00AA00;">,</span> 
figure<span style="color: #00AA00;">,</span> figcaption<span style="color: #00AA00;">,</span> footer<span style="color: #00AA00;">,</span> header<span style="color: #00AA00;">,</span> hgroup<span style="color: #00AA00;">,</span> 
menu<span style="color: #00AA00;">,</span> nav<span style="color: #00AA00;">,</span> output<span style="color: #00AA00;">,</span> ruby<span style="color: #00AA00;">,</span> section<span style="color: #00AA00;">,</span> summary<span style="color: #00AA00;">,</span>
time<span style="color: #00AA00;">,</span> mark<span style="color: #00AA00;">,</span> audio<span style="color: #00AA00;">,</span> video <span style="color: #00AA00;">&#123;</span>
	<span style="color: #000000; font-weight: bold;">margin</span><span style="color: #00AA00;">:</span> <span style="color: #cc66cc;">0</span><span style="color: #00AA00;">;</span>
	<span style="color: #000000; font-weight: bold;">padding</span><span style="color: #00AA00;">:</span> <span style="color: #cc66cc;">0</span><span style="color: #00AA00;">;</span>
	<span style="color: #000000; font-weight: bold;">border</span><span style="color: #00AA00;">:</span> <span style="color: #cc66cc;">0</span><span style="color: #00AA00;">;</span>
	<span style="color: #000000; font-weight: bold;">font-size</span><span style="color: #00AA00;">:</span> <span style="color: #933;">100%</span><span style="color: #00AA00;">;</span>
	<span style="color: #000000; font-weight: bold;">font</span><span style="color: #00AA00;">:</span> <span style="color: #993333;">inherit</span><span style="color: #00AA00;">;</span>
	<span style="color: #000000; font-weight: bold;">vertical-align</span><span style="color: #00AA00;">:</span> <span style="color: #993333;">baseline</span><span style="color: #00AA00;">;</span>
<span style="color: #00AA00;">&#125;</span>
<span style="color: #808080; font-style: italic;">/* HTML5 display-role reset for older browsers */</span>
article<span style="color: #00AA00;">,</span> aside<span style="color: #00AA00;">,</span> details<span style="color: #00AA00;">,</span> figcaption<span style="color: #00AA00;">,</span> figure<span style="color: #00AA00;">,</span> 
footer<span style="color: #00AA00;">,</span> header<span style="color: #00AA00;">,</span> hgroup<span style="color: #00AA00;">,</span> menu<span style="color: #00AA00;">,</span> nav<span style="color: #00AA00;">,</span> section <span style="color: #00AA00;">&#123;</span>
	<span style="color: #000000; font-weight: bold;">display</span><span style="color: #00AA00;">:</span> <span style="color: #993333;">block</span><span style="color: #00AA00;">;</span>
<span style="color: #00AA00;">&#125;</span>
body <span style="color: #00AA00;">&#123;</span>
	<span style="color: #000000; font-weight: bold;">line-height</span><span style="color: #00AA00;">:</span> <span style="color: #cc66cc;">1</span><span style="color: #00AA00;">;</span>
<span style="color: #00AA00;">&#125;</span>
ol<span style="color: #00AA00;">,</span> ul <span style="color: #00AA00;">&#123;</span>
	<span style="color: #000000; font-weight: bold;">list-style</span><span style="color: #00AA00;">:</span> <span style="color: #993333;">none</span><span style="color: #00AA00;">;</span>
<span style="color: #00AA00;">&#125;</span>
blockquote<span style="color: #00AA00;">,</span> q <span style="color: #00AA00;">&#123;</span>
	<span style="color: #000000; font-weight: bold;">quotes</span><span style="color: #00AA00;">:</span> <span style="color: #993333;">none</span><span style="color: #00AA00;">;</span>
<span style="color: #00AA00;">&#125;</span>
blockquote<span style="color: #3333ff;">:before</span><span style="color: #00AA00;">,</span> blockquote<span style="color: #3333ff;">:after</span><span style="color: #00AA00;">,</span>
q<span style="color: #3333ff;">:before</span><span style="color: #00AA00;">,</span> q<span style="color: #3333ff;">:after </span><span style="color: #00AA00;">&#123;</span>
	<span style="color: #000000; font-weight: bold;">content</span><span style="color: #00AA00;">:</span> <span style="color: #ff0000;">''</span><span style="color: #00AA00;">;</span>
	<span style="color: #000000; font-weight: bold;">content</span><span style="color: #00AA00;">:</span> <span style="color: #993333;">none</span><span style="color: #00AA00;">;</span>
<span style="color: #00AA00;">&#125;</span>
table <span style="color: #00AA00;">&#123;</span>
	<span style="color: #000000; font-weight: bold;">border-collapse</span><span style="color: #00AA00;">:</span> <span style="color: #993333;">collapse</span><span style="color: #00AA00;">;</span>
	<span style="color: #000000; font-weight: bold;">border-spacing</span><span style="color: #00AA00;">:</span> <span style="color: #cc66cc;">0</span><span style="color: #00AA00;">;</span>
<span style="color: #00AA00;">&#125;</span>
&nbsp;
<span style="color: #808080; font-style: italic;">/**************************** HTML 5 RESET **************************/</span>
<span style="color: #6666ff;">.label15Arial</span> <span style="color: #00AA00;">&#123;</span>
	<span style="color: #000000; font-weight: bold;">font-family</span><span style="color: #00AA00;">:</span>Arial<span style="color: #00AA00;">;</span>
	<span style="color: #000000; font-weight: bold;">color</span><span style="color: #00AA00;">:</span><span style="color: #cc00cc;">#fff</span><span style="color: #00AA00;">;</span>
	<span style="color: #000000; font-weight: bold;">font-size</span><span style="color: #00AA00;">:</span><span style="color: #933;">16pt</span><span style="color: #00AA00;">;</span>
	<span style="color: #000000; font-weight: bold;">font-weight</span><span style="color: #00AA00;">:</span><span style="color: #993333;">bolder</span><span style="color: #00AA00;">;</span>
	<span style="color: #000000; font-weight: bold;">text-shadow</span><span style="color: #00AA00;">:</span> <span style="color: #cc00cc;">#333</span> <span style="color: #cc66cc;">0</span> <span style="color: #cc66cc;">0</span> <span style="color: #cc66cc;">0</span><span style="color: #00AA00;">;</span>
	<span style="color: #000000; font-weight: bold;">padding-top</span><span style="color: #00AA00;">:</span><span style="color: #933;">10px</span><span style="color: #00AA00;">;</span>
	<span style="color: #000000; font-weight: bold;">text-align</span><span style="color: #00AA00;">:</span><span style="color: #993333;">center</span><span style="color: #00AA00;">;</span>
<span style="color: #00AA00;">&#125;</span>
&nbsp;
<span style="color: #6666ff;">.titleBar</span> <span style="color: #00AA00;">&#123;</span>
	<span style="color: #000000; font-weight: bold;">background-image</span><span style="color: #00AA00;">:</span> linear-gradient<span style="color: #00AA00;">&#40;</span><span style="color: #000000; font-weight: bold;">bottom</span><span style="color: #00AA00;">,</span> <span style="color: #993333;">rgb</span><span style="color: #00AA00;">&#40;</span><span style="color: #cc66cc;">0</span><span style="color: #00AA00;">,</span><span style="color: #cc66cc;">0</span><span style="color: #00AA00;">,</span><span style="color: #cc66cc;">0</span><span style="color: #00AA00;">&#41;</span> <span style="color: #933;">58%</span><span style="color: #00AA00;">,</span> <span style="color: #993333;">rgb</span><span style="color: #00AA00;">&#40;</span><span style="color: #cc66cc;">184</span><span style="color: #00AA00;">,</span><span style="color: #cc66cc;">184</span><span style="color: #00AA00;">,</span><span style="color: #cc66cc;">184</span><span style="color: #00AA00;">&#41;</span> <span style="color: #933;">80%</span><span style="color: #00AA00;">,</span> <span style="color: #993333;">rgb</span><span style="color: #00AA00;">&#40;</span><span style="color: #cc66cc;">39</span><span style="color: #00AA00;">,</span><span style="color: #cc66cc;">46</span><span style="color: #00AA00;">,</span><span style="color: #cc66cc;">46</span><span style="color: #00AA00;">&#41;</span> <span style="color: #933;">94%</span><span style="color: #00AA00;">&#41;</span><span style="color: #00AA00;">;</span>
	<span style="color: #000000; font-weight: bold;">background-image</span><span style="color: #00AA00;">:</span> -o-linear-gradient<span style="color: #00AA00;">&#40;</span><span style="color: #000000; font-weight: bold;">bottom</span><span style="color: #00AA00;">,</span> <span style="color: #993333;">rgb</span><span style="color: #00AA00;">&#40;</span><span style="color: #cc66cc;">0</span><span style="color: #00AA00;">,</span><span style="color: #cc66cc;">0</span><span style="color: #00AA00;">,</span><span style="color: #cc66cc;">0</span><span style="color: #00AA00;">&#41;</span> <span style="color: #933;">58%</span><span style="color: #00AA00;">,</span> <span style="color: #993333;">rgb</span><span style="color: #00AA00;">&#40;</span><span style="color: #cc66cc;">184</span><span style="color: #00AA00;">,</span><span style="color: #cc66cc;">184</span><span style="color: #00AA00;">,</span><span style="color: #cc66cc;">184</span><span style="color: #00AA00;">&#41;</span> <span style="color: #933;">80%</span><span style="color: #00AA00;">,</span> <span style="color: #993333;">rgb</span><span style="color: #00AA00;">&#40;</span><span style="color: #cc66cc;">39</span><span style="color: #00AA00;">,</span><span style="color: #cc66cc;">46</span><span style="color: #00AA00;">,</span><span style="color: #cc66cc;">46</span><span style="color: #00AA00;">&#41;</span> <span style="color: #933;">94%</span><span style="color: #00AA00;">&#41;</span><span style="color: #00AA00;">;</span>
	<span style="color: #000000; font-weight: bold;">background-image</span><span style="color: #00AA00;">:</span> -moz-linear-gradient<span style="color: #00AA00;">&#40;</span><span style="color: #000000; font-weight: bold;">bottom</span><span style="color: #00AA00;">,</span> <span style="color: #993333;">rgb</span><span style="color: #00AA00;">&#40;</span><span style="color: #cc66cc;">0</span><span style="color: #00AA00;">,</span><span style="color: #cc66cc;">0</span><span style="color: #00AA00;">,</span><span style="color: #cc66cc;">0</span><span style="color: #00AA00;">&#41;</span> <span style="color: #933;">58%</span><span style="color: #00AA00;">,</span> <span style="color: #993333;">rgb</span><span style="color: #00AA00;">&#40;</span><span style="color: #cc66cc;">184</span><span style="color: #00AA00;">,</span><span style="color: #cc66cc;">184</span><span style="color: #00AA00;">,</span><span style="color: #cc66cc;">184</span><span style="color: #00AA00;">&#41;</span> <span style="color: #933;">80%</span><span style="color: #00AA00;">,</span> <span style="color: #993333;">rgb</span><span style="color: #00AA00;">&#40;</span><span style="color: #cc66cc;">39</span><span style="color: #00AA00;">,</span><span style="color: #cc66cc;">46</span><span style="color: #00AA00;">,</span><span style="color: #cc66cc;">46</span><span style="color: #00AA00;">&#41;</span> <span style="color: #933;">94%</span><span style="color: #00AA00;">&#41;</span><span style="color: #00AA00;">;</span>
	<span style="color: #000000; font-weight: bold;">background-image</span><span style="color: #00AA00;">:</span> -webkit-linear-gradient<span style="color: #00AA00;">&#40;</span><span style="color: #000000; font-weight: bold;">bottom</span><span style="color: #00AA00;">,</span> <span style="color: #993333;">rgb</span><span style="color: #00AA00;">&#40;</span><span style="color: #cc66cc;">0</span><span style="color: #00AA00;">,</span><span style="color: #cc66cc;">0</span><span style="color: #00AA00;">,</span><span style="color: #cc66cc;">0</span><span style="color: #00AA00;">&#41;</span> <span style="color: #933;">58%</span><span style="color: #00AA00;">,</span> <span style="color: #993333;">rgb</span><span style="color: #00AA00;">&#40;</span><span style="color: #cc66cc;">184</span><span style="color: #00AA00;">,</span><span style="color: #cc66cc;">184</span><span style="color: #00AA00;">,</span><span style="color: #cc66cc;">184</span><span style="color: #00AA00;">&#41;</span> <span style="color: #933;">80%</span><span style="color: #00AA00;">,</span> <span style="color: #993333;">rgb</span><span style="color: #00AA00;">&#40;</span><span style="color: #cc66cc;">39</span><span style="color: #00AA00;">,</span><span style="color: #cc66cc;">46</span><span style="color: #00AA00;">,</span><span style="color: #cc66cc;">46</span><span style="color: #00AA00;">&#41;</span> <span style="color: #933;">94%</span><span style="color: #00AA00;">&#41;</span><span style="color: #00AA00;">;</span>
	<span style="color: #000000; font-weight: bold;">background-image</span><span style="color: #00AA00;">:</span> -ms-linear-gradient<span style="color: #00AA00;">&#40;</span><span style="color: #000000; font-weight: bold;">bottom</span><span style="color: #00AA00;">,</span> <span style="color: #993333;">rgb</span><span style="color: #00AA00;">&#40;</span><span style="color: #cc66cc;">0</span><span style="color: #00AA00;">,</span><span style="color: #cc66cc;">0</span><span style="color: #00AA00;">,</span><span style="color: #cc66cc;">0</span><span style="color: #00AA00;">&#41;</span> <span style="color: #933;">58%</span><span style="color: #00AA00;">,</span> <span style="color: #993333;">rgb</span><span style="color: #00AA00;">&#40;</span><span style="color: #cc66cc;">184</span><span style="color: #00AA00;">,</span><span style="color: #cc66cc;">184</span><span style="color: #00AA00;">,</span><span style="color: #cc66cc;">184</span><span style="color: #00AA00;">&#41;</span> <span style="color: #933;">80%</span><span style="color: #00AA00;">,</span> <span style="color: #993333;">rgb</span><span style="color: #00AA00;">&#40;</span><span style="color: #cc66cc;">39</span><span style="color: #00AA00;">,</span><span style="color: #cc66cc;">46</span><span style="color: #00AA00;">,</span><span style="color: #cc66cc;">46</span><span style="color: #00AA00;">&#41;</span> <span style="color: #933;">94%</span><span style="color: #00AA00;">&#41;</span><span style="color: #00AA00;">;</span>
	<span style="color: #000000; font-weight: bold;">width</span><span style="color: #00AA00;">:</span><span style="color: #933;">100%</span><span style="color: #00AA00;">;</span>
	<span style="color: #000000; font-weight: bold;">height</span><span style="color: #00AA00;">:</span><span style="color: #933;">45px</span><span style="color: #00AA00;">;</span>
<span style="color: #00AA00;">&#125;</span>
&nbsp;
<span style="color: #6666ff;">.borderContainer</span> <span style="color: #00AA00;">&#123;</span>
	<span style="color: #000000; font-weight: bold;">border</span><span style="color: #00AA00;">:</span><span style="color: #933;">1px</span> <span style="color: #993333;">solid</span> <span style="color: #cc00cc;">#c0c0c0</span><span style="color: #00AA00;">;</span>
	<span style="color: #000000; font-weight: bold;">margin-left</span><span style="color: #00AA00;">:</span><span style="color: #993333;">auto</span><span style="color: #00AA00;">;</span>
	<span style="color: #000000; font-weight: bold;">margin-right</span><span style="color: #00AA00;">:</span><span style="color: #993333;">auto</span><span style="color: #00AA00;">;</span>
	<span style="color: #000000; font-weight: bold;">margin-top</span><span style="color: #00AA00;">:</span><span style="color: #933;">15px</span><span style="color: #00AA00;">;</span>
	<span style="color: #000000; font-weight: bold;">width</span><span style="color: #00AA00;">:</span><span style="color: #933;">480px</span><span style="color: #00AA00;">;</span>
	<span style="color: #000000; font-weight: bold;">height</span><span style="color: #00AA00;">:</span><span style="color: #933;">320px</span><span style="color: #00AA00;">;</span>
	-moz-border-radius<span style="color: #00AA00;">:</span> <span style="color: #933;">8px</span><span style="color: #00AA00;">;</span>
	border-radius<span style="color: #00AA00;">:</span> <span style="color: #933;">8px</span><span style="color: #00AA00;">;</span>
<span style="color: #00AA00;">&#125;</span>
&nbsp;
<span style="color: #6666ff;">.controlsContainer</span> <span style="color: #00AA00;">&#123;</span>
	<span style="color: #000000; font-weight: bold;">border</span><span style="color: #00AA00;">:</span><span style="color: #933;">1px</span> <span style="color: #993333;">solid</span> <span style="color: #cc00cc;">#c0c0c0</span><span style="color: #00AA00;">;</span>
	<span style="color: #000000; font-weight: bold;">margin-left</span><span style="color: #00AA00;">:</span><span style="color: #993333;">auto</span><span style="color: #00AA00;">;</span>
	<span style="color: #000000; font-weight: bold;">margin-right</span><span style="color: #00AA00;">:</span><span style="color: #993333;">auto</span><span style="color: #00AA00;">;</span>
	<span style="color: #000000; font-weight: bold;">margin-top</span><span style="color: #00AA00;">:</span><span style="color: #933;">15px</span><span style="color: #00AA00;">;</span>
	<span style="color: #000000; font-weight: bold;">width</span><span style="color: #00AA00;">:</span><span style="color: #933;">480px</span><span style="color: #00AA00;">;</span>
	<span style="color: #000000; font-weight: bold;">height</span><span style="color: #00AA00;">:</span><span style="color: #933;">50px</span><span style="color: #00AA00;">;</span>
	-moz-border-radius<span style="color: #00AA00;">:</span> <span style="color: #933;">8px</span><span style="color: #00AA00;">;</span>
	border-radius<span style="color: #00AA00;">:</span> <span style="color: #933;">8px</span><span style="color: #00AA00;">;</span>
<span style="color: #00AA00;">&#125;</span>
&nbsp;
<span style="color: #6666ff;">.label1</span> <span style="color: #00AA00;">&#123;</span>
	<span style="color: #000000; font-weight: bold;">font-family</span><span style="color: #00AA00;">:</span>Arial<span style="color: #00AA00;">;</span>
	<span style="color: #000000; font-weight: bold;">color</span><span style="color: #00AA00;">:</span><span style="color: #cc00cc;">#000</span><span style="color: #00AA00;">;</span>
	<span style="color: #000000; font-weight: bold;">font-size</span><span style="color: #00AA00;">:</span><span style="color: #933;">14px</span><span style="color: #00AA00;">;</span>
	<span style="color: #000000; font-weight: bold;">margin-top</span><span style="color: #00AA00;">:</span><span style="color: #933;">15px</span><span style="color: #00AA00;">;</span>
	<span style="color: #000000; font-weight: bold;">margin-left</span><span style="color: #00AA00;">:</span><span style="color: #933;">15px</span><span style="color: #00AA00;">;</span>
	<span style="color: #000000; font-weight: bold;">width</span><span style="color: #00AA00;">:</span><span style="color: #933;">255px</span><span style="color: #00AA00;">;</span>
	<span style="color: #000000; font-weight: bold;">font-weight</span><span style="color: #00AA00;">:</span><span style="color: #993333;">bolder</span><span style="color: #00AA00;">;</span>
	<span style="color: #000000; font-weight: bold;">text-shadow</span><span style="color: #00AA00;">:</span> <span style="color: #cc00cc;">#333</span> <span style="color: #cc66cc;">0</span> <span style="color: #cc66cc;">0</span> <span style="color: #cc66cc;">0</span><span style="color: #00AA00;">;</span>
	<span style="color: #000000; font-weight: bold;">float</span><span style="color: #00AA00;">:</span><span style="color: #000000; font-weight: bold;">left</span><span style="color: #00AA00;">;</span>
<span style="color: #00AA00;">&#125;</span>
&nbsp;
<span style="color: #6666ff;">.buttons</span> <span style="color: #00AA00;">&#123;</span>
	-moz-border-radius<span style="color: #00AA00;">:</span> <span style="color: #933;">6px</span><span style="color: #00AA00;">;</span>
	border-radius<span style="color: #00AA00;">:</span> <span style="color: #933;">6px</span><span style="color: #00AA00;">;</span>
	<span style="color: #000000; font-weight: bold;">width</span><span style="color: #00AA00;">:</span><span style="color: #933;">300px</span><span style="color: #00AA00;">;</span>
	<span style="color: #000000; font-weight: bold;">background</span><span style="color: #00AA00;">:</span><span style="color: #cc00cc;">#fff</span><span style="color: #00AA00;">;</span>
	<span style="color: #000000; font-weight: bold;">height</span><span style="color: #00AA00;">:</span><span style="color: #933;">30px</span><span style="color: #00AA00;">;</span>
	<span style="color: #000000; font-weight: bold;">margin-top</span><span style="color: #00AA00;">:</span><span style="color: #933;">15px</span><span style="color: #00AA00;">;</span>
	<span style="color: #000000; font-weight: bold;">color</span><span style="color: #00AA00;">:</span><span style="color: #cc00cc;">#000</span><span style="color: #00AA00;">;</span>
<span style="color: #00AA00;">&#125;</span>
&nbsp;
<span style="color: #cc00cc;">#canvas</span> <span style="color: #00AA00;">&#123;</span>
	-moz-border-radius<span style="color: #00AA00;">:</span> <span style="color: #933;">6px</span><span style="color: #00AA00;">;</span>
	border-radius<span style="color: #00AA00;">:</span> <span style="color: #933;">6px</span><span style="color: #00AA00;">;</span>
	<span style="color: #000000; font-weight: bold;">background</span><span style="color: #00AA00;">:</span><span style="color: #cc00cc;">#990000</span><span style="color: #00AA00;">;</span>
<span style="color: #00AA00;">&#125;</span></pre></div></div>

<p>Hope you enjoy this code samples. Don&#8217;t forget to try out the <strong><a href="http://www.isgoodstuff.com/wp-content/demo/Tutorial%202/" target="_blank">demo here</a></strong>.<br />
For today&#8217;s source code.<br />
<p><strong><a href="http://www.isgoodstuff.com/wp-content/plugins/download-monitor/download.php?id=32">Download Here</a></strong></p></br></p>
]]></content:encoded>
			<wfw:commentRss>http://www.isgoodstuff.com/2012/01/30/html5-keyboard-controls-update-loop-enterframer/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>HTML5 : Canvas Image Manipulation Tutorial</title>
		<link>http://www.isgoodstuff.com/2012/01/05/html5-image-in-canvas-tutorial/</link>
		<comments>http://www.isgoodstuff.com/2012/01/05/html5-image-in-canvas-tutorial/#comments</comments>
		<pubDate>Thu, 05 Jan 2012 10:53:20 +0000</pubDate>
		<dc:creator>Alex T.</dc:creator>
				<category><![CDATA[Tech]]></category>
		<category><![CDATA[canvas]]></category>
		<category><![CDATA[HTML5]]></category>
		<category><![CDATA[javascript]]></category>
		<category><![CDATA[Tutorials]]></category>

		<guid isPermaLink="false">http://www.isgoodstuff.com/?p=2127</guid>
		<description><![CDATA[<p><img src="http://www.isgoodstuff.com/wp-content/uploads/2012/01/html5.png"/></p>Short tutorial on Image manipulation using Canvas. Look Ma...no flash o_O!]]></description>
			<content:encoded><![CDATA[<p><img src="http://www.isgoodstuff.com/wp-content/uploads/2012/01/html5.png"/></p><p style="text-align: justify;">Today, I&#8217;m sharing with you a little on Image manipulation using Canvas. Since it&#8217;s already 2012, I figured it&#8217;s time to write more on my HTML5 stuff. As you already know by now, one of the most powerful and interactive element in html5 is none other than the Canvas. Rather, than blogging about theory of what html5 is and what&#8217;s the new tag blah blah&#8230;I&#8217;m just gonna make a simple project out of it &#8211; a straight forward implementation. So today&#8217;s tutorial, I will be covering the followings :-</p>
<p style="text-align: center;"><a href="http://www.isgoodstuff.com/wp-content/demo/Tutorial%201/Tutorial%201%20-%20CanvasImage.html" target="_blank"><img class="aligncenter size-full wp-image-2129" title="SampleCanvas" src="http://www.isgoodstuff.com/wp-content/uploads/2012/01/SampleCanvas.png" alt="" width="480" height="467" style="margin-top:5px" valign="5" /></a></p>
<ul>
<li style="text-align: justify;">Loading an image into the canvas</li>
<li>Image blurring effect &#8211; using an External Library (StackBlur.js)</li>
<li>Image rotation &#8211; pure html5 canvas programming</li>
<li>Little on CSS3  - a little on the border radius stuff, gradient stuff.</li>
<li>Slider element of HTML5. &#8211; pure html5 usage of input type=&#8221;range&#8221; (yes, No more JQueryUI and loading lots of js files &#8211; just for one slider)</li>
</ul>
<p style="text-align: justify;">First of you might wanna have a look at the demo I&#8217;ve prepared in advance <a href="http://www.isgoodstuff.com/wp-content/demo/Tutorial%201/Tutorial 1 - CanvasImage.html" target="_blank">here</a>. You may also download the entire tutorial below.</p>
<p><strong><a href="http://www.isgoodstuff.com/wp-content/plugins/download-monitor/download.php?id=31">Download Here</a></strong></p></br>
<p style="text-align: justify;">Ok, first let&#8217;s look html code itself. Like all standard html5 page, the standard doctype must be declared prior to anything. Click on the button to load an image into the canvas which is the white box with rounded borders in the center of the html page. Try playing around with the sliders. Apply blur effect and the rotation.</p>

<div class="wp_syntax"><table><tr><td class="line_numbers"><pre>1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
</pre></td><td class="code"><pre class="text" style="font-family:monospace;">&lt;!DOCTYPE HTML&gt;
&lt;html&gt;
&lt;head&gt;
	&lt;meta http-equiv=&quot;Content-Type&quot; content=&quot;text/html; charset=utf-8&quot;&gt;
	&lt;title&gt;Sample App HTML5 One - Using Canvas and Filters&lt;/title&gt;
	&lt;meta name=&quot;generator&quot; content=&quot;TextMate http://macromates.com/&quot;&gt;
	&lt;meta name=&quot;author&quot; content=&quot;Alex Tam Ming Yen&quot;&gt;
	&lt;LINK href=&quot;default.css&quot; rel=&quot;stylesheet&quot; type=&quot;text/css&quot;&gt;
	&lt;!-- Date: 2011-12-31 --&gt;
	&lt;script type=&quot;text/javascript&quot; src=&quot;lib/StackBlur.js&quot;&gt;&lt;/script&gt;
	&lt;script&gt;
		function triggerReady(){
			var btnLoadImage 	= document.getElementById('btnLoadImage');
			var blur_range 		= document.getElementById('blurRange');
			var rotation_range 	= document.getElementById('rotationRange');
			var canvas 		 = document.getElementById('canvas');
			var imageRefence = document.getElementById('imgSrc');
                        // The Canvas context governs the rendering of the canvas content itself. 
			var contxt = canvas.getContext('2d');
                        // Declaring an image Object.
			var img = new Image();
			img.width = 480;
			img.height = 320;
&nbsp;
			btnLoadImage.onclick = function(){
				img.onload = function(){
				    clear();
				    contxt.drawImage(img, 0, 0, img.width, img.height);
				}
				img.src = 'images/ProfilePic.png';
				imageRefence.src = img.src;
			}
&nbsp;
			blur_range.onchange = function(){
				processImageBlur( blur_range.value );
			}
&nbsp;
			rotation_range.onchange = function(){
				processRotateImage( rotation_range.value );
			}
&nbsp;
			function processImageBlur( value ){
                                // I use stackBlur.js for this refer to this site to know more on how to use and apply this.
                                // http://www.quasimondo.com/StackBlurForCanvas/StackBlurDemo.html
				stackBlurImage( &quot;imgSrc&quot;, &quot;canvas&quot;, value, false );
				rotation_range.value = 0;
			}
&nbsp;
			function processRotateImage( value ){
				clear();
				contxt.save();
                                // Like all rotation, it needs a center pivot to refer to.
                                // For that we use translate and move the coordinate to the middle of the image
				contxt.translate(480/2, 320/2);
                                contxt.rotate(value * Math.PI / 180);
				// You need to reverse translate back the coordinate because, you still need to render the image from 0,0.
                                contxt.translate(-(480/2), -(320/2));
				contxt.drawImage(img, 0, 0, 480, 320);
				contxt.restore();
			}
&nbsp;
			function clear(){
                                // Erase content of the canvas and refresh.
				contxt.clearRect(0, 0, 480, 320);
			}
		}
&nbsp;
	&lt;/script&gt;
&lt;/head&gt;
&lt;body onload=&quot;triggerReady()&quot;&gt;
	&lt;div class=&quot;titleBar&quot;&gt;
		&lt;h1 class=&quot;label15Arial&quot;&gt;Sample App With Canvas&lt;h1&gt;
	&lt;/div&gt;
&nbsp;
	&lt;div class=&quot;borderContainer&quot;&gt;&lt;canvas id=&quot;canvas&quot; width=&quot;480&quot; height=&quot;320&quot;&gt;&lt;/canvas&gt;&lt;/div&gt;
	&lt;div class=&quot;controlsContainer&quot;&gt;
		&lt;label class=&quot;range1label&quot;&gt;Blur Range&lt;/label&gt;
		&lt;input type=&quot;range&quot; min=&quot;0&quot; max=&quot;100&quot; value=&quot;0&quot; step=&quot;1&quot; class=&quot;range1&quot; id=&quot;blurRange&quot;/&gt;
&nbsp;
		&lt;label class=&quot;range2label&quot;&gt;Rotation&lt;/label&gt;
		&lt;input type=&quot;range&quot; min=&quot;0&quot; max=&quot;359&quot; value=&quot;0&quot; step=&quot;1&quot; class=&quot;range2&quot; id=&quot;rotationRange&quot;/&gt;
		&lt;center&gt;
		&lt;input type=&quot;submit&quot; value=&quot;Load Image...&quot; class=&quot;buttons&quot; id=&quot;btnLoadImage&quot; /&gt;
		&lt;/center&gt;
	&lt;/div&gt;
&nbsp;
	&lt;div id=&quot;referenceData&quot; hidden=&quot;true&quot;&gt;&lt;img id=&quot;imgSrc&quot;&gt;&lt;/div&gt;
&lt;/body&gt;
&lt;/html&gt;</pre></td></tr></table></div>

<p style="text-align: justify;">Take a look how the canvas is implemented, just a simple and clean tag isn&#8217;t it sweet ? Notice, in canvas programming, you must always remember, to &#8220;represent&#8221; an object e.g. image in our case, everything must be done in data abstraction in the memory &#8211; then render to display. Like the case of rotation (see line 48).</p>
<ul>
<li>The canvas content is cleared, </li>
<li>New angle is calculated, </li>
<li>The coordinates is translated</li>
<li>Image object is rotated in memory</li>
<li>Image object is redrawn into the canvas</li>
</ul>
<p style="text-align: justify;">Every time a rotation slider value is changed. Well, the rest you can read up and experiment more by tweaking my codes in the source to find out more. We now take a look at the CSS file. By the way, I generate my gradient <a href="http://gradients.glrzad.com/">here</a> </p>
<p>&nbsp;</p>

<div class="wp_syntax"><div class="code"><pre class="css" style="font-family:monospace;"><span style="color: #808080; font-style: italic;">/**************************** HTML 5 RESET **************************/</span>
html<span style="color: #00AA00;">,</span> body<span style="color: #00AA00;">,</span> div<span style="color: #00AA00;">,</span> span<span style="color: #00AA00;">,</span> applet<span style="color: #00AA00;">,</span> object<span style="color: #00AA00;">,</span> iframe<span style="color: #00AA00;">,</span>
h1<span style="color: #00AA00;">,</span> h2<span style="color: #00AA00;">,</span> h3<span style="color: #00AA00;">,</span> h4<span style="color: #00AA00;">,</span> h5<span style="color: #00AA00;">,</span> h6<span style="color: #00AA00;">,</span> p<span style="color: #00AA00;">,</span> blockquote<span style="color: #00AA00;">,</span> pre<span style="color: #00AA00;">,</span>
a<span style="color: #00AA00;">,</span> abbr<span style="color: #00AA00;">,</span> acronym<span style="color: #00AA00;">,</span> address<span style="color: #00AA00;">,</span> big<span style="color: #00AA00;">,</span> cite<span style="color: #00AA00;">,</span> code<span style="color: #00AA00;">,</span>
del<span style="color: #00AA00;">,</span> dfn<span style="color: #00AA00;">,</span> em<span style="color: #00AA00;">,</span> img<span style="color: #00AA00;">,</span> ins<span style="color: #00AA00;">,</span> kbd<span style="color: #00AA00;">,</span> q<span style="color: #00AA00;">,</span> s<span style="color: #00AA00;">,</span> samp<span style="color: #00AA00;">,</span>
small<span style="color: #00AA00;">,</span> strike<span style="color: #00AA00;">,</span> strong<span style="color: #00AA00;">,</span> sub<span style="color: #00AA00;">,</span> sup<span style="color: #00AA00;">,</span> tt<span style="color: #00AA00;">,</span> var<span style="color: #00AA00;">,</span>
b<span style="color: #00AA00;">,</span> u<span style="color: #00AA00;">,</span> i<span style="color: #00AA00;">,</span> <span style="color: #993333;">center</span><span style="color: #00AA00;">,</span>
dl<span style="color: #00AA00;">,</span> dt<span style="color: #00AA00;">,</span> dd<span style="color: #00AA00;">,</span> ol<span style="color: #00AA00;">,</span> ul<span style="color: #00AA00;">,</span> li<span style="color: #00AA00;">,</span>
fieldset<span style="color: #00AA00;">,</span> form<span style="color: #00AA00;">,</span> label<span style="color: #00AA00;">,</span> legend<span style="color: #00AA00;">,</span>
table<span style="color: #00AA00;">,</span> caption<span style="color: #00AA00;">,</span> tbody<span style="color: #00AA00;">,</span> tfoot<span style="color: #00AA00;">,</span> thead<span style="color: #00AA00;">,</span> tr<span style="color: #00AA00;">,</span> th<span style="color: #00AA00;">,</span> td<span style="color: #00AA00;">,</span>
article<span style="color: #00AA00;">,</span> aside<span style="color: #00AA00;">,</span> canvas<span style="color: #00AA00;">,</span> details<span style="color: #00AA00;">,</span> <span style="color: #993333;">embed</span><span style="color: #00AA00;">,</span> 
figure<span style="color: #00AA00;">,</span> figcaption<span style="color: #00AA00;">,</span> footer<span style="color: #00AA00;">,</span> header<span style="color: #00AA00;">,</span> hgroup<span style="color: #00AA00;">,</span> 
menu<span style="color: #00AA00;">,</span> nav<span style="color: #00AA00;">,</span> output<span style="color: #00AA00;">,</span> ruby<span style="color: #00AA00;">,</span> section<span style="color: #00AA00;">,</span> summary<span style="color: #00AA00;">,</span>
time<span style="color: #00AA00;">,</span> mark<span style="color: #00AA00;">,</span> audio<span style="color: #00AA00;">,</span> video <span style="color: #00AA00;">&#123;</span>
	<span style="color: #000000; font-weight: bold;">margin</span><span style="color: #00AA00;">:</span> <span style="color: #cc66cc;">0</span><span style="color: #00AA00;">;</span>
	<span style="color: #000000; font-weight: bold;">padding</span><span style="color: #00AA00;">:</span> <span style="color: #cc66cc;">0</span><span style="color: #00AA00;">;</span>
	<span style="color: #000000; font-weight: bold;">border</span><span style="color: #00AA00;">:</span> <span style="color: #cc66cc;">0</span><span style="color: #00AA00;">;</span>
	<span style="color: #000000; font-weight: bold;">font-size</span><span style="color: #00AA00;">:</span> <span style="color: #933;">100%</span><span style="color: #00AA00;">;</span>
	<span style="color: #000000; font-weight: bold;">font</span><span style="color: #00AA00;">:</span> <span style="color: #993333;">inherit</span><span style="color: #00AA00;">;</span>
	<span style="color: #000000; font-weight: bold;">vertical-align</span><span style="color: #00AA00;">:</span> <span style="color: #993333;">baseline</span><span style="color: #00AA00;">;</span>
<span style="color: #00AA00;">&#125;</span>
<span style="color: #808080; font-style: italic;">/* HTML5 display-role reset for older browsers */</span>
article<span style="color: #00AA00;">,</span> aside<span style="color: #00AA00;">,</span> details<span style="color: #00AA00;">,</span> figcaption<span style="color: #00AA00;">,</span> figure<span style="color: #00AA00;">,</span> 
footer<span style="color: #00AA00;">,</span> header<span style="color: #00AA00;">,</span> hgroup<span style="color: #00AA00;">,</span> menu<span style="color: #00AA00;">,</span> nav<span style="color: #00AA00;">,</span> section <span style="color: #00AA00;">&#123;</span>
	<span style="color: #000000; font-weight: bold;">display</span><span style="color: #00AA00;">:</span> <span style="color: #993333;">block</span><span style="color: #00AA00;">;</span>
<span style="color: #00AA00;">&#125;</span>
body <span style="color: #00AA00;">&#123;</span>
	<span style="color: #000000; font-weight: bold;">line-height</span><span style="color: #00AA00;">:</span> <span style="color: #cc66cc;">1</span><span style="color: #00AA00;">;</span>
<span style="color: #00AA00;">&#125;</span>
ol<span style="color: #00AA00;">,</span> ul <span style="color: #00AA00;">&#123;</span>
	<span style="color: #000000; font-weight: bold;">list-style</span><span style="color: #00AA00;">:</span> <span style="color: #993333;">none</span><span style="color: #00AA00;">;</span>
<span style="color: #00AA00;">&#125;</span>
blockquote<span style="color: #00AA00;">,</span> q <span style="color: #00AA00;">&#123;</span>
	<span style="color: #000000; font-weight: bold;">quotes</span><span style="color: #00AA00;">:</span> <span style="color: #993333;">none</span><span style="color: #00AA00;">;</span>
<span style="color: #00AA00;">&#125;</span>
blockquote<span style="color: #3333ff;">:before</span><span style="color: #00AA00;">,</span> blockquote<span style="color: #3333ff;">:after</span><span style="color: #00AA00;">,</span>
q<span style="color: #3333ff;">:before</span><span style="color: #00AA00;">,</span> q<span style="color: #3333ff;">:after </span><span style="color: #00AA00;">&#123;</span>
	<span style="color: #000000; font-weight: bold;">content</span><span style="color: #00AA00;">:</span> <span style="color: #ff0000;">''</span><span style="color: #00AA00;">;</span>
	<span style="color: #000000; font-weight: bold;">content</span><span style="color: #00AA00;">:</span> <span style="color: #993333;">none</span><span style="color: #00AA00;">;</span>
<span style="color: #00AA00;">&#125;</span>
table <span style="color: #00AA00;">&#123;</span>
	<span style="color: #000000; font-weight: bold;">border-collapse</span><span style="color: #00AA00;">:</span> <span style="color: #993333;">collapse</span><span style="color: #00AA00;">;</span>
	<span style="color: #000000; font-weight: bold;">border-spacing</span><span style="color: #00AA00;">:</span> <span style="color: #cc66cc;">0</span><span style="color: #00AA00;">;</span>
<span style="color: #00AA00;">&#125;</span>
&nbsp;
<span style="color: #808080; font-style: italic;">/**************************** HTML 5 RESET **************************/</span>
<span style="color: #6666ff;">.label15Arial</span> <span style="color: #00AA00;">&#123;</span>
	<span style="color: #000000; font-weight: bold;">font-family</span><span style="color: #00AA00;">:</span>Arial<span style="color: #00AA00;">;</span>
	<span style="color: #000000; font-weight: bold;">color</span><span style="color: #00AA00;">:</span><span style="color: #cc00cc;">#fff</span><span style="color: #00AA00;">;</span>
	<span style="color: #000000; font-weight: bold;">font-size</span><span style="color: #00AA00;">:</span><span style="color: #933;">16pt</span><span style="color: #00AA00;">;</span>
	<span style="color: #000000; font-weight: bold;">font-weight</span><span style="color: #00AA00;">:</span><span style="color: #993333;">bolder</span><span style="color: #00AA00;">;</span>
	<span style="color: #000000; font-weight: bold;">text-shadow</span><span style="color: #00AA00;">:</span> <span style="color: #cc00cc;">#333</span> <span style="color: #cc66cc;">0</span> <span style="color: #cc66cc;">0</span> <span style="color: #cc66cc;">0</span><span style="color: #00AA00;">;</span>
	<span style="color: #000000; font-weight: bold;">padding-top</span><span style="color: #00AA00;">:</span><span style="color: #933;">10px</span><span style="color: #00AA00;">;</span>
	<span style="color: #000000; font-weight: bold;">text-align</span><span style="color: #00AA00;">:</span><span style="color: #993333;">center</span><span style="color: #00AA00;">;</span>
<span style="color: #00AA00;">&#125;</span>
&nbsp;
<span style="color: #6666ff;">.titleBar</span> <span style="color: #00AA00;">&#123;</span>
        // Here is the cool gradient stuff - use generator http<span style="color: #00AA00;">:</span>//gradients<span style="color: #6666ff;">.glrzad</span>.com/
	<span style="color: #000000; font-weight: bold;">background-image</span><span style="color: #00AA00;">:</span> linear-gradient<span style="color: #00AA00;">&#40;</span><span style="color: #000000; font-weight: bold;">bottom</span><span style="color: #00AA00;">,</span> <span style="color: #993333;">rgb</span><span style="color: #00AA00;">&#40;</span><span style="color: #cc66cc;">0</span><span style="color: #00AA00;">,</span><span style="color: #cc66cc;">0</span><span style="color: #00AA00;">,</span><span style="color: #cc66cc;">0</span><span style="color: #00AA00;">&#41;</span> <span style="color: #933;">58%</span><span style="color: #00AA00;">,</span> <span style="color: #993333;">rgb</span><span style="color: #00AA00;">&#40;</span><span style="color: #cc66cc;">184</span><span style="color: #00AA00;">,</span><span style="color: #cc66cc;">184</span><span style="color: #00AA00;">,</span><span style="color: #cc66cc;">184</span><span style="color: #00AA00;">&#41;</span> <span style="color: #933;">80%</span><span style="color: #00AA00;">,</span> <span style="color: #993333;">rgb</span><span style="color: #00AA00;">&#40;</span><span style="color: #cc66cc;">39</span><span style="color: #00AA00;">,</span><span style="color: #cc66cc;">46</span><span style="color: #00AA00;">,</span><span style="color: #cc66cc;">46</span><span style="color: #00AA00;">&#41;</span> <span style="color: #933;">94%</span><span style="color: #00AA00;">&#41;</span><span style="color: #00AA00;">;</span>
	<span style="color: #000000; font-weight: bold;">background-image</span><span style="color: #00AA00;">:</span> -o-linear-gradient<span style="color: #00AA00;">&#40;</span><span style="color: #000000; font-weight: bold;">bottom</span><span style="color: #00AA00;">,</span> <span style="color: #993333;">rgb</span><span style="color: #00AA00;">&#40;</span><span style="color: #cc66cc;">0</span><span style="color: #00AA00;">,</span><span style="color: #cc66cc;">0</span><span style="color: #00AA00;">,</span><span style="color: #cc66cc;">0</span><span style="color: #00AA00;">&#41;</span> <span style="color: #933;">58%</span><span style="color: #00AA00;">,</span> <span style="color: #993333;">rgb</span><span style="color: #00AA00;">&#40;</span><span style="color: #cc66cc;">184</span><span style="color: #00AA00;">,</span><span style="color: #cc66cc;">184</span><span style="color: #00AA00;">,</span><span style="color: #cc66cc;">184</span><span style="color: #00AA00;">&#41;</span> <span style="color: #933;">80%</span><span style="color: #00AA00;">,</span> <span style="color: #993333;">rgb</span><span style="color: #00AA00;">&#40;</span><span style="color: #cc66cc;">39</span><span style="color: #00AA00;">,</span><span style="color: #cc66cc;">46</span><span style="color: #00AA00;">,</span><span style="color: #cc66cc;">46</span><span style="color: #00AA00;">&#41;</span> <span style="color: #933;">94%</span><span style="color: #00AA00;">&#41;</span><span style="color: #00AA00;">;</span>
	<span style="color: #000000; font-weight: bold;">background-image</span><span style="color: #00AA00;">:</span> -moz-linear-gradient<span style="color: #00AA00;">&#40;</span><span style="color: #000000; font-weight: bold;">bottom</span><span style="color: #00AA00;">,</span> <span style="color: #993333;">rgb</span><span style="color: #00AA00;">&#40;</span><span style="color: #cc66cc;">0</span><span style="color: #00AA00;">,</span><span style="color: #cc66cc;">0</span><span style="color: #00AA00;">,</span><span style="color: #cc66cc;">0</span><span style="color: #00AA00;">&#41;</span> <span style="color: #933;">58%</span><span style="color: #00AA00;">,</span> <span style="color: #993333;">rgb</span><span style="color: #00AA00;">&#40;</span><span style="color: #cc66cc;">184</span><span style="color: #00AA00;">,</span><span style="color: #cc66cc;">184</span><span style="color: #00AA00;">,</span><span style="color: #cc66cc;">184</span><span style="color: #00AA00;">&#41;</span> <span style="color: #933;">80%</span><span style="color: #00AA00;">,</span> <span style="color: #993333;">rgb</span><span style="color: #00AA00;">&#40;</span><span style="color: #cc66cc;">39</span><span style="color: #00AA00;">,</span><span style="color: #cc66cc;">46</span><span style="color: #00AA00;">,</span><span style="color: #cc66cc;">46</span><span style="color: #00AA00;">&#41;</span> <span style="color: #933;">94%</span><span style="color: #00AA00;">&#41;</span><span style="color: #00AA00;">;</span>
	<span style="color: #000000; font-weight: bold;">background-image</span><span style="color: #00AA00;">:</span> -webkit-linear-gradient<span style="color: #00AA00;">&#40;</span><span style="color: #000000; font-weight: bold;">bottom</span><span style="color: #00AA00;">,</span> <span style="color: #993333;">rgb</span><span style="color: #00AA00;">&#40;</span><span style="color: #cc66cc;">0</span><span style="color: #00AA00;">,</span><span style="color: #cc66cc;">0</span><span style="color: #00AA00;">,</span><span style="color: #cc66cc;">0</span><span style="color: #00AA00;">&#41;</span> <span style="color: #933;">58%</span><span style="color: #00AA00;">,</span> <span style="color: #993333;">rgb</span><span style="color: #00AA00;">&#40;</span><span style="color: #cc66cc;">184</span><span style="color: #00AA00;">,</span><span style="color: #cc66cc;">184</span><span style="color: #00AA00;">,</span><span style="color: #cc66cc;">184</span><span style="color: #00AA00;">&#41;</span> <span style="color: #933;">80%</span><span style="color: #00AA00;">,</span> <span style="color: #993333;">rgb</span><span style="color: #00AA00;">&#40;</span><span style="color: #cc66cc;">39</span><span style="color: #00AA00;">,</span><span style="color: #cc66cc;">46</span><span style="color: #00AA00;">,</span><span style="color: #cc66cc;">46</span><span style="color: #00AA00;">&#41;</span> <span style="color: #933;">94%</span><span style="color: #00AA00;">&#41;</span><span style="color: #00AA00;">;</span>
	<span style="color: #000000; font-weight: bold;">background-image</span><span style="color: #00AA00;">:</span> -ms-linear-gradient<span style="color: #00AA00;">&#40;</span><span style="color: #000000; font-weight: bold;">bottom</span><span style="color: #00AA00;">,</span> <span style="color: #993333;">rgb</span><span style="color: #00AA00;">&#40;</span><span style="color: #cc66cc;">0</span><span style="color: #00AA00;">,</span><span style="color: #cc66cc;">0</span><span style="color: #00AA00;">,</span><span style="color: #cc66cc;">0</span><span style="color: #00AA00;">&#41;</span> <span style="color: #933;">58%</span><span style="color: #00AA00;">,</span> <span style="color: #993333;">rgb</span><span style="color: #00AA00;">&#40;</span><span style="color: #cc66cc;">184</span><span style="color: #00AA00;">,</span><span style="color: #cc66cc;">184</span><span style="color: #00AA00;">,</span><span style="color: #cc66cc;">184</span><span style="color: #00AA00;">&#41;</span> <span style="color: #933;">80%</span><span style="color: #00AA00;">,</span> <span style="color: #993333;">rgb</span><span style="color: #00AA00;">&#40;</span><span style="color: #cc66cc;">39</span><span style="color: #00AA00;">,</span><span style="color: #cc66cc;">46</span><span style="color: #00AA00;">,</span><span style="color: #cc66cc;">46</span><span style="color: #00AA00;">&#41;</span> <span style="color: #933;">94%</span><span style="color: #00AA00;">&#41;</span><span style="color: #00AA00;">;</span>
	<span style="color: #000000; font-weight: bold;">width</span><span style="color: #00AA00;">:</span><span style="color: #933;">100%</span><span style="color: #00AA00;">;</span>
	<span style="color: #000000; font-weight: bold;">height</span><span style="color: #00AA00;">:</span><span style="color: #933;">45px</span><span style="color: #00AA00;">;</span>
<span style="color: #00AA00;">&#125;</span>
&nbsp;
<span style="color: #6666ff;">.borderContainer</span> <span style="color: #00AA00;">&#123;</span>
	<span style="color: #000000; font-weight: bold;">border</span><span style="color: #00AA00;">:</span><span style="color: #933;">1px</span> <span style="color: #993333;">solid</span> <span style="color: #cc00cc;">#c0c0c0</span><span style="color: #00AA00;">;</span>
	<span style="color: #000000; font-weight: bold;">margin-left</span><span style="color: #00AA00;">:</span><span style="color: #993333;">auto</span><span style="color: #00AA00;">;</span>
	<span style="color: #000000; font-weight: bold;">margin-right</span><span style="color: #00AA00;">:</span><span style="color: #993333;">auto</span><span style="color: #00AA00;">;</span>
	<span style="color: #000000; font-weight: bold;">margin-top</span><span style="color: #00AA00;">:</span><span style="color: #933;">15px</span><span style="color: #00AA00;">;</span>
	<span style="color: #000000; font-weight: bold;">width</span><span style="color: #00AA00;">:</span><span style="color: #933;">480px</span><span style="color: #00AA00;">;</span>
	<span style="color: #000000; font-weight: bold;">height</span><span style="color: #00AA00;">:</span><span style="color: #933;">320px</span><span style="color: #00AA00;">;</span>
	-moz-border-radius<span style="color: #00AA00;">:</span> <span style="color: #933;">8px</span><span style="color: #00AA00;">;</span>
	border-radius<span style="color: #00AA00;">:</span> <span style="color: #933;">8px</span><span style="color: #00AA00;">;</span>
<span style="color: #00AA00;">&#125;</span>
&nbsp;
<span style="color: #6666ff;">.controlsContainer</span> <span style="color: #00AA00;">&#123;</span>
	<span style="color: #000000; font-weight: bold;">border</span><span style="color: #00AA00;">:</span><span style="color: #933;">1px</span> <span style="color: #993333;">solid</span> <span style="color: #cc00cc;">#c0c0c0</span><span style="color: #00AA00;">;</span>
	<span style="color: #000000; font-weight: bold;">margin-left</span><span style="color: #00AA00;">:</span><span style="color: #993333;">auto</span><span style="color: #00AA00;">;</span>
	<span style="color: #000000; font-weight: bold;">margin-right</span><span style="color: #00AA00;">:</span><span style="color: #993333;">auto</span><span style="color: #00AA00;">;</span>
	<span style="color: #000000; font-weight: bold;">margin-top</span><span style="color: #00AA00;">:</span><span style="color: #933;">15px</span><span style="color: #00AA00;">;</span>
	<span style="color: #000000; font-weight: bold;">width</span><span style="color: #00AA00;">:</span><span style="color: #933;">480px</span><span style="color: #00AA00;">;</span>
	<span style="color: #000000; font-weight: bold;">height</span><span style="color: #00AA00;">:</span><span style="color: #933;">120px</span><span style="color: #00AA00;">;</span>
	-moz-border-radius<span style="color: #00AA00;">:</span> <span style="color: #933;">8px</span><span style="color: #00AA00;">;</span>
	border-radius<span style="color: #00AA00;">:</span> <span style="color: #933;">8px</span><span style="color: #00AA00;">;</span>
<span style="color: #00AA00;">&#125;</span>
&nbsp;
<span style="color: #6666ff;">.range1</span> <span style="color: #00AA00;">&#123;</span>
	<span style="color: #000000; font-weight: bold;">margin-top</span><span style="color: #00AA00;">:</span><span style="color: #933;">15px</span><span style="color: #00AA00;">;</span>
	<span style="color: #000000; font-weight: bold;">width</span><span style="color: #00AA00;">:</span><span style="color: #933;">280px</span><span style="color: #00AA00;">;</span>
	<span style="color: #000000; font-weight: bold;">float</span><span style="color: #00AA00;">:</span><span style="color: #000000; font-weight: bold;">left</span><span style="color: #00AA00;">;</span>
<span style="color: #00AA00;">&#125;</span>
&nbsp;
<span style="color: #6666ff;">.range1label</span> <span style="color: #00AA00;">&#123;</span>
	<span style="color: #000000; font-weight: bold;">font-family</span><span style="color: #00AA00;">:</span>Arial<span style="color: #00AA00;">;</span>
	<span style="color: #000000; font-weight: bold;">color</span><span style="color: #00AA00;">:</span><span style="color: #cc00cc;">#000</span><span style="color: #00AA00;">;</span>
	<span style="color: #000000; font-weight: bold;">font-size</span><span style="color: #00AA00;">:</span><span style="color: #933;">14px</span><span style="color: #00AA00;">;</span>
	<span style="color: #000000; font-weight: bold;">margin-top</span><span style="color: #00AA00;">:</span><span style="color: #933;">15px</span><span style="color: #00AA00;">;</span>
	<span style="color: #000000; font-weight: bold;">margin-left</span><span style="color: #00AA00;">:</span><span style="color: #933;">15px</span><span style="color: #00AA00;">;</span>
	<span style="color: #000000; font-weight: bold;">width</span><span style="color: #00AA00;">:</span><span style="color: #933;">105px</span><span style="color: #00AA00;">;</span>
	<span style="color: #000000; font-weight: bold;">font-weight</span><span style="color: #00AA00;">:</span><span style="color: #993333;">bolder</span><span style="color: #00AA00;">;</span>
	<span style="color: #000000; font-weight: bold;">text-shadow</span><span style="color: #00AA00;">:</span> <span style="color: #cc00cc;">#333</span> <span style="color: #cc66cc;">0</span> <span style="color: #cc66cc;">0</span> <span style="color: #cc66cc;">0</span><span style="color: #00AA00;">;</span>
	<span style="color: #000000; font-weight: bold;">float</span><span style="color: #00AA00;">:</span><span style="color: #000000; font-weight: bold;">left</span><span style="color: #00AA00;">;</span>
<span style="color: #00AA00;">&#125;</span>
&nbsp;
<span style="color: #6666ff;">.range2</span> <span style="color: #00AA00;">&#123;</span>
	<span style="color: #000000; font-weight: bold;">margin-top</span><span style="color: #00AA00;">:</span><span style="color: #933;">15px</span><span style="color: #00AA00;">;</span>
	<span style="color: #000000; font-weight: bold;">width</span><span style="color: #00AA00;">:</span><span style="color: #933;">280px</span><span style="color: #00AA00;">;</span>
	<span style="color: #000000; font-weight: bold;">float</span><span style="color: #00AA00;">:</span><span style="color: #000000; font-weight: bold;">left</span><span style="color: #00AA00;">;</span>
<span style="color: #00AA00;">&#125;</span>
&nbsp;
<span style="color: #6666ff;">.range2label</span> <span style="color: #00AA00;">&#123;</span>
	<span style="color: #000000; font-weight: bold;">font-family</span><span style="color: #00AA00;">:</span>Arial<span style="color: #00AA00;">;</span>
	<span style="color: #000000; font-weight: bold;">color</span><span style="color: #00AA00;">:</span><span style="color: #cc00cc;">#000</span><span style="color: #00AA00;">;</span>
	<span style="color: #000000; font-weight: bold;">font-size</span><span style="color: #00AA00;">:</span><span style="color: #933;">14px</span><span style="color: #00AA00;">;</span>
	<span style="color: #000000; font-weight: bold;">margin-top</span><span style="color: #00AA00;">:</span><span style="color: #933;">15px</span><span style="color: #00AA00;">;</span>
	<span style="color: #000000; font-weight: bold;">margin-left</span><span style="color: #00AA00;">:</span><span style="color: #933;">15px</span><span style="color: #00AA00;">;</span>
	<span style="color: #000000; font-weight: bold;">width</span><span style="color: #00AA00;">:</span><span style="color: #933;">105px</span><span style="color: #00AA00;">;</span>
	<span style="color: #000000; font-weight: bold;">font-weight</span><span style="color: #00AA00;">:</span><span style="color: #993333;">bolder</span><span style="color: #00AA00;">;</span>
	<span style="color: #000000; font-weight: bold;">text-shadow</span><span style="color: #00AA00;">:</span> <span style="color: #cc00cc;">#333</span> <span style="color: #cc66cc;">0</span> <span style="color: #cc66cc;">0</span> <span style="color: #cc66cc;">0</span><span style="color: #00AA00;">;</span>
	<span style="color: #000000; font-weight: bold;">float</span><span style="color: #00AA00;">:</span><span style="color: #000000; font-weight: bold;">left</span><span style="color: #00AA00;">;</span>
<span style="color: #00AA00;">&#125;</span>
&nbsp;
<span style="color: #6666ff;">.buttons</span> <span style="color: #00AA00;">&#123;</span>
	-moz-border-radius<span style="color: #00AA00;">:</span> <span style="color: #933;">6px</span><span style="color: #00AA00;">;</span>
	border-radius<span style="color: #00AA00;">:</span> <span style="color: #933;">6px</span><span style="color: #00AA00;">;</span>
	<span style="color: #000000; font-weight: bold;">width</span><span style="color: #00AA00;">:</span><span style="color: #933;">300px</span><span style="color: #00AA00;">;</span>
	<span style="color: #000000; font-weight: bold;">background</span><span style="color: #00AA00;">:</span><span style="color: #cc00cc;">#fff</span><span style="color: #00AA00;">;</span>
	<span style="color: #000000; font-weight: bold;">height</span><span style="color: #00AA00;">:</span><span style="color: #933;">30px</span><span style="color: #00AA00;">;</span>
	<span style="color: #000000; font-weight: bold;">margin-top</span><span style="color: #00AA00;">:</span><span style="color: #933;">15px</span><span style="color: #00AA00;">;</span>
	<span style="color: #000000; font-weight: bold;">color</span><span style="color: #00AA00;">:</span><span style="color: #cc00cc;">#000</span><span style="color: #00AA00;">;</span>
<span style="color: #00AA00;">&#125;</span>
&nbsp;
<span style="color: #cc00cc;">#canvas</span> <span style="color: #00AA00;">&#123;</span>
        // Just two lines for cool <span style="color: #000000; font-weight: bold;">border</span> radius<span style="color: #00AA00;">,</span> no more IE hack or using Image<span style="color: #00AA00;">,</span> then abusing of divs 
	-moz-border-radius<span style="color: #00AA00;">:</span> <span style="color: #933;">6px</span><span style="color: #00AA00;">;</span>
	border-radius<span style="color: #00AA00;">:</span> <span style="color: #933;">6px</span><span style="color: #00AA00;">;</span>
<span style="color: #00AA00;">&#125;</span></pre></div></div>

<blockquote><p><strong>Note of warning</strong> :Things you should know about canvas. For some apparent reason,<strong> try not to style / css width and height of the canvas element</strong>. Instead using the attribute of width and height on to the tag itself. Reason being, some browsers will render the content scale weirdly. This information is accurate to date of the post. This issue might be fix in near future.</p></blockquote>
<p style="text-align: justify;">That&#8217;s it for today sharing. Oh yeah and Happy New Year 2012.</p>
<p style="text-align: justify;">&nbsp;</p>
]]></content:encoded>
			<wfw:commentRss>http://www.isgoodstuff.com/2012/01/05/html5-image-in-canvas-tutorial/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Mobile Development &#8211; Titanium Appcelerator</title>
		<link>http://www.isgoodstuff.com/2011/11/17/mobile-development-titanium-appcelerator/</link>
		<comments>http://www.isgoodstuff.com/2011/11/17/mobile-development-titanium-appcelerator/#comments</comments>
		<pubDate>Thu, 17 Nov 2011 05:56:51 +0000</pubDate>
		<dc:creator>Alex T.</dc:creator>
				<category><![CDATA[Tech]]></category>
		<category><![CDATA[android]]></category>
		<category><![CDATA[iphone]]></category>
		<category><![CDATA[javascript]]></category>
		<category><![CDATA[Mobile Development]]></category>

		<guid isPermaLink="false">http://www.isgoodstuff.com/?p=2005</guid>
		<description><![CDATA[<p><img src="http://www.isgoodstuff.com/wp-content/uploads/2011/11/thumbTA.png"/></p>Titanium Appcelerator 3rd party mobile SDK, I choose you! :)]]></description>
			<content:encoded><![CDATA[<p><img src="http://www.isgoodstuff.com/wp-content/uploads/2011/11/thumbTA.png"/></p><p style="text-align: justify;">Today, I&#8217;m gonna talk a bit about native smartphone app development. As you may know by now, there&#8217;s a lot of third party cross compiling mobile development out there. Titanium Appcelerator is a third party development tool that allows user to develop smartphone/mobile apps using javascript and then cross compile into native language. It is also the development technology I used to make all the apps you see in <strong><a href="http://www.watchlearnknow.com">Watch, Learn and Know</a></strong>.</p>
<p style="text-align: center;"><a href="http://www.isgoodstuff.com/wp-content/uploads/2011/11/thumbTA.png"><img class="aligncenter size-full wp-image-2020" style="margin-top: 3px; margin-bottom: 3px;" title="thumbTA" src="http://www.isgoodstuff.com/wp-content/uploads/2011/11/thumbTA.png" alt="" width="220" height="180" /></a></p>
<p style="text-align: justify;">Since, everyone is hyped up about using html5 and mobile web app, the question remains&#8230;</p>
<blockquote>
<p style="text-align: justify;">Why bother making native compiled app using Titanium Appcelerator?</p>
</blockquote>
<p>Firstly, we have to know there are 3 types of approach when it comes to smartphone content / app development (using the non pure-native way).</p>
<ol>
<li style="text-align: justify;"><strong>Mobile phone enabled website / A Pure WebApp</strong> &#8211; This means when the server detects the client is using a smartphone immediately it switches(battery saving, fast loading, simple)  design template for the entire site. This approach is not a native app, but all you need is just a mobile browser and internet connection. Skips all the &#8220;hassle&#8221; of registering developer license and getting the app on appStore to be downloaded and installed. This is useful for specific training content e.g. Enterprise learning/training sites.</li>
<li style="text-align: justify;"><strong>Native mobile app</strong>, built using<strong> html5 and mobile framework</strong> &#8211; This means the app is made using 100% mobile js frameworks and html5 stuff, then later using sdk like phonegap, we compile it into an app. This approach is useful if you have all the stuff running in web form and you only need some limited hardware controls like geo-location and camera input.</li>
<li style="text-align: justify;"><strong>Native mobile app</strong>, built using <strong>third party cross compiler</strong> &#8211; Runs exactly using native ui made for the phone. Full hardware control and useful if internet connection is not mandatory to view the content. Good native apps normally useful for user for references, simple editing and social sharing. Very fast performance.</li>
</ol>
<blockquote><p>So, when do I really need what and when?</p></blockquote>
<p>&nbsp;</p>
<h6><strong>Decide for mobile phone enabled website or a pure WebApp, if you have thoughts like below&#8230;</strong></h6>
<blockquote><p>I already have a high traffic website and is well designed. People are coming for my site for news and updates. I do not have any complex tools/services for my readers. Just pure good content and I want as minimal and cost effort possible. &#8211; in this case, making mobile enabled version of the site is more feasible.</p></blockquote>
<h6><strong>Native mobile app, html5 and framework approach, </strong><strong>if you have thoughts like below&#8230;</strong></h6>
<blockquote><p>Almost everything I already have web tools/ services all ready for use online. I just need a mobile client with minimal effort and cost. Design and theme must retain as much as possible and I have only web programmers that can do html stuff at hand.</p></blockquote>
<h6><strong>Native mobile app</strong>, built using <strong>third party cross compiler, if you have thoughts like below&#8230;</strong></h6>
<blockquote><p><strong></strong>Got all contents and ideas for the app. I do not want user to connect to internet all the time. I may not have servers/website. I also do not want user to have different UI experience other than the native user interface provided by the smartphone itself. Performance and hardware controls is a big deal.</p></blockquote>
<p style="text-align: justify;">I hope that <strong>covers why Titanium</strong> still have the advantage of others, plus is also an open source and free tool to use.  To know more about <strong><a href="http://www.appcelerator.com/">Titanium Appcelerator read more here</a></strong>.</p>
<p>&nbsp;</p>
]]></content:encoded>
			<wfw:commentRss>http://www.isgoodstuff.com/2011/11/17/mobile-development-titanium-appcelerator/feed/</wfw:commentRss>
		<slash:comments>3</slash:comments>
		</item>
		<item>
		<title>WTH is Encapsulating Javascript?</title>
		<link>http://www.isgoodstuff.com/2011/10/16/wth-is-encapsulating-javascript/</link>
		<comments>http://www.isgoodstuff.com/2011/10/16/wth-is-encapsulating-javascript/#comments</comments>
		<pubDate>Sun, 16 Oct 2011 00:16:27 +0000</pubDate>
		<dc:creator>Alex T.</dc:creator>
				<category><![CDATA[Tech]]></category>
		<category><![CDATA[javascript]]></category>
		<category><![CDATA[Tutorials]]></category>
		<category><![CDATA[Useful Scripts]]></category>

		<guid isPermaLink="false">http://www.isgoodstuff.com/?p=1919</guid>
		<description><![CDATA[<p><img src="http://www.isgoodstuff.com/wp-content/uploads/2011/10/JavaScript-Web.png"/></p>Your javascript in a neater way, more than a function, less than a traditional OOP class.]]></description>
			<content:encoded><![CDATA[<p><img src="http://www.isgoodstuff.com/wp-content/uploads/2011/10/JavaScript-Web.png"/></p><p style="text-align: justify;">Over the weekend, I&#8217;ve been doing javascripting and some one messaged me on how to write an <em>encapsulating javascript functions</em> which is a common practice in web development nowadays. Especially when we involved in <strong>mobile where memory and processor is critical</strong></p>
<blockquote>
<p style="text-align: justify;">I remember around 8 years ago when, javascript was just a simple procedural language used for web development then it evolved into DHTML which we can use to make cool effects. Later, comes AJAX and wonderful js frameworks we had today.</p>
<p><BR></p>
<p style="text-align: justify;">Today this script language evolved into some kind of <em>magical development language of wonders</em> &#8211; you can even write a full mobile to desktop app using this scripting language with the help of cross compilers.</p>
</blockquote>
<p>Because of that, developing a javascript application can lead to complex scripting due to huge number of variables and objects you control.</p>
<p>Therefore for best practice sake,</p>
<ol>
<li style="text-align: justify;">You need to keep your javascript functions in main webpage <strong>as minimal as possible and js files must be as human readable as possible</strong>. e.g. &lt;script src=&#8221;calculate.js&#8221;&gt;&lt;/script&gt; should at least have calculate related functions in it like <em> &#8221;calculate.sum( myNumberList );&#8221;</em> so that, is easy to use calculate.js like an util file.</li>
<li style="text-align: justify;"><strong>Don&#8217;t pollute the global scope!</strong> &#8211; A complex javascript script will have alot of variable flowing everywhere thus polluting the global scope and making it easier to read. (this means, we don&#8217;t overuse var VariableName everywhere in our js file &#8211; put in an encapsulated js instead) To control that, we use encapsulated function. An Encapsulated function are  more than a function, less than a traditional OOP class but better than nothing <img src='http://www.isgoodstuff.com/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' />  .</li>
<li>There&#8217;s several ways I found can achieve this but, I&#8217;m gonna list this one first because is one of my favorites.</li>
</ol>
<div>Method one, encapsulating js using namespace and self-triggering function.</div>
<blockquote>
<p style="text-align: justify;">What is a self-triggering function?, Self -triggering function is a function construct which fires straightaway. We normally use that for &#8220;container&#8221; &#8211; to contain variables, and related functions.</p>
</blockquote>
<p style="text-align: justify;">Here is how to write a self triggering function,</p>

<div class="wp_syntax"><div class="code"><pre class="javascript" style="font-family:monospace;"><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>
	<span style="color: #000066;">alert</span><span style="color: #009900;">&#40;</span><span style="color: #3366CC;">'fired immediately'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #009900;">&#125;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span></pre></div></div>

<p>Let&#8217;s write a chained self triggering function. Follow the code below.</p>

<div class="wp_syntax"><div class="code"><pre class="javascript" style="font-family:monospace;"><span style="color: #003366; font-weight: bold;">var</span> trigger <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>
       <span style="color: #000066;">alert</span><span style="color: #009900;">&#40;</span><span style="color: #3366CC;">'chained function'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #009900;">&#125;</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
<span style="color: #006600; font-style: italic;">//try calling it using</span>
trigger<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #006600; font-style: italic;">// and compare with</span>
trigger<span style="color: #339933;">;</span></pre></div></div>

<p style="text-align: justify;">Noticed, the behaviour of trigger, is no longer regarded as function in browser. In-fact, if you use trigger(); you will get an error in firebug. Notice also that, when you just call trigger without brackets, and yet it fires the function. This is <strong>how we do our namespace in encapsulating js</strong>.</p>
<p style="text-align: justify;">Let&#8217;s work on other namespace &#8211; this time with proper function, namespace are used to clearly define and separate our javascript so that, same function names and variables don&#8217;t get mixed up. It&#8217;s like writing a class with methods all encapsulated within.</p>

<div class="wp_syntax"><div class="code"><pre class="javascript" style="font-family:monospace;"><span style="color: #003366; font-weight: bold;">var</span> calc <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>
    <span style="color: #000066; font-weight: bold;">return</span> <span style="color: #009900;">&#123;</span><span style="color: #009900;">&#125;</span><span style="color: #339933;">;</span>
<span style="color: #009900;">&#125;</span></pre></div></div>

<p style="text-align: justify;">The code above simply creates a function that returns nothing. We normally use this as our <strong>namespace starter/definer</strong>. Then, we proceed further with writing a specific function / method like construct e.g. calc.sum.</p>
<blockquote>
<p style="text-align: justify;">Note calc.sum is undefined, if you do not declare a namespace starter/definer which is a chained self-triggering function in memory that returns nothing.</p>
</blockquote>

<div class="wp_syntax"><div class="code"><pre class="javascript" style="font-family:monospace;"><span style="color: #006600; font-style: italic;">//Secondary Namespace calc.sum - wrapped using self triggering function</span>
calc.<span style="color: #660066;">sum</span> <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>
	<span style="color: #009966; font-style: italic;">/* private variables only to calc.sum see how variables are kept within */</span>
	<span style="color: #003366; font-weight: bold;">var</span> value1 <span style="color: #339933;">=</span> <span style="color: #CC0000;">0</span><span style="color: #339933;">;</span>
	<span style="color: #003366; font-weight: bold;">var</span> value2 <span style="color: #339933;">=</span> <span style="color: #CC0000;">0</span><span style="color: #339933;">;</span>  
&nbsp;
	<span style="color: #006600; font-style: italic;">// private method to calc.sum</span>
	<span style="color: #003366; font-weight: bold;">function</span> calc<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#123;</span>
	<span style="color: #003366; font-weight: bold;">var</span> sum <span style="color: #339933;">=</span> parseInt<span style="color: #009900;">&#40;</span>value1<span style="color: #009900;">&#41;</span> <span style="color: #339933;">+</span> parseInt<span style="color: #009900;">&#40;</span>value2<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
	    <span style="color: #000066; font-weight: bold;">return</span> sum<span style="color: #339933;">;</span>
	<span style="color: #009900;">&#125;</span>
&nbsp;
	<span style="color: #006600; font-style: italic;">// public functions</span>
	<span style="color: #000066; font-weight: bold;">return</span> <span style="color: #009900;">&#123;</span>
	    init<span style="color: #339933;">:</span> <span style="color: #003366; font-weight: bold;">function</span><span style="color: #009900;">&#40;</span>external_value1<span style="color: #339933;">,</span> external_value2<span style="color: #009900;">&#41;</span><span style="color: #009900;">&#123;</span>
	         <span style="color: #000066; font-weight: bold;">this</span>.<span style="color: #660066;">setValue1</span><span style="color: #009900;">&#40;</span>external_value1<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
	         <span style="color: #000066; font-weight: bold;">this</span>.<span style="color: #660066;">setValue2</span><span style="color: #009900;">&#40;</span>external_value2<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
	    <span style="color: #009900;">&#125;</span><span style="color: #339933;">,</span>
&nbsp;
	    setValue1<span style="color: #339933;">:</span> <span style="color: #003366; font-weight: bold;">function</span><span style="color: #009900;">&#40;</span>val<span style="color: #009900;">&#41;</span><span style="color: #009900;">&#123;</span>
	        value1 <span style="color: #339933;">=</span> val<span style="color: #339933;">;</span>
	    <span style="color: #009900;">&#125;</span><span style="color: #339933;">,</span>
&nbsp;
	    setValue2<span style="color: #339933;">:</span> <span style="color: #003366; font-weight: bold;">function</span><span style="color: #009900;">&#40;</span>val<span style="color: #009900;">&#41;</span><span style="color: #009900;">&#123;</span>
	        value2 <span style="color: #339933;">=</span> val<span style="color: #339933;">;</span>
	    <span style="color: #009900;">&#125;</span><span style="color: #339933;">,</span>
&nbsp;
	    getSum<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>
	       <span style="color: #006600; font-style: italic;">// calling an internal private function</span>
               <span style="color: #006600; font-style: italic;">// (requires no &quot;this.&quot;)</span>
		<span style="color: #000066; font-weight: bold;">return</span> calc<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
	    <span style="color: #009900;">&#125;</span>
	<span style="color: #009900;">&#125;</span>
<span style="color: #009900;">&#125;</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span></pre></div></div>

<p>Now, we have a &#8220;class util&#8221; like javascript, and everything is kept within&#8230;isn&#8217;t that neat?</p>
<p>To use, we simply need to init it.</p>

<div class="wp_syntax"><div class="code"><pre class="javascript" style="font-family:monospace;"><span style="color: #006600; font-style: italic;">//init calc.sum which requires two integer,</span>
calc.<span style="color: #660066;">sum</span>.<span style="color: #660066;">init</span><span style="color: #009900;">&#40;</span><span style="color: #CC0000;">10</span><span style="color: #339933;">,</span><span style="color: #CC0000;">30</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #000066;">alert</span><span style="color: #009900;">&#40;</span>calc.<span style="color: #660066;">sum</span>.<span style="color: #660066;">getSum</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #006600; font-style: italic;">// should return you 40</span></pre></div></div>

<p>Today&#8217;s tutorial in HTML : <p><strong><a href="http://www.isgoodstuff.com/wp-content/plugins/download-monitor/download.php?id=25">Download Here</a></strong></p></br></p>
<p>&nbsp;</p>
]]></content:encoded>
			<wfw:commentRss>http://www.isgoodstuff.com/2011/10/16/wth-is-encapsulating-javascript/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Cross Mobile Development Findings</title>
		<link>http://www.isgoodstuff.com/2011/08/08/cross-mobile-development-findings/</link>
		<comments>http://www.isgoodstuff.com/2011/08/08/cross-mobile-development-findings/#comments</comments>
		<pubDate>Mon, 08 Aug 2011 14:16:48 +0000</pubDate>
		<dc:creator>Alex T.</dc:creator>
				<category><![CDATA[Tech]]></category>
		<category><![CDATA[android]]></category>
		<category><![CDATA[HTML5]]></category>
		<category><![CDATA[iphone]]></category>
		<category><![CDATA[javascript]]></category>
		<category><![CDATA[Tech Stuff]]></category>
		<category><![CDATA[Tutorials]]></category>

		<guid isPermaLink="false">http://www.isgoodstuff.com/?p=1879</guid>
		<description><![CDATA[<p><img src="http://www.isgoodstuff.com/wp-content/uploads/et_temp/ohlala1-153375_300x185.png"/></p>Yes..yes, I've been away from R&#038;D and findings for a long while...but, I'm back now and I'm sharing again on cross mobile development using js and HTML5...Read more]]></description>
			<content:encoded><![CDATA[<p><img src="http://www.isgoodstuff.com/wp-content/uploads/et_temp/ohlala1-153375_300x185.png"/></p><p style="text-align: justify;"><a href="http://www.isgoodstuff.com/wp-content/uploads/2011/08/jquery-mobile-devices-beta.png"><br />
</a><a href="http://www.isgoodstuff.com/wp-content/uploads/2011/08/HTML5_Logo_256.png"><img class="alignleft" style="margin-bottom: 2px;" title="HTML5_Logo_256" src="http://www.isgoodstuff.com/wp-content/uploads/2011/08/HTML5_Logo_256.png" alt="" width="137" height="137" /></a>It&#8217;s been almost 2 years since, I stepped out from the R&amp;D world &#8211; into &#8220;the narrow path of the production work cycle&#8221;. You won&#8217;t believe me when you compared my current mundane everyday task vs the days I used to do in my previous company &#8211; gosh &#8220;facepalm&#8221;.</p>
<p style="text-align: justify;">Now, I&#8217;m back for good (I hope hahahaha) &#8211; back in R&amp;D into mobile development using HTML5, CSS and Javascript technology. It feels so go to be able to contribute back again!! Super!</p>
<p style="text-align: justify;">Heads up, before I indulge myself into reporting of my findings &#8211; I wanna make things clear to you that, one of my core believe in using these technology as opposed to native language is because, of the concept below :-</p>
<blockquote>
<p style="text-align: justify;">Write once, Runs everywhere &#8211; Get it?</p>
</blockquote>
<p style="text-align: justify;">I know, is kinda risky and a unknown area to venture myself into &#8211; but,then again isn&#8217;t the &#8220;unknown&#8221; is sometimes worth discovering &#8211; where is the fun when everything is all set and hardcoded?!!!</p>
<p style="text-align: justify;">Okay nuff said, let&#8217;s get into action! Over the past 3 weeks, I&#8217;ve been doing some groundwork on which type of technology should I use to develop apps on the smartphones (mainly the iPhone and the Android). </p>
<p style="text-align: justify;">Here are some of the few path I took :-</p>
<ul>
<li><a href="www.appcelerator.com/">Titanium Appcelerator</a></li>
<li><a href="http://www.phonegap.com/">PhoneGap </a>with <a href="http://jquerymobile.com/">jQueryMobile</a></li>
<li><a href="http://www.phonegap.com/">PhoneGap</a> with <a href="http://www.sencha.com/products/touch/">Sencha Touch</a></li>
</ul>
<p>Of the 3 path, the one that favors me the most is the 2nd one. Development of html5 technology using jQueryMobile and compiled into an App using PhoneGap.</p>
<p>I like jQueryMobile mainly because, it&#8217;s doesn&#8217;t involved hundreds of css lines to code, I really like the DOM controls and its (header, content and footer) framework design &#8211; AWESOMELICIOUS!!</p>
<p><a href="http://www.isgoodstuff.com/wp-content/uploads/2011/08/jquery-mobile-devices-beta.png"><img class="aligncenter" style="margin-top: 2px; margin-bottom: 2px;" title="jquery-mobile-devices-beta" src="http://www.isgoodstuff.com/wp-content/uploads/2011/08/jquery-mobile-devices-beta.png" alt="" width="380" height="377" /></a></p>
<p style="text-align: center;"><a href="http://www.isgoodstuff.com/wp-content/uploads/2011/08/jQueryMobile.jpg"><img class="aligncenter size-full wp-image-1894" style="margin-top: 4px; margin-bottom: 4px;" title="jQueryMobile" src="http://www.isgoodstuff.com/wp-content/uploads/2011/08/jQueryMobile.jpg" alt="" width="387" height="99" /></a></p>
<p>However, there are <strong>hiccups</strong> here and there, like for example, javascript isn&#8217;t that fast to render on slower devices mainly if you were to develop js apps &#8211; do avoid from catering hardware specification below.</p>
<ul>
<li>iPod Touch 1st Generation (firmware is stucked on version 3, device is slow ; bad performance but functional).</li>
<li>Android phones using version 1.5 and 1.6 (sluggish). Minimum suggested version 2.2 and 2.3</li>
<li>Low spec processor mainly those below 700 Mhz will suffer in performance. You can still develop on it but you basically have to minimize all the transition effects. Even, google&#8217;s recommended hardware phone (Nexus One has a 1 Ghz processor)</li>
</ul>
<p style="text-align: center;"><a href="http://www.isgoodstuff.com/wp-content/uploads/2011/08/tattoo_type_09.jpg"><img style="margin-top: 4px; margin-bottom: 4px;" title="tattoo_type_09" src="http://www.isgoodstuff.com/wp-content/uploads/2011/08/tattoo_type_09.jpg" alt="" width="400" height="266" /></a></p>
<p>To start with the path I choose. (and no you don&#8217;t need to have a tatoo behind your neck like above).</p>
<p>These are the prerequisites (for Windows to Android Development ~ I&#8217;ll write on the Mac Environment once, I get my Mac Mini) :-</p>
<ul>
<li>You need to have at least a basic knowledge of DOM and how jQuery function on Web. A little bit of html 5 knowledge and css as well.</li>
<li><a href="http://www.eclipse.org/">Eclipse JS Edition installed</a></li>
<li><a href="http://developer.android.com/sdk/index.html">Setup Android Development Environment</a> (with <a href="http://www.oracle.com/technetwork/java/javase/downloads/index.html">JAVA SDK 6</a>) &#8211; If you developing using Windows 7 you need manual zip extract Android SDK installation, then set environment Path yourself.</li>
<li><a href="http://www.apachefriends.org/en/xampp-windows.html">XAMPP server</a> (for inHouse web development)</li>
<li><a href="http://www.google.com/chrome/">Latest Chrome</a> and<a href="http://www.apple.com/safari/"> Safari Browser</a> (Web Kit Variant)</li>
<li><a href="http://www.youtube.com/watch?v=NLqswS6r-e0">Knowledge on how to debug js using console.log and how to access Chrome&#8217;s Developer Inspector Tool</a> (CTRL + SHIFT + I)</li>
<li>In Device Remote JS Mobile Apps debug using  <a href="http://www.jsconsole.com">jsconsole.com</a></li>
</ul>
<p>Use the links above, to guide you to specific reading material and follow them as I did because, eventually you will be able to setup a descent development environment as I did.</p>
<p>I&#8217;ve divided the development of JS mobile into 4 stages.</p>
<ul>
<li>Stage 1 &#8211; Local Web Server (xampp) and Browser (it is good to place your source code htdocs pointed to dropbox that way you your development files backup for you&#8230;jolly good aint it)</li>
<li>Stage 2 &#8211; Web Server hosted somewhere and your Browser (to test the response of a remote calls e.g. for example, feeds coming from another domain your app is reading or remote database query)</li>
<li>Stage 3 &#8211; Web Server hosted somewhere and your mobile Browser (this is where you start using jsconsole.com because, the mobile browser do not have tools like firebug and etc). This is also the time you make optimization on certain stuff so that, they will look better when compiled to native.</li>
<li>Stage 4 &#8211; Localized all resource, js and css. Place em into www of phoneGap, push to device and test !!! &#8211; This is also where, the hardware control to device are done (camera, get GPS and etc). REMEMBER IN HEART : These Sacred 4 steps/warning everytime you compile into device</li>
<ul>
<li>Make sure you copy all your files (include folder names case sensitivity e.g. JQuery/lib different from jQuery/lib &#8211; refresh the folders</li>
<li>CLEAN before you build!!! Is under Project &gt; Clean</li>
<li>Make sure you. Uninstall the app from your device!</li>
<li>jQueryMobile IS SLOW in those 600 &#8211; 700mhz processor, just turn off the transitions to make the app useable &#8211; emphasize more on loading ajax circles if you are receiving data from hardware e.g. photo</li>
</ul>
</ul>
<p>If you experiencing form input text scrolling or bouncing up and down as if it loses it focus during keyboard input in Android is probably related to this css hack (see below) to counter flickering for slow processor device running jQueryMobile. (to remove all your suffering and headache just remove all the transition for slower devices and live with it for now) &#8211; this is referring to the latest @JQM 1.0 beta 2 tested on a <a href="http://www.mobile88.com.my/cellphone/CSL/CSL-Spice-MI300/specification.asp" target="_blank">CSL Spice MI300 DroidPhone</a></p>

<div class="wp_syntax"><div class="code"><pre class="css" style="font-family:monospace;">.ui-<span style="color: #000000; font-weight: bold;">page</span> <span style="color: #00AA00;">&#123;</span>
    -webkit-backface-<span style="color: #000000; font-weight: bold;">visibility</span><span style="color: #00AA00;">:</span> <span style="color: #993333;">hidden</span><span style="color: #00AA00;">;</span>
<span style="color: #00AA00;">&#125;</span></pre></div></div>

<p style="text-align: justify;">Well I hope this article proof useful to all the html5 mobile technology adopters. Best of luck to you all!</p>
<p style="text-align: justify;">
]]></content:encoded>
			<wfw:commentRss>http://www.isgoodstuff.com/2011/08/08/cross-mobile-development-findings/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>

