tokamak4: some js love

February 25, 2010 at 5:07 pm 2 comments

Some years ago, I used to think that real programmers only do C or C++ and that script languages were not for real man. Of course, I was wrong and realized that when I did my pet project doing the server in C and the client in python.

Javascript seems to be all the rage lately (Palm WebOS anyone?). An amazing idea that I have being discussing for 2 days with aseigo, richmoore, notmart, igorto (all good hackers lurking in the #plasma channel) while in Tokamak4 is somewhat that might sound strange: javascript based animations.

Currently is possible to use our C++ animations in javascript plasmoids, which is good. But if we look at the code of those classes, a significant part is just boiler plate code to setup the object. So, what if we have a single JavascriptAnimation class coded in C++ and put the logic of setting/reseting the properties of animated target widgets on a javascript file?

Some clear advantages:

  • easier to prototype an animation
  • easier to make animations theme dependent
  • easier for users (and designers) to contribute animations

And some obvious disavantages:

  • execution speed might suffer
  • exposing some properties of widget objects that might be dangerous for js coders (no offense intended!) 😀

So, maybe you are wondering ‘Nice, but where is the code?’. You can look at it here: svn://anonsvn.kde.org/home/kde/trunk/playground/base/plasma/libs/jsanimation

(it will probably only compile with KDE trunk but might work with KDE 4.4. SC).

It is really interesting to see that a simple zoom animation (and somewhat limited, it is just an example) becomes in javascript:

function updateCurrentTime(currentTime)
{
var delta = currentTime/duration
target.scale = delta
}

So what now? This is just a PoC, a lot of work is waiting for us to port other animations, test, profile, do some js black magic for speed ups. What is really interesting is that until last night I have never used the QScriptEngine class, but thanks to its good documentation (and hacking the whole night on it while in the hostel) I got the PoC working. It is quite funny how Qt can be an enabler for experiments like this.

Interested to join the boat? Follow plasma-devel and KDE techbase.

Advertisements

Entry filed under: Uncategorized.

Tokamak4: high quality pulse Delayed post: Nuremberg

2 Comments Add your own

  • 1. Marcelo Eduardo  |  February 27, 2010 at 5:22 pm

    If you are using JS why not use the same method shown in CSS3 for animations? 😉

    Reply
    • 2. savago  |  March 1, 2010 at 2:17 am

      I will have to check it and discover if we can reuse it in plasma.
      🙂

      Regards

      Adenilson

      Reply

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

Trackback this post  |  Subscribe to the comments via RSS Feed


Calendar

February 2010
M T W T F S S
« Jan   Mar »
1234567
891011121314
15161718192021
22232425262728

Most Recent Posts


%d bloggers like this: