Showing posts with label javascript. Show all posts
Showing posts with label javascript. Show all posts

iPad 2 JavaScript Benchmark Results 37% Faster Than iPad 1

SunSpider JavaScript Benchmark marks 37% faster score on iPad 2 / iOS 4.3.1 / Mobile Safari 5.0 compared to iPad 1st gen.



Also note that iPad 1 could get significant peformance improvement by updating iOS from 4.2.1 to 4.3.1. This means Mobile Safari 5.0's "Nitro" Engine enabled on iOS 4.3 runs JavaScript quite fast.

Benchmark results captured are below:

iPad 2 - 4.3.1 and 4.3


iPad 1 - 4.3.1 and 4.2.1


PS.
My Mac results 344ms on Chrome and 360ms on Safari.
iPads are still nothing compared to Mac. :-<

* Japanese version of this post is here.

Shibuya.js won the prize at LT championship, LLTiger

July 31st, the Japan UNIX Society hosted the LL Tiger conference as a series of their annual Lightweight Language developer events. Eight teams competed at the lightening talks tournament championship held in the conference. Our team of Shibuya.js, Tokyo-based JavaScript developers group, did it to win the first prize at the hard knockout competition!

Preliminary Round

Just a day before the championship, we Shibuya.js members had an tech meetup event titled Shibuya.js beyond HTML5 as the preliminary round to pick up the presenters.


(photo by @takesako)

At the pre-round, three speakers, @gyuque, @yukoba and me was selected.

The First Round - @gyuque

On the following day, our presenter for the first round was @gyuque. He gave a talk about a software modem implemented by JavaScript. His JavaScript FSK modulator generates sound waves for data payloads. Then it plays generated .wav data encoded in base64 via data: scheme through HTML5's <audio> element.



See also @gyuque's slides on Slideshare.

The Second Round - @kawanet

At the semi-final match, I @kawanet gave a talk about 3D JavaScript. The talk was enhanced since I gave the former talk at OSDC.TW 2010 in Taipei.



See also my slides.
* Right cursor or mouse click - Proceed to the next
* Left cursor - Back to the previous
* 0 key - Return to the first slide
* 3 key - Toggle 3D mode and 2D mode
* Use red-blue glasses to see anaglyph 3D.

At the intermission after the first round, we decided to add an additional demo for the second round. Our JavaScript guru @gyuque wrote the real-time 3D demo below within just 30 minutes.



The Final Round - @yukoba vs. @takesako

At the final, our last speaker @yukoba fighted against @takesako from the Project-D Team. He is a tough rival as he is also a member of our Shibuya.js group. This means the last match is blue-on-blue.

Takesako gave a talk about an 8086 assembler implemented by JavaScript. The assembler is not normal but generates bytes covered with many ASCII arts of smileys like [^_^].



At Yukoba's turn, he gave a talk about a JVM including MIDP implemented by JavaScript. He compiles .class binary files of Java to .js source code files of JavaScript. The compiled code runs on his JS-based JVM which works on HTML5 web browsers including Google Chrome and WebKit. It means mobile phone applications for MIDP devices would run on iPhone and Android phones without any codes changed. I'm sure that his system has incredible potential for mobile game market.



See also @takesako's slides and @yukoba's video from 07:40 on Ustream.

I won an iPad!

Our team Shibuya.js won the championship at last. As the bonus prize, I got an iPad. Thanks!



Invitations for other tournaments are welcomed. ; )

Related Posts

The 2nd JUI Conference in Adobe MAX Japan 2009 - Feb 2009
The JUI 2008 Tokyo was over - Jun 2008
John Resig and The Future of JavaScript - Oct 2007
"Shuccho Shibuya.JS 24" in Mozilla 24 - Sep 2007

About Shibuya.js, see also John Resig's post.

* Original post written in Japanese is here

HTML5.Audio - JavaScript MP3 Player Library (HTML5-like)

HTML5 allows <audio> element to play MP3 and other sound formats by HTML and JavaScript. But HTML5 is still not in major. So I wrote HTML5.Audio which is a JavaScript library to play MP3 music via Flash.

Demo #1: Play sound by HTML5.Audio

Demo #2: MP3 player

Before Using It


You can manipulate HTML5.Audio object like HTML5's Audio object.
To prepare it, load three JavaScript files on HTML header.
<script type="text/javascript" src="js/swfobject.js"></script> 
<script type="text/javascript" src="js/jkl-js2as.js"></script>
<script type="text/javascript" src="js/html5-audio.js"></script>

Plat MP3


Create HTML5.Audio instance with MP3 file URL. Then, call play() method to play it. It totally simple like HTML5's Audio object.
<script type="text/javascript"><!--

music = new HTML5.Audio('sound.mp3');
music.play();

