mutter/examples/behave.c
Emmanuele Bassi 734f808fbc 2006-11-15 Emmanuele Bassi <ebassi@openedhand.com>
* clutter/clutter-alpha.h:
	* clutter/clutter-alpha.c: Add a data parameter to
	the ClutterAlphaFunc; add a data+destroy parameter
	to clutter_alpha_set_func() and to clutter_alpha_new(),
	and turned the latter into clutter_alpha_new_full();
	add a simple, empty constructor clutter_alpha_new().

	These changes makes writing bindings a tad more easy,
	as bindings require passing their own functions in
	order to call the real alpha function.

	* clutter/clutter-behaviour.h: Clean up the header.

	* clutter/clutter-behaviours.[ch]:
	* clutter/clutter-behaviour-opacity.[ch]:
	* clutter/clutter-behaviour-path.[ch]:
	* clutter/clutter-behaviour-scale.[ch]: Split the
	ClutterBehaviourPath, ClutterBehaviourOpacity and
	ClutterBehaviourScale into their own files as they
	have been growing a bit. Fix ClutterBehaviourPath
	API.

	* clutter/clutter-media.h: Remove the commented
	"metadata_available" signal: gtk-doc chokes up on that.

	* clutter/clutter-timeline.h:
	* clutter/clutter-timeline.c: Remove the useless
	ClutterTimelineAlphaFunc signature; add missing accessor
	methods for the properties; clean up a bit.

	* clutter/clutter-util.h:
	* clutter/clutter-util.c: Remove unneeded function
	clutter_util_can_create_texture().

	* clutter/clutter-feature.h: Sync the name of
	clutter_feature_get_all() with the name declared
	in clutter-feature.h.

	* clutter/Makefile.am:
	* clutter/clutter.h: Update.

	* examples/behave.c: Update to the new ClutterAlpha
	constructor.

	* examples/super-oh.c: Use the right pointer and avoid
	the compiler making a fuss about it.
2006-11-15 23:37:53 +00:00

61 lines
1.7 KiB
C

#include <clutter/clutter.h>
int
main (int argc, char *argv[])
{
ClutterTimeline *timeline;
ClutterAlpha *alpha;
ClutterBehaviour *behave;
ClutterActor *stage, *hand;
ClutterColor stage_color = { 0xcc, 0xcc, 0xcc, 0xff };
GdkPixbuf *pixbuf;
ClutterKnot knots[] = {{ 100, 100 }, { 100, 200 }, { 200, 200 },
{ 200, 100 }, {100, 100 }};
clutter_init (&argc, &argv);
stage = clutter_stage_get_default ();
pixbuf = gdk_pixbuf_new_from_file ("redhand.png", NULL);
if (!pixbuf)
g_error("pixbuf load failed");
clutter_stage_set_color (CLUTTER_STAGE (stage),
&stage_color);
/* Make a hand */
hand = clutter_texture_new_from_pixbuf (pixbuf);
clutter_actor_set_position (hand, 100, 100);
clutter_group_add (CLUTTER_GROUP (stage), hand);
/* Make a timeline */
timeline = clutter_timeline_new (100, 60); /* num frames, fps */
g_object_set (timeline, "loop", TRUE, 0);
/* Set an alpha func to power behaviour - ramp is constant rise/fall */
alpha = clutter_alpha_new_full (timeline,
CLUTTER_ALPHA_RAMP,
NULL, NULL);
/* Create a behaviour for that alpha */
behave = clutter_behaviour_opacity_new (alpha, 0X33, 0xff);
/* Apply it to our actor */
clutter_behaviour_apply (behave, hand);
/* Make a path behaviour and apply that too */
behave = clutter_behaviour_path_new (alpha, knots, 5);
clutter_behaviour_apply (behave, hand);
/* start the timeline and thus the animations */
clutter_timeline_start (timeline);
clutter_group_show_all (CLUTTER_GROUP (stage));
clutter_main();
return 0;
}