コード例 #1
0
ファイル: test-kinect.c プロジェクト: Zeraphil/Skeltrack
static void
on_texture_draw (ClutterCairoTexture *texture,
                 cairo_t *cairo,
                 gpointer user_data)
{
  guint width, height;
  ClutterColor *color;
  SkeltrackJoint *head, *left_hand, *right_hand,
    *left_shoulder, *right_shoulder, *left_elbow, *right_elbow;
  if (list == NULL)
    return;

  head = skeltrack_joint_list_get_joint (list,
                                         SKELTRACK_JOINT_ID_HEAD);
  left_hand = skeltrack_joint_list_get_joint (list,
                                              SKELTRACK_JOINT_ID_LEFT_HAND);
  right_hand = skeltrack_joint_list_get_joint (list,
                                               SKELTRACK_JOINT_ID_RIGHT_HAND);
  left_shoulder = skeltrack_joint_list_get_joint (list,
                                       SKELTRACK_JOINT_ID_LEFT_SHOULDER);
  right_shoulder = skeltrack_joint_list_get_joint (list,
                                       SKELTRACK_JOINT_ID_RIGHT_SHOULDER);
  left_elbow = skeltrack_joint_list_get_joint (list,
                                               SKELTRACK_JOINT_ID_LEFT_ELBOW);
  right_elbow = skeltrack_joint_list_get_joint (list,
                                                SKELTRACK_JOINT_ID_RIGHT_ELBOW);

  /* Paint it white */
  clutter_cairo_texture_clear (texture);
  clutter_cairo_texture_get_surface_size (texture, &width, &height);
  color = clutter_color_new (255, 255, 255, 255);
  clutter_cairo_set_source_color (cairo, color);
  cairo_rectangle (cairo, 0, 0, width, height);
  cairo_fill (cairo);
  clutter_color_free (color);

  paint_joint (cairo, head, 50, "#FFF800");

  connect_joints (cairo, left_shoulder, right_shoulder, "#afafaf");

  connect_joints (cairo, left_shoulder, left_elbow, "#afafaf");

  connect_joints (cairo, right_shoulder, right_elbow, "#afafaf");

  connect_joints (cairo, right_hand, right_elbow, "#afafaf");

  connect_joints (cairo, left_hand, left_elbow, "#afafaf");

  paint_joint (cairo, left_hand, 30, "#C2FF00");

  paint_joint (cairo, right_hand, 30, "#00FAFF");

  skeltrack_joint_list_free (list);
  list = NULL;
}
コード例 #2
0
static void
glide_theme_preview_actor_update_texture (GlideThemePreviewActor *preview)
{
    guint width, height;
    cairo_t *cr;

    clutter_cairo_texture_get_surface_size (CLUTTER_CAIRO_TEXTURE (preview->priv->preview_texture), &width, &height);
    cr = clutter_cairo_texture_create (CLUTTER_CAIRO_TEXTURE (preview->priv->preview_texture));
    glide_theme_preview (preview->priv->theme, cr, width, height);
    cairo_destroy (cr);
}
static void
empathy_rounded_rectangle_paint (EmpathyRoundedRectangle *self)
{
  guint width, height;
  guint tmp_alpha;
  cairo_t *cr;

#define RADIUS (height / 8.)

  clutter_cairo_texture_get_surface_size (CLUTTER_CAIRO_TEXTURE (self),
      &width, &height);

  /* compute the composited opacity of the actor taking into
   * account the opacity of the color set by the user */
  tmp_alpha = clutter_actor_get_paint_opacity (CLUTTER_ACTOR (self))
            * self->priv->border_color.alpha
            / 255;

  cr = clutter_cairo_texture_create (CLUTTER_CAIRO_TEXTURE (self));

  cairo_set_source_rgba (cr,
      self->priv->border_color.red,
      self->priv->border_color.green,
      self->priv->border_color.blue,
      tmp_alpha);

  cairo_set_line_width (cr, self->priv->border_width);

  cairo_set_operator (cr, CAIRO_OPERATOR_CLEAR);
  cairo_paint (cr);
  cairo_set_operator (cr, CAIRO_OPERATOR_OVER);

  cairo_new_sub_path (cr);
  cairo_arc (cr, width - RADIUS, RADIUS, RADIUS,
      -M_PI/2.0, 0);
  cairo_arc (cr, width - RADIUS, height - RADIUS, RADIUS,
      0, M_PI/2.0);
  cairo_arc (cr, RADIUS, height - RADIUS, RADIUS,
      M_PI/2.0, M_PI);
  cairo_arc (cr, RADIUS, RADIUS, RADIUS,
      M_PI, -M_PI/2.0);
  cairo_close_path (cr);

  cairo_stroke (cr);
  cairo_destroy (cr);

#undef RADIUS
}
コード例 #4
0
void
shell_global_clutter_cairo_texture_draw_clock (ClutterCairoTexture *texture,
                                               int                  hour,
                                               int                  minute)
{
  cairo_t *cr;
  guint width, height;
  double xc, yc, radius, hour_radius, minute_radius;
  double angle;

  clutter_cairo_texture_get_surface_size (texture, &width, &height);
  xc = (double)width / 2;
  yc = (double)height / 2;
  radius = (double)(MIN(width, height)) / 2 - 2;
  minute_radius = radius - 3;
  hour_radius = radius / 2;

  clutter_cairo_texture_clear (texture);
  cr = clutter_cairo_texture_create (texture);
  cairo_set_line_width (cr, 1.0);

  /* Outline */
  cairo_arc (cr, xc, yc, radius, 0.0, 2.0 * M_PI);
  cairo_stroke (cr);

  /* Hour hand. (We add a fraction to @hour for the minutes, then
   * convert to radians, and then subtract pi/2 because cairo's origin
   * is at 3:00, not 12:00.)
   */
  angle = ((hour + minute / 60.0) / 12.0) * 2.0 * M_PI - M_PI / 2.0;
  cairo_move_to (cr, xc, yc);
  cairo_line_to (cr,
                 xc + hour_radius * cos (angle),
                 yc + hour_radius * sin (angle));
  cairo_stroke (cr);

  /* Minute hand */
  angle = (minute / 60.0) * 2.0 * M_PI - M_PI / 2.0;
  cairo_move_to (cr, xc, yc);
  cairo_line_to (cr,
                 xc + minute_radius * cos (angle),
                 yc + minute_radius * sin (angle));
  cairo_stroke (cr);

  cairo_destroy (cr);
}