ClutterActor * gb_player_rounded_rect (GbPlayer *self, gint width, gint height, ClutterColor *bgcolor, gint round_radius) { /* Mostly code of this function was got from Tweet, */ /* thanks to Emanuelle Bassi. (http://live.gnome.org/Tweet) */ ClutterActor *actor; cairo_t *cr; actor = clutter_cairo_new (width, height); cr = clutter_cairo_create (CLUTTER_CAIRO (actor)); cairo_move_to (cr, round_radius, 0); cairo_line_to (cr, width - round_radius, 0); cairo_curve_to (cr, width, 0, width, 0, width, round_radius); cairo_line_to (cr, width, height - round_radius); cairo_curve_to (cr, width, height, width, height, width - round_radius, height); cairo_line_to (cr, round_radius, height); cairo_curve_to (cr, 0, height, 0, height, 0, height - round_radius); cairo_line_to (cr, 0, round_radius); cairo_curve_to (cr, 0, 0, 0, 0, round_radius, 0); cairo_close_path (cr); clutter_cairo_set_source_color (cr, bgcolor); cairo_fill_preserve (cr); cairo_destroy (cr); return actor; }
static inline void draw_background (TweetOverlay *overlay) { TweetOverlayPrivate *priv = overlay->priv; cairo_t *cr; gint width, height; g_assert (CLUTTER_IS_CAIRO (priv->base)); cr = clutter_cairo_create (CLUTTER_CAIRO (priv->base)); g_assert (cr != NULL); width = height = 0; g_object_get (G_OBJECT (priv->base), "surface-width", &width, "surface-height", &height, NULL); cairo_set_operator (cr, CAIRO_OPERATOR_CLEAR); cairo_paint (cr); cairo_set_operator (cr, CAIRO_OPERATOR_OVER); cairo_move_to (cr, BG_ROUND_RADIUS, 0); cairo_line_to (cr, width - BG_ROUND_RADIUS, 0); cairo_curve_to (cr, width, 0, width, 0, width, BG_ROUND_RADIUS); cairo_line_to (cr, width, height - BG_ROUND_RADIUS); cairo_curve_to (cr, width, height, width, height, width - BG_ROUND_RADIUS, height); cairo_line_to (cr, BG_ROUND_RADIUS, height); cairo_curve_to (cr, 0, height, 0, height, 0, height - BG_ROUND_RADIUS); cairo_line_to (cr, 0, BG_ROUND_RADIUS); cairo_curve_to (cr, 0, 0, 0, 0, BG_ROUND_RADIUS, 0); cairo_close_path (cr); clutter_cairo_set_source_color (cr, &priv->base_color); cairo_fill_preserve (cr); cairo_destroy (cr); }