Class: Teacup::TransformLayer

Inherits:
Object
  • Object
show all
Defined in:
lib/teacup/stylesheet_extensions/transform.rb

Instance Method Summary collapse

Instance Method Details

#flip(angle) ⇒ Object

rotates the “up & down” direction. The bottom of the view will rotate towards the user as angle increases.



32
33
34
# File 'lib/teacup/stylesheet_extensions/transform.rb', line 32

def flip(angle)
  CATransform3DRotate(identity, angle, 1, 0, 0)
end

#identityObject



26
27
28
# File 'lib/teacup/stylesheet_extensions/transform.rb', line 26

def identity
  [1,0,0,0, 0,1,0,0, 0,0,1,0, 0,0,0,1]
end

#rotate(angle, x, y, z) ⇒ Object

rotates the layer arbitrarily



49
50
51
# File 'lib/teacup/stylesheet_extensions/transform.rb', line 49

def rotate(angle, x, y, z)
  CATransform3DRotate(identity, angle, x, y, z)
end

#spin(angle) ⇒ Object

spins, along the z axis. This is probably the one you want, for “spinning” a view like you might a drink coaster or paper napkin.



44
45
46
# File 'lib/teacup/stylesheet_extensions/transform.rb', line 44

def spin(angle)
  CATransform3DRotate(identity, angle, 0, 0, 1)
end

#twist(angle) ⇒ Object

rotates the “left & right” direction. The right side of the view will rotate towards the user as angle increases.



38
39
40
# File 'lib/teacup/stylesheet_extensions/transform.rb', line 38

def twist(angle)
  CATransform3DRotate(identity, angle, 0, 1, 0)
end