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.
34 35 36 |
# File 'lib/gd2/canvas.rb', line 34 def initialize(x, y) @x, @y = x, y end |
Instance Attribute Details
#x ⇒ Object (readonly)
Returns the value of attribute x.
32 33 34 |
# File 'lib/gd2/canvas.rb', line 32 def x @x end |
#y ⇒ Object (readonly)
Returns the value of attribute y.
32 33 34 |
# File 'lib/gd2/canvas.rb', line 32 def y @y end |
Instance Method Details
#coordinates ⇒ Object
38 39 40 |
# File 'lib/gd2/canvas.rb', line 38 def coordinates [@x, @y] end |
#draw(image, mode) ⇒ Object
51 52 53 |
# File 'lib/gd2/canvas.rb', line 51 def draw(image, mode) image.set_pixel(@x, @y, mode) end |
#transform(matrix) ⇒ Object
47 48 49 |
# File 'lib/gd2/canvas.rb', line 47 def transform(matrix) dup.transform!(matrix) end |
#transform!(matrix) ⇒ Object
42 43 44 45 |
# File 'lib/gd2/canvas.rb', line 42 def transform!(matrix) @x, @y = (Matrix.row_vector([@x, @y, 1]) * matrix)[0, 0..1] self end |