Class: Vector2

Inherits:
Object
  • Object
show all
Defined in:
lib/sparkle_motion/vector2.rb

Overview

TODO: Namespacing! A 2-component vector, where components go from 0.0..1.0.

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(x: 0.0, y: 0.0) ⇒ Vector2

Returns a new instance of Vector2.



5
6
7
8
# File 'lib/sparkle_motion/vector2.rb', line 5

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

Instance Attribute Details

#xObject (readonly)

Returns the value of attribute x.



4
5
6
# File 'lib/sparkle_motion/vector2.rb', line 4

def x
  @x
end

#yObject (readonly)

Returns the value of attribute y.



4
5
6
# File 'lib/sparkle_motion/vector2.rb', line 4

def y
  @y
end

Instance Method Details

#to_sObject



10
# File 'lib/sparkle_motion/vector2.rb', line 10

def to_s; "<<#{@x}, #{@y}>>"; end