class Cairo::Path

Public Class Methods

new() click to toggle source
static VALUE
cr_path_initialize (VALUE self)
{
  cairo_path_t *path;

  path = RB_ALLOC (cairo_path_t);
  path->status = CAIRO_STATUS_SUCCESS;
  path->data = NULL;
  path->num_data = 0;
  DATA_PTR (self) = path;

  return Qnil;
}

Public Instance Methods

[](p1) click to toggle source
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() click to toggle source
# File lib/cairo/path.rb, line 11
def close
  @context.close_path
end
each() click to toggle source
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?() click to toggle source
static VALUE
cr_path_empty_p (VALUE self)
{
  cairo_path_t *path = _SELF (self);

  return CBOOL2RVAL (path->num_data == 0);
}
length()
Alias for: size
size() click to toggle source
static VALUE
cr_path_size (VALUE self)
{
  cairo_path_t *path = _SELF (self);
  return INT2NUM (cairo_path_get_size (path));
}
Also aliased as: length