Class: Cairo::ScriptSurface

Inherits:
Surface
  • Object
show all
Defined in:
ext/cairo/rb_cairo_surface.c

Instance Method Summary collapse

Methods inherited from Surface

#clone, #content, #copy_page, #create_similar, #create_similar_image, #destroy, #device, #device_offset, #dup, #fallback_resolution, #finish, #flush, #font_options, #get_mime_data, gl_supported?, gl_texture_supported?, image_supported?, #map_to_image, #mark_dirty, pdf_supported?, ps_supported?, quartz_image_supported?, quartz_supported?, recording_supported?, script_supported?, #set_device_offset, #set_fallback_resolution, #set_mime_data, #show_page, #sub_rectangle_surface, supported?, #supported_mime_type?, svg_supported?, tee_supported?, #unmap_image, win32_printing_supported?, win32_supported?, #write_to_png, xml_supported?

Constructor Details

#initializeObject

script surface functions



1469
1470
1471
1472
1473
1474
1475
1476
1477
1478
1479
1480
1481
1482
1483
1484
1485
1486
1487
1488
1489
1490
1491
1492
1493
1494
1495
1496
1497
1498
1499
1500
1501
1502
1503
1504
1505
1506
1507
1508
1509
1510
1511
1512
1513
1514
1515
1516
1517
1518
1519
# File 'ext/cairo/rb_cairo_surface.c', line 1469

static VALUE
cr_script_surface_initialize (int argc, VALUE *argv, VALUE self)
{
  cairo_surface_t *surface = NULL, *target = NULL;
  cairo_device_t *device;
  double width = 0.0, height = 0.0;
  cairo_content_t content = CAIRO_CONTENT_COLOR_ALPHA;
  VALUE arg1, arg2, arg3, arg4;

  rb_scan_args (argc, argv, "22", &arg1, &arg2, &arg3, &arg4);

  device = RVAL2CRDEVICE (arg1);
  if (argc == 2)
    {
      target = RVAL2CRSURFACE (arg2);
    }
  else
    {
      width = NUM2DBL (arg2);
      height = NUM2DBL (arg3);
      switch (TYPE (arg4))
        {
        case T_NIL:
          break;
        case T_STRING:
        case T_SYMBOL:
        case T_FIXNUM:
          content = RVAL2CRCONTENT (arg4);
          break;
        default:
          rb_raise (rb_eArgError,
                    "invalid argument (expect "
                    "(device, width, height), "
                    "(device, width, height, content) or "
                    "(device, surface)): %s",
                    rb_cairo__inspect (rb_ary_new4 (argc, argv)));
          break;
        }
    }

  if (target)
    surface = cairo_script_surface_create_for_target (device, target);
  else
    surface = cairo_script_surface_create (device, content, width, height);

  cr_surface_check_status (surface);
  DATA_PTR (self) = surface;
  if (rb_block_given_p ())
    yield_and_finish (self);
  return Qnil;
}