Class: Cairo::Point

Inherits:
Object
  • Object
show all
Defined in:
lib/cairo/point.rb,
ext/cairo/rb_cairo_path.c

Instance Method Summary collapse

Constructor Details

#initializeObject



36
37
38
39
40
41
42
# File 'ext/cairo/rb_cairo_path.c', line 36

static VALUE
cr_point_initialize (VALUE self, VALUE x, VALUE y)
{
  rb_ivar_set (self, id_at_x, x);
  rb_ivar_set (self, id_at_y, y);
  return Qnil;
}

Instance Method Details

#distance(other) ⇒ Object



3
4
5
# File 'lib/cairo/point.rb', line 3

def distance(other)
  Math.sqrt((other.x - x) ** 2 + (other.y - y) ** 2)
end

#to_aObject Also known as: to_ary



44
45
46
47
48
49
50
# File 'ext/cairo/rb_cairo_path.c', line 44

static VALUE
cr_point_to_a (VALUE self)
{
  return rb_ary_new3 (2,
                      rb_ivar_get (self, id_at_x),
                      rb_ivar_get (self, id_at_y));
}