--></script>
Note that HTML5.Audio library support MP3 files at this time.
WAV file and other sound formats are not supported. ActionScript's Sound class limits it.

Properties


HTML5.Audio library supports some properties imported from HTML5's Audio object: currentTime, volume, paused, ended, loop and duration
You need to call set()/get() method to set/get properties.
var ctime = music.get('currentTime');

music.set('volume',0.8);
Note that currentTime property will be updated only when playing music is started and paused.

Events


HTML5.Audio library supports some of events callbacked: onloadstart, onload, onplay, onpause and onended
You need to call set() method to set callback function for event property.
var onended = function () {
alert( 'sound ended' );
}

music.set( 'onended', onended );

Options


HTML5.Audio library loads html5-audio.swf flash file which was written by ActionScript 3.0.
To set path for html5-audio.swf, call getProxy() method before creating the first instance of HTML5.Audio.
<script type="text/javascript"><!--

HTML5.Audio.Proxy.getProxy({swfPath:'./html5-audio.swf',onready: init});

--></script>
Note that onready property is an event which will invoked when HTML5.Audio library was ready to play. You can call getProxy() method before window.onload event was invoked.

Files

  • js/html5-audio.js - HTML5.Audio library core (JS part)
  • js/jkl-js2as.js - JS-AS bridge (JS part)
  • js/swfobject.js - Library to load flash file
  • swf/html5-audio.swf - HTML5.Audio library Flash binary
  • swf/expressInstall.swf - Says install/update Flash!

Download


Check out files from the Spark project repository:
svn co http://svn.coderepos.org/share/lang/javascript/HTML5.Audio/trunk html5-audio


* Original post of this was written in Japanese at 2009/05/17 17:40

JSARToolKit - AR (Augmented Reality) by JavaScript

After my talk at OSDC.TW 2009 in Taipei, I've released JSAR's source code on the Spark project's repository:
http://www.libspark.org/svn/js/JSARToolKit/trunk

JSARToolKit is a JavaScript library to run AR (augmented reality).
This is the first JavaScript project on the Spark. :)


Demo #1 - Show Logo

Try: JSAR Logo Demo
Download and print marker pdf: Maker PDF (JSAR Logo Only)

Demo #1 shows a label "JSAR" in DIV element overlayed on Flash. Red square border on marker was drawn by canvas. It means both of label and lines are controlled by JavaScript not by ActionScript.

Demo #2 - Mic Volume

Try: Mic Volume Demo
Download and print markers pdf: Makrers PDF (4 patterns)

Demo #2 shows a label for each markers and changes its font size effected by microphone volume inputed.

Sample Code

<script type="text/javascript" src="../js/swfobject.js"></script>
<script type="text/javascript" src="../js/jsar.js"></script>
<script type="text/javascript"><!--

  var jsar;
  function init () {
    jsar = new JSAR( 'jsar_here' );
    jsar.drawMarkerRect = true;
    jsar.onDetected = function ( result ) { ... };
    jsar.onLost = function ( result ) { ... };
    jsar.captureX = 320;
    jsar.captureY = 240;
    jsar.displayX = 640;
    jsar.displayY = 480;
    jsar.init();
    jsar.setMarker( [ '../code/jsarlogo.pat' ] );
  }
  window.onload = init;
--></script>
<div id="jsar_here"></div>

How To Compile It

JSARToolKit uses FLARToolKit in it. This means JSAR is not pure JavaScript, but flash powered. Download JSARToolKit from the Spark project by svn command, and compile it by Flash CS4 or by FlashDevelop + Flex SDK.

svn co http://www.libspark.org/svn/js/JSARToolKit/trunk jsar
mkdir -p jsar/src/org/libspark
svn co http://www.libspark.org/svn/as3/FLARToolKit/trunk/src/org/libspark/flartoolkit jsar/src/org/libspark/flartoolkit

In fact, you can use jsar.swf pre-compiled. So you don't need to compile it by your self.

I need say thank you to Saqoosha who has developed FLARToolKit.

* Original post of this was written in Japanese at 2009/05/05 01:46.
 

JSAR (JavaScript Augmented Reality) at OSDC.TW 2009 Taipei

Last weekend, I flew to Taipei to attend the OSDC.TW 2009, OpenSource Developers Conference in Taiwan. I had a talk titled "The JUI Digest Taipei" there. JUI means JavaScript User Interface:

The JUI 2008 Tokyo (first)
The 2nd JUI Conference in Adobe MAX Japan 2009

In addition to the recent topics in the 2nd JUI, I showed the JASR (JavaScript Augmented Reality) demonstration.

JSARToolKit is a library to run AR by JavaScript. It works as a proxy wrapper for a bridge application using FLARToolKit.

