Class: Teacup::TransformView

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

Instance Method Summary collapse

Instance Method Details

#identityObject



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

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

#rotate(angle) ⇒ Object

Rotates the view counterclockwise



62
63
64
# File 'lib/teacup/stylesheet_extensions/transform.rb', line 62

def rotate angle
  CGAffineTransformMakeRotation(angle)
end

#scale(scale_x, scale_y = nil) ⇒ Object

Scales the view



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

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



73
74
75
76
77
78
79
80
81
82
83
84
# File 'lib/teacup/stylesheet_extensions/transform.rb', line 73

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