| 1 |
#include <stdio.h> |
| 2 |
#include <stdlib.h> |
| 3 |
#include <string.h> |
| 4 |
|
| 5 |
#include <glib.h> |
| 6 |
#include <gmodule.h> |
| 7 |
|
| 8 |
#include <clutter/clutter.h> |
| 9 |
|
| 10 |
G_MODULE_EXPORT int |
| 11 |
test_shader_effects_main (int argc, char *argv[]) |
| 12 |
{ |
| 13 |
ClutterTimeline *timeline; |
| 14 |
ClutterActor *stage, *hand, *label, *rect; |
| 15 |
gchar *file; |
| 16 |
|
| 17 |
if (clutter_init (&argc, &argv) != CLUTTER_INIT_SUCCESS) |
| 18 |
return 1; |
| 19 |
|
| 20 |
/* Make a timeline */ |
| 21 |
timeline = clutter_timeline_new (7692); |
| 22 |
clutter_timeline_set_repeat_count (timeline, -1); |
| 23 |
|
| 24 |
stage = clutter_stage_new (); |
| 25 |
clutter_stage_set_title (CLUTTER_STAGE (stage), "Rotations"); |
| 26 |
clutter_actor_set_background_color (stage, CLUTTER_COLOR_Aluminium3); |
| 27 |
g_signal_connect (stage, "destroy", G_CALLBACK (clutter_main_quit), NULL); |
| 28 |
|
| 29 |
/* Make a hand */ |
| 30 |
file = g_build_filename (TESTS_DATADIR, "redhand.png", NULL); |
| 31 |
hand = clutter_texture_new_from_file (file, NULL); |
| 32 |
if (!hand) |
| 33 |
g_error("Unable to load '%s'", file); |
| 34 |
|
| 35 |
g_free (file); |
| 36 |
|
| 37 |
clutter_actor_set_position (hand, 326, 265); |
| 38 |
clutter_actor_add_effect_with_name (hand, "desaturate", clutter_desaturate_effect_new (0.75)); |
| 39 |
clutter_actor_add_effect_with_name (hand, "blur", clutter_blur_effect_new ()); |
| 40 |
clutter_actor_animate_with_timeline (hand, CLUTTER_LINEAR, timeline, |
| 41 |
"@effects.desaturate.factor", 1.0, |
| 42 |
"rotation-angle-z", 360.0, |
| 43 |
"fixed::anchor-x", 86.0, |
| 44 |
"fixed::anchor-y", 125.0, |
| 45 |
"opacity", 128, |
| 46 |
NULL); |
| 47 |
|
| 48 |
rect = clutter_rectangle_new_with_color (CLUTTER_COLOR_DarkOrange); |
| 49 |
clutter_actor_add_effect_with_name (rect, "blur", clutter_blur_effect_new ()); |
| 50 |
clutter_actor_set_position (rect, 415, 215); |
| 51 |
clutter_actor_set_size (rect, 150, 150); |
| 52 |
clutter_actor_animate_with_timeline (rect, CLUTTER_LINEAR, timeline, |
| 53 |
"rotation-angle-z", 360.0, |
| 54 |
"fixed::anchor-x", 75.0, |
| 55 |
"fixed::anchor-y", 75.0, |
| 56 |
NULL); |
| 57 |
|
| 58 |
label = clutter_text_new_with_text ("Mono 16", |
| 59 |
"The Wonder\n" |
| 60 |
"of the\n" |
| 61 |
"Spinning Hand"); |
| 62 |
clutter_text_set_line_alignment (CLUTTER_TEXT (label), PANGO_ALIGN_CENTER); |
| 63 |
clutter_actor_set_position (label, 336, 275); |
| 64 |
clutter_actor_set_size (label, 500, 100); |
| 65 |
clutter_actor_animate_with_timeline (label, CLUTTER_LINEAR, timeline, |
| 66 |
"rotation-angle-z", 360.0, |
| 67 |
"fixed::anchor-x", 86.0, |
| 68 |
"fixed::anchor-y", 125.0, |
| 69 |
NULL); |
| 70 |
|
| 71 |
clutter_container_add (CLUTTER_CONTAINER (stage), rect, hand, label, NULL); |
| 72 |
|
| 73 |
/* start the timeline and thus the animations */ |
| 74 |
clutter_timeline_start (timeline); |
| 75 |
|
| 76 |
clutter_actor_show_all (stage); |
| 77 |
|
| 78 |
clutter_main(); |
| 79 |
|
| 80 |
g_object_unref (timeline); |
| 81 |
|
| 82 |
return 0; |
| 83 |
} |