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.
15 16 17 |
# File 'lib/gd2/canvas.rb', line 15 def initialize(x, y) @x, @y = x, y end |
Instance Attribute Details
#x ⇒ Object (readonly)
Returns the value of attribute x.
13 14 15 |
# File 'lib/gd2/canvas.rb', line 13 def x @x end |
#y ⇒ Object (readonly)
Returns the value of attribute y.
13 14 15 |
# File 'lib/gd2/canvas.rb', line 13 def y @y end |
Instance Method Details
#coordinates ⇒ Object
19 20 21 |
# File 'lib/gd2/canvas.rb', line 19 def coordinates [@x, @y] end |
#draw(image, mode) ⇒ Object
32 33 34 |
# File 'lib/gd2/canvas.rb', line 32 def draw(image, mode) image.set_pixel(@x, @y, mode) end |
#transform(matrix) ⇒ Object
28 29 30 |
# File 'lib/gd2/canvas.rb', line 28 def transform(matrix) dup.transform!(matrix) end |
#transform!(matrix) ⇒ Object
23 24 25 26 |
# File 'lib/gd2/canvas.rb', line 23 def transform!(matrix) @x, @y = (Matrix.row_vector([@x, @y, 1]) * matrix)[0, 0..1] self end |