Class: Cairo::Path
- Inherits:
-
Object
- Object
- Cairo::Path
- Extended by:
- Forwardable
- Includes:
- Enumerable
- Defined in:
- lib/cairo/path.rb,
ext/cairo/rb_cairo_path.c
Instance Method Summary collapse
- #[] ⇒ Object
- #close ⇒ Object
- #each ⇒ Object
- #empty? ⇒ Boolean
- #initialize ⇒ Object constructor
- #size ⇒ Object (also: #length)
Constructor Details
#initialize ⇒ Object
298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 |
# File 'ext/cairo/rb_cairo_path.c', line 298
static VALUE
cr_path_initialize (VALUE self)
{
cairo_path_t *path;
path = ALLOC(cairo_path_t);
path->status = CAIRO_STATUS_SUCCESS;
path->data = NULL;
path->num_data = 0;
DATA_PTR (self) = path;
cr_path_ensure_internal_context (self, path);
return Qnil;
}
|
Instance Method Details
#[] ⇒ Object
340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 |
# File 'ext/cairo/rb_cairo_path.c', line 340
static VALUE
cr_path_ref (VALUE self, VALUE index)
{
cairo_path_t *path = _SELF (self);
int i, requested_index, real_index;
requested_index = NUM2INT (index);
if (requested_index < 0)
{
requested_index += cairo_path_get_size (path);
if (requested_index < 0)
return Qnil;
}
for (i = 0, real_index = 0; i < requested_index; i++)
{
if (real_index >= path->num_data)
return Qnil;
real_index += path->data[real_index].header.length;
}
if (real_index < path->num_data)
return cr_path_data_to_ruby_object (&path->data[real_index]);
else
return Qnil;
}
|
#close ⇒ Object
11 12 13 |
# File 'lib/cairo/path.rb', line 11 def close @context.close_path end |
#each ⇒ Object
368 369 370 371 372 373 374 375 376 377 378 379 380 |
# File 'ext/cairo/rb_cairo_path.c', line 368
static VALUE
cr_path_each (VALUE self)
{
cairo_path_t *path = _SELF(self);
int i;
for (i = 0; i < path->num_data; i += path->data[i].header.length)
{
rb_yield (cr_path_data_to_ruby_object (&(path->data[i])));
}
return self;
}
|
#empty? ⇒ Boolean
314 315 316 317 318 319 320 |
# File 'ext/cairo/rb_cairo_path.c', line 314
static VALUE
cr_path_empty_p (VALUE self)
{
cairo_path_t *path = _SELF (self);
return CBOOL2RVAL (path->num_data == 0);
}
|
#size ⇒ Object Also known as: length
333 334 335 336 337 338 |
# File 'ext/cairo/rb_cairo_path.c', line 333
static VALUE
cr_path_size (VALUE self)
{
cairo_path_t *path = _SELF (self);
return INT2NUM (cairo_path_get_size (path));
}
|