Try it : JSAR Demo #1
Get marker PDF : JSAR logo for print
Get marker PDF : 4 markers for print

Then, today's main dish was "AiR Xiaolongbao".
A dozen XiaoLongBao (小籠包) were shown on the table by JavaScript!

Try it : AiR Xiaolongbao Demo
Get marker PDF : XiaoLongbao markers for print (free)

This was a hommage for Air Yakiniku (Air焼肉) as a Chinese version.

Some of front-row seated attendees helped me to show that JSAR supports multiple markers. Jesse drew his improvisatorial "JSAR" marker whis was fainally recognized at the last of my talk.

See my slides on slideshare.

This was my sencond trip to Taipei. We really enjoyed there again. Last year, I gave another talk titled DOM manipulation by Wiimote/Gainer over HTTP in OSDC.TW 2008. That was also first time for me to talk about Wii Remote. I evolved it later and talked it in some other YAPCs places. I guess I will talk the JSAR again for other conferences this year as well. See you soon!

BTW, JSARToolKit uses FLARToolKit internally. I must say thank you for Saqoosha who is one of the most cool Japanese Flash guys. And he will give a talk about FLARToolKit in the FITC Tronto 2009 conference this weekend. Don't miss it!

The history of JavaScript's 3D tech development

Before most of popular browsers start to support canvas "3d" context, we JavaScript developers have struggled how to implement to enable 3D by JavaScript without any extensions like Java, Flash, etc. Here is a part of the history of JavaScript's 3D tech development.

Animation.Cube - April 2006


Three years ago, I wrote a library named Animation.Cube which slices images into many vertical lines to show rotating cube. I demonstrated this at the first technical talks of Shibuya.js community. The code is on JSAN. See also digg.

Triangles by Border of Div - October 2006



Useless Pickles (Jeff Lau) shows polygons drawn by many triangles made by <div> elements using trick of borders. It means we could develop Virtua Fighter (1) by JavaScript.

3D by Canvas - March 2008


Again, I wrote a new demo using <canvas> element to draw wireframe image and polygons as well. The code was written for another demo to manipulate Wii Remote controllers, I had sessions talked at OSDC.TW 2008 (Taipei), YAPC::Asia 2008 (Tokyo), YAPC::NA 2008 (Chicago), and YAPC::Europe 2008 (Copenhagen) conferences.

3D Renderer with Textures - March 2008


At just about the same time, Jacob Seidelin gave a great demo with texture mapped polygons using <canvas> element.

Triangle Texture Mapping on Wii - April 2008



Daniel Gump released Wii Opera SDK which had triangle texture-mapping feature. It is a SDK for Nintendo Wii's Internet Channel. He said it could show 500 textured triangles per second on Wii.

Motion Blur - May (maybe) 2008



Kaarel Lumi represented a beautiful motion blur using alpha blending tech by fillStyle. Thanks, @moriyoshi.

Projective Texturing - November 2008



Steven Wittens also wrote projective transform renderer. I'm interested in the tech which make an adjustment on size of the image cutted. It makes many cuts for front pieces.

Sphere Environment Mapping - February 2009



Satoshi Ueyama reported that Chrome had extremely fast canvas rendering engine named Skia by demonstrating his demos and benchmarks. He also described in detail how to implement texture mapping by canvas in his post. He also implemented physical computing and sphere environment mapping feature on it. His demos showed us that now we could run JavaScript 3D by real-time / daily-usable performance on Chrome. And I guess rest of popular browsers will soon come to the stage. See also my post.

Incredible JavaScript+Canvas 3D demos from Japan!

Mr. Satoshi Ueyama hacked out the new era of JavaScript 3D tech by unveiling the real of Google Chrome's power. Satoshi is one of the great JavaScript hackers in Japan, and also known as gyuque listed on the article of 30 Japanese geeks you should follow on Twitter. (cached)

He has introduced the brand new JavaScript technique using Canvas for 3D on his post. Browsing with Google Chrome is strongly recommended for all demos below.

I'm sure this could be one giant leap for JavaScript user interface technologies.

Demo #1: 3D texture mapped with physical computing

This is his first demo which shows 3D textured by Canvas. You can click on the cloth to make it waved.


http://gyu.que.jp/jscloth/

Demo #2: Hatsune Miku 3D with OOP

The 3D Miku is OO-style implemented as an object which has swing() method. This means she swings green onion in her hand when swing() method is called. Click on her.


http://gyu.que.jp/jscloth/miku.html

She wears hundreds of polygons. The demo was created for Paul Bakaus, jQuery UI lib's lead, visiting Japan.


Demo #3: 3D iPod touch with environment mapping

You may find the all demos above have the same width as 480px. Yes, it is definitely same as the horizontal viewport size which iPhone and iPod touch have. Now you can see iPod touch displayed on your iPod touch by the demo #3!

