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.



33
34
35
# File 'lib/gd2/canvas.rb', line 33

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

Instance Attribute Details

#xObject (readonly)

Returns the value of attribute x.



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

def x
  @x
end

#yObject (readonly)

Returns the value of attribute y.



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

def y
  @y
end

Instance Method Details

#coordinatesObject



37
38
39
# File 'lib/gd2/canvas.rb', line 37

def coordinates
  [@x, @y]
end

#draw(image, mode) ⇒ Object



50
51
52
# File 'lib/gd2/canvas.rb', line 50

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

#transform(matrix) ⇒ Object



46
47
48
# File 'lib/gd2/canvas.rb', line 46

def transform(matrix)
  dup.transform!(matrix)
end

#transform!(matrix) ⇒ Object



41
42
43
44
# File 'lib/gd2/canvas.rb', line 41

def transform!(matrix)
  @x, @y = (Matrix.row_vector([@x, @y, 1]) * matrix)[0, 0..1]
  self
end