Class: Rubyvis::Transform

Inherits:
Object show all
Defined in:
lib/rubyvis/transform.rb

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initializeTransform

Returns a new instance of Transform.



7
8
9
10
11
# File 'lib/rubyvis/transform.rb', line 7

def initialize
  @k=1
  @x=0
  @y=0
end

Instance Attribute Details

#kObject

Returns the value of attribute k.



6
7
8
# File 'lib/rubyvis/transform.rb', line 6

def k
  @k
end

#xObject

Returns the value of attribute x.



6
7
8
# File 'lib/rubyvis/transform.rb', line 6

def x
  @x
end

#yObject

Returns the value of attribute y.



6
7
8
# File 'lib/rubyvis/transform.rb', line 6

def y
  @y
end

Class Method Details

.identityObject



20
21
22
# File 'lib/rubyvis/transform.rb', line 20

def self.identity
  Transform.new
end

Instance Method Details

#translate(x, y) ⇒ Object



12
13
14
15
16
17
18
19
# File 'lib/rubyvis/transform.rb', line 12

def translate(x,y)
  v=Transform.new
  v.k=self.k
  v.x=self.k*x+self.x
  v.y=self.k*y+self.y
  v

end