class Cairo::MeshPattern

Public Class Methods

new() click to toggle source

Cairo::MeshPattern

static VALUE
cr_mesh_pattern_initialize (VALUE self)
{
  cairo_pattern_t *pattern;

  pattern = cairo_pattern_create_mesh ();
  cr_pattern_check_status (pattern);
  DATA_PTR (self) = pattern;
  return Qnil;
}

Public Instance Methods

begin_patch() click to toggle source
static VALUE
cr_mesh_pattern_begin_patch (VALUE self)
{
  cairo_pattern_t *pattern;

  pattern = _SELF (self);
  cairo_mesh_pattern_begin_patch (pattern);
  cr_pattern_check_status (pattern);
  if (rb_block_given_p ())
    return rb_ensure (rb_yield, self, cr_mesh_pattern_end_patch, self);
  else
    return self;
}
curve_to(p1, p2, p3, p4, p5, p6) click to toggle source
static VALUE
cr_mesh_pattern_curve_to (VALUE self,
                          VALUE x1, VALUE y1,
                          VALUE x2, VALUE y2,
                          VALUE x3, VALUE y3)
{
  cairo_pattern_t *pattern;

  pattern = _SELF (self);
  cairo_mesh_pattern_curve_to (pattern,
                               NUM2DBL (x1), NUM2DBL (y1),
                               NUM2DBL (x2), NUM2DBL (y2),
                               NUM2DBL (x3), NUM2DBL (y3));
  cr_pattern_check_status (pattern);
  return self;
}
end_patch() click to toggle source
static VALUE
cr_mesh_pattern_end_patch (VALUE self)
{
  cairo_pattern_t *pattern;

  pattern = _SELF (self);
  cairo_mesh_pattern_end_patch (pattern);
  cr_pattern_check_status (pattern);
  return self;
}
get_control_point(p1, p2) click to toggle source
static VALUE
cr_mesh_pattern_get_control_point (VALUE self,
                                   VALUE rb_nth_patch, VALUE rb_nth_point)
{
  cairo_pattern_t *pattern;
  unsigned int nth_patch, nth_point;
  double x, y;
  cairo_status_t status;

  nth_patch = NUM2UINT (rb_nth_patch);
  nth_point = NUM2UINT (rb_nth_point);
  if (nth_point > 3)
    {
      VALUE inspected;

      inspected = rb_funcall (rb_ary_new3 (2, rb_nth_patch, rb_nth_point),
                              id_inspect, 0);
      rb_raise (rb_eArgError, "nth_point must be 0, 1, 2 or 3: <%u>: <%s>",
                nth_point, RVAL2CSTR (inspected));
    }

  pattern = _SELF (self);
  status = cairo_mesh_pattern_get_control_point (pattern,
                                                 nth_patch, nth_point,
                                                 &x, &y);
  rb_cairo_check_status (status);
  return rb_ary_new3 (2, rb_float_new (x), rb_float_new (y));
}
get_corner_color(p1, p2) click to toggle source
static VALUE
cr_mesh_pattern_get_corner_color (VALUE self,
                                  VALUE rb_nth_patch, VALUE rb_nth_corner)
{
  cairo_pattern_t *pattern;
  unsigned int nth_patch, nth_corner;
  double red, green, blue, alpha;
  cairo_status_t status;

  nth_patch = NUM2UINT (rb_nth_patch);
  nth_corner = NUM2UINT (rb_nth_corner);
  if (nth_corner > 3)
    {
      VALUE inspected;

      inspected = rb_funcall (rb_ary_new3 (2, rb_nth_patch, rb_nth_corner),
                              id_inspect, 0);
      rb_raise (rb_eArgError, "nth_corner must be 0, 1, 2 or 3: <%u>: <%s>",
                nth_corner, RVAL2CSTR (inspected));
    }

  pattern = _SELF (self);
  status = cairo_mesh_pattern_get_corner_color_rgba (pattern,
                                                     nth_patch, nth_corner,
                                                     &red,
                                                     &green,
                                                     &blue,
                                                     &alpha);
  rb_cairo_check_status (status);
  return rb_ary_new3 (4,
                      rb_float_new (red), rb_float_new (green),
                      rb_float_new (blue), rb_float_new (alpha));
}
get_path(p1) click to toggle source
static VALUE
cr_mesh_pattern_get_path (VALUE self, VALUE nth_patch)
{
  cairo_pattern_t *pattern;
  cairo_path_t *path;

  pattern = _SELF (self);
  path = cairo_mesh_pattern_get_path (pattern, NUM2UINT (nth_patch));
  rb_cairo_check_status (path->status);
  return CRPATH2RVAL (path);
}
line_to(p1, p2) click to toggle source
static VALUE
cr_mesh_pattern_line_to (VALUE self, VALUE x, VALUE y)
{
  cairo_pattern_t *pattern;

  pattern = _SELF (self);
  cairo_mesh_pattern_line_to (pattern, NUM2DBL (x), NUM2DBL (y));
  cr_pattern_check_status (pattern);
  return self;
}
move_to(p1, p2) click to toggle source
static VALUE
cr_mesh_pattern_move_to (VALUE self, VALUE x, VALUE y)
{
  cairo_pattern_t *pattern;

  pattern = _SELF (self);
  cairo_mesh_pattern_move_to (pattern, NUM2DBL (x), NUM2DBL (y));
  cr_pattern_check_status (pattern);
  return self;
}
patch_count() click to toggle source
static VALUE
cr_mesh_pattern_get_patch_count (VALUE self)
{
  cairo_pattern_t *pattern;
  unsigned int count;
  cairo_status_t status;

  pattern = _SELF (self);
  status = cairo_mesh_pattern_get_patch_count (pattern, &count);
  rb_cairo_check_status (status);
  return UINT2NUM (count);
}
set_control_point(p1, p2, p3) click to toggle source
static VALUE
cr_mesh_pattern_set_control_point (VALUE self, VALUE rb_nth_point,
                                   VALUE rb_x, VALUE rb_y)
{
  cairo_pattern_t *pattern;
  unsigned int nth_point;

  pattern = _SELF (self);
  nth_point = NUM2UINT (rb_nth_point);
  if (nth_point <= 3)
    {
      cairo_mesh_pattern_set_control_point (pattern, nth_point,
                                            NUM2DBL (rb_x), NUM2DBL (rb_y));
    }
  else
    {
      VALUE inspected;

      inspected = rb_funcall (rb_ary_new3 (3, rb_nth_point, rb_x, rb_y),
                              id_inspect, 0);
      rb_raise (rb_eArgError, "nth_point must be 0, 1, 2 or 3: <%u>: <%s>",
                nth_point, RVAL2CSTR (inspected));
    }
  cr_pattern_check_status (pattern);
  return self;
}
set_corner_color(*args) click to toggle source
static VALUE
cr_mesh_pattern_set_corner_color_generic (int argc, VALUE *argv, VALUE self)
{
  cairo_pattern_t *pattern;
  VALUE rb_nth_corner, rb_red, rb_green, rb_blue, rb_alpha;
  unsigned int nth_corner;
  double red, green, blue, alpha;

  rb_scan_args (argc, argv, "41",
                &rb_nth_corner, &rb_red, &rb_green, &rb_blue, &rb_alpha);

  nth_corner = NUM2UINT (rb_nth_corner);
  if (nth_corner > 3)
    {
      VALUE inspected;

      inspected = rb_funcall (rb_ary_new4 (argc, argv), id_inspect, 0);
      rb_raise (rb_eArgError, "nth_corner must be 0, 1, 2 or 3: <%u>: <%s>",
                nth_corner, RVAL2CSTR (inspected));
    }

  pattern = _SELF (self);
  red = NUM2DBL (rb_red);
  green = NUM2DBL (rb_green);
  blue = NUM2DBL (rb_blue);
  if (NIL_P (rb_alpha))
    {
      cairo_mesh_pattern_set_corner_color_rgb (pattern, nth_corner,
                                               red, green, blue);
    }
  else
    {
      alpha = NUM2DBL (rb_alpha);
      cairo_mesh_pattern_set_corner_color_rgba (pattern, nth_corner,
                                                red, green, blue, alpha);
    }
  cr_pattern_check_status (pattern);
  return self;
}
set_corner_color_rgb(*args)
Alias for: set_corner_color
set_corner_color_rgba(*args)
Alias for: set_corner_color