Beispiel #1
0
VALUE
shoes_canvas_shape(int argc, VALUE *argv, VALUE self)
{
  int x;
  double x1, y1, x2, y2;
  cairo_t *shape = NULL;
  cairo_path_t *line = NULL;
  SETUP_SHAPE();

  shape = canvas->shape;
  VALUE attr = shoes_shape_attr(argc, argv, 2, s_left, s_top);
  canvas->shape = cairo_create(cairo_image_surface_create(CAIRO_FORMAT_ARGB32, 1, 1));
  cairo_move_to(canvas->shape, 0, 0);
  if (rb_block_given_p()) rb_funcall(rb_block_proc(), s_call, 0);

#if CAIRO_VERSION_MAJOR == 1 && CAIRO_VERSION_MINOR <= 4
  cairo_fill_extents(canvas->shape, &x1, &y1, &x2, &y2);
#else
  cairo_path_extents(canvas->shape, &x1, &y1, &x2, &y2);
#endif
  x = x2 - x1;
  ATTRSET(attr, width, INT2NUM(x));
  x = y2 - y1;
  ATTRSET(attr, height, INT2NUM(x));
  line = cairo_copy_path(canvas->shape);
  canvas->shape = shape;
  return shoes_add_shape(self, s_shape, attr, line);
}
Beispiel #2
0
VALUE
shoes_canvas_shape(int argc, VALUE *argv, VALUE self)
{
  int x;
  double x1, y1, x2, y2;
  cairo_t *shape = NULL;
  cairo_path_t *line = NULL;
  SETUP_SHAPE();

  shape = canvas->shape;
  attr = shoes_shape_attr(argc, argv, 2, s_left, s_top);
  canvas->shape = cairo_create(cairo_image_surface_create(CAIRO_FORMAT_ARGB32, 1, 1));
  cairo_move_to(canvas->shape, 0, 0);
  if (rb_block_given_p()) rb_yield(Qnil);

  cairo_path_extents(canvas->shape, &x1, &y1, &x2, &y2);
  x = x2 - x1;
  ATTRSET(attr, width, INT2NUM(x));
  x = y2 - y1;
  ATTRSET(attr, height, INT2NUM(x));
  line = cairo_copy_path(canvas->shape);
  canvas->shape = shape;
  return shoes_add_shape(self, s_shape, attr, line);
}
Beispiel #3
0
VALUE
shoes_canvas_shadow(int argc, VALUE *argv, VALUE self)
{
  VALUE attr = shoes_shape_attr(argc, argv, 2, s_distance, s_radius);
  return shoes_add_effect(self, s_shadow, attr);
}
Beispiel #4
0
VALUE
shoes_canvas_blur(int argc, VALUE *argv, VALUE self)
{
  VALUE attr = shoes_shape_attr(argc, argv, 1, s_radius);
  return shoes_add_effect(self, s_blur, attr);
}
Beispiel #5
0
VALUE
shoes_canvas_star(int argc, VALUE *argv, VALUE self)
{
  VALUE attr = shoes_shape_attr(argc, argv, 5, s_left, s_top, s_points, s_outer, s_inner);
  return shoes_add_shape(self, s_star, attr, NULL);
}
Beispiel #6
0
VALUE
shoes_canvas_arrow(int argc, VALUE *argv, VALUE self)
{
  VALUE attr = shoes_shape_attr(argc, argv, 3, s_left, s_top, s_width);
  return shoes_add_shape(self, s_arrow, attr, NULL);
}
Beispiel #7
0
VALUE
shoes_canvas_line(int argc, VALUE *argv, VALUE self)
{
  VALUE attr = shoes_shape_attr(argc, argv, 4, s_left, s_top, s_right, s_bottom);
  return shoes_add_shape(self, s_line, attr, NULL);
}
Beispiel #8
0
VALUE
shoes_canvas_oval(int argc, VALUE *argv, VALUE self)
{
  VALUE attr = shoes_shape_attr(argc, argv, 4, s_left, s_top, s_width, s_height);
  return shoes_add_shape(self, s_oval, attr, NULL);
}
Beispiel #9
0
VALUE
shoes_canvas_rect(int argc, VALUE *argv, VALUE self)
{
  VALUE attr = shoes_shape_attr(argc, argv, 5, s_left, s_top, s_width, s_height, s_curve);
  return shoes_add_shape(self, s_rect, attr, NULL);
}
Beispiel #10
0
VALUE
shoes_canvas_arc(int argc, VALUE *argv, VALUE self)
{
  VALUE attr = shoes_shape_attr(argc, argv, 6, s_left, s_top, s_width, s_height, s_angle1, s_angle2);
  return shoes_add_shape(self, s_arc, attr, NULL);
}