Class: GD2::Canvas::Point

Inherits:
Object
  • Object
show all
Defined in:
lib/gd2/canvas.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(x, y) ⇒ Point

Returns a new instance of Point.



31
32
33
# File 'lib/gd2/canvas.rb', line 31

def initialize(x, y)
  @x, @y = x, y
end

Instance Attribute Details

#xObject (readonly)

Returns the value of attribute x.



29
30
31
# File 'lib/gd2/canvas.rb', line 29

def x
  @x
end

#yObject (readonly)

Returns the value of attribute y.



29
30
31
# File 'lib/gd2/canvas.rb', line 29

def y
  @y
end

Instance Method Details

#coordinatesObject



35
36
37
# File 'lib/gd2/canvas.rb', line 35

def coordinates
  [@x, @y]
end

#draw(image, mode) ⇒ Object



39
40
41
# File 'lib/gd2/canvas.rb', line 39

def draw(image, mode)
  image.set_pixel(@x, @y, mode)
end