Class: Teacup::TransformView

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

Instance Method Summary collapse

Instance Method Details

#identityObject



77
78
79
# File 'lib/teacup/stylesheet_extensions/transform.rb', line 77

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

#rotate(angle) ⇒ Object

Rotates the view counterclockwise



82
83
84
# File 'lib/teacup/stylesheet_extensions/transform.rb', line 82

def rotate angle
  CGAffineTransformMakeRotation(angle)
end

#scale(scale_x, scale_y = nil) ⇒ Object

Scales the view



87
88
89
90
# File 'lib/teacup/stylesheet_extensions/transform.rb', line 87

def scale scale_x, scale_y=nil
  scale_y ||= scale_x
  CGAffineTransformMakeScale(scale_x, scale_y)
end

#translate(point, y = nil) ⇒ Object

Translates the view



93
94
95
96
97
98
99
100
101
102
103
104
# File 'lib/teacup/stylesheet_extensions/transform.rb', line 93

def translate point, y=nil
  if point.respond_to?(:x) &&point.respond_to?(:y)
    x = point.x
    y = point.y
  elsif point.is_a? Array
    x = point[0]
    y = point[1]
  else
    x = point
  end
  CGAffineTransformMakeTranslation(x, y)
end