cookbook: Added video of two texture cross-fade

Added a video showing the two texture cross-fade.

Modified the example code to animate on key press, so
this video could be captured.

Also altered the stage size to minimise the video size.
This commit is contained in:
Elliot Smith 2010-08-17 15:46:48 +01:00
parent 0486c56a41
commit e54d3e716b
3 changed files with 18 additions and 4 deletions

View File

@ -53,6 +53,7 @@ VIDEO_FILES = \
videos/animations-rotating-container-reverses-direction.ogv \ videos/animations-rotating-container-reverses-direction.ogv \
videos/textures-split-go.ogv \ videos/textures-split-go.ogv \
videos/events-mouse-scroll.ogv \ videos/events-mouse-scroll.ogv \
videos/textures-crossfade-two-textures.ogv \
$(NULL) $(NULL)
EXTRA_DIST = \ EXTRA_DIST = \

View File

@ -28,6 +28,16 @@ static GOptionEntry entries[] = {
{ NULL } { NULL }
}; };
static gboolean
start_animation (ClutterActor *actor,
ClutterEvent *event,
gpointer user_data)
{
ClutterState *transitions = CLUTTER_STATE (user_data);
clutter_state_set_state (transitions, "show-top");
return TRUE;
}
static gboolean static gboolean
load_image (ClutterTexture *texture, load_image (ClutterTexture *texture,
gchar *image_path) gchar *image_path)
@ -75,7 +85,7 @@ main (int argc, char *argv[])
stage = clutter_stage_get_default (); stage = clutter_stage_get_default ();
clutter_stage_set_title (CLUTTER_STAGE (stage), "cross-fade"); clutter_stage_set_title (CLUTTER_STAGE (stage), "cross-fade");
clutter_actor_set_size (stage, 600, 600); clutter_actor_set_size (stage, 400, 300);
clutter_actor_show (stage); clutter_actor_show (stage);
g_signal_connect (stage, "destroy", G_CALLBACK (clutter_main_quit), NULL); g_signal_connect (stage, "destroy", G_CALLBACK (clutter_main_quit), NULL);
@ -83,7 +93,7 @@ main (int argc, char *argv[])
CLUTTER_BIN_ALIGNMENT_CENTER); CLUTTER_BIN_ALIGNMENT_CENTER);
box = clutter_box_new (layout); box = clutter_box_new (layout);
clutter_actor_set_size (box, 600, 600); clutter_actor_set_size (box, 400, 300);
bottom = clutter_texture_new (); bottom = clutter_texture_new ();
top = clutter_texture_new (); top = clutter_texture_new ();
@ -113,8 +123,11 @@ main (int argc, char *argv[])
/* make the bottom opaque and top transparent */ /* make the bottom opaque and top transparent */
clutter_state_warp_to_state (transitions, "show-bottom"); clutter_state_warp_to_state (transitions, "show-bottom");
/* fade in the top texture and fade out the bottom texture */ /* on key press, fade in the top texture and fade out the bottom texture */
clutter_state_set_state (transitions, "show-top"); g_signal_connect (stage,
"key-press-event",
G_CALLBACK (start_animation),
transitions);
clutter_actor_show (stage); clutter_actor_show (stage);