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

<channel>
	<title>kepo-ing Zz85</title>
	<atom:link href="http://www.lab4games.net/zz85/blog/feed/" rel="self" type="application/rss+xml" />
	<link>http://www.lab4games.net/zz85/blog</link>
	<description>Dumping Ground for Diverse Dictus Thoughts of Me</description>
	<pubDate>Tue, 09 Mar 2010 19:18:54 +0000</pubDate>
	<generator>http://wordpress.org/?v=2.7</generator>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
			<item>
		<title>Rain, Water, Ripples with HTML Canvas, Javascript, JQuery</title>
		<link>http://www.lab4games.net/zz85/blog/2010/03/10/rain-water-ripples-with-html-canvas-javascript-jquery/</link>
		<comments>http://www.lab4games.net/zz85/blog/2010/03/10/rain-water-ripples-with-html-canvas-javascript-jquery/#comments</comments>
		<pubDate>Tue, 09 Mar 2010 17:33:18 +0000</pubDate>
		<dc:creator>Zz85</dc:creator>
		
		<category><![CDATA[Browsers]]></category>

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

		<category><![CDATA[Interesting Stuff]]></category>

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

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

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

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

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

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

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

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

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

		<guid isPermaLink="false">http://www.lab4games.net/zz85/blog/?p=1110</guid>
		<description><![CDATA[One of the exciting reasons to work with canvas is that you are not only able to create 2d graphics easily with javascript, one can easily do do pixel manipulation on images.
Think about it, in case you don&#8217;t think its cool right now, is that you only need notepad, a recent web browser and a [...]]]></description>
			<content:encoded><![CDATA[<p>One of the exciting reasons to work with canvas is that you are not only able to create 2d graphics easily with javascript, one can easily do do pixel manipulation on images.</p>
<p>Think about it, in case you don&#8217;t think its cool right now, is that you only need notepad, a recent web browser and a few lines of code to do cool stuff work with 2d graphics without compilation. Take an example, you can create a greyscale image from a color photo into without photoshop or other software as see in <a href="http://www.pixastic.com/">pixastic</a>.</p>
<p>In this post, I will outline how easy it is to code with javascript and canvas to simulate water ripples, along with some issues encountered. After I discovered this <a href="http://freespace.virgin.net/hugo.elias/graphics/x_water.htm">old water algorithm</a> (during the DOS era I suspect) on creating waves, I thought why not try this with HTML Canvas, and so I did.</p>
<p><a href="http://jabtunes.com/notation/ripples.html"><img src="http://photos-h.ak.fbcdn.net/hphotos-ak-ash1/hs465.ash1/25525_342125018301_724118301_3594829_1543748_n.jpg" alt="Ripples with Javascript" /></a></p>
<p><strong>STEP 1. Creating a canvas element.</strong><br />
This can created easily with javascript, or just add some html code into the body </p>
<p><code>&lt;canvas id=&quot;jripples&quot;&gt;&lt;/canvas&gt;</code></p>
<p><strong>STEP 2. Load an image with JS when document is loaded for which we can use the jquery $(document).ready</strong></p>
<p><code>$(document).ready(function(){<br />
	init(); // Run stuff when document is ready.<br />
});</code></p>
<p>Here&#8217;s the code to load an image</p>
<p><code><br />
var img = new Image();<br />
img.src = "hello.jpg" // path and filename of image<br />
img.onload = function() {} // run the next portion of code when the image loads<br />
</code></p>
<p><strong>STEP 3. Draw the image onto the canvas</strong></p>
<p><code><br />
canvas = document.getElementById('jripples');<br />
 $('#jripples').width(img.width); // We set the canvas width and height with jquery<br />
$('#jripples').height(img.height);<br />
canvas.style.height = canvas.height = img.height ; // Set the canvas size to the image<br />
canvas.style.width = canvas.width =img.width;</p>
<p>ctx = canvas.getContext("2d"); // Get the 2d drawing context<br />
ctx.clearRect(0,0,canvas.width,canvas.height); // Clear the canvas<br />
ctx.drawImage(img, 0,0,canvas.width,canvas.height); // Draw the image</code></p>
<p>Just a caveat though, to get or manipulate pixels from an image, the image needs to be loaded from the domain or would result in a browser security violation.</p>
<p><strong>STEP 4. Build the data structures behind the wave</strong><br />
<code>orginalData = ctx.getImageData(0,0,canvas.width,canvas.height).data; // The array of pixels for the image<br />
myImageData = ctx.getImageData(0,0,canvas.width,canvas.height); // Modifications of pixels<br />
buffer1 = []; // Create new array for the image buffer<br />
buffer2 = [];<br />
// orginal data length is 4 times the pixel dimensions since they store RGBA (red,green, blue, alpha)<br />
for (var i=0; i<orginaldata .length/4; i++) { // We initialize the wave maps to<br />
	 buffer1[i] = 0;<br />
	 buffer2[i] = 0;<br />
 }</code></p>
<p><strong>STEP 5. Creating ripples (the wave algorithm) function</strong></p>
<p><code> function processWater(source, dest) {<br />
        	for (var i=imagewidth; i< source.length-imagewidth; i++)<br />
		{<br />
			// check for bounds<br />
			var xi = i % imagewidth;<br />
			if ((xi==0) || (xi==imagewidth-1)) continue; </p>
<p>		    dest[i] = (<br />
				((source[i-1]+<br />
				  source[i+1]+<br />
				  source[i-imagewidth]+<br />
				  source[i+imagewidth])  >>1) ) -dest[i];</p>
<p>		    dest[i] -= (dest[i] >> 5); // Damping - Quick divde by 32 (5 bits)</p>
<p>		}<br />
        }</code></p>
<p>while the original article explains how this works, <a href="http://www.neilwallis.com/java/water.htm">this article</a> explains it in another simpler manner</p>
<blockquote><p>Two height maps are used to store the current and previous states of the water.<br />
Each frame you will toggle between state maps.<br />
For each array element in the current state array:-<br />
Look at the neighbouring pixels from the previous state, i.e. above, below, left and right. Take the sum and divide by 2. Because we are dividing by 2 a right-shift will work beautifully.<br />
Now subtract the value in the current state map.<br />
If we left it like that the ripples would never subside so we need to diminish the strength of the ripple every pass. The most realistic way of doing this is to reduce the resulting height by a fraction of itself. Once again we can use right-shift to optimise this.
</p></blockquote>
<p>Note that I ensured the loops avoid any edge bound pixel to prevent wrap arounds.</p>
<p><strong>STEP 6. Render the new image with waves.</strong><br />
<code>function texture(buffer) {<br />
		var xoffset, yoffset;<br />
		for (var i=imagewidth; i<buffer .length-imagewidth; i++)<br />
		{<br />
			// check for bounds<br />
			var xi = i % imagewidth;<br />
			if ((xi==0) || (xi==imagewidth-1)) continue; </p>
<p>		    xoffset = buffer[i-1] - buffer[i+1];<br />
		    yoffset = buffer[i-imagewidth] - buffer [i+imagewidth];</p>
<p>		    var offset = i+xoffset+yoffset*imagewidth;</p>
<p>		    if (offset>0 &#038;&#038; offset</buffer><buffer .length) {</p>
<p>			    for (var x=0;x&lt;3;x++) { //4 for alpha<br />
				    myImageData.data[i*4+x] = orginalData[offset*4+x];<br />
			    }</p>
<p>		    }</p>
<p>		}<br />
		// Draw<br />
		ctx.putImageData(myImageData, 0, 0);</p>
<p>}</code></p>
<p>This estimates the pixel offset due to refraction of water (read more on <a href="http://www.gamedev.net/reference/articles/article915.asp">Transparent Surface Ray-Tracing</a>)  based on height of the wave and copies the pixels from the orginal array into the new imagearray object. This imagedata is returned to the 2d object using putImageData to be drawn.</p>
<p><strong>STEP 7. Call the rippling function in a timer</strong><br />
<code>rippling = setInterval(ripple, 50); // This calls the ripple function every 20 times a second</code></p>
<p><strong>STEP 8</strong><br />
We can calling another timer to add rain<br />
<code>raining = setInterval(function() {					// random rain<br />
				var randomX = Math.round(Math.random() * canvas.width);<br />
				var randomY = Math.round(Math.random() * canvas.height);<br />
				buffer1[randomY*imagewidth+randomX] += Math.round( Math.random()*-500);<br />
			},300);</code></p>
<p><strong>STEP 9. Add more raindrops/ripples reactivity to mouse clicks. We use jquery to add mouse listeners quickly.</strong><br />
<code>$(canvas).mousedown(function(e) {<br />
			var x = e.pageX - $(this).offset().left;<br />
			var y = e.pageY - $(this).offset().top  ;</p>
<p>			buffer1[y*imagewidth+x] = -400;<br />
			clicked.dragged= true;</p>
<p>		}).</code></p>
<p><strong>STEP 10. Provides FPS(Frames per second)</strong><br />
		<code>setInterval(function() {<br />
			$('#jdebug').html(fpsCount + &quot; fps&quot;);<br />
			fpsCount= 0; // recent<br />
		},1000);</code></p>
<p>This isn&#8217;t the most accurate way to calculate FPS, since the callback may not be accurate in itself. Rather, one should try getting the actual time subtracted from the last elapsed time to calculate the fps.</p>
<p><strong>Enjoy. Here&#8217;s the link to <a href="http://jabtunes.com/notation/ripples.html">javascript ripples demo</a></strong><br />
Remember that you may need to upload your html and images to a webserver to test (or change your browser security settings).</p>
<p><strong>Other Considerations.</strong><br />
This run on all modern browsers (Firefox, Safari, Chrome, Opera) except IE due to the lack of support with Canvas. While the Excanvas provides some compatibility, it does not provides get/putImageData calls. Until IE9 releases, <a href="http://flashcanvas.net/">flashcanvas pro</a> may solve this compatibility issue. </p>
<p>From my observations, the bottleneck seems to be when the browser render the image after the putImageData javascript. Right now firefox seems to be able to render 2x faster than chrome, and the self proclaimed fastest browser on earth, Opera, seems to renders about 3 times faster than chrome (to 100fps on small images).</p>
<p>While this wave algorithm may be efficient when there are many waves, this method may not be as efficient when there are few waves on large images/canvases. Even a image of 640 pixels can hang the browser (be warned).</p>
<p>One simple way to speed up the waves is scale down the image.  If putImageData is the bottleneck, then we can hope that  the browser would optimize these soon. (with <a href="http://www.basschouten.com/blog1.php/2010/03/02/presenting-direct2d-hardware-acceleratio">Direct2D just implemented</a> for firefox nighties, maybe soon will be soon!) Other interesting alternatives would be to implement <a href="http://www.khronos.org/webgl/">WEBGL</a> or <a href="http://code.google.com/apis/o3d/">O3D</a> which uses the C++ stack or GPU to speed up the rendering, although these are not widely supported right now. The better idea, I imagine, is to implement another algorithm which renders the ripples from its wave source, which would probably run faster on large images with few waves.</p>
<p>Finally, creating ripples seems to be a classic challenge and if you were to do a simple search, would be able to find implementations for <a href="http://toykeeper.net/programs/water/">DOS graphics</a>, OpenGL or other <a href="http://nylander.wordpress.com/2005/07/29/water-ripple-simulation/">3d Programming</a>, Java graphics, and for the most recent implementations, <a href="http://www.openprocessing.org/visuals/?visualID=4699">Processing</a> <a href="http://www.escapemotions.com/experiments/processing/water_ripples/applet/index.html?KeepThis=true&#038;TB_iframe=true&#038;width=380&#038;height=500">applet</a> and Flash/<a href="http://lab.andre-michelle.com/water">AS3</a>. One can even find this effect on desktops with dreamrender or <a href="http://www.compiz.org/">beryl/compiz fuzion</a>. Still this seems to be the first implementation with javascript/canvas other than one other on the net have seem to created a <a href="http://my.opera.com/edvakf/blog/2009/05/01/ripple-effect-by-canvas">&#8220;ripple effect&#8221; with canvas</a>, which is not really similar.</p>
<p>School work along other commitments is keeping me really busy, besides this is not even part of any computer graphics classes I required to take. So while there are perhaps more enhancements and optimizations that can be done, I&#8217;ll be leaving that up to you readers <img src='http://www.lab4games.net/zz85/blog/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' /> </buffer></code></orginaldata></code></p>
]]></content:encoded>
			<wfw:commentRss>http://www.lab4games.net/zz85/blog/2010/03/10/rain-water-ripples-with-html-canvas-javascript-jquery/feed/</wfw:commentRss>
		</item>
		<item>
		<title>&#8220;Huh?&#8221; - A Short Piano Composition</title>
		<link>http://www.lab4games.net/zz85/blog/2010/02/24/huh-a-short-piano-composition/</link>
		<comments>http://www.lab4games.net/zz85/blog/2010/02/24/huh-a-short-piano-composition/#comments</comments>
		<pubDate>Tue, 23 Feb 2010 17:21:23 +0000</pubDate>
		<dc:creator>Zz85</dc:creator>
		
		<category><![CDATA[Music]]></category>

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

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

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

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

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

		<guid isPermaLink="false">http://www.lab4games.net/zz85/blog/?p=1104</guid>
		<description><![CDATA[&#8220;Huh?&#8221; is a short piano composition I came out with last week. It is not delicated to anybody in mind but you can view, download or print the score for free or listen to the computer generated midi. 

The long story: I went up to the piano with one day without anything in mind but [...]]]></description>
			<content:encoded><![CDATA[<p>&#8220;Huh?&#8221; is a short piano composition I came out with last week. It is not delicated to anybody in mind but you can view, download or print <a href="http://jabtunes.com/music/huh.pdf">the score</a> for free or listen to the <a href=" http://jabtunes.com/music/huh.mid">computer generated midi</a>. </p>
<p><a href="http://musescore.org/sites/musescore.org/files/huh%20-%20score.pdf"><img src="http://photos-d.ak.fbcdn.net/hphotos-ak-snc3/hs412.snc3/24906_316813468301_724118301_3521380_1849453_n.jpg" alt="Huh?" /></a></p>
<p>The long story: I went up to the piano with one day without anything in mind but started playing some tunes when i least expected it. I quickly grab a pen and paper to jot down some notes in case I forgot them and <a href="http://jabtunes.com/music/huh.mp3">recorded this song</a> on my netbook, everything done almost in a sitting.</p>
<p>Of course writing it down and typesetting it actually takes a lot more time. <a href="http://jabtunes.com/music/huh.mscz">typed the piece of music</a> using the software <a href="http://musescore.org/">MuseScore</a> 1.9.6 beta, a great free music notation software. I later <a href="http://jabtunes.com/music/huh.ly">save it as a lilypond format</a> which was more familiar with me for tweaking the nice finishing touches for music scores layouts with the help of jedit <a href="http://lilypondtool.organum.hu/">lilypondtool</a>. </p>
<p>Like several of my songs, I think it sounds a little nostalgia (like <a href="http://www.reubenkee.com/music/singles/Act%20Four%20-%20Who%20Am%20I.mp3">&#8220;Who am I&#8221;</a>  which Reuben Kee arranged and used for his musical). Then again, I wasn&#8217;t really expecting to compose any thing on the piano that day which prompted me to title it &#8220;Huh?&#8221;. </p>
<p>I got a mixed bag of reactions to the piece. Some say its sounds classical, some says pop, some says a mixed. Some thinks it from Chopin Ballet, or Granados Spanish dance - Andaluza, or a little Japanese, Korean, Amelie soundtrack sounding, some feels its too happy, too sad, etc. You get the idea. I think much would be coincidental and subjective to the listeners. </p>
<p>Some suggestions by my friend Gerald - playing the harmony with broken chord pattern instead of the oom-pah bass will make it sound &#8220;more fluid&#8221;, and &#8220;less static&#8221;. He also suggest arranging the melody on the flute with a harp accompaniment in broken chords, in which after I just found out from my harp friends its difficult for lever harps to play keys with 5 flats.</p>
<p>Have fun trying out this piece out and let me know if you have other comments.</p>
<p>p.s. Since I&#8217;m on the topic of music, do let me know if you want to attend the nusso concert on 19 march friday evening 2010 at VCH. Details <a href="http://www.facebook.com/event.php?eid=247182169774&#038;ref=ts">here</a> and <a href="http://nusso.org/event/romantic-fantastique">here</a>.</p>
<p><img src="http://photos-h.ak.fbcdn.net/hphotos-ak-snc3/hs412.snc3/24906_316835633301_724118301_3521389_5715310_n.jpg" alt="Score" /></p>
<p>update: the audio generated by musescore can be heard here. <a href="http://soundcloud.com/zz85nus/huh-1">http://soundcloud.com/zz85nus/huh-1</a><br />
or <a href="http://soundcloud.com/zz85nus/huh-recording">http://soundcloud.com/zz85nus/huh-recording</a> for the original recording.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.lab4games.net/zz85/blog/2010/02/24/huh-a-short-piano-composition/feed/</wfw:commentRss>
<enclosure url="http://jabtunes.com/music/huh.mid" length="2729" type="audio/midi" />
<enclosure url="http://jabtunes.com/music/huh.mp3" length="1010070" type="audio/mpeg" />
		</item>
		<item>
		<title>JS 中文笔画输入法 (Javascript Chinese Stroke Input)</title>
		<link>http://www.lab4games.net/zz85/blog/2010/02/17/js-%e4%b8%ad%e6%96%87%e7%ac%94%e7%94%bb%e8%be%93%e5%85%a5%e6%b3%95-javascript-chinese-stroke-input/</link>
		<comments>http://www.lab4games.net/zz85/blog/2010/02/17/js-%e4%b8%ad%e6%96%87%e7%ac%94%e7%94%bb%e8%be%93%e5%85%a5%e6%b3%95-javascript-chinese-stroke-input/#comments</comments>
		<pubDate>Tue, 16 Feb 2010 20:13:21 +0000</pubDate>
		<dc:creator>Zz85</dc:creator>
		
		<category><![CDATA[Browsers]]></category>

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

		<category><![CDATA[Interesting Stuff]]></category>

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

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

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

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

		<guid isPermaLink="false">http://www.lab4games.net/zz85/blog/?p=1098</guid>
		<description><![CDATA[In case the title didn&#8217;t appear correctly, this is a post for another of my javascript experiments. This demonstrate chinese character recognition using stroke based or radicals input, instead of the usual pinyin(romanized mandarin system) method. Although this method is usually slower for typing, it allows beginners to find or input a word he does [...]]]></description>
			<content:encoded><![CDATA[<p>In case the title didn&#8217;t appear correctly, this is a post for another of my javascript experiments. This demonstrate chinese character recognition using stroke based or radicals input, instead of the usual pinyin(romanized mandarin system) method. Although this method is usually slower for typing, it allows beginners to find or input a word he does not recognize or a word whose pronunciation and pinyin is forgotten. I thought what better time could I release this than during the Lunar New Year.</p>
<p><a href="http://jabtunes.com/notation/chinesestroke.html"><img src="http://photos-d.ak.fbcdn.net/hphotos-ak-ash1/hs424.ash1/23467_303776653301_724118301_3474391_2269867_n.jpg" alt="Chinese Stroke Recognition" /></a></p>
<p>To try it, click on the screenshot above. Wait for files to be completed loaded before clicking and dragging to write a chinese character in correct stroke order (top left to bottom right, outer to enclosed), and the suggested words would appear in the right box. Right now the recognition algorithm is pretty rigid, you need to have the exact amount of strokes in an almost perfect sequence and writing to get the correct recognition. As mentioned, its pretty experimental, but it shows how fast javascript can be, character lookups are usually within 1 second, often below 100ms. The biggest bottleneck right now is parsing of the huge data files (usually the case for javascript engines these days), which may be solved with an ajax call to the server instead of caching all locally. Okay, I&#8217;m going into more implementation details so non-technical readers can do some skipping.</p>
<p>So basically this application is a modified and really simplified port of <a href="http://kiang.org/jordan/software/hanzilookup/hanzidict.html">Kiang&#8217;s Hanzi Lookup Java Application</a> to Javascript.<br />
For example, I used my javascript port of shortstraw (<a href="http://www.lab4games.net/zz85/blog/2010/01/21/geeknotes-shortstrawjs-fast-and-simple-corner-detection/">shortstrawJs</a>) for substroke recognition. This works well in many situations and badly for many (when strokes are short, etc). There ought to be better input filtering, and better matching against the database. Right now, all the substrokes are flatten, ignoring the exact strokes the user make. There&#8217;s currently isn&#8217;t fuzzy matching, or partial matches which gives lots of room for improvements. Of course, if you are able to, you can be grab the code by viewing source and trying making changes.</p>
<p><img src="http://photos-b.ak.fbcdn.net/hphotos-ak-snc3/hs384.snc3/23467_303776758301_724118301_3474392_718004_s.jpg" alt="Yi" /><br />
<em>Some traditional words supported. This is the traditional character for my middle character of my chinese name.</em></p>
<p>If I have the time, there are a few features I like to have in the future.<br />
- One is creating a bookmarklet, for which this input method would work with any site - like my <a href="http://www.lab4games.net/zz85/blog/2010/02/06/online-virtual-keyboard-with-canvas-and-javascript/">virtual keyboard bookmarklet</a> released previously. The advantages that bookmarklets have over browsers addon is that the browser like firefox does not need to be restarted, making it a very useful tool for non-home computers. (Gangwen, if you are still finding a online IME, you may like to try <a href="http://pinyin.sogou.com/cloud/">Sogou&#8217;s Cloud Pinyin/启用搜狗云输入法 bookmarklet</a>).<br />
- Another is tying this input to a chinese dictionary, making it a valuable tool for chinese beginners.<br />
- I also hope to implement custom font rendering (For example using <a href="http://www.sino.uni-heidelberg.de/edv/sinopc/chinese_fonts.htm">漢鼎繁舒體</a>) rendered on canvas for computers without these custom chinese fonts installed. Currently this is another of my javascript experiments - I have managed to render a couple of characters, but have yet to figure out the Adobe&#8217;s CID implementation and quirk character mapping that<br />
<a href="http://ttf2pt1.sourceforge.net/">ttf2pt1</a> gives me.<br />
- Another idea is hooking this up to a <a href="http://ccv.nuigroup.com/">DIY Multi-touch pad</a> if I get to built one.</p>
<p>And so I wonder if there&#8217;s a need for this application.<br />
- I heard that Macs already have this input method using their touchpads built into the OS. Windows 7 seems to have pretty good chinese recognition with their stylus input as seen <a href="http://blogs.msdn.com/e7/archive/2009/04/23/ink-input-and-tablet.aspx">from their blog</a><br />
- Newer HTC phones running Android have a HTC custom native input method called Touch Input. See <a href="http://forum.tgbus.com/viewthread.php?tid=148219">HTC_CIME HTC的官方手写输入法</a>. It doesn&#8217;t come with my HTC Magic, and requires some rooting or hacking - something I don&#8217;t have time for now, otherwise I could try writing android applications too. </p>
<p>Some friends may think that I started this experimented because of my inability to read chinese and maybe its true, or indeed its true my chinese language (similar my other verbals and written languages) is pretty weak! So maybe someone might still find this useful. Again, the source code is available for anyone to modify it.</p>
<p>Lastly for those still celebrating the launar new year, happy new year!</p>
<p><a href="http://jabtunes.com/notation/chinesestroke.html"><img src="http://photos-e.ak.fbcdn.net/hphotos-ak-ash1/hs424.ash1/23467_303776903301_724118301_3474394_1205344_n.jpg" alt="Dao Fu" /></a></p>
<p>p.s. I created an easter egg in view of the chinese new year. Double clicking on a suggestion turn the word upside down. Some homes turn their words upside down to symbolize prosperity falling to their homes. This animation is done using Css3 transform properties (supported by the new firefox, opera and webkits- safari, chrome browsers).</p>
]]></content:encoded>
			<wfw:commentRss>http://www.lab4games.net/zz85/blog/2010/02/17/js-%e4%b8%ad%e6%96%87%e7%ac%94%e7%94%bb%e8%be%93%e5%85%a5%e6%b3%95-javascript-chinese-stroke-input/feed/</wfw:commentRss>
		</item>
		<item>
		<title>Online Virtual Keyboard With Canvas and Javascript</title>
		<link>http://www.lab4games.net/zz85/blog/2010/02/06/online-virtual-keyboard-with-canvas-and-javascript/</link>
		<comments>http://www.lab4games.net/zz85/blog/2010/02/06/online-virtual-keyboard-with-canvas-and-javascript/#comments</comments>
		<pubDate>Sat, 06 Feb 2010 12:00:34 +0000</pubDate>
		<dc:creator>Zz85</dc:creator>
		
		<category><![CDATA[Browsers]]></category>

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

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

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

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

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

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

		<category><![CDATA[virtual keyboard]]></category>

		<guid isPermaLink="false">http://www.lab4games.net/zz85/blog/?p=1083</guid>
		<description><![CDATA[I&#8217;m releasing a HTML Canvas and Javascript based virtual, online, onscreen keyboard for testing and whatever fun you can make out of it. This release is actually dedicated for my friend&#8217;s 25th birthday, but its kind of way overdued. (CH, if you are reading this, happy belated!)

Basically what&#8217;s a virtual keyboard is that its simply [...]]]></description>
			<content:encoded><![CDATA[<p>I&#8217;m releasing a HTML Canvas and Javascript based virtual, online, onscreen keyboard for testing and whatever fun you can make out of it. This release is actually dedicated for my friend&#8217;s 25th birthday, but its kind of way overdued. (CH, if you are reading this, happy belated!)</p>
<p><a href="http://jabtunes.com/notation/keyboardcanvasexamples.html"><img src="http://photos-c.ak.fbcdn.net/hphotos-ak-snc3/hs169.snc3/19632_284413848301_724118301_3407084_7953637_n.jpg" alt="Virtual Keyboard" /></a></p>
<p>Basically what&#8217;s a <a href="http://ignorethecode.net/blog/2009/08/07/virtual-keyboards-on-iphone-and-android/">virtual keyboard</a> is that its simply an input without a physcial keyboard.<br />
If you add this as a <a href="javascript:(function(){var%20e=document.createElement('script');e.type='text/javascript';e.src='http://jabtunes.com/notation/jKeyboard.js.php';document.getElementsByTagName('head')[0].appendChild(e);})();">Keyboard Bookmarklet</a> (Firefox recommended - drag this to your toolbar), you may use this keyboard on various websites buy clicking on your bookmark which launch as translucent, mac like, on screen keyboard.</p>
<p>If you are thinking of projection keyboards, sorry, it isn&#8217;t as cool as that, yet.<br />
<a href="http://palmaddict.typepad.com/palmaddicts/2006/05/review_of_itech.html"><img src="http://palmaddict.typepad.com/palmaddicts/images/virtual_keyboard1.jpg" alt="" /></a></p>
<p>However, you can use this keyboard to enter text into textareas and input field by using your mouse, stylus or touchscreen. If you decide to use your physical keyboard, the virtual keyboard gets &#8220;lighted up&#8221;.</p>
<p>Some have asked me the purpose of this project anyway. <a href="http://lifehacker.com/5137148/virtual-keyboard-interface-dodges-key+loggers">Some sites</a> like <a href="http://designshack.co.uk/articles/javascript/creating-a-virtual-jquery-keyboard">this</a> would say there&#8217;s enhanced security particular from keyloggers. Of course, this isn&#8217;t really true since virtual keyboards may be backdoors themselves so please do not use this or any other bookmarklet, greasemonkey, addons etc you do not trust for sensitive information. </p>
<p>Yes, one reason is that I&#8217;m having playing around with html canvas again. Another is that I have always been interested to with <a href="http://www.lab4games.net/zz85/blog/2007/02/25/2-users-using-a-single-pc-part-i/">multiple inputs/users</a>. Creating custom interfaces with canvas could create the possibility of interfacing 2 users in a browser - imagine 2 users surfing the net together by sharing a wide browser screen on a pc. Fifa 95 (thats over a decade ago!) allowed 2 users to play with or against each other - one with the keyboard, another with the mouse, and this would be possible with a virtual keyboard (for the 2nd user). Whether this is another lame project, or whether there are possible great ideas, I&#8217;ll leave it up to your imagination.</p>
<p>Before ending with the tons of technical details, try out the <a href="http://jabtunes.com/notation/keyboardcanvasexamples.html">demo</a> and let me know of your comments, if any <img src='http://www.lab4games.net/zz85/blog/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' /> </p>
<p><a href="http://jabtunes.com/notation/keyboardcanvasexamples.html"><img src="http://photos-a.ak.fbcdn.net/hphotos-ak-snc3/hs169.snc3/19632_284476743301_724118301_3407244_6738679_n.jpg" alt="Virtual Keyboard works with Google.com" /></a></p>
<p>More details of this release<br />
+ Uses <a href="http://jquery14.com/day-12/jquery-141-released">jQuery 1.4.1</a> (Loads dynamically in bookmarklet)<br />
+ Virtual Keyboard - Drawned with Javascript and HTML Canvas Element<br />
+ The Mac lookalike Design of the keyboard inspired from this <a href="http://net.tutsplus.com/tutorials/javascript-ajax/creating-a-keyboard-with-css-and-jquery/">NetTuts tutorial</a> which used html, jquery and css instead.<br />
+ Autofire keys &#038; work around for text selection when autofiring in Chrome.<br />
+ Onscreen Keypresses Feedback as you typed - Keybindings aided with plugin <a href="http://code.google.com/p/js-hotkeys/">jHotKeys</a><br />
+ Onscreen Key Highlighting Disabled for Password fields<br />
+ Keyboard is draggable around the screen<br />
+ Works with Textarea and Input fields.<br />
+ Demonstrates a simple drawing framework with JSON<br />
+ Uses <a href="http://www.federated.com/~jim/canvastext/">TextCanvas</a> for canvas rendering of text<br />
+ Bookmarklet - see this interesting <a href="http://coder-zone.blogspot.com/2009/05/jquery-bookmarklet.html">jQuery Bookmarklet boot code</a> </p>
<p>See <a href="http://jabtunes.com/notation/jKeyboard.js.php?src=1">here</a> for source code, and here for <a href="http://jabtunes.com/notation/jKeyboard.js.php">YUI compressed version</a>. </p>
<p>Future improvements I would love to see.<br />
+ 100% Bugs Free<br />
+ IE compatibility<br />
+ Docking<br />
+ API<br />
+ Stay tuned <img src='http://www.lab4games.net/zz85/blog/wp-includes/images/smilies/icon_wink.gif' alt=';)' class='wp-smiley' /> </p>
]]></content:encoded>
			<wfw:commentRss>http://www.lab4games.net/zz85/blog/2010/02/06/online-virtual-keyboard-with-canvas-and-javascript/feed/</wfw:commentRss>
		</item>
		<item>
		<title>[geeknotes] ShortStrawJS - Fast and Simple Corner Detection</title>
		<link>http://www.lab4games.net/zz85/blog/2010/01/21/geeknotes-shortstrawjs-fast-and-simple-corner-detection/</link>
		<comments>http://www.lab4games.net/zz85/blog/2010/01/21/geeknotes-shortstrawjs-fast-and-simple-corner-detection/#comments</comments>
		<pubDate>Thu, 21 Jan 2010 13:49:44 +0000</pubDate>
		<dc:creator>Zz85</dc:creator>
		
		<category><![CDATA[Browsers]]></category>

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

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

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

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

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

		<guid isPermaLink="false">http://www.lab4games.net/zz85/blog/?p=1075</guid>
		<description><![CDATA[One of the challenges dealing with stroke/pen based input systems is finding corners in free form lines created by pen based drawing.
ShortStraw presents a simple yet accurate algorithm described in a recent (2008) paper for detecting corners.
To summarize this paper briefly from my understanding, ShortStraw takes in points of a stroke, resamples them, uses distances [...]]]></description>
			<content:encoded><![CDATA[<p>One of the challenges dealing with stroke/pen based input systems is finding corners in free form lines created by pen based drawing.</p>
<p><a href="http://srlweb.cs.tamu.edu/srlng_media/content/objects/object-1246294647-350817e4b0870da27e16472ed36475db/Wolin_SBIM08.pdf">ShortStraw</a> presents a simple yet accurate algorithm described in a recent (2008) paper for detecting corners.</p>
<p>To summarize this paper briefly from my understanding, ShortStraw takes in points of a stroke, resamples them, uses distances of points to determinate whether the points are from straight lines or corners.  </p>
<p>I learnt about this a method when after stumbling on <a href="http://www.betriebsraum.de/blog/2009/07/21/efficient-gesture-recognition-and-corner-finding-in-as3/">Felix Raab&#8217;s blog post</a>, who created <a href="http://www.betriebsraum.de/projects/gestures/">flex example</a> of the <a href="http://www.betriebsraum.de/projects/gestures/srcview/source/de/betriebsraum/geom/cornerfinder/ShortStraw.as.html">ShortStraw algorithm implemented in actionscript</a>.</p>
<p>This makes implementing a javascript version much easier, since most of the code can be derived heavily from the AS3 implementation. So here&#8217;s an <a href="http://jabtunes.com/notation/shortstraws.html">example</a> and the <a href="http://jabtunes.com/notation/shortstraw.js">source code</a> to my shortstraw.js implementation.</p>
<p><a href="http://jabtunes.com/notation/shortstraws.html"><img src="http://photos-b.ak.fbcdn.net/hphotos-ak-snc3/hs160.snc3/18732_257391738301_724118301_3314082_579631_n.jpg" alt="ShortStrawJS" /></a></p>
<p>As usual, the demo uses html 5 canvas for drawing (sorry IE users, but any other modern browser like firefox, chrome or safari would work), jquery for simple event handling, and of course the shortstraw javascript file for corner detection.</p>
<p>For the daring, you may want to look at the paper <a href="http://portal.acm.org/citation.cfm?id=1572759&#038;dl=GUIDE&#038;coll=GUIDE&#038;CFID=72437283&#038;CFTOKEN=16568700">Revisiting ShortStraw</a> which describes iStraw, a technique which attempts to address the shortcomings of shortstraw, mainly in the area of curved lines.</p>
<p>p.s. The screenshot is in contrast with <a href="http://stevehanov.ca/blog/index.php?id=93">Steve Hanov&#8217;s</a> html 5 canvas <a href="http://www.hanovsolutions.com/webdraw/">Web draw</a>, which creates &#8220;wavy lines&#8221; while Shortstraw helps to &#8220;straighten&#8221; hand drawn lines.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.lab4games.net/zz85/blog/2010/01/21/geeknotes-shortstrawjs-fast-and-simple-corner-detection/feed/</wfw:commentRss>
		</item>
		<item>
		<title>[geeknotes] JSON DB</title>
		<link>http://www.lab4games.net/zz85/blog/2010/01/12/geeknotes-json-db/</link>
		<comments>http://www.lab4games.net/zz85/blog/2010/01/12/geeknotes-json-db/#comments</comments>
		<pubDate>Mon, 11 Jan 2010 17:33:42 +0000</pubDate>
		<dc:creator>Zz85</dc:creator>
		
		<category><![CDATA[Uncategorized]]></category>

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

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

		<guid isPermaLink="false">http://www.lab4games.net/zz85/blog/?p=1072</guid>
		<description><![CDATA[When I first learn&#8217;t about the json format, I thought: &#8220;what a great idea!&#8221;.
All the great things about it- simplicity, leanness, exactly what xml wasn&#8217;t but ought to be. 
Soon I reasoned that the json format can be persisted in storage in its own form. One can build a simple, portable database using json records [...]]]></description>
			<content:encoded><![CDATA[<p>When I first learn&#8217;t about the <a href="http://www.json.org/">json format</a>, I thought: &#8220;what a great idea!&#8221;.</p>
<p>All the great things about it- simplicity, leanness, exactly what xml wasn&#8217;t but ought to be. </p>
<p>Soon I reasoned that the json format can be persisted in storage in its own form. One can build a simple, portable database using json records with minimal code.</p>
<p>&#8220;Why hasn&#8217;t anyone else built it?&#8221; I thought.</p>
<p><img src="http://couchdb.apache.org/img/sketch.png" alt="CouchDb" /><br />
<em>(sketch from couchdb&#8217;s site)</em></p>
<p>Well, now we have <a href="http://couchdb.apache.org/">CouchDB</a>, a <a href="http://kore-nordmann.de/talks/08_04_unconf_document_storage.pdf">document based storage</a> project by <a href="http://www.apache.org/">apache</a> and <a href="http://cloudant.com/">Cloudant</a>, for your couchdb cloud needs.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.lab4games.net/zz85/blog/2010/01/12/geeknotes-json-db/feed/</wfw:commentRss>
		</item>
		<item>
		<title>[geeknotes] Repairing a Broken MJPEG AVI</title>
		<link>http://www.lab4games.net/zz85/blog/2010/01/06/geeknotes-repairing-a-broken-mjpeg-avi/</link>
		<comments>http://www.lab4games.net/zz85/blog/2010/01/06/geeknotes-repairing-a-broken-mjpeg-avi/#comments</comments>
		<pubDate>Tue, 05 Jan 2010 17:02:36 +0000</pubDate>
		<dc:creator>Zz85</dc:creator>
		
		<category><![CDATA[Uncategorized]]></category>

		<category><![CDATA[40d]]></category>

		<category><![CDATA[eos movie hack]]></category>

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

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

		<guid isPermaLink="false">http://www.lab4games.net/zz85/blog/?p=1069</guid>
		<description><![CDATA[out_21.avi
file created: 2009-05-24 14:09
file size: 514 MB (538,972,160 bytes)

Its kinda sad. We drove over 4 states (5 if we count montana) for over a day (another half to get to old faithful), setup my equipment, and when the recording of the eruption was almost over, I tripped over my own cables which caused this laptop [...]]]></description>
			<content:encoded><![CDATA[<p>out_21.avi<br />
file created: 2009-05-24 14:09<br />
file size: 514 MB (538,972,160 bytes)</p>
<p><img src="http://photos-d.ak.fbcdn.net/hphotos-ak-snc3/hs160.snc3/18732_230606248301_724118301_3202847_2055053_n.jpg" alt="Fixing Broken AVI Header" /></p>
<p>Its kinda sad. We drove over 4 states (5 if we count montana) for over a day (another half to get to old faithful), setup my equipment, and when the recording of the eruption was almost over, I tripped over my own cables which caused this laptop to crash to the floor while recording the video to crash , with the battery pack disengaged. </p>
<p>Maybe its one of those times my heart dropped together with my items, but since the rugged laptop still manage to boot, and some hope lied within me that I would be able to recover the video one day. While I thought streaming broken video files were no big deal, it wasn&#8217;t so easy. My usual tools- media player classic, virtualdub, videolan etc were unable to play this file at all. It wasn&#8217;t until yesterday I attempted to rescue this file again.</p>
<p>1st I tried this open source &#8220;DivFix++ is #1 AVI Video Repair &#038; Preview Utility&#8221;  called <a href="http://divfixpp.sourceforge.net/">DivFix++</a>. While it managed to detect FourCC frames, the resulting video file was still unplayable. Okay let&#8217;s take a step back. Then because the  Canon 40D I was using have officially has no video features, I used the open source <a href="http://sourceforge.net/projects/eos-movrec">EOS Video Record</a> which allowed some form of video recording if the camera was tethered to a pc.</p>
<p>EOS Movie Record saves the resulting video in a MJPG format, so I tried figuring if JPGs could be extracted from the motion video file. I tried looking for MJPG2JPEG converters but none existing other than 2 examples of source codes <a href="http://www.riseoftheants.com/mmx/faq.htm">here</a> and <a href="http://alexmogurenko.com/blog/programming/mjpeg-to-jpeg-cpp-csharp-delphi/">here</a>. I also started to examine and studying the file structures of <a href="http://www.fastgraph.com/help/avi_header_format.html">AVIs</a>, <a href="http://msdn.microsoft.com/en-us/library/ms779636(VS.85).aspx">RIFF</a>, <a href="http://www.bsdg.org/swag/GRAPHICS/0143.PAS.html">JPEG</a> etc, and with the help of a hex editor (the freeware <a href="http://mh-nexus.de/en/hxd/">HxD</a> works great ), started digging around the file.</p>
<p>So when I&#8217;m peeking around the file at HEX Offset 04F0000 or human friendly number 75431936, the viewer showed full of zeros. Not a good news, because it meant there was not data beyond that point (buffer were not flush). From my estimation, based on file sizes, what was an approximately 2minute video is probably a sub 20s video. Which makes me feel like rewriting the subject as: &#8220;repairing a broken heart&#8221;, but read on&#8230;</p>
<p>I noticed DivFix++ almost generated a 75MB file which i meant it must have found the same errors I suspected and strip them off. So using the software did not entirely gone to waste. On examining the headers of the file, I found it empty which is a pretty good reason that nothing could play this file. I then remembered that EOS Movie Record writes the video headers only after recording. So following the avi riff structure, I copied in header values like frame rate, resolution etc, and eureka, the video became playable.</p>
<p>So, its not too sad and not all&#8217;s lost. The badly abused laptop (actually my mom&#8217;s and the 1st laptop I used much) still survived, I managed to recover 16s, and learn a couple of things about video file formats. And my photography apprentice of that day Ben Chua did took some photos with my spare camera.<br />
<img src="http://photos-b.ak.fbcdn.net/hphotos-ak-snc3/hs160.snc3/18732_230615348301_724118301_3202878_7566234_n.jpg" alt="Old Faithful, Yellowstone" /></p>
<p>p.s. You might be able to see the short segment of the recovered <a href="http://www.facebook.com/video/video.php?v=230824803301">video</a> below.<br />
<object width="400" height="224" ><param name="allowfullscreen" value="true" /><param name="allowscriptaccess" value="always" /><param name="movie" value="http://www.facebook.com/v/230824803301" /><embed src="http://www.facebook.com/v/230824803301" type="application/x-shockwave-flash" allowscriptaccess="always" allowfullscreen="true" width="400" height="224"></embed></object></p>
]]></content:encoded>
			<wfw:commentRss>http://www.lab4games.net/zz85/blog/2010/01/06/geeknotes-repairing-a-broken-mjpeg-avi/feed/</wfw:commentRss>
		</item>
		<item>
		<title>Sweeter As The Years Go By</title>
		<link>http://www.lab4games.net/zz85/blog/2010/01/04/sweeter-as-the-years-go-by/</link>
		<comments>http://www.lab4games.net/zz85/blog/2010/01/04/sweeter-as-the-years-go-by/#comments</comments>
		<pubDate>Sun, 03 Jan 2010 16:48:34 +0000</pubDate>
		<dc:creator>Zz85</dc:creator>
		
		<category><![CDATA[Church]]></category>

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

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

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

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

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

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

		<category><![CDATA[howmean.com]]></category>

		<category><![CDATA[html 5]]></category>

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

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

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

		<guid isPermaLink="false">http://www.lab4games.net/zz85/blog/?p=1062</guid>
		<description><![CDATA[Here&#8217;s something that has kept me a little occupied over the past weeks.

To find out, head over to http://howmean.com. This site belongs to the couple to be, Caleb and How Mean. And no, rather than its perceived adjective &#8220;how mean!&#8221;, I hope one experience some sweetness visiting the site.
There are several talented people behind the [...]]]></description>
			<content:encoded><![CDATA[<p>Here&#8217;s something that has kept me a little occupied over the past weeks.</p>
<p><a href="http://www.howmean.com"><img src="http://photos-d.ak.fbcdn.net/hphotos-ak-snc3/hs160.snc3/18732_227934433301_724118301_3186717_1369356_n.jpg" alt="Howmean.com Main Page" /></a></p>
<p>To find out, head over to <a href="http://howmean.com">http://howmean.com</a>. This site belongs to the couple to be, Caleb and How Mean. And no, rather than its perceived adjective &#8220;how mean!&#8221;, I hope one experience some sweetness visiting the site.</p>
<p>There are several talented people behind the making of this site. Graphics and concept were designed by Grace Wong, and the web design was done by Meng Lung of <a href="http://www.gcds.com.au/">Gold Coast Web Design</a>. My little contributions would be some subjective augmentations to the site and one might make intelligent guesses to what I did by spotting non-traditional elements on the site. For those who aren&#8217;t guessing, here&#8217;s a list</p>
<p>+ Mouse over the dandelions near the footer, and one may see little particles floating away. On most modern browsers except IE, these particles are drawn with html 5 canvas elements. In unsupported browsers, 1 pixel rendering with css are used instead.<br />
+ Meant to be an easter egg, rolling the mouse wheel renders lighter dandelions particles around the screen.<br />
+ Ajax calls are used for navigation when possible to prevent disruption of the background music<br />
+ To support browsers not running flash (the iPhones and Androids mainly!), flash objects degrade gracefully<br />
+ To degrade the photo gallery for non flash clients, the xml used by the flash slideshow player is parsed and rendered with jquery.<br />
<a href="http://photos-a.ak.fbcdn.net/hphotos-ak-snc3/hs140.snc3/18732_225025458301_724118301_3165781_7818662_n.jpg"><img src="http://photos-c.ak.fbcdn.net/hphotos-ak-snc3/hs140.snc3/18732_225025528301_724118301_3165782_983124_s.jpg" alt="Howmean.com on the android" /></a><br />
+ A small widget (which dates back to my legendary ORD count down wallpaper) is used to display the time till or from the wedding date in the credit page.</p>
<p>Of course all these would not be present if not for the weds-to-be. </p>
<p>So this&#8217;s my 1st post of the new year, and its a great reminder to reflect whether each passing day gets sweeter. A blessed new year for you readers!</p>
]]></content:encoded>
			<wfw:commentRss>http://www.lab4games.net/zz85/blog/2010/01/04/sweeter-as-the-years-go-by/feed/</wfw:commentRss>
		</item>
		<item>
		<title>[geeknotes] Panning Navigator with jQuery, Html 5 Canvas</title>
		<link>http://www.lab4games.net/zz85/blog/2009/12/30/geeknotes-panning-navigator-with-jquery-html-5-canvas/</link>
		<comments>http://www.lab4games.net/zz85/blog/2009/12/30/geeknotes-panning-navigator-with-jquery-html-5-canvas/#comments</comments>
		<pubDate>Wed, 30 Dec 2009 11:07:05 +0000</pubDate>
		<dc:creator>Zz85</dc:creator>
		
		<category><![CDATA[Browsers]]></category>

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

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

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

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

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

		<category><![CDATA[html 5]]></category>

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

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

		<category><![CDATA[panning navigator]]></category>

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

		<guid isPermaLink="false">http://www.lab4games.net/zz85/blog/?p=1004</guid>
		<description><![CDATA[Seems that I happen to like coding several stuff when it comes to the end of the year. As such, I&#8217;ll decide to delicate this piece of script/code/site to my all my fellow photo enthusiasts and geeky friends as a late Christmas but an early new year&#8217;s gift.


I decided to implement a Panning Navigator in [...]]]></description>
			<content:encoded><![CDATA[<p>Seems that I happen to like coding several stuff when it comes to the end of the year. As such, I&#8217;ll decide to delicate this piece of script/code/site to my all my fellow photo enthusiasts and geeky friends as a late Christmas but an early new year&#8217;s gift.</p>
<p><a href="http://jabtunes.com/notation/panning_navigator.html"><br />
<img src="http://photos-b.ak.fbcdn.net/hphotos-ak-snc3/hs160.snc3/18732_221627938301_724118301_3151501_4798955_n.jpg" alt="Panning Navigator - jQuery + Canvas by Zz85" /></a></p>
<p>I decided to implement a Panning Navigator in Canvas while experimenting with various UI navigation working on my notation project (like the navigator in Sibelius). This panning navigator is what one might usually see in Adobe Photoshop, Illustrator, etc, and it seems few have implemented this, perhaps a handful implementations with flash, but none I came across with javascript. As for its name, I was not even sure what&#8217;s the name but seem this site seem to suggest this ui pattern as a <a href="http://www.welie.com/patterns/showPattern.php?patternID=navigator">panning navigator</a> for dealing with large canvases with a draggable viewport.</p>
<p>So without further to do, check out the demo here. <a href="http://jabtunes.com/notation/panning_navigator.html">http://jabtunes.com/notation/panning_navigator.html</a></p>
<p>Here are some of the features<br />
+ Drag the viewport in the navigator to view around<br />
+ Mouse wheel can control the zoooming<br />
+ Fill, Fit to screen for quickly zooming out, 1:1 for actual size and 3:1 for zooming in.<br />
+ Fullscreen photos and navigator response to browser resizes<br />
+ Features some photos from my early photography<br />
+ Canvas used for drawing the navigator and creating the &#8220;thumbnailed&#8221; image.<br />
+ Css for aligning navigator, resizing and repositioning image<br />
+ Seems useful with large photos and panoramas<br />
+ Should run iphone and android browsers although experience may be improved<br />
+ Oh also released as do what every you like to do with the source license, but remember to let me know your comments.<br />
(Warning: Some images are huge, please be patient while waiting)</p>
<p>Comments are welcomed. Maybe, when its polished up, bug free and extensible, I might release this as a jquery plugin.</p>
<p>Goodbye 2009 and an early happy new year to all!</p>
<p>p.s. One might check out the <a href="http://buildinternet.com/2009/05/supersized-20-full-screen-imagebackground-slideshow-jquery-plugin-w-transitions-and-controls/">jQuery supersized plugin</a> for where the fullscreen photos were partly inspired by.</p>
<p>p.p.s. For source code: use your browser &#8220;View Source&#8221;.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.lab4games.net/zz85/blog/2009/12/30/geeknotes-panning-navigator-with-jquery-html-5-canvas/feed/</wfw:commentRss>
		</item>
		<item>
		<title>[geeknotes] Scrollbars with Html 5 Canvas</title>
		<link>http://www.lab4games.net/zz85/blog/2009/12/30/geeknotes-scrollbars-with-html-5-canvas/</link>
		<comments>http://www.lab4games.net/zz85/blog/2009/12/30/geeknotes-scrollbars-with-html-5-canvas/#comments</comments>
		<pubDate>Tue, 29 Dec 2009 18:41:42 +0000</pubDate>
		<dc:creator>Zz85</dc:creator>
		
		<category><![CDATA[Technology]]></category>

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

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

		<category><![CDATA[html 5]]></category>

		<guid isPermaLink="false">http://www.lab4games.net/zz85/blog/?p=997</guid>
		<description><![CDATA[I couldn&#8217;t remember when was the last time I even logged into my blog. Certainly I can&#8217;t even remember my password each time. Thankful I manage to retrieve my password each time.
At times when I&#8217;m doing something experimental I think, maybe someone would find such information useful if I place it on my blog- since [...]]]></description>
			<content:encoded><![CDATA[<p>I couldn&#8217;t remember when was the last time I even logged into my blog. Certainly I can&#8217;t even remember my password each time. Thankful I manage to retrieve my password each time.</p>
<p>At times when I&#8217;m doing something experimental I think, maybe someone would find such information useful if I place it on my blog- since I learn a great deal from many other&#8217;s developers&#8217; blogs. </p>
<p>Just to touch quickly, I&#8217;m working on a personal project to build an <a href="http://jabtunes.com/notation/">online music notation software</a> which works in a modern browser (think Noteworthy Composer in the cloud with Html 5). I soon find the canvas element really powerful (supported in all major browser - firefox, safari, chrome, opera except ie), but a really raw api. Yet possibilities are already very <a href="http://www.canvasdemos.com/">attractive</a>, and closes the gap between flash and web design (as mentioned in my last geeknote on facebook). </p>
<p><a href="http://jabtunes.com/notation/"><br />
<img src="http://photos-f.ak.fbcdn.net/hphotos-ak-snc3/hs039.snc3/12633_191002178301_724118301_3019940_5256990_n.jpg" alt="Notation Project" /></a></p>
<p>Anyway, more the project next time, but what I would like to cover here is dealing using scrollbars to deal with an oversized canvas. If you ever did any Java AWT/Swing programming, you might know this can be done simply with placing your components into a JScrollPane. So here&#8217;s my current quick implementation of a scrollpane with CSS.</p>
<p>First the html elements.<br />
&lt;div id=&quot;omw_scrollpane&quot;&gt;<br />
	&lt;canvas id=&quot;omw_canvas&quot; width=&quot;800&quot; height=&quot;320&quot;&gt;&lt;/canvas&gt;<br />
&lt;/div&gt;  </p>
<p>Basically, this wraps the canvas element into a div container we call scrollpane, responsible for providing the scrollbars.</p>
<p>Then the css.</p>
<p>#omw_scrollpane<br />
{<br />
	width:400px;<br />
	overflow:auto;<br />
	border: solid 1px white;<br />
	background-color:white;<br />
}</p>
<p>This simply constrains the enclosing div to a view port, and the overflow properties automatically adds scrollbars when the canvas element is larger than the specified width. The canvas would continue to work without recalculating coordinates.</p>
<p>Real simple hack? Yes and no. This may works for simple application, but perhaps more complex situations may require custom scrollbars (which brings me back to the flash pre-mx days where scrollbars need custom coding). Its seems to me that having a canvas of over 80,000 pixels width seems to hang chrome and opera 9 browsers.</p>
<p>The only other example I could find on the net which require scrollbars with their canvas application is actually the amazing <a href="http://bespin.mozilla.org">Mozilla Bespin</a> project (collaborative &#8220;code in the cloud&#8221; with your browser). Right now their implementation uses a custom scrollbar which docks/hides itself when not being used. One might wish to investigate the ui framework mozilla built ontop of canvas call <a href="https://wiki.mozilla.org/Labs/Thunderhead">Mozilla Thunderhead</a> used in the bespin project. Seen by some to be a competitor to flex or other RIAs, you may wish to learn more following one of their <a href="http://bengalbraith.wordpress.com/2009/02/18/bespin-and-canvas-part-2/">developer&#8217;s blog</a>.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.lab4games.net/zz85/blog/2009/12/30/geeknotes-scrollbars-with-html-5-canvas/feed/</wfw:commentRss>
		</item>
	</channel>
</rss>
