Class: Cairo::RecordingSurface

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

recording surface functions



1524
1525
1526
1527
1528
1529
1530
1531
1532
1533
1534
1535
1536
1537
1538
1539
1540
1541
1542
1543
1544
1545
1546
1547
1548
1549
1550
1551
1552
1553
1554
1555
1556
1557
1558
1559
1560
1561
1562
1563
1564
1565
1566
1567
1568
1569
1570
1571
1572
1573
1574
# File 'ext/cairo/rb_cairo_surface.c', line 1524

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);
  cr_surface_check_status (surface);
  DATA_PTR (self) = surface;
  if (rb_block_given_p ())
    yield_and_finish (self);
  return Qnil;
}

Instance Method Details

#extentsObject



1591
1592
1593
1594
1595
1596
1597
1598
1599
1600
1601
1602
1603
1604
1605
# File 'ext/cairo/rb_cairo_surface.c', line 1591

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);
  cr_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_extentsObject



1576
1577
1578
1579
1580
1581
1582
1583
1584
1585
1586
1587
1588
# File 'ext/cairo/rb_cairo_surface.c', line 1576

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);
  cr_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));
}