Exemple #1
0
static void
make_clip_path (Clip *clip)
{
  switch (clip->type)
    {
    case CLIP_NONE:
      break;

    case CLIP_RECTANGLE:
      cogl_path_rectangle (clip->x1,
                           clip->y1,
                           clip->x2,
                           clip->y2);
      break;

    case CLIP_ROTATED_RECTANGLE:
      {
        int size = MIN (ABS (clip->x2 - clip->x1),
                        ABS (clip->y2 - clip->y1));
        int cx = (clip->x1 + clip->x2) / 2;
        int cy = (clip->y1 + clip->y2) / 2;

        cogl_path_move_to (cx - size / 2, cy);
        cogl_path_line_to (cx, cy - size / 2);
        cogl_path_line_to (cx + size / 2, cy);
        cogl_path_line_to (cx, cy + size / 2);
        cogl_path_close ();
      }
      break;

    case CLIP_SHAPES:
      {
        int x, y, width, height;

        if (clip->x1 < clip->x2)
          {
            x = clip->x1;
            width = clip->x2 - x;
          }
        else
          {
            x = clip->x2;
            width = clip->x1 - x;
          }
        if (clip->y1 < clip->y2)
          {
            y = clip->y1;
            height = clip->y2 - y;
          }
        else
          {
            y = clip->y2;
            height = clip->y1 - y;
          }

        path_shapes (x, y, width, height);
      }
      break;
    }
}
static void
test_paint_rect ()
{
  cogl_path_rectangle (CLUTTER_INT_TO_FIXED (-50),
                       CLUTTER_INT_TO_FIXED (-25),
                       CLUTTER_INT_TO_FIXED (100),
                       CLUTTER_INT_TO_FIXED (50));
}
static VALUE
rb_cogl_path_rectangle (VALUE self,
                        VALUE x,
                        VALUE y,
                        VALUE width,
                        VALUE height)
{
  cogl_path_rectangle (rbclt_num_to_fixed (x),
                       rbclt_num_to_fixed (y),
                       rbclt_num_to_fixed (width),
                       rbclt_num_to_fixed (height));

  return Qnil;
}
Exemple #4
0
static void
path_shapes (gint x, gint y, gint width, gint height)
{
  cogl_path_move_to (x, y);
  cogl_path_line_to (x, (y + height * 4 / 5));
  cogl_path_line_to ((x + width * 4 / 15), (y + height * 4 / 5));
  cogl_path_close ();

  cogl_path_rectangle (x + width / 3,
                       y,
                       x + width * 9 / 15,
                       y + height * 4 / 5);

  cogl_path_ellipse ((x + width * 4 / 5),
                     (y + height * 2 / 5),
                     (width * 2 / 15),
                     (height * 2 / 5));
}
Exemple #5
0
static void
test_paint_rect (void)
{
  cogl_path_rectangle (-50, -25, 50, 25);
}