It could be slightly slow on ITSELF, however, it's still cool. These demos show us that we rarely need Flash anymore on the mobile platform, right? ;)


http://gyu.que.jp/jscloth/touch.html

But the most important point of the demo is not its width. You need to see behind of it. He also implemented the reflection mapping feature on his lib.


http://gyu.que.jp/jscloth/touch.html

The all demos above are coded only by pure JavaScript using Canvas. Here are no Java, Flash, ActionScript etc. but just the Web standards.

You can see Google Chrome runs all demos much faster than any other browsers. It has a great rendering engine named Skia. CPUs are already enough fast to calculate most things, you know, and now JITs are implemented as well. But canvas renderers admit of their performance. Skia is special. Safari is also fine. Firefox, 3.0 and 3.1 JIT-ed, are seem to be slower, unfortunately. We don't have to say that IE have no capability to run these.

Gyuque runs several benchmarks to describe Skia has significant advantage on its canvas rendering engine.


http://d.hatena.ne.jp/gyuque/20090211#1234364019

The 3D JavaScript tech could be one of the killer applications of Chrome now. I guess the next generation of browsers will soon compete on Canvas performance.

Original of this post was written for my Japanese blog.
You must see more detail on gyuque's post.

The 2nd JUI Conference in Adobe MAX Japan 2009

Almost one year has been past since we held the 1st JUI conference in Tokyo. The JUI is a conference forcused into user interface techs using JavaScript. At he end of this January, we held the JUI again in Adobe MAX Japan 2009 conference as a sub conference. I think it's definitely true that Adobe is really big-hearted company. Five of JavaScript guys could talked only about JavaScript at the session which has the sub-title of "we don't need FLash any more!" in Japanese.

At first, I gave an introduction talk.


JavaScript Hot Topics 2008 (Adobe MAX Edition)
#10 - 10th Anniversary of MM_SwapImage()
#9 - Shibuya.js comes to Kyoto
#8 - ECMAScript 4 failed. Now 3.1 instead.
#7 - Adobe launches Flash 10
#6 - iPhone 3G integrated with JavaScript
#5 - Many companies switching to JavaScript
#4 - Microsoft follows web standards by IE8
#3 - Varieties of JavaScript libraries
#2 - Playing .swf by JavaScript on the scene
#1 - Too Rapid JavaScript. No JIT, No Life.

The 2nd speaker was Yu Kobayashi a.k.a. yukoba who was the author of HotRuby virtual machine. His talk was about "How to implement a Flash Player."


The next was Satoshi Ueyama a.k.a. gyuque. He also implemented another Flash Player named "JSplash" which had a trick to translate ActionScript code to JavaScript code. This pre-compiling feature gave it enough performance compared to Adobe's native Flash Player. That means we don't need flash player any more.


The 4th was Moriyoshi Koizumi who was one of Japanese PHP committers. He gave a talk about "JavaScript's Sound Generation" using data scheme.


The last was Hotoshi Amano a.k.a. amachang. He always starts to develop new presentation tool before he writes slides for each conferences. Now he made it in 3D. Note that only nightly build of WebKits - at that time, now Safari 4 is available - could show his slides. His talk itself was about "DOM Performance Tuning."


Anyway, in the Adobe's conference, we're happy to let them know these crazy JavaScript guys're existing and working hard for the high level of techniques and user experience.


The 2nd JUI Speakers

The original post of this was written in Japanese.

Translatable presentation with the S6 JavaScript library

For my talk at OSDC.TW 2008 in Taiwan, I have added a couple of features to the S6. The S6 is a great presentation tool developed by amachang, based on HTML/Web standards and implemented in pure JavaScript. (demo)


Writing a slide with the lib is entirely easy:
<div class="s6_fadeScale">
    <h3>page title here</h3>
    <p>page body here</p>
</div>
class="s6_fadeScale" means the fading/scaling effect on paging.

And the most noteworthy feature of this special version of the S6 is automatic translation feature which is powered by Google AJAX Language API.

Just clicking a text node on the slide, it's translated into Japanese or another language in a moment. This is efficient for I18N, M17N and native language support. (demo)


13 languages, Japanese, Korean, Traditional Chinese, Simplified Chinese, Arabic, Russian, Greek, German, Italian, Dutch, French, Spanish and Portuguese, are supported to be translated into. The number of languages is depend on it of the Google Translate. Reverse translation, ex. translating from Japanese to English, is also supported for granted.

This means, with the lib, your presentation would get more familiar for the people who could not read the language of it.
I'll welcome you giving cool talks in Japan with the lib. We Japanese don't need to be afraid of slides written in English anymore! :-)

Download it now and enjoy!

* The original post of this was written in Japanese and was translatable.