class Cairo::RecordingSurface
recording surface
Public Class Methods
new(*args)
click to toggle source
recording surface functions
static VALUE
cr_recording_surface_initialize (int argc, VALUE *argv, VALUE self)
{
VALUE arg1, arg2, arg3, arg4, arg5;
cairo_surface_t *surface;
cairo_content_t content = CAIRO_CONTENT_COLOR_ALPHA;
cairo_rectangle_t extents;
const char *error_message =
"invalid argument (expect "
"(x, y, width, height), "
"([x, y, width, height]),"
"(x, y, width, height, content) or "
"([x, y, width, height], content)): %s";
rb_scan_args (argc, argv, "14", &arg1, &arg2, &arg3, &arg4, &arg5);
if (argc == 1 || argc == 2)
{
VALUE rb_extents;
rb_extents = rb_check_array_type (arg1);
if (RARRAY_LEN (rb_extents) != 4)
rb_raise (rb_eArgError, error_message, rb_cairo__inspect (arg1));
extents.x = NUM2DBL (RARRAY_PTR (rb_extents)[0]);
extents.y = NUM2DBL (RARRAY_PTR (rb_extents)[1]);
extents.width = NUM2DBL (RARRAY_PTR (rb_extents)[2]);
extents.height = NUM2DBL (RARRAY_PTR (rb_extents)[3]);
if (!NIL_P (arg2))
content = RVAL2CRCONTENT (arg2);
}
else if (argc == 4 || argc == 5)
{
extents.x = NUM2DBL (arg1);
extents.y = NUM2DBL (arg2);
extents.width = NUM2DBL (arg3);
extents.height = NUM2DBL (arg4);
if (!NIL_P (arg5))
content = RVAL2CRCONTENT (arg5);
}
else
{
rb_raise (rb_eArgError, error_message,
rb_cairo__inspect (rb_ary_new4 (argc, argv)));
}
surface = cairo_recording_surface_create (content, &extents);
rb_cairo_surface_check_status (surface);
DATA_PTR (self) = surface;
if (rb_block_given_p ())
rb_cairo__surface_yield_and_finish (self);
return Qnil;
}
Public Instance Methods
extents()
click to toggle source
static VALUE
cr_recording_surface_get_extents (VALUE self)
{
cairo_surface_t *surface;
cairo_rectangle_t extents;
surface = _SELF;
cairo_recording_surface_get_extents (surface, &extents);
rb_cairo_surface_check_status (surface);
return rb_ary_new3 (4,
rb_float_new (extents.x),
rb_float_new (extents.y),
rb_float_new (extents.width),
rb_float_new (extents.height));
}
ink_extents()
click to toggle source
static VALUE
cr_recording_surface_get_ink_extents (VALUE self)
{
cairo_surface_t *surface;
double x, y, width, height;
surface = _SELF;
cairo_recording_surface_ink_extents (surface, &x, &y, &width, &height);
rb_cairo_surface_check_status (surface);
return rb_ary_new3 (4,
rb_float_new (x), rb_float_new (y),
rb_float_new (width), rb_float_new (height));
}