Class: CGAffineTransform
- Inherits:
-
Object
- Object
- CGAffineTransform
- Defined in:
- lib/motion-ui-geometry/cgaffinetransform.rb
Class Method Summary collapse
- .identity ⇒ Object
- .rotation(angle_in_rad) ⇒ Object
- .scale(sx, sy = nil) ⇒ Object
- .skew(sx, sy) ⇒ Object
- .translation(tx, ty) ⇒ Object
Instance Method Summary collapse
- #*(other) ⇒ Object
- #+(other) ⇒ Object
- #-(other) ⇒ Object
- #-@ ⇒ Object
- #/(other) ⇒ Object
- #==(other) ⇒ Object
- #=~(other) ⇒ Object
- #apply_on(other) ⇒ Object
- #concat(other) ⇒ Object
- #det ⇒ Object
- #identity? ⇒ Boolean
-
#initialize(a, b, c, d, tx, ty) ⇒ CGAffineTransform
constructor
A new instance of CGAffineTransform.
- #invert ⇒ Object (also: #inverse)
- #rotate(angle_in_rad) ⇒ Object
- #scale(sx, sy = nil) ⇒ Object
- #skew(sx, sy) ⇒ Object
- #to_s ⇒ Object
- #to_value ⇒ Object
- #translate(tx, ty) ⇒ Object
Constructor Details
#initialize(a, b, c, d, tx, ty) ⇒ CGAffineTransform
Returns a new instance of CGAffineTransform.
3 4 5 |
# File 'lib/motion-ui-geometry/cgaffinetransform.rb', line 3 def initialize(a, b, c, d, tx, ty) CGAffineTransformMake(a, b, c, d, tx, ty) end |
Class Method Details
.identity ⇒ Object
8 9 10 |
# File 'lib/motion-ui-geometry/cgaffinetransform.rb', line 8 def self.identity CGAffineTransformIdentity end |
.rotation(angle_in_rad) ⇒ Object
12 13 14 |
# File 'lib/motion-ui-geometry/cgaffinetransform.rb', line 12 def self.rotation(angle_in_rad) CGAffineTransformMakeRotation(angle_in_rad) end |
.scale(sx, sy = nil) ⇒ Object
16 17 18 |
# File 'lib/motion-ui-geometry/cgaffinetransform.rb', line 16 def self.scale(sx, sy = nil) CGAffineTransformMakeScale(sx, sy || sx) end |
.skew(sx, sy) ⇒ Object
24 25 26 |
# File 'lib/motion-ui-geometry/cgaffinetransform.rb', line 24 def self.skew(sx, sy) CGAffineTransformMake 1.0, sy, sx, 1.0, 0.0, 0.0 end |
.translation(tx, ty) ⇒ Object
20 21 22 |
# File 'lib/motion-ui-geometry/cgaffinetransform.rb', line 20 def self.translation(tx, ty) CGAffineTransformMakeTranslation(tx, ty) end |
Instance Method Details
#*(other) ⇒ Object
98 99 100 101 102 103 104 105 106 107 108 |
# File 'lib/motion-ui-geometry/cgaffinetransform.rb', line 98 def *(other) case other when Float, Fixnum scale other, other when CGAffineTransform concat other else raise TypeError, "Right operand for * must be Fixnum, "\ "Float or CGAffineTransform (got #{other.class})." end end |
#+(other) ⇒ Object
78 79 80 81 82 83 84 85 86 87 88 |
# File 'lib/motion-ui-geometry/cgaffinetransform.rb', line 78 def +(other) case other when CGSize translate other.width, other.height when CGPoint translate other.x, other.y else raise TypeError, "Right operand for + and - must be "\ "CGSize or CGPoint (got #{other.class})." end end |
#-(other) ⇒ Object
90 91 92 |
# File 'lib/motion-ui-geometry/cgaffinetransform.rb', line 90 def -(other) self + (-other) end |
#-@ ⇒ Object
94 95 96 |
# File 'lib/motion-ui-geometry/cgaffinetransform.rb', line 94 def -@ invert end |
#/(other) ⇒ Object
110 111 112 113 114 115 116 117 118 119 120 |
# File 'lib/motion-ui-geometry/cgaffinetransform.rb', line 110 def /(other) case other when Float, Fixnum scale 1.0/other, 1.0/other when CGAffineTransform concat other.inverse else raise TypeError, "Right operand for / must be Fixnum, "\ "Float or CGAffineTransform (got #{other.class})." end end |
#==(other) ⇒ Object
60 61 62 |
# File 'lib/motion-ui-geometry/cgaffinetransform.rb', line 60 def ==(other) other.is_a?(CGAffineTransform) && CGAffineTransformEqualToTransform(self, other) end |
#=~(other) ⇒ Object
64 65 66 67 68 69 70 71 72 73 74 75 |
# File 'lib/motion-ui-geometry/cgaffinetransform.rb', line 64 def =~(other) unless other.is_a? CGAffineTransform raise TypeError, "Right operand for =~ must be a CGAffineTransform (got #{other})." end a =~ other.a && b =~ other.b && c =~ other.c && d =~ other.d && tx =~ other.tx && ty =~ other.ty end |
#apply_on(other) ⇒ Object
55 56 57 |
# File 'lib/motion-ui-geometry/cgaffinetransform.rb', line 55 def apply_on(other) other.concat self end |
#concat(other) ⇒ Object
51 52 53 |
# File 'lib/motion-ui-geometry/cgaffinetransform.rb', line 51 def concat(other) CGAffineTransformConcat self, other end |
#det ⇒ Object
123 124 125 |
# File 'lib/motion-ui-geometry/cgaffinetransform.rb', line 123 def det a * d - b * c end |
#identity? ⇒ Boolean
128 129 130 |
# File 'lib/motion-ui-geometry/cgaffinetransform.rb', line 128 def identity? CGAffineTransformIsIdentity self end |
#invert ⇒ Object Also known as: inverse
46 47 48 |
# File 'lib/motion-ui-geometry/cgaffinetransform.rb', line 46 def invert CGAffineTransformInvert self end |
#rotate(angle_in_rad) ⇒ Object
37 38 39 |
# File 'lib/motion-ui-geometry/cgaffinetransform.rb', line 37 def rotate(angle_in_rad) CGAffineTransformRotate(self, angle_in_rad) end |
#scale(sx, sy = nil) ⇒ Object
33 34 35 |
# File 'lib/motion-ui-geometry/cgaffinetransform.rb', line 33 def scale(sx, sy = nil) CGAffineTransformScale(self, sx, sy || sx) end |
#skew(sx, sy) ⇒ Object
41 42 43 |
# File 'lib/motion-ui-geometry/cgaffinetransform.rb', line 41 def skew(sx, sy) self * self.class.skew(sx, sy) end |
#to_s ⇒ Object
137 138 139 |
# File 'lib/motion-ui-geometry/cgaffinetransform.rb', line 137 def to_s NSStringFromCGAffineTransform self end |
#to_value ⇒ Object
133 134 135 |
# File 'lib/motion-ui-geometry/cgaffinetransform.rb', line 133 def to_value NSValue.valueWithCGAffineTransform self end |
#translate(tx, ty) ⇒ Object
29 30 31 |
# File 'lib/motion-ui-geometry/cgaffinetransform.rb', line 29 def translate(tx, ty) CGAffineTransformTranslate(self, tx, ty) end |