mirror of
https://github.com/brl/mutter.git
synced 2024-12-27 13:22:15 +00:00
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:
parent
0486c56a41
commit
e54d3e716b
@ -53,6 +53,7 @@ VIDEO_FILES = \
|
||||
videos/animations-rotating-container-reverses-direction.ogv \
|
||||
videos/textures-split-go.ogv \
|
||||
videos/events-mouse-scroll.ogv \
|
||||
videos/textures-crossfade-two-textures.ogv \
|
||||
$(NULL)
|
||||
|
||||
EXTRA_DIST = \
|
||||
|
@ -28,6 +28,16 @@ static GOptionEntry entries[] = {
|
||||
{ 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
|
||||
load_image (ClutterTexture *texture,
|
||||
gchar *image_path)
|
||||
@ -75,7 +85,7 @@ main (int argc, char *argv[])
|
||||
|
||||
stage = clutter_stage_get_default ();
|
||||
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);
|
||||
g_signal_connect (stage, "destroy", G_CALLBACK (clutter_main_quit), NULL);
|
||||
|
||||
@ -83,7 +93,7 @@ main (int argc, char *argv[])
|
||||
CLUTTER_BIN_ALIGNMENT_CENTER);
|
||||
|
||||
box = clutter_box_new (layout);
|
||||
clutter_actor_set_size (box, 600, 600);
|
||||
clutter_actor_set_size (box, 400, 300);
|
||||
|
||||
bottom = clutter_texture_new ();
|
||||
top = clutter_texture_new ();
|
||||
@ -113,8 +123,11 @@ main (int argc, char *argv[])
|
||||
/* make the bottom opaque and top transparent */
|
||||
clutter_state_warp_to_state (transitions, "show-bottom");
|
||||
|
||||
/* fade in the top texture and fade out the bottom texture */
|
||||
clutter_state_set_state (transitions, "show-top");
|
||||
/* on key press, fade in the top texture and fade out the bottom texture */
|
||||
g_signal_connect (stage,
|
||||
"key-press-event",
|
||||
G_CALLBACK (start_animation),
|
||||
transitions);
|
||||
|
||||
clutter_actor_show (stage);
|
||||
|
||||
|
BIN
doc/cookbook/videos/textures-crossfade-two-textures.ogv
Normal file
BIN
doc/cookbook/videos/textures-crossfade-two-textures.ogv
Normal file
Binary file not shown.
Loading…
Reference in New Issue
Block a user