purplish-frame 0.0.4 → 0.0.5
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.gitignore +1 -0
- data/README.md +22 -15
- data/lib/purplish-frame/non-ui/cg_rect.rb +4 -0
- data/lib/purplish-frame/non-ui/osx/ns_rect.rb +4 -0
- data/lib/purplish-frame/ui/view.rb +4 -0
- data/lib/purplish-frame/version.rb +1 -1
- data/spec/non-ui/cg_rect_spec.rb +6 -0
- data/spec/non-ui/osx/ns_rect_spec.rb +10 -0
- data/spec/ui/ios/ui_view_spec.rb +34 -9
- data/spec/ui/osx/ns_view_spec.rb +43 -0
- metadata +4 -3
- data/Gemfile.lock +0 -14
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 620ee6f6ae016e428618a81f1d44ba6d8f72985b
|
4
|
+
data.tar.gz: 759de6822bda48e2b1a0eea47ad4534fd563168d
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 5761348b7fec5d0dc1635b876b1379cb4971a178a530ea724930feb85be558d8ce0afca47ac39526961a289089e196c79c72cfdbc3978b63d87d3c012e5aaf7d
|
7
|
+
data.tar.gz: 86a7b65265ceee3365c406d970d65e07ef52163d800261416325d8dfdef7613fd8c788a25fce8cc6ecf4d59e4fac8be883d8f489407c218b8d74bfd90311c6f8
|
data/.gitignore
CHANGED
data/README.md
CHANGED
@@ -5,45 +5,52 @@ Usage
|
|
5
5
|
For iOS & OS X:
|
6
6
|
|
7
7
|
```ruby
|
8
|
-
rect =
|
8
|
+
rect = CGRectMake(10, -20, 100, 100)
|
9
9
|
rect.left
|
10
|
-
#10
|
10
|
+
=> #10
|
11
11
|
rect.right
|
12
|
-
#110
|
12
|
+
=> #110
|
13
13
|
rect.top
|
14
|
-
#-20
|
14
|
+
=> #-20
|
15
15
|
rect.bottom
|
16
|
-
#80
|
16
|
+
=> #80
|
17
17
|
rect.width
|
18
|
-
#100
|
18
|
+
=> #100
|
19
19
|
rect.height
|
20
|
-
#100
|
20
|
+
=> #100
|
21
21
|
rect.center_x
|
22
|
-
#60
|
22
|
+
=> #60
|
23
23
|
rect.center_y
|
24
|
-
#30
|
24
|
+
=> #30
|
25
25
|
```
|
26
26
|
|
27
27
|
Similar usage for UIView for iOS and NSView, NSSize, NSPoint, NSRect for OS X.
|
28
28
|
|
29
|
+
```ruby
|
30
|
+
rect = CGRectMake(10, -20, 100, 100)
|
31
|
+
rect.inset(5, 20)
|
32
|
+
=> #<CGRect origin=#<CGPoint x=15.0 y=0.0> size=#<CGSize width=90.0 height=60.0>>
|
33
|
+
```
|
34
|
+
Similar usage for UIView for iOS and NSView, NSRect for OS X.
|
35
|
+
|
29
36
|
```ruby
|
30
37
|
CGSize.new(100, 100).scale_to_fit(CGSize.new(10, 10))
|
31
|
-
|
38
|
+
=> #<CGSize width=10.0 height=10>
|
32
39
|
|
33
40
|
CGSize.new(200, 100).scale_to_fill(CGSize.new(15, 15))
|
34
|
-
|
41
|
+
=> #<CGSize width=30 height=15>
|
35
42
|
|
36
43
|
CGSize.new(100, 100).scale_to_fit!
|
37
44
|
CGSize.new(200, 100).scale_to_fill!
|
38
45
|
|
39
46
|
CGPoint.new(100, 200)*10
|
40
|
-
|
47
|
+
=> #<CGPoint x=1000 y=2000>
|
41
48
|
|
42
49
|
CGPoint.new(100, 200)/10
|
43
|
-
|
50
|
+
=> #<CGPoint x=10 y=20>
|
44
51
|
|
45
|
-
|
46
|
-
|
52
|
+
CGRectMake(10, 20, 100, 100).scale(10)
|
53
|
+
=> #<CGRect origin=#<CGPoint x=100.0 y=200.0> size=#<CGSize width=1000.0 height=1000.0>>
|
47
54
|
```
|
48
55
|
|
49
56
|
Similar usage for NSSize, NSPoint, NSRect on OS X.
|
data/spec/non-ui/cg_rect_spec.rb
CHANGED
@@ -28,4 +28,10 @@ describe "Rects" do
|
|
28
28
|
rect.center_y.should.equal 30
|
29
29
|
end
|
30
30
|
|
31
|
+
it "Insets" do
|
32
|
+
rect = CGRectMake(10, -20, 100, 100)
|
33
|
+
rect.inset(10, 10).should.close CGRectMake(20, -10, 80, 80), delta
|
34
|
+
rect.inset(5, 20).should.close CGRectMake(15, 0, 90, 60), delta
|
35
|
+
rect.inset(-5, -20).should.close CGRectMake(5, -40, 110, 140), delta
|
36
|
+
end
|
31
37
|
end
|
@@ -6,6 +6,8 @@ end
|
|
6
6
|
|
7
7
|
if PurplishFrame.osx?
|
8
8
|
describe "Rects" do
|
9
|
+
delta = 0.0001
|
10
|
+
|
9
11
|
it "NSRect sides" do
|
10
12
|
#Careful not to use NSMakeRect(). Somehow, it creates a CGRect instead
|
11
13
|
rect = NSRect.new([10, -20], [100, 100])
|
@@ -18,5 +20,13 @@ if PurplishFrame.osx?
|
|
18
20
|
rect.center_x.should.equal 60
|
19
21
|
rect.center_y.should.equal 30
|
20
22
|
end
|
23
|
+
|
24
|
+
it "Insets" do
|
25
|
+
#Careful not to use NSMakeRect(). Somehow, it creates a CGRect instead
|
26
|
+
rect = NSRect.new([10, -20], [100, 100])
|
27
|
+
rect.inset(10, 10).should.close NSRect.new([20, -10], [80, 80]), delta
|
28
|
+
rect.inset(5, 20).should.close NSRect.new([15, 0], [90, 60]), delta
|
29
|
+
rect.inset(-5, -20).should.close NSRect.new([5, -40], [110, 140]), delta
|
30
|
+
end
|
21
31
|
end
|
22
32
|
end
|
data/spec/ui/ios/ui_view_spec.rb
CHANGED
@@ -1,15 +1,40 @@
|
|
1
1
|
if PurplishFrame.ios?
|
2
|
+
class CGRect
|
3
|
+
def close?(to, delta)
|
4
|
+
origin.x.close?(to.origin.x, delta) && origin.y.close?(to.origin.y, delta) && size.width.close?(to.size.width, delta) && size.height.close?(to.size.height, delta)
|
5
|
+
end
|
6
|
+
end
|
7
|
+
|
2
8
|
describe "UIView" do
|
9
|
+
delta = 0.0001
|
10
|
+
before do
|
11
|
+
@v = UIView.alloc.initWithFrame([[10, 20], [100, 200]])
|
12
|
+
end
|
13
|
+
|
3
14
|
it "Accessing" do
|
4
|
-
v
|
5
|
-
v.
|
6
|
-
v.
|
7
|
-
v.
|
8
|
-
v.
|
9
|
-
v.
|
10
|
-
v.
|
11
|
-
v.
|
12
|
-
|
15
|
+
@v.left.should.equal 10
|
16
|
+
@v.right.should.equal 110
|
17
|
+
@v.top.should.equal 20
|
18
|
+
@v.bottom.should.equal 220
|
19
|
+
@v.center_x.should.equal 60
|
20
|
+
@v.center_y.should.equal 120
|
21
|
+
@v.width.should.equal 100
|
22
|
+
@v.height.should.equal 200
|
23
|
+
end
|
24
|
+
|
25
|
+
it "Insets" do
|
26
|
+
@v.inset!(10, 10)
|
27
|
+
@v.frame.should.close CGRectMake(20, 30, 80, 180), delta
|
28
|
+
end
|
29
|
+
|
30
|
+
it "Insets" do
|
31
|
+
@v.inset!(5, 20)
|
32
|
+
@v.frame.should.close CGRectMake(15, 40, 90, 160), delta
|
33
|
+
end
|
34
|
+
|
35
|
+
it "Insets" do
|
36
|
+
@v.inset!(-5, -20)
|
37
|
+
@v.frame.should.close CGRectMake(5, 0, 110, 240), delta
|
13
38
|
end
|
14
39
|
end
|
15
40
|
end
|
@@ -0,0 +1,43 @@
|
|
1
|
+
if PurplishFrame.osx?
|
2
|
+
class CGRect
|
3
|
+
def close?(to, delta)
|
4
|
+
origin.x.close?(to.origin.x, delta) && origin.y.close?(to.origin.y, delta) && size.width.close?(to.size.width, delta) && size.height.close?(to.size.height, delta)
|
5
|
+
end
|
6
|
+
end
|
7
|
+
|
8
|
+
describe "NSView" do
|
9
|
+
delta = 0.0001
|
10
|
+
before do
|
11
|
+
@v = NSView.alloc.initWithFrame([[10, 20], [100, 200]])
|
12
|
+
end
|
13
|
+
|
14
|
+
it "Accessing" do
|
15
|
+
@v.left.should.equal 10
|
16
|
+
@v.right.should.equal 110
|
17
|
+
@v.top.should.equal 220
|
18
|
+
@v.bottom.should.equal 20
|
19
|
+
@v.center_x.should.equal 60
|
20
|
+
@v.center_y.should.equal 120
|
21
|
+
@v.width.should.equal 100
|
22
|
+
@v.height.should.equal 200
|
23
|
+
end
|
24
|
+
|
25
|
+
it "Insets" do
|
26
|
+
#Returns CGRect!
|
27
|
+
@v.inset!(10, 10)
|
28
|
+
@v.frame.should.close CGRectMake(20, 30, 80, 180), delta
|
29
|
+
end
|
30
|
+
|
31
|
+
it "Insets" do
|
32
|
+
#Returns CGRect!
|
33
|
+
@v.inset!(5, 20)
|
34
|
+
@v.frame.should.close CGRectMake(15, 40, 90, 160), delta
|
35
|
+
end
|
36
|
+
|
37
|
+
it "Insets" do
|
38
|
+
#Returns CGRect!
|
39
|
+
@v.inset!(-5, -20)
|
40
|
+
@v.frame.should.close CGRectMake(5, 0, 110, 240), delta
|
41
|
+
end
|
42
|
+
end
|
43
|
+
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: purplish-frame
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.5
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Hwee-Boon Yar
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2015-12-
|
11
|
+
date: 2015-12-12 00:00:00.000000000 Z
|
12
12
|
dependencies: []
|
13
13
|
description: Make working with rects, sizes and points more convenient with RubyMotion
|
14
14
|
for iOS & OS X
|
@@ -19,7 +19,6 @@ extra_rdoc_files: []
|
|
19
19
|
files:
|
20
20
|
- ".gitignore"
|
21
21
|
- Gemfile
|
22
|
-
- Gemfile.lock
|
23
22
|
- LICENSE
|
24
23
|
- README.md
|
25
24
|
- Rakefile
|
@@ -56,6 +55,7 @@ files:
|
|
56
55
|
- spec/ui/ios/ui_screen_spec.rb
|
57
56
|
- spec/ui/ios/ui_view_spec.rb
|
58
57
|
- spec/ui/osx/ns_screen_spec.rb
|
58
|
+
- spec/ui/osx/ns_view_spec.rb
|
59
59
|
homepage: https://github.com/hboon/purplish-frame
|
60
60
|
licenses:
|
61
61
|
- BSD
|
@@ -91,4 +91,5 @@ test_files:
|
|
91
91
|
- spec/ui/ios/ui_screen_spec.rb
|
92
92
|
- spec/ui/ios/ui_view_spec.rb
|
93
93
|
- spec/ui/osx/ns_screen_spec.rb
|
94
|
+
- spec/ui/osx/ns_view_spec.rb
|
94
95
|
has_rdoc:
|