mutter/examples/behave.c
Jorn Baayen bc3d914ccd 2006-08-28 Jorn Baayen <jorn@openedhand.com>
* clutter/Makefile.am:
	* clutter/clutter-alpha.c:
	* clutter/clutter-alpha.h:
	* clutter/clutter-behaviours.c:
	(clutter_behaviour_opacity_dispose),
	(clutter_behaviour_opacity_init),
	(clutter_behaviour_opacity_frame_foreach),
	(clutter_behaviour_opacity_frame):
	* clutter/clutter-behaviours.h:
	* clutter/clutter-timeline.c: (clutter_timeline_class_init):
	* clutter/clutter-timeline.h:
	* clutter/clutter.h:
	* examples/behave.c: (main):

	Separate alpha calculation into its own class.

	* clutter/clutter-behaviour.c: (clutter_behaviour_set_timelime):

	Correct NULL check.
2006-08-28 17:11:15 +00:00

53 lines
1.3 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;
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, 30); /* 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 (timeline, CLUTTER_ALPHA_RAMP);
/* Create a behaviour for that time line */
behave = clutter_behaviour_opacity_new (alpha, 0X33 ,0xff);
/* Apply it to our actor */
clutter_behaviour_apply (behave, hand);
/* start the timeline */
clutter_timeline_start (timeline);
clutter_group_show_all (CLUTTER_GROUP (stage));
clutter_main();
return 0;
}