sugarcube 1.5.1 → 1.5.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 6716fc5629e9a81b77ea3b82a3ad2b17ca33bef3
4
- data.tar.gz: 8a3117abdb7192610107153219896869399ae9d7
3
+ metadata.gz: bcbd6cc3b891a5629f4076ad76609dd7c5dbc77d
4
+ data.tar.gz: 58279eb857e9af976a24349e1d61d1f1f0e6f392
5
5
  SHA512:
6
- metadata.gz: 64dd9520c3f692e884870bb9071271e1e4886f2e685b90c1cab63b984735af6857d783c224d9474180f18280e84fa9c3df5b27bb8c8c05158fabe62af088da5a
7
- data.tar.gz: 8bc745f50a2b2f29a87f6b7c7caadfe8a854cf79ec971095f01baa81c0de05c8529dd68145863336b238509f8079727746b44c425608348d4e348ece8efc2e56
6
+ metadata.gz: 684329a0721adf33fcc0b5c8fee70af989e1fc3a7cc07607335a8766f6b93ee5e44aa7331fb2ed19ae2b050b6f09066fc51389c0b6e2a1b8d0a3dd414fd2504f
7
+ data.tar.gz: 14fc25bc8e77d8580442921ef792ba40311aa761ff75c26d191514abcfe16cc396a187ca62b6886c97d8474d697f3b588cd18d8cf04a5837a9c98d15439e5073
data/.gitignore CHANGED
@@ -2,3 +2,4 @@ pkg/
2
2
  *.gem
3
3
  .DS_Store
4
4
  /build/
5
+ .idea/
data/Gemfile.lock CHANGED
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- sugarcube (1.5.1)
4
+ sugarcube (1.5.2)
5
5
 
6
6
  GEM
7
7
  remote: https://rubygems.org/
data/README.md CHANGED
@@ -857,6 +857,11 @@ Animations ([wiki][Animations Wiki])
857
857
  Careful, once you start using these helpers, you'll never go back.
858
858
 
859
859
  ```ruby
860
+ view.move_to [100.0, 100.0] # origin
861
+ view.center_to [100.0, 100.0] # center
862
+ view.scale_to 2 # double the size, and preserves existing rotation transform
863
+ # view.scale_to 4 -> CGAffineTransformMakeScale(4, 4)
864
+ # view.scale_to [4, 3] -> CGAffineTransformMakeScale(4, 3)
860
865
  view.fade_out
861
866
  view.slide :left, 100
862
867
  view.rotate_to 180.degrees
@@ -183,6 +183,41 @@ class UIView
183
183
  fade_out(options, &after_remove)
184
184
  end
185
185
 
186
+ def scale_to(scale, options={}, more_options={}, &after)
187
+ if options.is_a? Numeric
188
+ options = more_options.merge(duration: options)
189
+ end
190
+
191
+ if scale.is_a?(Numeric)
192
+ scale_x = scale_y = scale
193
+ else # this could be an array, or CGSize; either way we'll use []
194
+ scale_x = scale[0]
195
+ scale_y = scale[1]
196
+ end
197
+
198
+ options[:after] = after
199
+
200
+ animate(options) {
201
+ radians = Math.atan2(self.transform.b, self.transform.a)
202
+ # radians = self.valueForKeyPath('layer.transform.rotation.z')
203
+ rotation_t = CGAffineTransformMakeRotation(radians)
204
+ scale_t = CGAffineTransformMakeScale(scale_x, scale_y)
205
+ self.transform = CGAffineTransformConcat(rotation_t, scale_t)
206
+ }
207
+ end
208
+
209
+ def center_to(center, options={}, more_options={}, &after)
210
+ if options.is_a? Numeric
211
+ options = more_options.merge(duration: options)
212
+ end
213
+
214
+ options[:after] = after
215
+
216
+ animate(options) {
217
+ self.center = SugarCube::CoreGraphics::Point(center)
218
+ }
219
+ end
220
+
186
221
  def move_to(position, options={}, more_options={}, &after)
187
222
  if options.is_a? Numeric
188
223
  options = more_options.merge(duration: options)
@@ -1,3 +1,3 @@
1
1
  module SugarCube
2
- Version = '1.5.1'
2
+ Version = '1.5.2'
3
3
  end
@@ -11,7 +11,7 @@ describe "UIView animation methods" do
11
11
  @view.resize_to([5,6]).frame.should == CGRectMake(1,2,5,6)
12
12
  end
13
13
 
14
- it 'should reframe_to ' do
14
+ it 'should reframe_to x:2 y:4 w:5 h:6' do
15
15
  @view.reframe_to([[2,4],[5,6]]).frame.should == CGRectMake(2,4,5,6)
16
16
  end
17
17
 
@@ -19,6 +19,32 @@ describe "UIView animation methods" do
19
19
  @view.move_to([2,4]).frame.should == CGRectMake(2,4,3,4)
20
20
  end
21
21
 
22
+ it 'should center_to x:2 y:4' do
23
+ @view.center_to([2,4]).center.should == CGPointMake(2,4)
24
+ end
25
+
26
+ it 'should scale to 4' do
27
+ radians = Math.atan2(@view.transform.b,
28
+ @view.transform.a)
29
+ new_view = @view.scale_to(4)
30
+ new_radians = Math.atan2(new_view.transform.b,
31
+ new_view.transform.a)
32
+ radians.should == new_radians
33
+ new_view.transform.a.should == 4.to_f
34
+ new_view.transform.d.should == 4.to_f
35
+ end
36
+
37
+ it 'should scale to x:4 y:3' do
38
+ radians = Math.atan2(@view.transform.b,
39
+ @view.transform.a)
40
+ new_view = @view.scale_to([4, 3])
41
+ new_radians = Math.atan2(new_view.transform.b,
42
+ new_view.transform.a)
43
+ radians.should == new_radians
44
+ new_view.transform.a.should == 4.to_f
45
+ new_view.transform.d.should == 3.to_f
46
+ end
47
+
22
48
  it 'should rotate 45 degrees' do
23
49
  angle = 45.degrees
24
50
  @view.rotate_to(angle)
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: sugarcube
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.5.1
4
+ version: 1.5.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Colin T.A. Gray
@@ -11,7 +11,7 @@ authors:
11
11
  autorequire:
12
12
  bindir: bin
13
13
  cert_chain: []
14
- date: 2014-03-03 00:00:00.000000000 Z
14
+ date: 2014-03-04 00:00:00.000000000 Z
15
15
  dependencies: []
16
16
  description: |
17
17
  == Description