Re: GtkCanvas requirements?
- From: Benjamin Otte <otte gnome org>
- To: gtk-devel-list gnome org
- Subject: Re: GtkCanvas requirements?
- Date: Tue, 24 Apr 2007 08:12:58 +0000 (UTC)
Federico Mena Quintero <federico <at> ximian.com> writes:
> Now for the other use-case... in GNOME we don't have much experience
> with loading SVG-like things and then manipulating them (think Flash).
> Maybe we can find someone with Flash experience to comment on what API
> would be helpful to them?
>
Model-View-Controller
Flash is all about being able to separate creating the visual contents from
writing the code to interact with them.
And separating means being able to do both in completely different apps by
completely different people.
I'll give a little intro to this part of Flash now, since I think it is pure
genius.
Flash knows exactly one graphical object: a shape. You can think of it as a
simple static SVG (no scripting) or better as a cairo_path_t with a
cairo_pattern_t to fill it. That's it. All drawing is done that way.
The most important container object is the Sprite. It's just a timeline that
starts playing automatically. Inside that timeline are placement instructions
(including animnations) how other objects are placed inside it.
Example: draw a ball (the Shape), create a sprite and move the shape up and
down in its timeline. Tell the timeline to loop and you have a bouncing ball.
This is probably equivalent to a pretty advanced SVG, with animations etc.
Another container object is a Button. A button has 3 states (roughly the Gtk
button states normal, prelight and active) and you place objects for those
states. So you can now put the bouncing ball into the button and only in the
prelight state and boom, you have a nice animated indicator that your mouse is
hovering over a button.
Up to this point, we haven't left the Flash equivalent of Inkscape, we're still
in the realm of the graphic artist. We haven't written a single line of code.
But we have a ball bouncing in front of a button.
To get a feel of how that looks, I recently linked to a tutorial [1] in my blog
[2] that I think describes it quite well.
As Havoc said in the other mail, a programmer interacts with these items using
a pretty simple API [3].
So what does that mean for a GtkCanvas?
The canvas should make it easy to load the full graphical description from a
file created by a graphic artist. So you want a function like
gtk_canvas_new_from_svg (char *filename). That would create the right amount of
canvas items for the SVG and place them correctly. It would also give you
access to the items by name like glade: gtk_canvas_get_item_by_name (canvas,
"name"). You probably want an easy way to duplicate them, too.
That way the developers could specify what items they need ("asteroid",
"space-ship", "rocket" and "ufo") and then code the functionality for these
objects into their app and the graphic designers work on the agreed on SVG
file. And then you end up with a very famous game with even greater graphics.
[4]
Cheers,
Benjamin
[1] http://www.kirupa.com/developer/flash8/simple_animation.htm
[2] http://www.advogato.org/person/company/diary.html?start=39
[3] http://www.brajeshwar.com/reference/as2/MovieClip.html - note that children
movie clips get their own variable, so if movie has a child named "foo" you can
reference it as movie.foo in your script.
[4] http://en.wikipedia.org/wiki/Image:Asteroi1.png
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]