class Cairo::RasterSourcePattern
Public Class Methods
new(*args)
click to toggle source
static VALUE
cr_raster_source_pattern_initialize (int argc, VALUE *argv, VALUE self)
{
cairo_pattern_t *pattern;
cairo_content_t content;
int width, height;
VALUE arg1, arg2, arg3;
rb_scan_args (argc, argv, "21", &arg1, &arg2, &arg3);
if (argc == 2)
{
content = CAIRO_CONTENT_COLOR_ALPHA;
width = NUM2INT (arg1);
height = NUM2INT (arg2);
}
else
{
content = RVAL2CRCONTENT (arg1);
width = NUM2INT (arg2);
height = NUM2INT (arg3);
}
pattern = cairo_pattern_create_raster_source (RVAL2POINTER (self),
content, width, height);
cr_pattern_check_status (pattern);
RTYPEDDATA_DATA (self) = pattern;
rb_iv_set (self, "@acquire", Qnil);
rb_iv_set (self, "@release", Qnil);
rb_iv_set (self, "@snapshot", Qnil);
rb_iv_set (self, "@copy", Qnil);
rb_iv_set (self, "@finish", Qnil);
cairo_raster_source_pattern_set_acquire (pattern,
cr_raster_source_acquire_callback,
cr_raster_source_release_callback);
cairo_raster_source_pattern_set_snapshot (pattern,
cr_raster_source_snapshot_callback);
cairo_raster_source_pattern_set_copy (pattern,
cr_raster_source_copy_callback);
cairo_raster_source_pattern_set_finish (pattern,
cr_raster_source_finish_callback);
return Qnil;
}
Public Instance Methods
acquire()
click to toggle source
static VALUE
cr_raster_source_pattern_acquire (VALUE self)
{
if (!rb_block_given_p ())
{
VALUE inspected;
inspected = rb_funcall (self, id_inspect, 0);
rb_raise (rb_eArgError, "acquire block is missing: %s",
RVAL2CSTR (inspected));
}
rb_iv_set (self, "@acquire", rb_block_proc ());
return self;
}
copy()
click to toggle source
static VALUE
cr_raster_source_pattern_copy (VALUE self)
{
if (!rb_block_given_p ())
{
VALUE inspected;
inspected = rb_funcall (self, id_inspect, 0);
rb_raise (rb_eArgError, "copy block is missing: %s",
RVAL2CSTR (inspected));
}
rb_iv_set (self, "@copy", rb_block_proc ());
return self;
}
finish()
click to toggle source
static VALUE
cr_raster_source_pattern_finish (VALUE self)
{
if (!rb_block_given_p ())
{
VALUE inspected;
inspected = rb_funcall (self, id_inspect, 0);
rb_raise (rb_eArgError, "finish block is missing: %s",
RVAL2CSTR (inspected));
}
rb_iv_set (self, "@finish", rb_block_proc ());
return self;
}
release()
click to toggle source
static VALUE
cr_raster_source_pattern_release (VALUE self)
{
if (!rb_block_given_p ())
{
VALUE inspected;
inspected = rb_funcall (self, id_inspect, 0);
rb_raise (rb_eArgError, "release block is missing: %s",
RVAL2CSTR (inspected));
}
rb_iv_set (self, "@release", rb_block_proc ());
return self;
}
snapshot()
click to toggle source
static VALUE
cr_raster_source_pattern_snapshot (VALUE self)
{
if (!rb_block_given_p ())
{
VALUE inspected;
inspected = rb_funcall (self, id_inspect, 0);
rb_raise (rb_eArgError, "snapshot block is missing: %s",
RVAL2CSTR (inspected));
}
rb_iv_set (self, "@snapshot", rb_block_proc ());
return self;
}