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.



52
53
54
# File 'lib/teacup/stylesheet_extensions/transform.rb', line 52

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

#identityObject



46
47
48
# File 'lib/teacup/stylesheet_extensions/transform.rb', line 46

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



69
70
71
# File 'lib/teacup/stylesheet_extensions/transform.rb', line 69

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.



64
65
66
# File 'lib/teacup/stylesheet_extensions/transform.rb', line 64

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.



58
59
60
# File 'lib/teacup/stylesheet_extensions/transform.rb', line 58

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