Saturday, July 14, 2007


Before boarding a flight I'm eagerly awaiting the security presentation that is about to ensue. I figure that these people spent their valuable time learning how to point to the ground, back, forward and to the side and someone needs to appreciate that effort. During my last flight I even went ahead and tried to inspect my life jacket. "Tried" because as it turned out my seat was missing it. As the security announcement advised, I "calmly" informed the fellow sitting next to me that "in the unlikely event of a water landing" he's screwed because as a stronger man I'm taking his life jacket. This also prompted me to think about tools that make our life easier (just to clarify, when I say "our" I mean "my"). I've spent a little time yesterday creating a tool that will make my (when I say "my" I mean "our") life a lot easier. So today I wanted to tell him (when I say "him" I mean "you") about us (when I say "us" I mean "it").

I've spent a lot of time writing simple C++ applications to test out some kind of rendering algorithm. Internally we had a tool that automated a lot of it. The tool uses a very simplistic, reg-exp based language to specify commands. I wanted something more powerful. This is how scripter came to be. Scripter is a very simple application that uses QtScript's bindings to Arthur to do its rendering. It allows for rapid prototyping of algorithms and most importantly for me, quick testing of Qt's rendering framework. At first it was a whole IDE with its own code editor, very quickly though I decided to remove the editor and just make it a content widget that monitors the file it was opened with for changes. The reason for that is that I wanted to keep working in my own editor and just have a dynamic, visual preview of everything I was doing. So with Scripter one can be writing rendering code while the visuals effects of the editing are immediately visible. Here are two screenshots of examples included with it:

But the whole beauty of this application is ability to create animations, while seeing the changes done in real-time. I recorded two demos:
Scripter requires Qt 4.4. If you don't have Qt 4.4's snapshot it won't work. Get it from the SVN at with :
 svn co svn://


Anonymous said...

Amazing stuff. This will trigger fantastic plasmoids. I'm gonna have to rewrite my dbKalendar and trailertracker as soon as KDE 4 is out. :D

jospoortvliet said...

It almost makes one think KDE 4 should be based on Qt 4.4... Of course, that would lead to a delay, so that sucks.

Anonymous said...

Really cool, thanks! :)

However your code states that you use anti aliasing and at the edges your picture is still crippled. Why is that?

Zack said...

@Guybrush: as you point out it's a picture that undergoes transformation. To get smooth pixmap transformation you use QPainter::SmoothPixmapTransform.

Unknown said...

I have played around with this for about an hour or so, it will be a great time-saver for trying to create effects.

I had encountered a few problems ( which might be my fault as a graphics newbie ):

- Setting the painter's composition mode using painter.setCompositionMode(QPainter.CompositionMode_XXX)
didn't appear to have any effect.

- I wasn't able to create a painter on a pixmap.

px = new QPixmap("/path/to/pixmap");
painter = new QPainter(px);

- With the 'modification' button enabled in the UI, it detected the first time a change in the .js file being shown occurred but ignored subsequent ones.

Zack said...

@Robert Knight: 1) we haven't bound them, use integer values. 2) we haven't bound that. 3) never seen it and i kinda doubt that, i think it's more likely that the script had errors and simply was throwing an exception that you weren't catching, otherwise you'll have to debug it

Rich Moore said...

It looks like it should be possible to use these bindings with 4.3 too which is nice. :-) Should be useful for my qtscriptable plasmoid!

Sami Kyöstilä said...

Cool. For some reason, this reminds me of Ken Silverman's EvalDraw.

Anonymous said...

zack, you are the SHIT. period.