3D Christmas tree (aka the “Merry Christmas” post)

3D, actionscript 3, Math, Particles

Hi there,

lot of time without posting some code. I have been working three months on a Disney project, which will be on-line soon and makes me very proud, but almost drained all of my energies.

Here is my Christmas card/gift for my readers, in less than 80 lines of code. Obviously with source code. The lights are vector graphics in the attached FLA’s library to make it easy to customize or animate.

Nothing too fancy here about the code, just some trigonometric math. You can have a look at the correctOrientations function which can be interesting to avoid lights deformations due to the FP10 native 3D.
Download source code.

I wish you all great winter holidays, and an awesome beginning of 2010!
And make me smile by leaving a greetings comment ;)

Watch the running example:
Click to start (mouseX affects rotation)


Google Translate database is… Windows Font Viewer

bugs, fun

Google Translate goes realtime… -_-

Just a quick (non-technical) post, but I cannot resist… Ok, Google translate introduces a realtime translation feature as highlighted as every new Google feature by billions of blogs (I saw it here: http://mashable.com/2009/11/16/google-translate-update/), but where is the GTranslate database taken from?

Does Anyone know? I do…
The Google Translate source database is… Windows Font Viewer!

Any other way to explain how is it possible that writing:
“a quick brown fox”

is translated in

uno Cantami o Diva” (literally: “one Sing, O goddess”)

(Try it yourself)

For those not into Greek epic poems translated in Italian, this is the beginning of the Homer’s Iliad which in my language reads:

Cantami, o Diva, del Pelìde Achille
l’ira funesta che infiniti addusse
lutti agli Achei, molte anzi tempo all’Orco
generose travolse alme d’eroi,
e di cani e d’augelli orrido pasto
lor salme abbandonò (così di Giove
l’alto consiglio s’adempìa), da quando
primamente disgiunse aspra contesa
il re de’ prodi Atride e il divo Achille.
E qual de’ numi inimicolli?

So how is it possible that a brown fox becomes a singing Goddess? I couldn’t remember but then I realized that the beginning of that poem is used by the Italian version of Windows in the font viewer to preview fonts!

So “A quick brown fox jumped over a lazy dog” (which is used in the English version since it contains every letter of the alphabet –a pangram) according to GTranslate in Italian should be translated with the beginning of a classical piece of literature… just because it’s another common pangram (almost)).

Obviously the magic doesn’t end here: just change “a quick brown fox” in “A quick brown fox” (with capital A) and the result is “Una volpe veloce” (correct)…

or remove the article: “quick brown fox” and the result is “quick brown fox” (not translated at all)!

I can understand translating from english to japanese (which are structurally completely different languages) back and forth can produce funny idiosyncrasies as seen on Translation Party but Italian is more similar and “quick”, “brown” and “fox” are common words learned at the first grade during the English lessons.

So I never wrote a dictionary db or algorithm and I am not so sure I could do better, but Google surely can, and first things should come first.


NihongoUp by divita – Learn japanese the fun way

fun, game, general, japanese

This is the first time I publish a review, but since I am learning japanese and this game is so much fun and so much useful I think it deserves visibility.

NihongoUp is a japanese learning game developed in Adobe AIR by Philip Seyfi.
It is structured in four main categories:

  • Kana (Hiragana, Katakana, All kana)
  • Kanji (JLPT 3, JLPT 2)
  • Vocabulary (JLPT 4, JLPT 3, JLPT 2, JLPT 1)
  • Grammar (particles, counters)


There are mainly two kinds of games, a typing one, used in the “Kana” section where lots of balloon comes down the screen with a japanese symbol attached. You have to type the translitterated kana before the balloon disappears to gain score points and raise the level number. It’s simply funny and perfect for someone at the beginning of the studying process.


The other kind of game reuses the concept of the falling balloons but you simply have to choose between four possible answers to the question located at the bottom of the screen. This game concept is used in the other sections, where you can train your Kanji knowledge, grammar skills or the richness of your japanese vocabulary.


What else to say? It is well coded and the database is huge with 8000 10000 (!) records filled all the JLPT Kanjis and training sentences, so this game could really help the willing student to become a japanese language master, with fun.

So if you are studying japanese and you are a flash developer (likely as you are reading this…), support this valuable work. A license serial number costs only $4.99 and before buying you can trying a free trial to test it out.


I’ll soon be back posting lots of new actionscript stuff. Have a nice sushi day ;)


Actionscript 3 – as3 | Rorschach mask (realtime animated inkblots)

actionscript 3, BitmapData, classes, fluids, fun, morphing, perlinNoise, simulation, threshold

Everybody knows about Rorschach inkblot tests, and they always charmed me… It’s like looking clouds and recognizing different shapes.

However I must admit the real turn on came after watching Watchmen the movie. Seeing those animated inkblots on the face of the character symbolically named Rorschach is something really fascinating. So here we are, after about an hour of coding fun this is what I came up with.

Click to start

Here after adding a cool persistence of the ink (call it motion blur if you like), and the face oval:

Click to start

How it’s made is quite simple:

- perlinNoise a bitmapData
- draw a circular gradient mask (I used a beginGradientFill on a Shape/Sprite)
- BitmapData.draw() the mask onto the perlinNoise bitmapData
- threshold
- (optional) a little blur to simulate antialias

Since a picture is worth a thousand words:

Click to see it moving

I’ve built a class to do this easily. Six parameters are optional to instance it:

public function Rorschach(w:uint=400, h:uint=400, mirror:Boolean=true, seed:uint=0, ovalClass:Class=null, ovalScale:Number=1, ovalYOffset:Number=0)

ovalClass is the (optional) reference to the class containing the face background.

So the usage is very simple, here an example:

import com.oaxoa.fx.Rorschach;
addChild(new Rorschach(300,300));
//addChild(new Rorschach(300,300,true,0,blankMaskImage, 1.2, -20));

Download Rorschach class for your experimentation pleasure.

All nice, but the aim of this simple experiment is seeing Rorschach animated face in action so here we go… we will be using this class in a practical example.

To simulate 3D volume and perspective we need flash CS4 (or any 3D engine):
we create a MovieClip which has the Rorschach class instanced and a rectangular solid background for composition reference in it. Then we set layer visibility to wireframe and add another instance to the stage, which is flipped horizontally.
Just position the two instances using 3D rotations and we are ready.

Just build et voilà!

Click to start

Rorschach’s Journal. October 12th, 1985. Dog Carcass in alley this morning, tire tread on burst stomach. This city is afraid of me. I have seen its true face. The streets are extended gutters and the gutters are full of blood and when the drains finally scab over, all the vermin will drown. The accumulated filth of all their sex and murder will foam up about their waists and all the whores and politicians will look up and shout ‘Save us!’ And I’ll look down, and whisper ‘no.’

The last (and D-E-F-I-N-I-T-I-V-E! :-D ) usage for this is apply it to a realtime webcam face detection algorithm. I used this originally created by Ohtsuka Masakazu and optimized by Mario Klingemann. The result is totally weird (don’t expect photoreal hollywood effect LOL) but it’s funny, even if the face detection algorithm is not perfectly smooth.

Have fun being the definitive comics anti-hero:

Click to start


Actionscript 3 – as3 Lightning / Thunderbolt / Electric discharge Class

actionscript 3, algorithms, BitmapData, classes, fun, Math, morphing, perlinNoise, simulation

Finally here we come!

Yup, sry for the delay, I’ve had a lot of work recently.

I have prepared three demos and a publishable (but far from perfect and not yet documented) class. The demos are FLA based… you can find the timeline code to assemble the demos at the bottom of the post. I’ll publish some documentation in the next days, so until then just look at the demos’ code to unserstand the basic of the class usage.

Download Lightning classes

Demo N°1:
This demo shows the two different behaviours the class can mimic: Electric discharge/beam or lightning. Drag the ball near or far to the coil to see different behaviors.

Click to start

Demo N°2:
This demos show the maxLength and maxLengthVary properties in action.
Bring the fingers near to the plug to have continuos electricity. Bringing the hand far from the plug lowers the discharge probability. Reaching the max distance simply disables it.

Click to start

Demo N°3:
This demo is a good reason for the publishing delay :P

A nice sandbox to play with (some of) the properties.
The class is recursive to create children so many properties have also a decay twin property which rule how the property is passed to children.
As instance if you set a childrenMaxCount = 6 to the main Lightning instance it will have a maximum of 6 direct children. Its children will have a childrenMaxCount value which depends on the main instance childrenMaxCount and childrenMaxCountDecay.
So if you set childrenMaxCount = 6 and childrenMaxCountDecay = .5 the children of the main instance will have childrenMaxCount = 3.
If you set childrenMaxCount = 6 and childrenMaxCountDecay = 0 the children of the main instance will have childrenMaxCount = 6 (no decay).

This value can be very useful to optimize the speed of execution cause smaller branches don’t need many children or many steps of detail.

Click to start

Ok, I’m too tired to write more. I’ll publish some documentation in the next days.
Feel free to ask everything question you can have in the comments, and as usual if you like this stuff scream it in the comments!

Demos’ code after the break. Waiting for your comments I will surf through the website of fatcow and see if they have any good hosting plans.

Continue Reading »

« Older Posts