Proposal: Animate cairo's drawing operations in a Clutter-way




Hello Clutter-developers,

since a month I'm playing around with a small Vala-library I wrote,
called "Sketch". It is built around the idea, that one could simplify
the rendering process for Cairo-Canvases pretty elegantly  (my
opinion ;) ) using an object-based approach.

-- So how does it work? ---
Sketch provides a set of "Operation"-classes. Each Operation knows how
to draw something on a "Layer" (a ClutterActor which allows to add
Operation objects) under certain conditions. Those conditions are
specified using the properties of the Operation.

Example:
Instead of making a rectangle grow each frame by a certain amount
explicitly, you just create a "RectPathOperation" (used to create a
rectangular path) and add it to a Layer. Afterwards you create a
"StrokePaintOperation" (similar to Cairo.Context.stroke) and add it too.
Then you set the easing-duration of the RectPathOperation to 500ms and
set the size properties afterwards.
Now a redraw is needed, so the Layer-object iterates over the Operations
and draws a rectangle, according to the current size, growing over time.


What is awesome about this approach, is

a) creating complex animations is very easy. Just think about a rotating
circle with animated border width, gradient and border-color. Check the
demo-programs.

b) it is consistent with the way Clutter deals with animations (Sketch
even uses ClutterAnimationMode for property-transitions). So now you
can't only animate a pre-drawn canvas, but also the drawing process
itself, using the same API (at least in the future).

As I'm momentarily quite busy due to my studies, I'm not able to work on
this for myself right now.
However I would really appreciate some response/feedback to this idea
and of course it would be nice to see this implemented some time.

That said, I wouldn't call it more than a "proof of concept" right now,
as there are lots of hacks in there. Especially most of the
animation-logic should be shared with Clutter, as it works similarly.

Some documentation (valadoc) exists.

You find all the sources here:
http://sourceforge.net/projects/sketchframework/
(either download from "Files"-section or check-out svn)

Thank you for reading this and giving it a try,
Moritz Renftle




[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]