Class: GD2::Canvas::Point
- Inherits:
-
Object
- Object
- GD2::Canvas::Point
- Defined in:
- lib/gd2/canvas.rb
Instance Attribute Summary collapse
-
#x ⇒ Object
readonly
Returns the value of attribute x.
-
#y ⇒ Object
readonly
Returns the value of attribute y.
Instance Method Summary collapse
- #coordinates ⇒ Object
- #draw(image, mode) ⇒ Object
-
#initialize(x, y) ⇒ Point
constructor
A new instance of Point.
- #transform(matrix) ⇒ Object
- #transform!(matrix) ⇒ Object
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
#x ⇒ Object (readonly)
Returns the value of attribute x.
31 32 33 |
# File 'lib/gd2/canvas.rb', line 31 def x @x end |
#y ⇒ Object (readonly)
Returns the value of attribute y.
31 32 33 |
# File 'lib/gd2/canvas.rb', line 31 def y @y end |
Instance Method Details
#coordinates ⇒ Object
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 |