static void gml_gtk_widget_create_rect (ClutterActor *parent, JsonObject *obj) { GList *l = NULL; GList *p = NULL; ClutterColor color = { 0x00, 0x00, 0x00, 0xff }; ClutterActor *rect = clutter_rectangle_new (); l = json_object_get_members (obj); for (p = l; p; p = p->next) { if (!strcmp (p->data, "width")) { clutter_actor_set_width (rect, (float)json_object_get_int_member (obj, p->data)); } else if (!strcmp (p->data, "height")) { clutter_actor_set_height (rect, (float)json_object_get_int_member (obj, p->data)); } else if (!strcmp (p->data, "x")) { clutter_actor_set_x (rect, (float)json_object_get_int_member (obj, p->data)); } else if (!strcmp (p->data, "y")) { clutter_actor_set_y (rect, (float)json_object_get_int_member (obj, p->data)); } else if (!strcmp (p->data, "color")) { clutter_color_from_string (&(color), json_object_get_string_member (obj, p->data)); clutter_rectangle_set_color (CLUTTER_RECTANGLE (rect), &color); } else if (!strcmp (p->data, "border.width")) { clutter_rectangle_set_border_width (CLUTTER_RECTANGLE (rect), json_object_get_int_member (obj, p->data)); } else if (!strcmp (p->data, "border.color")) { clutter_color_from_string (&(color), json_object_get_string_member (obj, p->data)); clutter_rectangle_set_border_color (CLUTTER_RECTANGLE (rect), &color); } } clutter_container_add_actor (CLUTTER_CONTAINER (parent), rect); }
static void draw_point (guchar *buffer, guint width, guint height, gchar *color_str, guint x, guint y) { ClutterColor *color = clutter_color_new (0, 0, 0, 255); clutter_color_from_string (color, color_str); gint i, j; for (i = -POINT_SIZE; i < POINT_SIZE; i++) { for (j = -POINT_SIZE; j < POINT_SIZE; j++) { if (x + i < 0 || x + i >= width || y + j < 0 || y + j >= height) continue; buffer[(width * (y + j) + x + i) * 3] = color->red; buffer[(width * (y + j) + x + i) * 3 + 1] = color->green; buffer[(width * (y + j) + x + i) * 3 + 2] = color->blue; } } clutter_color_free (color); }
static void connect_joints (cairo_t *cairo, SkeltrackJoint *joint_a, SkeltrackJoint *joint_b, const gchar *color_str) { ClutterColor *color; if (joint_a == NULL || joint_b == NULL) return; color = clutter_color_new (0, 0, 0, 200); clutter_color_from_string (color, color_str); cairo_set_line_width (cairo, 10); clutter_cairo_set_source_color (cairo, color); cairo_move_to (cairo, joint_a->screen_x, joint_a->screen_y); cairo_line_to (cairo, joint_b->screen_x, joint_b->screen_y); cairo_stroke (cairo); clutter_color_free (color); }
//doc ClutterColor fromString(str) IO_METHOD(IoClutterColor, fromString) { ClutterColor color; char *seq = CSTRING(IoMessage_locals_seqArgAt_(m, locals, 0)); clutter_color_from_string(&color, seq); return IoClutterColor_newWithColor(IOSTATE, color); }
static void paint_joint (cairo_t *cairo, SkeltrackJoint *joint, gint radius, const gchar *color_str) { ClutterColor *color; if (joint == NULL) return; color = clutter_color_new (0, 0, 0, 200); clutter_color_from_string (color, color_str); cairo_set_line_width (cairo, 10); clutter_cairo_set_source_color (cairo, color); cairo_arc (cairo, joint->screen_x, joint->screen_y, radius * (THRESHOLD_END - THRESHOLD_BEGIN) / joint->z, 0, G_PI * 2); cairo_fill (cairo); clutter_color_free (color); }
void App::createPalette() { ClutterColor white = { 255, 255, 255, 255 }; selection_rect_ = clutter_rectangle_new_with_color(&white); clutter_actor_set_size(selection_rect_, 55.0f, 55.0f); clutter_actor_set_anchor_point_from_gravity(selection_rect_, CLUTTER_GRAVITY_CENTER); clutter_container_add_actor(CLUTTER_CONTAINER(stage_), selection_rect_); std::vector<std::string> colors; colors.push_back(std::string("#c33")); // red colors.push_back(std::string("#cc3")); colors.push_back(std::string("#3c3")); // green colors.push_back(std::string("#3cc")); colors.push_back(std::string("#33c")); // blue colors.push_back(std::string("#c3c")); colors.push_back(std::string("#333")); // black colors.push_back(std::string("#999")); colors.push_back(std::string("#ccc")); // initial color: ClutterColor chosen; clutter_color_from_string(&chosen, (*colors.begin()).c_str()); setColor(chosen.red, chosen.green, chosen.blue); int i = 0; std::vector<std::string>::iterator iter; for (iter = colors.begin(); iter != colors.end(); ++iter) { ClutterColor color; clutter_color_from_string(&color, (*iter).c_str()); ClutterActor *rect = clutter_rectangle_new_with_color(&color); clutter_actor_set_size(rect, 50.0f, 50.0f); clutter_actor_set_anchor_point_from_gravity(rect, CLUTTER_GRAVITY_CENTER); clutter_actor_set_position(rect, 35.0f, i * 60.0f + 30.0f); clutter_actor_set_reactive(rect, TRUE); clutter_container_add_actor(CLUTTER_CONTAINER(stage_), rect); g_signal_connect(rect, "button-press-event", G_CALLBACK(button_press_color_cb), this); if (i == 0) { float x = clutter_actor_get_x(rect); float y = clutter_actor_get_y(rect); setSelectionPosition(x, y); } ++i; } }
App::App() : current_(0), osc_recv_port_(0), fullscreen_(false), recording_(false), verbose_(false), speed_(1.0f) { clutter_color_from_string(&color_, "#ffffffff"); }
void gml_gtk_widget_set_file (GmlGtkWidget *gml, gchar *f) { JsonParser *parser = NULL; JsonNode *node = NULL; JsonObject *obj = NULL; JsonArray *arr = NULL; GError *error = NULL; GList *l = NULL; GList *p = NULL; parser = json_parser_new (); json_parser_load_from_file (parser, f, &error); if (error) { g_print ("Unable to parse `%s': %s\n", f, error->message); g_error_free (error); g_object_unref (parser); return; } node = json_parser_get_root (parser); obj = json_node_get_object (node); l = json_object_get_members (obj); for (p = l; p; p = p->next) { if (!strcmp (p->data, "width")) { gml->width = json_object_get_int_member (obj, p->data); } else if (!strcmp (p->data, "height")) { gml->height = json_object_get_int_member (obj, p->data); } else if (!strcmp (p->data, "color")) { clutter_color_from_string (&(gml->stage_color), json_object_get_string_member (obj, p->data)); } else if (!strcmp (p->data, "elements")) { GList *al = NULL; GList *ap = NULL; JsonObject *arro = NULL; // parsing elements arr = json_object_get_array_member (obj, p->data); al = json_array_get_elements (arr); for (ap = al; ap; ap = ap->next) { arro = json_node_get_object (ap->data); gml_gtk_widget_create_element (gml->stage, arro); } } } g_list_free (l); g_object_unref (parser); gtk_widget_set_size_request (gml->clutter_widget, gml->width, gml->height); clutter_stage_set_color (CLUTTER_STAGE (gml->stage), &(gml->stage_color)); }
static gboolean cairo_renderer_make_point (PinPointRenderer *pp_renderer, PinPointPoint *point) { gboolean ret = TRUE; if (point->bg_type == PP_BG_COLOR) { ClutterColor color; ret = clutter_color_from_string (&color, point->bg); /* this roughly checks that the color is valid? */ } return ret; }
static gboolean action_add_text (ClutterActor *action, ClutterEvent *event, gpointer userdata) { ClutterActor *group = CLUTTER_ACTOR (userdata); ClutterActor *title; ClutterColor color; clutter_color_from_string (&color, "#888"); title = clutter_text_new_full ("Sans 30px", "fnord", &color); clutter_actor_set_position (title, event->button.x, event->button.y); clutter_group_add (CLUTTER_GROUP (group), title); return FALSE; }
int main (int argc, char *argv[]) { ClutterActor *video; /* So we can fade out at the end. */ clutter_x11_set_use_argb_visual (TRUE); if (clutter_gst_init (&argc, &argv) != CLUTTER_INIT_SUCCESS) return EXIT_FAILURE; if (argc < 2) { g_print ("Usage: %s [OPTIONS] <video file>\n", argv[0]); return EXIT_FAILURE; } if (!clutter_color_from_string (&bg_color, BG_COLOR)) { g_warning ("Invalid BG_COLOR"); exit (1); } stage = clutter_stage_new (); /* Clutter's full-screening code does not allow us to * set both that and _NET_WM_STATE_ABOVE, so do the state * management ourselves for now. */ #if 0 clutter_stage_set_fullscreen (CLUTTER_STAGE (stage), TRUE); #endif /* Clutter will set maximum size restrictions (meaning not * full screen) unless I set this. */ clutter_stage_set_user_resizable (CLUTTER_STAGE (stage), TRUE); clutter_stage_set_use_alpha (CLUTTER_STAGE (stage), TRUE); clutter_actor_set_background_color (stage, &bg_color); clutter_actor_set_layout_manager (stage, clutter_bin_layout_new (CLUTTER_BIN_ALIGNMENT_FIXED, CLUTTER_BIN_ALIGNMENT_FIXED)); clutter_actor_realize (stage); set_above_and_fullscreen (); video = clutter_gst_video_texture_new (); clutter_actor_set_x_expand (video, TRUE); clutter_actor_set_y_expand (video, TRUE); clutter_actor_set_x_align (video, CLUTTER_ACTOR_ALIGN_CENTER); clutter_actor_set_y_align (video, CLUTTER_ACTOR_ALIGN_CENTER); set_idle_material (CLUTTER_GST_VIDEO_TEXTURE (video)); g_signal_connect (video, "eos", G_CALLBACK (on_video_texture_eos), NULL); g_signal_connect (stage, "destroy", G_CALLBACK (clutter_main_quit), NULL); clutter_media_set_filename (CLUTTER_MEDIA (video), argv[1]); clutter_stage_hide_cursor (CLUTTER_STAGE (stage)); clutter_actor_add_child (stage, video); g_signal_connect (stage, "key-press-event", G_CALLBACK (key_press_cb), NULL); clutter_media_set_playing (CLUTTER_MEDIA (video), TRUE); clutter_actor_show (stage); clutter_main (); return EXIT_SUCCESS; }
static void _cairo_render_text (CairoRenderer *renderer, PinPointPoint *point) { PangoLayout *layout; PangoFontDescription *desc; PangoRectangle logical_rect = { 0, }; ClutterColor text_color, shading_color; float text_x, text_y, text_width, text_height, text_scale; float shading_x, shading_y, shading_width, shading_height; if (point == NULL) return; layout = pango_cairo_create_layout (renderer->ctx); desc = pango_font_description_from_string (point->font); pango_layout_set_font_description (layout, desc); if (point->use_markup) pango_layout_set_markup (layout, point->text, -1); else pango_layout_set_text (layout, point->text, -1); pango_layout_set_alignment (layout, point->text_align); pango_layout_get_extents (layout, NULL, &logical_rect); text_width = (logical_rect.x + logical_rect.width) / 1024; text_height = (logical_rect.y + logical_rect.height) / 1024; if (text_width < 1) goto out; pp_get_text_position_scale (point, renderer->width, renderer->height, text_width, text_height, &text_x, &text_y, &text_scale); pp_get_shading_position_size (renderer->height, renderer->width, /* XXX: is this right order?? */ text_x, text_y, text_width, text_height, text_scale, &shading_x, &shading_y, &shading_width, &shading_height); clutter_color_from_string (&text_color, point->text_color); clutter_color_from_string (&shading_color, point->shading_color); cairo_set_source_rgba (renderer->ctx, shading_color.red / 255.f, shading_color.green / 255.f, shading_color.blue / 255.f, shading_color.alpha / 255.f * point->shading_opacity); cairo_rectangle (renderer->ctx, shading_x, shading_y, shading_width, shading_height); cairo_fill (renderer->ctx); cairo_save (renderer->ctx); cairo_translate (renderer->ctx, text_x, text_y); cairo_scale (renderer->ctx, text_scale, text_scale); cairo_set_source_rgba (renderer->ctx, text_color.red / 255.f, text_color.green / 255.f, text_color.blue / 255.f, text_color.alpha / 255.f); pango_cairo_show_layout (renderer->ctx, layout); cairo_restore (renderer->ctx); out: pango_font_description_free (desc); g_object_unref (layout); }
int main (int argc, char **argv) { ClutterActor *stage; ClutterActor *text; ClutterAnimation *animation; ClutterColor red, green, blue; g_thread_init (NULL); gst_init (&argc, &argv); if (clutter_init (&argc, &argv) != CLUTTER_INIT_SUCCESS) return 1; clutter_color_from_string (&red, "red"); clutter_color_from_string (&green, "green"); clutter_color_from_string (&blue, "blue"); stage = clutter_stage_get_default (); text = g_object_new (CLUTTER_TYPE_TEXT, "text", "Red", "font-name", "Sans 40px", "color", &red, NULL); clutter_container_add_actor (CLUTTER_CONTAINER (stage), text); animation = clutter_actor_animate (text, CLUTTER_EASE_IN_OUT_QUAD, 3000, "x", 320, "y", 240, NULL); g_signal_connect (animation, "completed", G_CALLBACK (on_animation_completed), NULL); text = g_object_new (CLUTTER_TYPE_TEXT, "text", "Blue", "font-name", "Sans 40px", "color", &blue, "x", 640, "y", 0, NULL); clutter_actor_set_anchor_point_from_gravity (text, CLUTTER_GRAVITY_NORTH_EAST); clutter_container_add_actor (CLUTTER_CONTAINER (stage), text); animation = clutter_actor_animate (text, CLUTTER_EASE_IN_OUT_QUAD, 3000, "x", 320, "y", 240, NULL); text = g_object_new (CLUTTER_TYPE_TEXT, "text", "Green", "font-name", "Sans 40px", "color", &green, "x", 0, "y", 480, NULL); clutter_actor_set_anchor_point_from_gravity (text, CLUTTER_GRAVITY_SOUTH_WEST); clutter_container_add_actor (CLUTTER_CONTAINER (stage), text); animation = clutter_actor_animate (text, CLUTTER_EASE_IN_OUT_QUAD, 3000, "x", 320, "y", 240, NULL); recorder = shell_recorder_new (CLUTTER_STAGE (stage)); shell_recorder_set_filename (recorder, "test-recorder.ogg"); clutter_actor_show (stage); shell_recorder_record (recorder); clutter_main (); return 0; }
static gboolean pp_is_color (const char *string) { ClutterColor color; return clutter_color_from_string (&color, string); }
int main (int argc, char **argv) { ClutterActor *stage; ClutterActor *text; ClutterAnimation *animation; ClutterColor red, green, blue; gtk_init (&argc, &argv); gst_init (&argc, &argv); if (clutter_init (&argc, &argv) != CLUTTER_INIT_SUCCESS) return 1; clutter_color_from_string (&red, "red"); clutter_color_from_string (&green, "green"); clutter_color_from_string (&blue, "blue"); stage = clutter_stage_new (); g_signal_connect (stage, "destroy", G_CALLBACK (clutter_main_quit), NULL); text = g_object_new (CLUTTER_TYPE_TEXT, "text", "Red", "font-name", "Sans 40px", "color", &red, NULL); clutter_actor_add_child (stage, text); animation = clutter_actor_animate (text, CLUTTER_EASE_IN_OUT_QUAD, 3000, "x", 320.0, "y", 240.0, NULL); g_signal_connect (animation, "completed", G_CALLBACK (on_animation_completed), stage); text = g_object_new (CLUTTER_TYPE_TEXT, "text", "Blue", "font-name", "Sans 40px", "color", &blue, "x", 640.0, "y", 0.0, NULL); clutter_actor_set_anchor_point_from_gravity (text, CLUTTER_GRAVITY_NORTH_EAST); clutter_actor_add_child (stage, text); animation = clutter_actor_animate (text, CLUTTER_EASE_IN_OUT_QUAD, 3000, "x", 320.0, "y", 240.0, NULL); text = g_object_new (CLUTTER_TYPE_TEXT, "text", "Green", "font-name", "Sans 40px", "color", &green, "x", 0.0, "y", 480.0, NULL); clutter_actor_set_anchor_point_from_gravity (text, CLUTTER_GRAVITY_SOUTH_WEST); clutter_actor_add_child (stage, text); animation = clutter_actor_animate (text, CLUTTER_EASE_IN_OUT_QUAD, 3000, "x", 320.0, "y", 240.0, NULL); g_signal_connect_after (stage, "realize", G_CALLBACK (on_stage_realized), NULL); clutter_actor_show (stage); clutter_main (); return 0; }
static void set_up_stage (CalibArea *calib_area, ClutterActor *stage) { ClutterPoint anchor; ClutterColor color; ClutterContent *success_content; gfloat height; gchar *markup; calib_area->stage = stage; calib_area->action_layer = clutter_actor_new (); calib_area->clock = cc_clock_actor_new (); calib_area->target = cc_target_actor_new (); calib_area->text_title_holder = clutter_actor_new (); calib_area->helper_text_title = clutter_text_new (); calib_area->text_body_holder = clutter_actor_new (); calib_area->helper_text_body = clutter_text_new (); calib_area->error_text = clutter_text_new (); calib_area->success_image = clutter_actor_new (); clutter_stage_set_use_alpha (CLUTTER_STAGE (stage), TRUE); clutter_actor_hide (calib_area->target); /* bind the action layer's geometry to the stage's */ clutter_actor_add_constraint (calib_area->action_layer, clutter_bind_constraint_new (stage, CLUTTER_BIND_SIZE, 0)); clutter_actor_add_child (stage, calib_area->action_layer); g_signal_connect (stage, "allocation-changed", G_CALLBACK (on_allocation_changed), calib_area); clutter_color_from_string (&color, "#000"); color.alpha = WINDOW_OPACITY * 255; clutter_actor_set_background_color (stage, &color); clutter_actor_add_child (calib_area->action_layer, calib_area->clock); clutter_actor_add_constraint (calib_area->clock, clutter_align_constraint_new (stage, CLUTTER_ALIGN_BOTH, 0.5)); clutter_actor_add_child (calib_area->action_layer, calib_area->target); /* set the helper text */ anchor.x = 0; g_object_set (calib_area->text_title_holder, "pivot-point", &anchor, NULL); clutter_actor_add_child (calib_area->action_layer, calib_area->text_title_holder); clutter_actor_add_child (calib_area->text_title_holder, calib_area->helper_text_title); height = clutter_actor_get_height (calib_area->clock); clutter_actor_add_constraint (calib_area->text_title_holder, clutter_bind_constraint_new (calib_area->clock, CLUTTER_BIND_Y, height * 1.5)); clutter_actor_add_constraint (calib_area->text_title_holder, clutter_align_constraint_new (stage, CLUTTER_ALIGN_X_AXIS, .5)); clutter_text_set_line_alignment (CLUTTER_TEXT (calib_area->helper_text_title), PANGO_ALIGN_CENTER); color.red = COLOR_GRAY; color.green = COLOR_GRAY; color.blue = COLOR_GRAY; color.alpha = 255; markup = g_strdup_printf ("<big><b>%s</b></big>", _(HELP_TEXT_TITLE)); clutter_text_set_markup (CLUTTER_TEXT (calib_area->helper_text_title), markup); clutter_text_set_color (CLUTTER_TEXT (calib_area->helper_text_title), &color); g_free (markup); g_object_set (calib_area->text_body_holder, "pivot-point", &anchor, NULL); clutter_actor_add_child (calib_area->action_layer, calib_area->text_body_holder); clutter_actor_add_child (calib_area->text_body_holder, calib_area->helper_text_body); height = clutter_actor_get_height (calib_area->helper_text_title); clutter_actor_add_constraint (calib_area->text_body_holder, clutter_bind_constraint_new (calib_area->text_title_holder, CLUTTER_BIND_Y, height * 1.2)); clutter_actor_add_constraint (calib_area->text_body_holder, clutter_align_constraint_new (stage, CLUTTER_ALIGN_X_AXIS, .5)); clutter_text_set_line_alignment (CLUTTER_TEXT (calib_area->helper_text_body), PANGO_ALIGN_CENTER); markup = g_strdup_printf ("<span foreground=\"white\"><big>%s</big></span>", _(HELP_TEXT_MAIN)); clutter_text_set_markup (CLUTTER_TEXT (calib_area->helper_text_body), markup); g_free (markup); /* set the error text */ g_object_set (calib_area->error_text, "pivot-point", &anchor, NULL); clutter_actor_add_child (calib_area->action_layer, calib_area->error_text); height = clutter_actor_get_height (calib_area->helper_text_body); clutter_actor_add_constraint (calib_area->error_text, clutter_bind_constraint_new (calib_area->text_title_holder, CLUTTER_BIND_Y, height * 3)); clutter_actor_add_constraint (calib_area->error_text, clutter_align_constraint_new (stage, CLUTTER_ALIGN_X_AXIS, .5)); clutter_text_set_line_alignment (CLUTTER_TEXT (calib_area->error_text), PANGO_ALIGN_CENTER); markup = g_strdup_printf ("<span foreground=\"white\"><big>" "<b>%s</b></big></span>", ERROR_MESSAGE); clutter_text_set_markup (CLUTTER_TEXT (calib_area->error_text), markup); g_free (markup); clutter_actor_hide (calib_area->error_text); /* configure success image */ success_content = clutter_image_new (); clutter_actor_set_content (calib_area->success_image, success_content); g_object_unref (success_content); clutter_actor_add_child (stage, calib_area->success_image); clutter_actor_add_constraint (calib_area->success_image, clutter_align_constraint_new (stage, CLUTTER_ALIGN_BOTH, .5)); /* animate clock */ calib_area->clock_timeline = clutter_property_transition_new ("angle"); clutter_timeline_set_progress_mode (CLUTTER_TIMELINE (calib_area->clock_timeline), CLUTTER_LINEAR); clutter_timeline_set_duration (CLUTTER_TIMELINE (calib_area->clock_timeline), MAX_TIME); clutter_transition_set_animatable (calib_area->clock_timeline, CLUTTER_ANIMATABLE (calib_area->clock)); clutter_transition_set_from (calib_area->clock_timeline, G_TYPE_FLOAT, .0); clutter_transition_set_to (calib_area->clock_timeline, G_TYPE_FLOAT, 360.0); clutter_timeline_set_repeat_count (CLUTTER_TIMELINE (calib_area->clock_timeline), -1); clutter_timeline_start (CLUTTER_TIMELINE (calib_area->clock_timeline)); g_signal_connect (CLUTTER_TIMELINE (calib_area->clock_timeline), "completed", G_CALLBACK (on_timeout), calib_area); g_signal_connect (stage, "button-press-event", G_CALLBACK (on_button_press_event), calib_area); g_signal_connect (stage, "key-release-event", G_CALLBACK (on_key_release_event), calib_area); }
G_MODULE_EXPORT int test_behave_main (int argc, char *argv[]) { ClutterTimeline *timeline; ClutterAlpha *alpha; ClutterBehaviour *o_behave, *p_behave; ClutterActor *stage; ClutterActor *group, *rect, *hand; ClutterColor stage_color = { 0xcc, 0xcc, 0xcc, 0xff }; ClutterColor rect_bg_color = { 0x33, 0x22, 0x22, 0xff }; ClutterColor rect_border_color = { 0, 0, 0, 0 }; int i; path_t path_type = PATH_POLY; const char *knots_poly = ("M 0, 0 L 0, 300 L 300, 300 " "L 300, 0 L 0, 0"); /* A spiral created with inkscake */ const char *knots_bspline = "M 34.285713,35.219326 " "C 44.026891,43.384723 28.084874,52.378758 20.714286,51.409804 " "C 0.7404474,48.783999 -4.6171866,23.967448 1.904757,8.0764719 " "C 13.570984,-20.348756 49.798303,-26.746504 74.999994,-13.352108 " "C 111.98449,6.3047056 119.56591,55.259271 99.047626,89.505034 " "C 71.699974,135.14925 9.6251774,143.91924 -33.571422,116.17172 " "C -87.929934,81.254291 -97.88804,5.8941057 -62.857155,-46.209236 " "C -20.430061,-109.31336 68.300385,-120.45954 129.2857,-78.114021 " "C 201.15479,-28.21129 213.48932,73.938876 163.80954,143.79074 " "C 106.45226,224.43749 -9.1490153,237.96076 -87.85713,180.93363 " "C -177.29029,116.13577 -192.00272,-12.937817 -127.61907,-100.49494 " "C -55.390344,-198.72081 87.170553,-214.62275 183.57141,-142.87593 " "C 290.59464,-63.223369 307.68641,92.835839 228.57145,198.07645"; for (i = 0; i < argc; ++i) { if (!strncmp (argv[i], "--path", 6)) { if (!strncmp (argv[i] + 7, "poly", 4)) path_type = PATH_POLY; else if (!strncmp (argv[i] + 7, "bspline", 7)) path_type = PATH_BSPLINE; else if (!strncmp (argv[i] + 7, "ellipse", 7)) path_type = PATH_ELLIPSE; } else if (!strncmp (argv[i], "--help", 6)) { printf ("behave [--path=poly|ellipse|bspline]\n"); exit (0); } } clutter_init (&argc, &argv); stage = clutter_stage_get_default (); clutter_stage_hide_cursor (CLUTTER_STAGE (stage)); g_signal_connect (stage, "button-press-event", G_CALLBACK (button_press_cb), NULL); g_signal_connect (stage, "scroll-event", G_CALLBACK (scroll_event_cb), NULL); g_signal_connect (stage, "key-press-event", G_CALLBACK (clutter_main_quit), NULL); clutter_stage_set_color (CLUTTER_STAGE (stage), &stage_color); /* Make a hand */ group = clutter_group_new (); clutter_container_add_actor (CLUTTER_CONTAINER (stage), group); clutter_actor_show (group); hand = clutter_texture_new_from_file ("redhand.png", NULL); if (hand == NULL) { g_error("pixbuf load failed"); return 1; } clutter_actor_set_position (hand, 0, 0); clutter_actor_show (hand); rect = clutter_rectangle_new (); clutter_actor_set_position (rect, 0, 0); clutter_actor_set_size (rect, clutter_actor_get_width (hand), clutter_actor_get_height (hand)); clutter_rectangle_set_color (CLUTTER_RECTANGLE (rect), &rect_bg_color); clutter_rectangle_set_border_width (CLUTTER_RECTANGLE (rect), 10); clutter_color_from_string (&rect_border_color, "DarkSlateGray"); clutter_rectangle_set_border_color (CLUTTER_RECTANGLE (rect), &rect_border_color); clutter_actor_show (rect); clutter_container_add (CLUTTER_CONTAINER (group), rect, hand, NULL); /* Make a timeline */ timeline = clutter_timeline_new (4000); /* num frames, fps */ clutter_timeline_set_loop (timeline, TRUE); g_signal_connect (timeline, "completed", G_CALLBACK (timeline_completed), NULL); /* Set an alpha func to power behaviour - ramp is constant rise */ alpha = clutter_alpha_new_full (timeline, CLUTTER_LINEAR); /* Create a behaviour for that alpha */ o_behave = clutter_behaviour_opacity_new (alpha, 0X33, 0xff); /* Apply it to our actor */ clutter_behaviour_apply (o_behave, group); /* Make a path behaviour and apply that too */ switch (path_type) { case PATH_POLY: { ClutterPath *path = clutter_path_new (); clutter_path_set_description (path, knots_poly); p_behave = clutter_behaviour_path_new (alpha, path); } break; case PATH_ELLIPSE: p_behave = clutter_behaviour_ellipse_new (alpha, 200, 200, 400, 300, CLUTTER_ROTATE_CW, 0.0, 360.0); clutter_behaviour_ellipse_set_angle_tilt (CLUTTER_BEHAVIOUR_ELLIPSE (p_behave), CLUTTER_X_AXIS, 45.0); clutter_behaviour_ellipse_set_angle_tilt (CLUTTER_BEHAVIOUR_ELLIPSE (p_behave), CLUTTER_Z_AXIS, 45.0); break; case PATH_BSPLINE: { ClutterPath *path = clutter_path_new (); clutter_path_set_description (path, knots_bspline); p_behave = clutter_behaviour_path_new (alpha, path); } break; } clutter_behaviour_apply (p_behave, group); /* start the timeline and thus the animations */ clutter_timeline_start (timeline); clutter_actor_show_all (stage); clutter_main(); g_object_unref (o_behave); g_object_unref (p_behave); return 0; }
static void on_monitors_changed (MetaScreen *screen, MetaPlugin *plugin) { MetaDefaultPlugin *self = META_DEFAULT_PLUGIN (plugin); __attribute__ ((unused)) ClutterAnimation *animation; int i, n; gchar *wallpaper = NULL; GFile *wallpaper_file = NULL; gchar *filename = NULL; GDesktopBackgroundStyle style; GDesktopBackgroundShading shading_direction; ClutterColor primary_color; ClutterColor secondary_color; gboolean random_colour = FALSE; clutter_actor_destroy_all_children (self->priv->background_group); wallpaper = g_settings_get_string (self->priv->settings, PICTURE_URI_KEY); /* We don't currently support slideshows */ if (!wallpaper || g_str_has_suffix(wallpaper, ".xml")) random_colour = TRUE; else { gchar *color_str; /* Shading direction*/ shading_direction = g_settings_get_enum (self->priv->settings, COLOR_SHADING_TYPE_KEY); /* Primary color */ color_str = g_settings_get_string (self->priv->settings, PRIMARY_COLOR_KEY); if (color_str) { clutter_color_from_string (&primary_color, color_str); g_free (color_str); color_str = NULL; } /* Secondary color */ color_str = g_settings_get_string (self->priv->settings, SECONDARY_COLOR_KEY); if (color_str) { clutter_color_from_string (&secondary_color, color_str); g_free (color_str); color_str = NULL; } /* Picture options: "none", "wallpaper", "centered", "scaled", "stretched", "zoom", "spanned" */ style = g_settings_get_enum (self->priv->settings, BACKGROUND_STYLE_KEY); wallpaper_file = g_file_new_for_uri(wallpaper); filename = g_file_get_path(wallpaper_file); } n = meta_screen_get_n_monitors (screen); for (i = 0; i < n; i++) { MetaBackground *content; MetaRectangle rect; ClutterActor *background; background = meta_background_actor_new (); content = meta_background_new (screen, i, META_BACKGROUND_EFFECTS_NONE); // Don't use rand() here, mesa calls srand() internally when // parsing the driconf XML, but it's nice if the colors are // reproducible. if (random_colour) { clutter_color_init (&primary_color, g_random_int () % 255, g_random_int () % 255, g_random_int () % 255, 255); meta_background_load_color (content, &primary_color); } else { if (style == G_DESKTOP_BACKGROUND_STYLE_NONE || g_str_has_suffix (filename, GNOME_COLOR_HACK)) { if (shading_direction == G_DESKTOP_BACKGROUND_SHADING_SOLID) meta_background_load_color (content, &primary_color); else meta_background_load_gradient (content, shading_direction, &primary_color, &secondary_color); } else { /* Set the background */ meta_background_load_file_async (content, filename, style, NULL, /*TODO use cancellable*/ background_load_file_cb, self); } } clutter_actor_set_content (background, CLUTTER_CONTENT (content)); g_object_unref (content); meta_screen_get_monitor_geometry (screen, i, &rect); clutter_actor_set_position (background, rect.x, rect.y); clutter_actor_set_size (background, rect.width, rect.height); clutter_actor_add_child (self->priv->background_group, background); clutter_actor_set_scale (background, 0.0, 0.0); clutter_actor_show (background); clutter_actor_set_pivot_point (background, 0.5, 0.5); /* Ease in the background using a scale effect */ animation = clutter_actor_animate (background, CLUTTER_EASE_IN_SINE, BACKGROUND_TIMEOUT, "scale-x", 1.0, "scale-y", 1.0, NULL); } if (wallpaper_file) g_object_unref(wallpaper_file); g_free(wallpaper); g_free(filename); }
static void _cairo_render_background (CairoRenderer *renderer, PinPointPoint *point) { char *full_path = NULL; const char *file; if (point == NULL) return; file = point->bg; if (point->bg_type != PP_BG_COLOR && renderer->path && file) { char *dir = g_path_get_dirname (renderer->path); full_path = g_build_filename (dir, file, NULL); g_free (dir); file = full_path; } if (point->stage_color) { ClutterColor color; clutter_color_from_string (&color, point->stage_color); cairo_set_source_rgba (renderer->ctx, color.red / 255.f, color.green / 255.f, color.blue / 255.f, color.alpha / 255.f); cairo_paint (renderer->ctx); } switch (point->bg_type) { case PP_BG_NONE: break; case PP_BG_COLOR: { ClutterColor color; clutter_color_from_string (&color, point->bg); cairo_set_source_rgba (renderer->ctx, color.red / 255.f, color.green / 255.f, color.blue / 255.f, color.alpha / 255.f); cairo_paint (renderer->ctx); } break; case PP_BG_IMAGE: { cairo_surface_t *surface; float bg_x, bg_y, bg_width, bg_height, bg_scale_x, bg_scale_y; surface = _cairo_get_surface (renderer, file); if (surface == NULL) break; bg_width = cairo_image_surface_get_width (surface); bg_height = cairo_image_surface_get_height (surface); pp_get_background_position_scale (point, renderer->width, renderer->height, bg_width, bg_height, &bg_x, &bg_y, &bg_scale_x, &bg_scale_y); cairo_save (renderer->ctx); cairo_translate (renderer->ctx, bg_x, bg_y); cairo_scale (renderer->ctx, bg_scale_x, bg_scale_y); cairo_set_source_surface (renderer->ctx, surface, 0., 0.); cairo_paint (renderer->ctx); cairo_restore (renderer->ctx); } break; case PP_BG_VIDEO: { #ifdef USE_CLUTTER_GST GdkPixbuf *pixbuf; cairo_surface_t *surface; float bg_x, bg_y, bg_width, bg_height, bg_scale_x, bg_scale_y; GCancellable* cancellable = g_cancellable_new (); GFile *abs_file; gchar *abs_path; abs_file = g_file_resolve_relative_path (pp_basedir, point->bg); abs_path = g_file_get_path (abs_file); g_object_unref (abs_file); pixbuf = gst_video_thumbnailer_get_shot (abs_path, cancellable); g_free (abs_path); if (pixbuf == NULL) { g_warning ("Could not create video thumbmail for %s", point->bg); break; } surface = _cairo_new_surface_from_pixbuf (pixbuf); g_hash_table_insert (renderer->surfaces, g_strdup (file), surface); bg_width = cairo_image_surface_get_width (surface); bg_height = cairo_image_surface_get_height (surface); pp_get_background_position_scale (point, renderer->width, A4_LS_HEIGHT, bg_width, bg_height, &bg_x, &bg_y, &bg_scale_x, &bg_scale_y); cairo_save (renderer->ctx); cairo_translate (renderer->ctx, bg_x, bg_y); cairo_scale (renderer->ctx, bg_scale_x, bg_scale_y); cairo_set_source_surface (renderer->ctx, surface, 0., 0.); cairo_paint (renderer->ctx); cairo_restore (renderer->ctx); #endif break; } case PP_BG_SVG: #ifdef HAVE_RSVG { RsvgHandle *svg = _cairo_get_svg (renderer, file); RsvgDimensionData dim; float bg_x, bg_y, bg_scale_x, bg_scale_y; if (svg == NULL) break; rsvg_handle_get_dimensions (svg, &dim); pp_get_background_position_scale (point, renderer->width, renderer->height, dim.width, dim.height, &bg_x, &bg_y, &bg_scale_x, &bg_scale_y); cairo_save (renderer->ctx); cairo_translate (renderer->ctx, bg_x, bg_y); cairo_scale (renderer->ctx, bg_scale_x, bg_scale_y); rsvg_handle_render_cairo (svg, renderer->ctx); cairo_restore (renderer->ctx); } #endif break; case PP_BG_CAMERA: /* silently ignore camera backgrounds */ break; default: g_assert_not_reached(); } g_free (full_path); }