Class: Cairo::Surface
- Inherits:
-
Object
- Object
- Cairo::Surface
- Defined in:
- lib/cairo.rb,
ext/cairo/rb_cairo_surface.c
Direct Known Subclasses
GLSurface, ImageSurface, QuartzImageSurface, QuartzSurface, RecordingSurface, ScriptSurface, TeeSurface, Win32PrintingSurface, Win32Surface, XMLSurface
Instance Method Summary collapse
- #clone ⇒ Object
- #content ⇒ Object
- #copy_page ⇒ Object
- #create_similar ⇒ Object
-
#destroy ⇒ Object
Surface manipulation.
- #device ⇒ Object
- #device_offset ⇒ Object
- #dup ⇒ Object
- #fallback_resolution ⇒ Object
- #finish ⇒ Object
- #flush ⇒ Object
- #font_options ⇒ Object
- #get_mime_data ⇒ Object
- #mark_dirty ⇒ Object
- #set_device_offset ⇒ Object
- #set_fallback_resolution ⇒ Object
- #set_mime_data ⇒ Object
- #show_page ⇒ Object
- #sub_rectangle_surface ⇒ Object
- #write_to_png ⇒ Object
Instance Method Details
#clone ⇒ Object
72 73 74 |
# File 'lib/cairo.rb', line 72 def clone raise NotImplementedError end |
#content ⇒ Object
384 385 386 387 388 |
# File 'ext/cairo/rb_cairo_surface.c', line 384
static VALUE
cr_surface_get_content (VALUE self)
{
return INT2NUM (cairo_surface_get_content (_SELF));
}
|
#copy_page ⇒ Object
586 587 588 589 590 591 592 |
# File 'ext/cairo/rb_cairo_surface.c', line 586
static VALUE
cr_surface_copy_page (VALUE self)
{
cairo_surface_copy_page (_SELF);
cr_surface_check_status (_SELF);
return self;
}
|
#create_similar ⇒ Object
317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 |
# File 'ext/cairo/rb_cairo_surface.c', line 317
static VALUE
cr_surface_create_similar (int argc, VALUE *argv, VALUE self)
{
cairo_surface_t *surface, *similar_surface;
cairo_content_t content;
int width, height;
VALUE arg1, arg2, arg3;
rb_scan_args (argc, argv, "21", &arg1, &arg2, &arg3);
surface = _SELF;
if (argc == 2)
{
content = cairo_surface_get_content (surface);
width = NUM2INT (arg1);
height = NUM2INT (arg2);
}
else
{
content = RVAL2CRCONTENT (arg1);
width = NUM2INT (arg2);
height = NUM2INT (arg3);
}
similar_surface = cairo_surface_create_similar (surface, content,
width, height);
cr_surface_check_status (similar_surface);
return CRSURFACE2RVAL_WITH_DESTROY (similar_surface);
}
|
#destroy ⇒ Object
Surface manipulation
273 274 275 276 277 278 279 280 281 282 283 |
# File 'ext/cairo/rb_cairo_surface.c', line 273
static VALUE
cr_surface_destroy (VALUE self)
{
cairo_surface_t *surface;
surface = _SELF;
cairo_surface_destroy (surface);
DATA_PTR (self) = NULL;
return self;
}
|
#device ⇒ Object
377 378 379 380 381 |
# File 'ext/cairo/rb_cairo_surface.c', line 377
static VALUE
cr_surface_get_device (VALUE self)
{
return CRDEVICE2RVAL (cairo_surface_get_device (_SELF));
}
|
#device_offset ⇒ Object
546 547 548 549 550 551 552 553 554 |
# File 'ext/cairo/rb_cairo_surface.c', line 546
static VALUE
cr_surface_get_device_offset (VALUE self)
{
double x_offset, y_offset;
cairo_surface_get_device_offset (_SELF, &x_offset, &y_offset);
cr_surface_check_status (_SELF);
return rb_ary_new3 (2, rb_float_new (x_offset), rb_float_new (y_offset));
}
|
#dup ⇒ Object
69 70 71 |
# File 'lib/cairo.rb', line 69 def dup raise NotImplementedError end |
#fallback_resolution ⇒ Object
569 570 571 572 573 574 575 576 577 578 579 580 581 |
# File 'ext/cairo/rb_cairo_surface.c', line 569
static VALUE
cr_surface_get_fallback_resolution (VALUE self)
{
double x_pixels_per_inch, y_pixels_per_inch;
cairo_surface_get_fallback_resolution (_SELF,
&x_pixels_per_inch,
&y_pixels_per_inch);
cr_surface_check_status (_SELF);
return rb_ary_new3 (2,
rb_float_new (x_pixels_per_inch),
rb_float_new (y_pixels_per_inch));
}
|
#finish ⇒ Object
285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 |
# File 'ext/cairo/rb_cairo_surface.c', line 285
static VALUE
cr_surface_finish (VALUE self)
{
cairo_surface_t *surface;
rb_cairo__io_callback_closure_t *closure;
surface = _SELF;
closure = cairo_surface_get_user_data (surface, &cr_closure_key);
cairo_surface_finish (surface);
cairo_surface_set_user_data (surface, &cr_finished_key, (void *)CR_TRUE, NULL);
cairo_surface_set_user_data (surface, &cr_object_holder_key, NULL, NULL);
if (closure && !NIL_P (closure->error))
rb_exc_raise (closure->error);
cr_surface_check_status (surface);
return self;
}
|
#flush ⇒ Object
490 491 492 493 494 495 496 |
# File 'ext/cairo/rb_cairo_surface.c', line 490
static VALUE
cr_surface_flush (VALUE self)
{
cairo_surface_flush (_SELF);
cr_surface_check_status (_SELF);
return self;
}
|
#font_options ⇒ Object
480 481 482 483 484 485 486 487 488 |
# File 'ext/cairo/rb_cairo_surface.c', line 480
static VALUE
cr_surface_get_font_options (VALUE self)
{
cairo_font_options_t *options = cairo_font_options_create();
cairo_surface_get_font_options (_SELF, options);
cr_surface_check_status (_SELF);
rb_cairo_check_status (cairo_font_options_status (options));
return CRFONTOPTIONS2RVAL (options);
}
|
#get_mime_data ⇒ Object
431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 |
# File 'ext/cairo/rb_cairo_surface.c', line 431
static VALUE
cr_surface_get_mime_data (VALUE self, VALUE mime_type)
{
cairo_surface_t *surface;
const unsigned char *data;
unsigned long length;
surface = _SELF;
cairo_surface_get_mime_data (surface, StringValueCStr (mime_type),
&data, &length);
if (data)
return rb_str_new ((const char *)data, length);
else
return Qnil;
}
|
#mark_dirty ⇒ Object
498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 526 527 528 529 530 531 532 533 534 |
# File 'ext/cairo/rb_cairo_surface.c', line 498
static VALUE
cr_surface_mark_dirty (int argc, VALUE *argv, VALUE self)
{
VALUE x, y, width, height;
int n;
n = rb_scan_args (argc, argv, "04", &x, &y, &width, &height);
if (n == 0)
{
cairo_surface_mark_dirty (_SELF);
}
else if (n == 4)
{
cairo_surface_mark_dirty_rectangle (_SELF,
NUM2INT (x), NUM2INT (y),
NUM2INT (width), NUM2INT (height));
}
else
{
int i;
VALUE args;
args = rb_ary_new2 (n);
for (i = 0; i < n; i++)
{
rb_ary_push (args, argv[i]);
}
rb_raise (rb_eArgError,
"invalid argument (expect () or (x, y, width, height)): %s",
rb_cairo__inspect (args));
}
cr_surface_check_status (_SELF);
return self;
}
|
#set_device_offset ⇒ Object
536 537 538 539 540 541 542 543 544 |
# File 'ext/cairo/rb_cairo_surface.c', line 536
static VALUE
cr_surface_set_device_offset (VALUE self, VALUE x_offset, VALUE y_offset)
{
cairo_surface_set_device_offset (_SELF,
NUM2DBL (x_offset),
NUM2DBL (y_offset));
cr_surface_check_status (_SELF);
return self;
}
|
#set_fallback_resolution ⇒ Object
556 557 558 559 560 561 562 563 564 565 566 |
# File 'ext/cairo/rb_cairo_surface.c', line 556
static VALUE
cr_surface_set_fallback_resolution (VALUE self,
VALUE x_pixels_per_inch,
VALUE y_pixels_per_inch)
{
cairo_surface_set_fallback_resolution (_SELF,
NUM2DBL (x_pixels_per_inch),
NUM2DBL (y_pixels_per_inch));
cr_surface_check_status (_SELF);
return self;
}
|
#set_mime_data ⇒ Object
447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 |
# File 'ext/cairo/rb_cairo_surface.c', line 447
static VALUE
cr_surface_set_mime_data (VALUE self, VALUE rb_mime_type, VALUE rb_data)
{
cairo_status_t status;
cairo_surface_t *surface;
const char *mime_type;
surface = _SELF;
mime_type = StringValueCStr (rb_mime_type);
if (NIL_P (rb_data))
{
status = cairo_surface_set_mime_data (surface, mime_type,
NULL, 0, NULL, NULL);
}
else
{
const char *raw_data;
unsigned char *data;
unsigned long length;
raw_data = StringValuePtr (rb_data);
length = RSTRING_LEN (rb_data);
data = xmalloc (length);
memcpy (data, raw_data, length);
status = cairo_surface_set_mime_data (surface, mime_type,
data, length,
xfree, data);
}
rb_cairo_check_status (status);
return Qnil;
}
|
#show_page ⇒ Object
594 595 596 597 598 599 600 |
# File 'ext/cairo/rb_cairo_surface.c', line 594
static VALUE
cr_surface_show_page (VALUE self)
{
cairo_surface_show_page (_SELF);
cr_surface_check_status (_SELF);
return self;
}
|
#sub_rectangle_surface ⇒ Object
356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 |
# File 'ext/cairo/rb_cairo_surface.c', line 356
static VALUE
cr_surface_create_sub_rectangle_surface (VALUE self, VALUE x, VALUE y,
VALUE width, VALUE height)
{
VALUE rb_surface;
cairo_surface_t *surface;
surface = cairo_surface_create_for_rectangle (RVAL2CRSURFACE (self),
NUM2DBL (x),
NUM2DBL (y),
NUM2DBL (width),
NUM2INT (height));
cr_surface_check_status (surface);
rb_surface = CRSURFACE2RVAL_WITH_DESTROY (surface);
if (rb_block_given_p ())
return rb_ensure (rb_yield, rb_surface,
cr_surface_destroy_with_destroy_check, rb_surface);
else
return rb_surface;
}
|
#write_to_png ⇒ Object
420 421 422 423 424 425 426 427 |
# File 'ext/cairo/rb_cairo_surface.c', line 420
static VALUE
cr_surface_write_to_png_generic (VALUE self, VALUE target)
{
if (rb_respond_to (target, rb_cairo__io_id_write))
return cr_surface_write_to_png_stream (self, target);
else
return cr_surface_write_to_png (self, target);
}
|