G_MODULE_EXPORT gint test_texture_quality_main (int argc, char *argv[]) { ClutterTimeline *timeline; ClutterAlpha *alpha; ClutterBehaviour *depth_behavior; ClutterActor *stage; ClutterActor *image; ClutterColor stage_color = { 0x12, 0x34, 0x56, 0xff }; ClutterFog stage_fog = { 10.0, -50.0 }; GError *error; clutter_init (&argc, &argv); stage = clutter_stage_get_default (); clutter_stage_set_color (CLUTTER_STAGE (stage), &stage_color); clutter_stage_set_use_fog (CLUTTER_STAGE (stage), TRUE); clutter_stage_set_fog (CLUTTER_STAGE (stage), &stage_fog); g_signal_connect (stage, "button-press-event", G_CALLBACK (clutter_main_quit), NULL); error = NULL; image = clutter_texture_new_from_file (argv[1]?argv[1]:"redhand.png", &error); if (error) g_error ("Unable to load image: %s", error->message); if (!argv[1]) g_print ("Hint: the redhand.png isn't a good test image for this test.\n" "This test can take any clutter loadable image as an argument\n"); /* center the image */ clutter_actor_set_position (image, (clutter_actor_get_width (stage) - clutter_actor_get_width (image))/2, (clutter_actor_get_height (stage) - clutter_actor_get_height (image))/2); clutter_container_add (CLUTTER_CONTAINER (stage), image, NULL); timeline = clutter_timeline_new (5000); g_signal_connect (timeline, "completed", G_CALLBACK (timeline_completed), NULL); alpha = clutter_alpha_new_full (timeline, CLUTTER_LINEAR); depth_behavior = clutter_behaviour_depth_new (alpha, -2500, 400); clutter_behaviour_apply (depth_behavior, image); clutter_actor_show (stage); clutter_timeline_start (timeline); g_timeout_add (10000, change_filter, image); clutter_main (); g_object_unref (depth_behavior); g_object_unref (timeline); return EXIT_SUCCESS; }
static VALUE rbclt_behaviour_depth_initialize (VALUE self, VALUE alpha, VALUE start_depth, VALUE end_depth) { ClutterBehaviour *behaviour; behaviour = clutter_behaviour_depth_new (RVAL2GOBJ (alpha), NUM2INT (start_depth), NUM2INT (end_depth)); G_INITIALIZE (self, behaviour); return Qnil; }
G_MODULE_EXPORT int test_pixmap_main (int argc, char **argv) { GOptionContext *context; Display *xdpy; int screen; ClutterActor *group = NULL, *label, *stage, *tex; Pixmap pixmap; const ClutterColor gry = { 0x99, 0x99, 0x99, 0xFF }; Window win_remote; guint w, h, d; GC gc; ClutterTimeline *timeline; ClutterAlpha *alpha; ClutterBehaviour *depth_behavior; int i; int row_height; #ifdef CLUTTER_WINDOWING_X11 clutter_set_windowing_backend (CLUTTER_WINDOWING_X11); #endif if (clutter_init (&argc, &argv) != CLUTTER_INIT_SUCCESS) return 1; #ifdef CLUTTER_WINDOWING_X11 if (!clutter_check_windowing_backend (CLUTTER_WINDOWING_X11)) g_error ("test-pixmap requires the X11 Clutter backend."); #endif xdpy = clutter_x11_get_default_display (); XSynchronize (xdpy, True); context = g_option_context_new (" - test-pixmap options"); g_option_context_add_main_entries (context, g_options, NULL); g_option_context_parse (context, &argc, &argv, NULL); pixmap = create_pixmap (&w, &h, &d); screen = DefaultScreen(xdpy); win_remote = XCreateSimpleWindow (xdpy, DefaultRootWindow(xdpy), 0, 0, 200, 200, 0, WhitePixel(xdpy, screen), WhitePixel(xdpy, screen)); XMapWindow (xdpy, win_remote); stage = clutter_stage_new (); clutter_actor_set_position (stage, 0, 150); clutter_actor_set_background_color (stage, &gry); clutter_stage_set_title (CLUTTER_STAGE (stage), "X11 Texture from Pixmap"); g_signal_connect (stage, "destroy", G_CALLBACK (clutter_main_quit), NULL); timeline = clutter_timeline_new (5000); g_signal_connect (timeline, "completed", G_CALLBACK (timeline_completed), NULL); alpha = clutter_alpha_new_full (timeline, CLUTTER_LINEAR); depth_behavior = clutter_behaviour_depth_new (alpha, -2500, 400); if (!disable_x11) { group = clutter_group_new (); clutter_container_add_actor (CLUTTER_CONTAINER (stage), group); label = clutter_text_new_with_text ("fixed", "ClutterX11Texture (Window)"); clutter_container_add_actor (CLUTTER_CONTAINER (group), label); tex = clutter_x11_texture_pixmap_new_with_window (win_remote); clutter_container_add_actor (CLUTTER_CONTAINER (group), tex); clutter_actor_set_position (tex, 0, 20); clutter_x11_texture_pixmap_set_automatic (CLUTTER_X11_TEXTURE_PIXMAP (tex), TRUE); clutter_texture_set_filter_quality (CLUTTER_TEXTURE (tex), CLUTTER_TEXTURE_QUALITY_HIGH); clutter_actor_set_position (group, 0, 0); if (!disable_animation) clutter_behaviour_apply (depth_behavior, group); } if (group) row_height = clutter_actor_get_height (group); else row_height = 0; /* NB: We only draw on the window after being redirected, so we dont * have to worry about handling expose events... */ gc = XCreateGC (xdpy, win_remote, 0, NULL); XSetForeground (xdpy, gc, BlackPixel (xdpy, screen)); XSetLineAttributes(xdpy, gc, 5, LineSolid, CapButt, JoinMiter); for (i = 0; i < 10; i++) XDrawLine (xdpy, win_remote, gc, 0+i*20, 0, 10+i*20+i, 200); group = clutter_group_new (); clutter_container_add_actor (CLUTTER_CONTAINER (stage), group); label = clutter_text_new_with_text ("fixed", "ClutterX11Texture (Pixmap)"); clutter_container_add_actor (CLUTTER_CONTAINER (group), label); tex = clutter_x11_texture_pixmap_new_with_pixmap (pixmap); clutter_x11_texture_pixmap_set_automatic (CLUTTER_X11_TEXTURE_PIXMAP (tex), TRUE); clutter_container_add_actor (CLUTTER_CONTAINER (group), tex); clutter_actor_set_position (tex, 0, 20); clutter_texture_set_filter_quality (CLUTTER_TEXTURE (tex), CLUTTER_TEXTURE_QUALITY_HIGH); /* oddly, the actor's size is 0 until it is realized, even though pixmap-height is set */ clutter_actor_set_position (group, 0, row_height); if (!disable_animation) clutter_behaviour_apply (depth_behavior, group); g_signal_connect (stage, "key-release-event", G_CALLBACK (stage_key_release_cb), (gpointer)pixmap); g_signal_connect (stage, "button-press-event", G_CALLBACK (stage_button_press_cb), (gpointer)pixmap); clutter_actor_show (stage); if (!disable_animation) clutter_timeline_start (timeline); clutter_threads_add_timeout (1000, draw_arc, GUINT_TO_POINTER (pixmap)); clutter_main (); return EXIT_SUCCESS; }
void aisleriot_slot_renderer_set_animations (AisleriotSlotRenderer *srend, guint n_anims, const AisleriotAnimStart *anims, guint n_unexposed_animated_cards) { AisleriotSlotRendererPrivate *priv; guint i; gint card_num; g_return_if_fail (AISLERIOT_IS_SLOT_RENDERER (srend)); priv = srend->priv; g_return_if_fail (n_anims <= priv->slot->exposed); /* Destroy the current animations */ for (i = 0; i < priv->animations->len; i++) { AnimationData *anim_data; anim_data = &g_array_index (priv->animations, AnimationData, i); if (anim_data->move) g_object_unref (anim_data->move); if (anim_data->rotate) g_object_unref (anim_data->rotate); if (anim_data->depth) g_object_unref (anim_data->depth); clutter_actor_destroy (anim_data->card_tex); g_object_unref (anim_data->card_tex); } g_array_set_size (priv->animations, 0); card_num = priv->slot->cards->len - n_anims; for (i = 0; i < n_anims; i++) { AnimationData anim_data; ClutterAlpha *alpha; ClutterKnot knots[2]; Card card = CARD (priv->slot->cards->data[card_num]); guint card_width, card_height; memset (&anim_data, 0, sizeof (anim_data)); anim_data.card_tex = aisleriot_card_new (priv->cache, anims[i].old_card, card); card_width = clutter_actor_get_width (anim_data.card_tex); card_height = clutter_actor_get_height (anim_data.card_tex); g_object_ref_sink (anim_data.card_tex); if (priv->animation_layer) clutter_container_add (priv->animation_layer, CLUTTER_ACTOR (anim_data.card_tex), NULL); clutter_actor_set_position (anim_data.card_tex, anims[i].cardx, anims[i].cardy); knots[0].x = anims[i].cardx; knots[0].y = anims[i].cardy; aisleriot_game_get_card_offset (priv->slot, card_num, FALSE, &knots[1].x, &knots[1].y); knots[1].x += priv->slot->rect.x; knots[1].y += priv->slot->rect.y; alpha = clutter_alpha_new_full (priv->timeline, CLUTTER_LINEAR); anim_data.move = clutter_behaviour_path_new_with_knots (alpha, knots, G_N_ELEMENTS (knots)); clutter_behaviour_apply (anim_data.move, anim_data.card_tex); if (anims[i].old_card.value != card.value) { int center_x, center_y; center_x = card_width / 2; center_y = card_height / 2; clutter_actor_set_rotation (anim_data.card_tex, CLUTTER_Y_AXIS, 180.0, center_x, center_y, 0); anim_data.rotate = clutter_behaviour_rotate_new (alpha, CLUTTER_Y_AXIS, CLUTTER_ROTATE_CW, 180.0, 0.0); clutter_behaviour_rotate_set_center (CLUTTER_BEHAVIOUR_ROTATE (anim_data.rotate), center_x, center_y, 0); clutter_behaviour_apply (anim_data.rotate, anim_data.card_tex); } if (anims[i].raise) { alpha = clutter_alpha_new_with_func (priv->timeline, aisleriot_slot_sine_animation_mode, NULL, NULL); anim_data.depth = clutter_behaviour_depth_new (alpha, 0, card_height); clutter_behaviour_apply (anim_data.depth, anim_data.card_tex); } g_array_append_val (priv->animations, anim_data); card_num++; } if (n_anims > 0) { clutter_timeline_rewind (priv->timeline); clutter_timeline_start (priv->timeline); } priv->n_unexposed_animated_cards = n_unexposed_animated_cards; clutter_actor_queue_redraw (CLUTTER_ACTOR (srend)); }
static gboolean task (gpointer user_data) { ClutterTimeline *timeline; ClutterAlpha *alpha; ClutterBehaviour *depth_behavior; ClutterActor *image[4]; ClutterActor *clone[4]; ClutterActor *stage; gchar *path = user_data; gint i; stage = clutter_stage_get_default (); image[0] = g_object_new (CLUTTER_TYPE_TEXTURE, NULL); g_signal_connect (image[0], "load-finished", G_CALLBACK (on_load_finished), GINT_TO_POINTER (LOAD_SYNC)); image[1] = g_object_new (CLUTTER_TYPE_TEXTURE, "load-data-async", TRUE, NULL); g_signal_connect (image[1], "load-finished", G_CALLBACK (on_load_finished), GINT_TO_POINTER (LOAD_DATA_ASYNC)); image[2] = g_object_new (CLUTTER_TYPE_TEXTURE, "load-async", TRUE, NULL); g_signal_connect (image[2], "load-finished", G_CALLBACK (on_load_finished), GINT_TO_POINTER (LOAD_ASYNC)); for (i = 0; i < 3; i++) { GError *error = NULL; clutter_texture_set_from_file (CLUTTER_TEXTURE (image[i]), path, &error); if (error != NULL) g_error ("Unable to load image at '%s': %s", path != NULL ? path : "<unknown>", error->message); } for (i = 0; i < 3; i++) clutter_container_add (CLUTTER_CONTAINER (stage), image[i], NULL); for (i = 0; i < 3; i++) { clutter_actor_set_position (image[i], 50+i*100, 0+i*50); clone[i]=clutter_clone_new (image[i]); g_signal_connect (image[i], "size-change", G_CALLBACK (size_change_cb), clone[i]); clutter_container_add (CLUTTER_CONTAINER (stage), clone[i], NULL); clutter_actor_set_position (clone[i], 50+i*100, 150+i*50+100); } for (i = 0; i < 3; i++) { timeline = clutter_timeline_new (5000); alpha = clutter_alpha_new_full (timeline, CLUTTER_LINEAR); depth_behavior = clutter_behaviour_depth_new (alpha, -2500, 0); clutter_behaviour_apply (depth_behavior, image[i]); clutter_timeline_start (timeline); } return FALSE; }