geomotion 0.13.1 → 0.13.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.
- data/README.md +1 -0
- data/lib/geomotion/cg_point.rb +2 -0
- data/lib/geomotion/cg_rect.rb +205 -108
- data/lib/geomotion/version.rb +1 -1
- data/spec/cg_point_spec.rb +5 -0
- data/spec/cg_rect_spec.rb +92 -3
- metadata +5 -10
data/README.md
CHANGED
data/lib/geomotion/cg_point.rb
CHANGED
data/lib/geomotion/cg_rect.rb
CHANGED
@@ -1,76 +1,79 @@
|
|
1
1
|
class CGRect
|
2
2
|
|
3
|
-
|
4
|
-
#
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
3
|
+
class << self
|
4
|
+
# CGRect.make # default rect: {origin: {x: 0, y: 0}, size: {width:0, height:0}}
|
5
|
+
# # aka CGRectZero
|
6
|
+
# CGRect.make(x: 10, y: 30) # default size: [0, 0]
|
7
|
+
# CGRect.make(x: 10, y: 30, width:100, height: 20)
|
8
|
+
#
|
9
|
+
# point = CGPoint.make(x: 10, y: 30)
|
10
|
+
# size = CGSize.make(width: 100, height: 20)
|
11
|
+
# CGRect.make(origin: point, size: size)
|
12
|
+
def make(options = {})
|
13
|
+
if options[:origin]
|
14
|
+
x = options[:origin][0]
|
15
|
+
y = options[:origin][1]
|
16
|
+
else
|
17
|
+
x = options[:x] || 0
|
18
|
+
y = options[:y] || 0
|
19
|
+
end
|
20
|
+
if options[:size]
|
21
|
+
w = options[:size][0]
|
22
|
+
h = options[:size][1]
|
23
|
+
else
|
24
|
+
w = options[:width] || 0
|
25
|
+
h = options[:height] || 0
|
26
|
+
end
|
27
|
+
self.new([x, y], [w, h])
|
18
28
|
end
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
else
|
23
|
-
w = options[:width] || 0
|
24
|
-
h = options[:height] || 0
|
29
|
+
|
30
|
+
def zero
|
31
|
+
CGRect.new([0, 0], [0, 0])
|
25
32
|
end
|
26
|
-
|
27
|
-
end
|
33
|
+
alias empty zero
|
28
34
|
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
|
35
|
+
def null
|
36
|
+
# Don't just return CGRectNull; can be mutated
|
37
|
+
CGRect.new([Float::INFINITY, Float::INFINITY], [0, 0])
|
38
|
+
end
|
33
39
|
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
-
|
40
|
+
def infinite
|
41
|
+
# This actually returns the not-very-infinite value of:
|
42
|
+
# [[-1.7014114289565e+38, -1.7014114289565e+38], [3.402822857913e+38, 3.402822857913e+38]]
|
43
|
+
# originally this method returned [[-Infinity, -Infinity], [Infinity, Infinity]],
|
44
|
+
# but that rect ended up returning `false` for any point in the method
|
45
|
+
# CGRect.infinite.contains?(point). CGRectInfinite returns `true` for any
|
46
|
+
# (sensible) point, so we'll go with that instead
|
47
|
+
CGRectInfinite.dup
|
48
|
+
end
|
38
49
|
|
39
|
-
|
40
|
-
#
|
41
|
-
#
|
42
|
-
|
43
|
-
|
44
|
-
|
45
|
-
|
46
|
-
|
47
|
-
end
|
50
|
+
# OPTIONS: [:above, :below, :left_of, :right_of, :margins]
|
51
|
+
# :margins is array of [top, right, bottom, left]
|
52
|
+
# EX CGRect.layout(rect1, above: rect2, left_of: rect3, margins: [0, 10, 20, 0])
|
53
|
+
def layout(rect1, options)
|
54
|
+
if options.empty?
|
55
|
+
p "No options provided in #{self.class}.layout"
|
56
|
+
return rect1
|
57
|
+
end
|
48
58
|
|
49
|
-
|
50
|
-
|
51
|
-
# EX CGRect.layout(rect1, above: rect2, left_of: rect3, margins: [0, 10, 20, 0])
|
52
|
-
def self.layout(rect1, options)
|
53
|
-
if options.empty?
|
54
|
-
p "No options provided in #{self.class}.layout"
|
55
|
-
return rect1
|
56
|
-
end
|
59
|
+
rect = self.new
|
60
|
+
rect.size = rect1.size
|
57
61
|
|
58
|
-
|
59
|
-
|
62
|
+
options[:margins] ||= []
|
63
|
+
margins = {}
|
64
|
+
[:top, :right, :bottom, :left].each_with_index do |margin, index|
|
65
|
+
margins[margin] = options[:margins][index] || 0
|
66
|
+
end
|
60
67
|
|
61
|
-
|
62
|
-
|
63
|
-
[:top, :right, :bottom, :left].each_with_index do |margin, index|
|
64
|
-
margins[margin] = options[:margins][index] || 0
|
65
|
-
end
|
68
|
+
rect.y = options[:above].up(rect.height + margins[:bottom]).y if options[:above]
|
69
|
+
rect.y = options[:below].below(margins[:top]).y if options[:below]
|
66
70
|
|
67
|
-
|
68
|
-
|
71
|
+
rect.x = options[:left_of].left(rect.width + margins[:right]).x if options[:left_of]
|
72
|
+
rect.x = options[:right_of].beside(margins[:left]).x if options[:right_of]
|
69
73
|
|
70
|
-
|
71
|
-
|
74
|
+
rect
|
75
|
+
end
|
72
76
|
|
73
|
-
rect
|
74
77
|
end
|
75
78
|
|
76
79
|
# bounds
|
@@ -99,44 +102,60 @@ class CGRect
|
|
99
102
|
end
|
100
103
|
|
101
104
|
# getters/setters
|
102
|
-
def x(setter =
|
105
|
+
def x(setter=nil, options=nil)
|
103
106
|
if setter
|
104
|
-
|
107
|
+
rect = CGRect.new([setter, self.origin.y], self.size)
|
108
|
+
if options
|
109
|
+
return rect.apply(options)
|
110
|
+
end
|
111
|
+
return rect
|
105
112
|
end
|
106
|
-
min_x
|
113
|
+
return min_x
|
107
114
|
end
|
108
115
|
|
109
116
|
def x=(_x)
|
110
117
|
self.origin.x = _x
|
111
118
|
end
|
112
119
|
|
113
|
-
def y(setter =
|
120
|
+
def y(setter=nil, options=nil)
|
114
121
|
if setter
|
115
|
-
|
122
|
+
rect = CGRect.new([self.origin.x, setter], self.size)
|
123
|
+
if options
|
124
|
+
return rect.apply(options)
|
125
|
+
end
|
126
|
+
return rect
|
116
127
|
end
|
117
|
-
min_y
|
128
|
+
return min_y
|
118
129
|
end
|
119
130
|
|
120
131
|
def y=(_y)
|
121
132
|
self.origin.y = _y
|
122
133
|
end
|
123
134
|
|
124
|
-
def width(setter =
|
135
|
+
def width(setter=nil, options=nil)
|
125
136
|
if setter
|
126
|
-
|
137
|
+
rect = CGRect.new(self.origin, [setter, self.size.height])
|
138
|
+
if options
|
139
|
+
return rect.apply(options)
|
140
|
+
end
|
141
|
+
return rect
|
127
142
|
end
|
128
|
-
CGRectGetWidth(self)
|
143
|
+
return CGRectGetWidth(self)
|
129
144
|
end
|
130
145
|
|
131
146
|
def width=(_width)
|
132
147
|
self.size.width = _width
|
133
148
|
end
|
134
149
|
|
135
|
-
def height(setter =
|
150
|
+
def height(setter=nil, options=nil)
|
136
151
|
if setter
|
137
|
-
|
152
|
+
rect = CGRect.new(self.origin, [self.size.width, setter])
|
153
|
+
if options
|
154
|
+
return rect.apply(options)
|
155
|
+
end
|
156
|
+
return rect
|
138
157
|
end
|
139
|
-
CGRectGetHeight(self)
|
158
|
+
return CGRectGetHeight(self)
|
140
159
|
end
|
141
160
|
|
142
161
|
def height=(_height)
|
@@ -217,8 +236,9 @@ class CGRect
|
|
217
236
|
end
|
218
237
|
raise "You must specify an amount in `CGRect#left`" unless dist.is_a?(Numeric)
|
219
238
|
|
220
|
-
|
221
|
-
|
239
|
+
self.apply({
|
240
|
+
left: dist
|
241
|
+
}.merge(options))
|
222
242
|
end
|
223
243
|
|
224
244
|
def right(dist=nil, options={})
|
@@ -228,8 +248,9 @@ class CGRect
|
|
228
248
|
end
|
229
249
|
raise "You must specify an amount in `CGRect#right`" unless dist.is_a?(Numeric)
|
230
250
|
|
231
|
-
|
232
|
-
|
251
|
+
self.apply({
|
252
|
+
right: dist
|
253
|
+
}.merge(options))
|
233
254
|
end
|
234
255
|
|
235
256
|
def up(dist=nil, options={})
|
@@ -239,8 +260,9 @@ class CGRect
|
|
239
260
|
end
|
240
261
|
raise "You must specify an amount in `CGRect#up`" unless dist.is_a?(Numeric)
|
241
262
|
|
242
|
-
|
243
|
-
|
263
|
+
self.apply({
|
264
|
+
up: dist
|
265
|
+
}.merge(options))
|
244
266
|
end
|
245
267
|
|
246
268
|
def down(dist=nil, options={})
|
@@ -250,36 +272,41 @@ class CGRect
|
|
250
272
|
end
|
251
273
|
raise "You must specify an amount in `CGRect#down`" unless dist.is_a?(Numeric)
|
252
274
|
|
253
|
-
|
254
|
-
|
275
|
+
self.apply({
|
276
|
+
down: dist
|
277
|
+
}.merge(options))
|
255
278
|
end
|
256
279
|
|
257
280
|
def wider(dist, options={})
|
258
281
|
raise "You must specify an amount in `CGRect#wider`" unless dist.is_a?(Numeric)
|
259
282
|
|
260
|
-
|
261
|
-
|
283
|
+
self.apply({
|
284
|
+
wider: dist
|
285
|
+
}.merge(options))
|
262
286
|
end
|
263
287
|
|
264
288
|
def thinner(dist, options={})
|
265
289
|
raise "You must specify an amount in `CGRect#thinner`" unless dist.is_a?(Numeric)
|
266
290
|
|
267
|
-
|
268
|
-
|
291
|
+
self.apply({
|
292
|
+
thinner: dist
|
293
|
+
}.merge(options))
|
269
294
|
end
|
270
295
|
|
271
296
|
def taller(dist, options={})
|
272
297
|
raise "You must specify an amount in `CGRect#taller`" unless dist.is_a?(Numeric)
|
273
298
|
|
274
|
-
|
275
|
-
|
299
|
+
self.apply({
|
300
|
+
taller: dist
|
301
|
+
}.merge(options))
|
276
302
|
end
|
277
303
|
|
278
304
|
def shorter(dist, options={})
|
279
305
|
raise "You must specify an amount in `CGRect#shorter`" unless dist.is_a?(Numeric)
|
280
306
|
|
281
|
-
|
282
|
-
|
307
|
+
self.apply({
|
308
|
+
shorter: dist
|
309
|
+
}.merge(options))
|
283
310
|
end
|
284
311
|
|
285
312
|
# adjacent rects
|
@@ -287,30 +314,96 @@ class CGRect
|
|
287
314
|
margin, options = 0, margin if margin.is_a?(NSDictionary)
|
288
315
|
|
289
316
|
height = options[:height] || self.size.height
|
290
|
-
|
291
|
-
|
317
|
+
self.apply({
|
318
|
+
up: height + margin
|
319
|
+
}.merge(options))
|
292
320
|
end
|
293
321
|
|
294
322
|
def below(margin = 0, options={})
|
295
323
|
margin, options = 0, margin if margin.is_a?(NSDictionary)
|
296
324
|
|
297
|
-
|
298
|
-
|
325
|
+
self.apply({
|
326
|
+
down: self.size.height + margin
|
327
|
+
}.merge(options))
|
299
328
|
end
|
300
329
|
|
301
330
|
def before(margin = 0, options={})
|
302
331
|
margin, options = 0, margin if margin.is_a?(NSDictionary)
|
303
332
|
|
304
333
|
width = options[:width] || self.size.width
|
305
|
-
|
306
|
-
|
334
|
+
self.apply({
|
335
|
+
left: width + margin
|
336
|
+
}.merge(options))
|
307
337
|
end
|
308
338
|
|
309
339
|
def beside(margin = 0, options={})
|
310
340
|
margin, options = 0, margin if margin.is_a?(NSDictionary)
|
311
341
|
|
312
|
-
|
313
|
-
|
342
|
+
self.apply({
|
343
|
+
right: self.size.width + margin
|
344
|
+
}.merge(options))
|
345
|
+
end
|
346
|
+
|
347
|
+
# these methods create a rect INSIDE the receiver
|
348
|
+
|
349
|
+
# Create a rect inside the receiver, on the left side. If `margin` is
|
350
|
+
# supplied, the rect will be moved that number of points to the right.
|
351
|
+
def from_left(options={})
|
352
|
+
width = options[:width]
|
353
|
+
margin = options.delete(:margin) || 0
|
354
|
+
raise "You must specify a width in `CGRect#from_left`" unless width
|
355
|
+
offset = cgrect_offset(options.delete(:absolute))
|
356
|
+
self.apply({
|
357
|
+
x: offset.x + margin,
|
358
|
+
y: offset.y,
|
359
|
+
height: self.size.height,
|
360
|
+
width: width
|
361
|
+
}.merge(options))
|
362
|
+
end
|
363
|
+
|
364
|
+
# Create a rect inside the receiver, on the right side. If `margin` is
|
365
|
+
# supplied, the rect will be moved that number of points to the left.
|
366
|
+
def from_right(options={})
|
367
|
+
width = options[:width]
|
368
|
+
margin = options.delete(:margin) || 0
|
369
|
+
raise "You must specify a width in `CGRect#from_right`" unless width
|
370
|
+
offset = cgrect_offset(options.delete(:absolute))
|
371
|
+
self.apply({
|
372
|
+
x: offset.x + self.size.width - width - margin,
|
373
|
+
y: offset.y,
|
374
|
+
height: self.size.height,
|
375
|
+
width: width
|
376
|
+
}.merge(options))
|
377
|
+
end
|
378
|
+
|
379
|
+
# Create a rect inside the receiver, on the top side. If `margin` is
|
380
|
+
# supplied, the rect will be moved that number of points down.
|
381
|
+
def from_top(options={})
|
382
|
+
height = options[:height]
|
383
|
+
margin = options.delete(:margin) || 0
|
384
|
+
raise "You must specify a height in `CGRect#from_top`" unless height
|
385
|
+
offset = cgrect_offset(options.delete(:absolute))
|
386
|
+
self.apply({
|
387
|
+
x: offset.x,
|
388
|
+
y: offset.y + margin,
|
389
|
+
width: self.size.width,
|
390
|
+
height: height
|
391
|
+
}.merge(options))
|
392
|
+
end
|
393
|
+
|
394
|
+
# Create a rect inside the receiver, on the bottom side. If `margin` is
|
395
|
+
# supplied, the rect will be moved that number of points up.
|
396
|
+
def from_bottom(options={})
|
397
|
+
height = options[:height]
|
398
|
+
margin = options.delete(:margin) || 0
|
399
|
+
raise "You must specify a height in `CGRect#from_bottom`" unless height
|
400
|
+
offset = cgrect_offset(options.delete(:absolute))
|
401
|
+
self.apply({
|
402
|
+
x: offset.x,
|
403
|
+
y: offset.y + self.size.height - height - margin,
|
404
|
+
width: self.size.width,
|
405
|
+
height: height
|
406
|
+
}.merge(options))
|
314
407
|
end
|
315
408
|
|
316
409
|
# positions
|
@@ -436,26 +529,28 @@ public
|
|
436
529
|
end
|
437
530
|
|
438
531
|
alias grow_right wider
|
439
|
-
def grow_left(amount, options=
|
532
|
+
def grow_left(amount, options={})
|
440
533
|
raise "You must specify an amount in `CGRect#grow_left`" unless amount.is_a?(Numeric)
|
441
534
|
|
442
|
-
|
443
|
-
|
535
|
+
self.apply({
|
536
|
+
grow_left: amount
|
537
|
+
}.merge(options))
|
444
538
|
end
|
445
539
|
|
446
540
|
alias grow_down taller
|
447
|
-
def grow_up(amount, options=
|
541
|
+
def grow_up(amount, options={})
|
448
542
|
raise "You must specify an amount in `CGRect#grow_up`" unless amount.is_a?(Numeric)
|
449
543
|
|
450
|
-
|
451
|
-
|
544
|
+
self.apply({
|
545
|
+
grow_up: amount
|
546
|
+
}.merge(options))
|
452
547
|
end
|
453
548
|
|
454
|
-
def grow_width(amount, options=
|
549
|
+
def grow_width(amount, options={})
|
455
550
|
return self.grow([amount, 0], options)
|
456
551
|
end
|
457
552
|
|
458
|
-
def grow_height(amount, options=
|
553
|
+
def grow_height(amount, options={})
|
459
554
|
return self.grow([0, amount], options)
|
460
555
|
end
|
461
556
|
|
@@ -474,16 +569,18 @@ public
|
|
474
569
|
def shrink_right(amount, options={})
|
475
570
|
raise "You must specify an amount in `CGRect#shrink_right`" unless amount.is_a?(Numeric)
|
476
571
|
|
477
|
-
|
478
|
-
|
572
|
+
self.apply({
|
573
|
+
shrink_right: amount
|
574
|
+
}.merge(options))
|
479
575
|
end
|
480
576
|
|
481
577
|
alias shrink_up shorter
|
482
578
|
def shrink_down(amount, options={})
|
483
579
|
raise "You must specify an amount in `CGRect#shrink_down`" unless amount.is_a?(Numeric)
|
484
580
|
|
485
|
-
|
486
|
-
|
581
|
+
self.apply({
|
582
|
+
shrink_down: amount
|
583
|
+
}.merge(options))
|
487
584
|
end
|
488
585
|
|
489
586
|
def shrink_width(amount, options={})
|
data/lib/geomotion/version.rb
CHANGED
data/spec/cg_point_spec.rb
CHANGED
@@ -84,6 +84,11 @@ describe "CGPoint" do
|
|
84
84
|
point = CGPoint.make(x: 100, y: 200)
|
85
85
|
(@point + point).should == CGPointMake(110, 220)
|
86
86
|
end
|
87
|
+
|
88
|
+
it "should work with CGRect" do
|
89
|
+
point = CGRect.make(x: 100, y: 200, width: 50, height: 50)
|
90
|
+
(@point + point).should == CGRectMake(110, 220, 50, 50)
|
91
|
+
end
|
87
92
|
end
|
88
93
|
|
89
94
|
describe "#*" do
|
data/spec/cg_rect_spec.rb
CHANGED
@@ -783,11 +783,14 @@ describe "CGRect" do
|
|
783
783
|
end
|
784
784
|
|
785
785
|
describe "#grow_left" do
|
786
|
-
# @rect = CGRect.make(x: 10, y: 100, width: 50, height: 20)
|
787
786
|
it "should work" do
|
788
787
|
rect = @rect.grow_left(10)
|
789
788
|
rect.should == CGRectMake(0, 100, 60, 20)
|
790
789
|
end
|
790
|
+
it "should work with options" do
|
791
|
+
rect = @rect.grow_left(10, height: 5)
|
792
|
+
rect.should == CGRectMake(0, 100, 60, 5)
|
793
|
+
end
|
791
794
|
end
|
792
795
|
|
793
796
|
describe "#grow_right" do
|
@@ -795,6 +798,10 @@ describe "CGRect" do
|
|
795
798
|
rect = @rect.grow_right(10)
|
796
799
|
rect.should == CGRectMake(10, 100, 60, 20)
|
797
800
|
end
|
801
|
+
it "should work with options" do
|
802
|
+
rect = @rect.grow_right(10, height: 5)
|
803
|
+
rect.should == CGRectMake(10, 100, 60, 5)
|
804
|
+
end
|
798
805
|
end
|
799
806
|
|
800
807
|
describe "#grow_up" do
|
@@ -802,6 +809,10 @@ describe "CGRect" do
|
|
802
809
|
rect = @rect.grow_up(10)
|
803
810
|
rect.should == CGRectMake(10, 90, 50, 30)
|
804
811
|
end
|
812
|
+
it "should work with options" do
|
813
|
+
rect = @rect.grow_up(10, width: 5)
|
814
|
+
rect.should == CGRectMake(10, 90, 5, 30)
|
815
|
+
end
|
805
816
|
end
|
806
817
|
|
807
818
|
describe "#grow_down" do
|
@@ -809,10 +820,13 @@ describe "CGRect" do
|
|
809
820
|
rect = @rect.grow_down(10)
|
810
821
|
rect.should == CGRectMake(10, 100, 50, 30)
|
811
822
|
end
|
823
|
+
it "should work with options" do
|
824
|
+
rect = @rect.grow_down(10, width: 5)
|
825
|
+
rect.should == CGRectMake(10, 100, 5, 30)
|
826
|
+
end
|
812
827
|
end
|
813
828
|
|
814
829
|
describe "#grow_width" do
|
815
|
-
# @rect = CGRect.make(x: 10, y: 100, width: 50, height: 20)
|
816
830
|
it "should work" do
|
817
831
|
rect = @rect.grow_width(10)
|
818
832
|
rect.should == CGRectMake(0, 100, 70, 20)
|
@@ -872,7 +886,6 @@ describe "CGRect" do
|
|
872
886
|
end
|
873
887
|
|
874
888
|
describe "#shrink_width" do
|
875
|
-
# @rect = CGRect.make(x: 10, y: 100, width: 50, height: 20)
|
876
889
|
it "should work" do
|
877
890
|
rect = @rect.shrink_width(10)
|
878
891
|
rect.should == CGRectMake(20, 100, 30, 20)
|
@@ -1015,4 +1028,80 @@ describe "CGRect" do
|
|
1015
1028
|
|
1016
1029
|
end
|
1017
1030
|
|
1031
|
+
describe "#from_left" do
|
1032
|
+
it "should work" do
|
1033
|
+
rect = @rect.from_left(width: 10)
|
1034
|
+
rect.should == CGRectMake(0, 0, 10, 20)
|
1035
|
+
end
|
1036
|
+
it "should work with margin" do
|
1037
|
+
rect = @rect.from_left(width: 10, margin: 5)
|
1038
|
+
rect.should == CGRectMake(5, 0, 10, 20)
|
1039
|
+
end
|
1040
|
+
it "should work with all options" do
|
1041
|
+
rect = @rect.from_left(width: 10, shrink_down: 5)
|
1042
|
+
rect.should == CGRectMake(0, 5, 10, 15)
|
1043
|
+
end
|
1044
|
+
it "should work with absolute" do
|
1045
|
+
rect = @rect.from_left(width: 10, absolute: true)
|
1046
|
+
rect.should == CGRectMake(10, 100, 10, 20)
|
1047
|
+
end
|
1048
|
+
end
|
1049
|
+
|
1050
|
+
describe "#from_right" do
|
1051
|
+
it "should work" do
|
1052
|
+
rect = @rect.from_right(width: 10)
|
1053
|
+
rect.should == CGRectMake(40, 0, 10, 20)
|
1054
|
+
end
|
1055
|
+
it "should work with margin" do
|
1056
|
+
rect = @rect.from_right(width: 10, margin: 5)
|
1057
|
+
rect.should == CGRectMake(35, 0, 10, 20)
|
1058
|
+
end
|
1059
|
+
it "should work with all options" do
|
1060
|
+
rect = @rect.from_right(width: 10, shrink_down: 5)
|
1061
|
+
rect.should == CGRectMake(40, 5, 10, 15)
|
1062
|
+
end
|
1063
|
+
it "should work with absolute" do
|
1064
|
+
rect = @rect.from_right(width: 10, absolute: true)
|
1065
|
+
rect.should == CGRectMake(50, 100, 10, 20)
|
1066
|
+
end
|
1067
|
+
end
|
1068
|
+
|
1069
|
+
describe "#from_top" do
|
1070
|
+
it "should work" do
|
1071
|
+
rect = @rect.from_top(height: 10)
|
1072
|
+
rect.should == CGRectMake(0, 0, 50, 10)
|
1073
|
+
end
|
1074
|
+
it "should work with margin" do
|
1075
|
+
rect = @rect.from_top(height: 10, margin: 5)
|
1076
|
+
rect.should == CGRectMake(0, 5, 50, 10)
|
1077
|
+
end
|
1078
|
+
it "should work with all options" do
|
1079
|
+
rect = @rect.from_top(height: 10, shrink_right: 5)
|
1080
|
+
rect.should == CGRectMake(5, 0, 45, 10)
|
1081
|
+
end
|
1082
|
+
it "should work with absolute" do
|
1083
|
+
rect = @rect.from_top(height: 10, absolute: true)
|
1084
|
+
rect.should == CGRectMake(10, 100, 50, 10)
|
1085
|
+
end
|
1086
|
+
end
|
1087
|
+
|
1088
|
+
describe "#from_bottom" do
|
1089
|
+
it "should work" do
|
1090
|
+
rect = @rect.from_bottom(height: 10)
|
1091
|
+
rect.should == CGRectMake(0, 10, 50, 10)
|
1092
|
+
end
|
1093
|
+
it "should work with margin" do
|
1094
|
+
rect = @rect.from_bottom(height: 10, margin: 5)
|
1095
|
+
rect.should == CGRectMake(0, 5, 50, 10)
|
1096
|
+
end
|
1097
|
+
it "should work with all options" do
|
1098
|
+
rect = @rect.from_bottom(height: 10, shrink_right: 5)
|
1099
|
+
rect.should == CGRectMake(5, 10, 45, 10)
|
1100
|
+
end
|
1101
|
+
it "should work with absolute" do
|
1102
|
+
rect = @rect.from_bottom(height: 10, absolute: true)
|
1103
|
+
rect.should == CGRectMake(10, 110, 50, 10)
|
1104
|
+
end
|
1105
|
+
end
|
1106
|
+
|
1018
1107
|
end
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: geomotion
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.13.
|
4
|
+
version: 0.13.2
|
5
5
|
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -10,11 +10,11 @@ authors:
|
|
10
10
|
autorequire:
|
11
11
|
bindir: bin
|
12
12
|
cert_chain: []
|
13
|
-
date: 2013-
|
13
|
+
date: 2013-11-08 00:00:00.000000000 Z
|
14
14
|
dependencies:
|
15
15
|
- !ruby/object:Gem::Dependency
|
16
16
|
name: rake
|
17
|
-
requirement: !ruby/object:Gem::Requirement
|
17
|
+
requirement: &70366710050360 !ruby/object:Gem::Requirement
|
18
18
|
none: false
|
19
19
|
requirements:
|
20
20
|
- - ! '>='
|
@@ -22,12 +22,7 @@ dependencies:
|
|
22
22
|
version: '0'
|
23
23
|
type: :development
|
24
24
|
prerelease: false
|
25
|
-
version_requirements:
|
26
|
-
none: false
|
27
|
-
requirements:
|
28
|
-
- - ! '>='
|
29
|
-
- !ruby/object:Gem::Version
|
30
|
-
version: '0'
|
25
|
+
version_requirements: *70366710050360
|
31
26
|
description: A RubyMotion Geometry Wrapper
|
32
27
|
email:
|
33
28
|
- clay.allsopp@gmail.com
|
@@ -81,7 +76,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
81
76
|
version: '0'
|
82
77
|
requirements: []
|
83
78
|
rubyforge_project:
|
84
|
-
rubygems_version: 1.8.
|
79
|
+
rubygems_version: 1.8.11
|
85
80
|
signing_key:
|
86
81
|
specification_version: 3
|
87
82
|
summary: A RubyMotion Geometry Wrapper
|