rays 0.1.17 → 0.1.22
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.doc/ext/rays/color_space.cpp +2 -2
- data/.doc/ext/rays/point.cpp +0 -8
- data/VERSION +1 -1
- data/ext/rays/color_space.cpp +2 -2
- data/ext/rays/point.cpp +0 -9
- data/lib/rays/autoinit.rb +1 -1
- data/lib/rays/bitmap.rb +3 -3
- data/lib/rays/bounds.rb +22 -22
- data/lib/rays/camera.rb +1 -1
- data/lib/rays/color.rb +13 -13
- data/lib/rays/color_space.rb +4 -4
- data/lib/rays/font.rb +2 -2
- data/lib/rays/image.rb +3 -3
- data/lib/rays/matrix.rb +3 -3
- data/lib/rays/module.rb +5 -5
- data/lib/rays/painter.rb +17 -17
- data/lib/rays/point.rb +11 -11
- data/lib/rays/polygon.rb +10 -10
- data/lib/rays/polygon_line.rb +4 -4
- data/lib/rays/polyline.rb +4 -4
- data/lib/rays/shader.rb +3 -3
- data/rays.gemspec +2 -2
- data/src/ios/camera.mm +14 -7
- data/src/osx/camera.mm +3 -2
- data/test/helper.rb +2 -2
- data/test/test_bitmap.rb +7 -7
- data/test/test_bounds.rb +26 -26
- data/test/test_color.rb +19 -19
- data/test/test_color_space.rb +10 -10
- data/test/test_font.rb +6 -6
- data/test/test_image.rb +14 -14
- data/test/test_matrix.rb +20 -20
- data/test/test_painter.rb +18 -18
- data/test/test_painter_shape.rb +10 -10
- data/test/test_point.rb +20 -20
- data/test/test_polygon.rb +30 -30
- data/test/test_polygon_line.rb +13 -13
- data/test/test_polyline.rb +38 -38
- data/test/test_rays.rb +1 -1
- data/test/test_shader.rb +7 -7
- metadata +6 -6
data/lib/rays/point.rb
CHANGED
@@ -12,23 +12,23 @@ module Rays
|
|
12
12
|
include Comparable
|
13
13
|
include Enumerable
|
14
14
|
|
15
|
-
def move_to
|
16
|
-
dup.move_to!
|
15
|
+
def move_to(*args)
|
16
|
+
dup.move_to!(*args)
|
17
17
|
end
|
18
18
|
|
19
|
-
def move_by
|
20
|
-
dup.move_by!
|
19
|
+
def move_by(*args)
|
20
|
+
dup.move_by!(*args)
|
21
21
|
end
|
22
22
|
|
23
|
-
def zero?
|
23
|
+
def zero?()
|
24
24
|
length == 0
|
25
25
|
end
|
26
26
|
|
27
|
-
def each
|
28
|
-
to_a.each
|
27
|
+
def each(&block)
|
28
|
+
to_a.each(&block)
|
29
29
|
end
|
30
30
|
|
31
|
-
def to_a
|
31
|
+
def to_a(dimension = 2)
|
32
32
|
case dimension
|
33
33
|
when 1 then [x]
|
34
34
|
when 2 then [x, y]
|
@@ -37,17 +37,17 @@ module Rays
|
|
37
37
|
end
|
38
38
|
end
|
39
39
|
|
40
|
-
def to_s
|
40
|
+
def to_s(dimension = 2)
|
41
41
|
to_a(dimension).to_s
|
42
42
|
end
|
43
43
|
|
44
|
-
def <=>
|
44
|
+
def <=>(o)
|
45
45
|
ret = x <=> o.x; return ret if ret != 0
|
46
46
|
ret = y <=> o.y; return ret if ret != 0
|
47
47
|
z <=> o.z
|
48
48
|
end
|
49
49
|
|
50
|
-
def inspect
|
50
|
+
def inspect()
|
51
51
|
"#<Rays::Point #{to_a(3).join ', '}>"
|
52
52
|
end
|
53
53
|
|
data/lib/rays/polygon.rb
CHANGED
@@ -12,43 +12,43 @@ module Rays
|
|
12
12
|
|
13
13
|
include Enumerable
|
14
14
|
|
15
|
-
def initialize
|
15
|
+
def initialize(*args, loop: true)
|
16
16
|
setup args, loop
|
17
17
|
end
|
18
18
|
|
19
|
-
def transform
|
19
|
+
def transform(matrix = nil, &block)
|
20
20
|
lines = to_a
|
21
21
|
lines = lines.map {|line| line.transform matrix} if matrix
|
22
22
|
lines = block.call lines if block
|
23
|
-
self.class.new
|
23
|
+
self.class.new(*lines)
|
24
24
|
end
|
25
25
|
|
26
|
-
def intersects
|
26
|
+
def intersects(obj)
|
27
27
|
!(self & obj).empty?
|
28
28
|
end
|
29
29
|
|
30
|
-
def self.line
|
31
|
-
new
|
30
|
+
def self.line(*args, loop: false)
|
31
|
+
new(*args, loop: loop)
|
32
32
|
end
|
33
33
|
|
34
|
-
def self.rect
|
34
|
+
def self.rect(
|
35
35
|
*args, round: nil, lt: nil, rt: nil, lb: nil, rb: nil, nsegment: nil)
|
36
36
|
|
37
37
|
create_rect args, round, lt, rt, lb, rb, nsegment
|
38
38
|
end
|
39
39
|
|
40
|
-
def self.ellipse
|
40
|
+
def self.ellipse(
|
41
41
|
*args, center: nil, radius: nil, hole: nil, from: nil, to: nil,
|
42
42
|
nsegment: nil)
|
43
43
|
|
44
44
|
create_ellipse args, center, radius, hole, from, to, nsegment
|
45
45
|
end
|
46
46
|
|
47
|
-
def self.curve
|
47
|
+
def self.curve(*args, loop: false)
|
48
48
|
create_curve args, loop
|
49
49
|
end
|
50
50
|
|
51
|
-
def self.bezier
|
51
|
+
def self.bezier(*args, loop: false)
|
52
52
|
create_bezier args, loop
|
53
53
|
end
|
54
54
|
|
data/lib/rays/polygon_line.rb
CHANGED
@@ -12,18 +12,18 @@ module Rays
|
|
12
12
|
|
13
13
|
class Line < Polyline
|
14
14
|
|
15
|
-
def initialize
|
15
|
+
def initialize(*points, loop: true, hole: false)
|
16
16
|
setup points, loop, hole
|
17
17
|
end
|
18
18
|
|
19
|
-
def transform
|
19
|
+
def transform(matrix = nil, loop: loop?, hole: hole?, &block)
|
20
20
|
points = to_a
|
21
21
|
points = points.map {|point| matrix * point} if matrix
|
22
22
|
points = block.call points if block
|
23
|
-
self.class.new
|
23
|
+
self.class.new(*points, loop: loop, hole: hole)
|
24
24
|
end
|
25
25
|
|
26
|
-
def inspect
|
26
|
+
def inspect()
|
27
27
|
"#<Rays::Polygon::Line #{to_a.join ', '}, loop: #{loop?}, hole: #{hole?}>"
|
28
28
|
end
|
29
29
|
|
data/lib/rays/polyline.rb
CHANGED
@@ -11,18 +11,18 @@ module Rays
|
|
11
11
|
|
12
12
|
include Enumerable
|
13
13
|
|
14
|
-
def initialize
|
14
|
+
def initialize(*points, loop: false)
|
15
15
|
setup points, loop
|
16
16
|
end
|
17
17
|
|
18
|
-
def transform
|
18
|
+
def transform(matrix = nil, loop: loop?, &block)
|
19
19
|
points = to_a
|
20
20
|
points = points.map {|point| matrix * point} if matrix
|
21
21
|
points = block.call points if block
|
22
|
-
self.class.new
|
22
|
+
self.class.new(*points, loop: loop)
|
23
23
|
end
|
24
24
|
|
25
|
-
def inspect
|
25
|
+
def inspect()
|
26
26
|
"#<Rays::Polyline #{to_a.join ', '}, loop: #{loop?}>"
|
27
27
|
end
|
28
28
|
|
data/lib/rays/shader.rb
CHANGED
@@ -10,16 +10,16 @@ module Rays
|
|
10
10
|
|
11
11
|
class Shader
|
12
12
|
|
13
|
-
def initialize
|
13
|
+
def initialize(source = nil, **uniforms, &block)
|
14
14
|
if source
|
15
15
|
setup source
|
16
|
-
uniform
|
16
|
+
uniform(**uniforms) unless uniforms.empty?
|
17
17
|
end
|
18
18
|
|
19
19
|
Xot::BlockUtil.instance_eval_or_block_call self, &block if block
|
20
20
|
end
|
21
21
|
|
22
|
-
def uniform
|
22
|
+
def uniform(name = nil, *args, **uniforms)
|
23
23
|
set_uniform name, *args if name
|
24
24
|
uniforms.each do |key, value|
|
25
25
|
set_uniform key, value
|
data/rays.gemspec
CHANGED
@@ -28,8 +28,8 @@ Gem::Specification.new do |s|
|
|
28
28
|
s.platform = Gem::Platform::RUBY
|
29
29
|
s.required_ruby_version = '~> 2'
|
30
30
|
|
31
|
-
s.add_runtime_dependency 'xot', '~> 0.1.
|
32
|
-
s.add_runtime_dependency 'rucy', '~> 0.1.
|
31
|
+
s.add_runtime_dependency 'xot', '~> 0.1.22'
|
32
|
+
s.add_runtime_dependency 'rucy', '~> 0.1.22'
|
33
33
|
|
34
34
|
s.files = `git ls-files`.split $/
|
35
35
|
s.executables = s.files.grep(%r{^bin/}) {|f| File.basename f}
|
data/src/ios/camera.mm
CHANGED
@@ -116,9 +116,9 @@ static int video_input_queue_index = 0;
|
|
116
116
|
return YES;
|
117
117
|
}
|
118
118
|
|
119
|
-
- (void)
|
119
|
+
- (void) updateOrientation
|
120
120
|
{
|
121
|
-
assert(
|
121
|
+
assert(NSThread.isMainThread);
|
122
122
|
|
123
123
|
switch (UIApplication.sharedApplication.statusBarOrientation)
|
124
124
|
{
|
@@ -126,11 +126,11 @@ static int video_input_queue_index = 0;
|
|
126
126
|
orientation = AVCaptureVideoOrientationPortraitUpsideDown;
|
127
127
|
break;
|
128
128
|
|
129
|
-
case
|
129
|
+
case UIInterfaceOrientationLandscapeLeft:
|
130
130
|
orientation = AVCaptureVideoOrientationLandscapeLeft;
|
131
131
|
break;
|
132
132
|
|
133
|
-
case
|
133
|
+
case UIInterfaceOrientationLandscapeRight:
|
134
134
|
orientation = AVCaptureVideoOrientationLandscapeRight;
|
135
135
|
break;
|
136
136
|
|
@@ -326,7 +326,7 @@ namespace Rays
|
|
326
326
|
*draw_x = min_width / 2 - *draw_width / 2;
|
327
327
|
*bitmap_width = min_width;
|
328
328
|
}
|
329
|
-
|
329
|
+
if (crop && min_height > 0)
|
330
330
|
{
|
331
331
|
*draw_y = min_height / 2 - *draw_height / 2;
|
332
332
|
*bitmap_height = min_height;
|
@@ -343,7 +343,13 @@ namespace Rays
|
|
343
343
|
AVCaptureDeviceDiscoverySession* discoverySession =
|
344
344
|
[AVCaptureDeviceDiscoverySession
|
345
345
|
discoverySessionWithDeviceTypes: @[
|
346
|
-
|
346
|
+
AVCaptureDeviceTypeBuiltInTripleCamera,
|
347
|
+
AVCaptureDeviceTypeBuiltInDualWideCamera,
|
348
|
+
AVCaptureDeviceTypeBuiltInDualCamera,
|
349
|
+
AVCaptureDeviceTypeBuiltInUltraWideCamera,
|
350
|
+
AVCaptureDeviceTypeBuiltInTelephotoCamera,
|
351
|
+
AVCaptureDeviceTypeBuiltInWideAngleCamera
|
352
|
+
]
|
347
353
|
mediaType: AVMediaTypeVideo
|
348
354
|
position: AVCaptureDevicePositionUnspecified];
|
349
355
|
NSArray<AVCaptureDevice*>* devices = discoverySession.devices;
|
@@ -414,7 +420,6 @@ namespace Rays
|
|
414
420
|
Camera::~Camera ()
|
415
421
|
{
|
416
422
|
stop();
|
417
|
-
if (self->video_input) [self->video_input release];
|
418
423
|
}
|
419
424
|
|
420
425
|
bool
|
@@ -432,6 +437,8 @@ namespace Rays
|
|
432
437
|
if (!self->video_input) return;
|
433
438
|
|
434
439
|
[self->video_input stop];
|
440
|
+
[self->video_input release];
|
441
|
+
self->video_input = nil;
|
435
442
|
}
|
436
443
|
|
437
444
|
bool
|
data/src/osx/camera.mm
CHANGED
@@ -280,7 +280,7 @@ namespace Rays
|
|
280
280
|
*draw_x = min_width / 2 - *draw_width / 2;
|
281
281
|
*bitmap_width = min_width;
|
282
282
|
}
|
283
|
-
|
283
|
+
if (crop && min_height > 0)
|
284
284
|
{
|
285
285
|
*draw_y = min_height / 2 - *draw_height / 2;
|
286
286
|
*bitmap_height = min_height;
|
@@ -355,7 +355,6 @@ namespace Rays
|
|
355
355
|
Camera::~Camera ()
|
356
356
|
{
|
357
357
|
stop();
|
358
|
-
if (self->video_input) [self->video_input release];
|
359
358
|
}
|
360
359
|
|
361
360
|
bool
|
@@ -373,6 +372,8 @@ namespace Rays
|
|
373
372
|
if (!self->video_input) return;
|
374
373
|
|
375
374
|
[self->video_input stop];
|
375
|
+
[self->video_input release];
|
376
|
+
self->video_input = nil;
|
376
377
|
}
|
377
378
|
|
378
379
|
bool
|
data/test/helper.rb
CHANGED
data/test/test_bitmap.rb
CHANGED
@@ -9,20 +9,20 @@ class TestBitmap < Test::Unit::TestCase
|
|
9
9
|
W = 32
|
10
10
|
H = 16
|
11
11
|
|
12
|
-
def bitmap
|
12
|
+
def bitmap(w = W, h = H)
|
13
13
|
Rays::Bitmap.new w, h
|
14
14
|
end
|
15
15
|
|
16
|
-
def color
|
17
|
-
Rays::Color.new
|
16
|
+
def color(*args)
|
17
|
+
Rays::Color.new(*args)
|
18
18
|
end
|
19
19
|
|
20
|
-
def test_initialize
|
20
|
+
def test_initialize()
|
21
21
|
assert_equal W, bitmap.width
|
22
22
|
assert_equal H, bitmap.height
|
23
23
|
end
|
24
24
|
|
25
|
-
def test_dup
|
25
|
+
def test_dup()
|
26
26
|
o = bitmap
|
27
27
|
assert_equal color(0, 0, 0, 0), o[0, 0]
|
28
28
|
o[0, 0] = color(1, 0, 0, 0)
|
@@ -34,14 +34,14 @@ class TestBitmap < Test::Unit::TestCase
|
|
34
34
|
assert_equal color(1, 0, 0, 0), o[0, 0]
|
35
35
|
end
|
36
36
|
|
37
|
-
def test_at
|
37
|
+
def test_at()
|
38
38
|
o = bitmap
|
39
39
|
assert_equal color(0, 0, 0, 0), o[0, 0]
|
40
40
|
o[0, 0] = 1
|
41
41
|
assert_equal color(1, 1, 1, 1), o[0, 0]
|
42
42
|
end
|
43
43
|
|
44
|
-
def test_to_a
|
44
|
+
def test_to_a()
|
45
45
|
colors = %w[#f00 #0f0 #00f #ff0].map {|s| color s}
|
46
46
|
bmp = bitmap 2, 2
|
47
47
|
bmp[0, 0], bmp[1, 0], bmp[0, 1], bmp[1, 1] = colors
|
data/test/test_bounds.rb
CHANGED
@@ -6,15 +6,15 @@ require_relative 'helper'
|
|
6
6
|
|
7
7
|
class TestBounds < Test::Unit::TestCase
|
8
8
|
|
9
|
-
def bounds
|
10
|
-
Rays::Bounds.new
|
9
|
+
def bounds(*args)
|
10
|
+
Rays::Bounds.new(*args)
|
11
11
|
end
|
12
12
|
|
13
|
-
def point
|
14
|
-
Rays::Point.new
|
13
|
+
def point(*args)
|
14
|
+
Rays::Point.new(*args)
|
15
15
|
end
|
16
16
|
|
17
|
-
def test_initialize
|
17
|
+
def test_initialize()
|
18
18
|
assert_equal bounds(0, 0, 0, 0, 0, 0), bounds()
|
19
19
|
assert_equal bounds(0, 0, 0, 1, 1, 0), bounds(1)
|
20
20
|
assert_equal bounds(0, 0, 0, 1, 2, 0), bounds(1, 2)
|
@@ -25,7 +25,7 @@ class TestBounds < Test::Unit::TestCase
|
|
25
25
|
assert_raise(ArgumentError) {bounds(1, 2, 3, 4, 5, 6, 7)}
|
26
26
|
end
|
27
27
|
|
28
|
-
def test_dup
|
28
|
+
def test_dup()
|
29
29
|
o = bounds
|
30
30
|
assert_equal bounds(0, 0, 0, 0, 0, 0), o
|
31
31
|
o.x = 1
|
@@ -37,17 +37,17 @@ class TestBounds < Test::Unit::TestCase
|
|
37
37
|
assert_equal bounds(1, 0, 0, 0, 0, 0), o
|
38
38
|
end
|
39
39
|
|
40
|
-
def test_intersect?
|
40
|
+
def test_intersect?()
|
41
41
|
assert bounds(10, 20, 30, 100, 100, 100).intersect?(bounds 50, 60, 70, 100, 100, 100)
|
42
42
|
assert_not bounds(10, 20, 30, 10, 10, 10).intersect?(bounds 50, 60, 70, 100, 100, 100)
|
43
43
|
end
|
44
44
|
|
45
|
-
def test_include?
|
45
|
+
def test_include?()
|
46
46
|
assert bounds(10, 20, 30, 100, 100, 100).include?(point 50, 60)
|
47
47
|
assert_not bounds(10, 20, 30, 10, 10, 10).include?(point 50, 60)
|
48
48
|
end
|
49
49
|
|
50
|
-
def test_valid?
|
50
|
+
def test_valid?()
|
51
51
|
assert bounds(0, 0, 0, 0, 0, 0).valid?
|
52
52
|
assert bounds(0, 0, 0, 1, 0, 0).valid?
|
53
53
|
assert bounds(0, 0, 0, 0, 1, 0).valid?
|
@@ -57,7 +57,7 @@ class TestBounds < Test::Unit::TestCase
|
|
57
57
|
assert_not bounds(0, 0, 0, 0, 0, -1).valid?
|
58
58
|
end
|
59
59
|
|
60
|
-
def test_get_xyzwhd
|
60
|
+
def test_get_xyzwhd()
|
61
61
|
o = bounds 1, 2, 3, 4, 5, 6
|
62
62
|
assert_equal 1, o.x
|
63
63
|
assert_equal 2, o.y
|
@@ -70,7 +70,7 @@ class TestBounds < Test::Unit::TestCase
|
|
70
70
|
assert_equal 6, o.depth
|
71
71
|
end
|
72
72
|
|
73
|
-
def test_set_xyzwhd
|
73
|
+
def test_set_xyzwhd()
|
74
74
|
o = bounds
|
75
75
|
o.x = 1
|
76
76
|
assert_equal [1, 0, 0, 0, 0, 0], o.to_a(3)
|
@@ -92,7 +92,7 @@ class TestBounds < Test::Unit::TestCase
|
|
92
92
|
assert_equal [1, 2, 3, 7, 8, 9], o.to_a(3)
|
93
93
|
end
|
94
94
|
|
95
|
-
def test_get_ltbrbf
|
95
|
+
def test_get_ltbrbf()
|
96
96
|
o = bounds 1, 2, 3, 4, 5, 6
|
97
97
|
assert_equal 1, o.left
|
98
98
|
assert_equal 2, o.top
|
@@ -106,7 +106,7 @@ class TestBounds < Test::Unit::TestCase
|
|
106
106
|
assert_equal [4, 6], o.rb.to_a
|
107
107
|
end
|
108
108
|
|
109
|
-
def test_set_ltbrbf
|
109
|
+
def test_set_ltbrbf()
|
110
110
|
assert_equal [1, 0, 0, -1, 0, 0], bounds.tap {|o| o.left = 1}.to_a(3)
|
111
111
|
assert_equal [0, 2, 0, 0, -2, 0], bounds.tap {|o| o.top = 2}.to_a(3)
|
112
112
|
assert_equal [0, 0, 3, 0, 0, -3], bounds.tap {|o| o.back = 3}.to_a(3)
|
@@ -132,7 +132,7 @@ class TestBounds < Test::Unit::TestCase
|
|
132
132
|
assert_equal [10, 20, 0, 40, 50, 0], bounds(10, 20, 30, 40).tap {|o| o.rb += 10}.to_a(3)
|
133
133
|
end
|
134
134
|
|
135
|
-
def test_position
|
135
|
+
def test_position()
|
136
136
|
o = bounds 1, 2, 3, 4, 5, 6
|
137
137
|
assert_equal [ 1, 2, 3], o.position.to_a(3)
|
138
138
|
o.position = point 7, 8, 9
|
@@ -142,14 +142,14 @@ class TestBounds < Test::Unit::TestCase
|
|
142
142
|
assert_equal [10, 11, 12], o.pos.to_a(3)
|
143
143
|
end
|
144
144
|
|
145
|
-
def test_size
|
145
|
+
def test_size()
|
146
146
|
o = bounds 1, 2, 3, 4, 5, 6
|
147
147
|
assert_equal point(4, 5, 6), o.size
|
148
148
|
o.size = point 7, 8, 9
|
149
149
|
assert_equal point(7, 8, 9), o.size
|
150
150
|
end
|
151
151
|
|
152
|
-
def test_move_to
|
152
|
+
def test_move_to()
|
153
153
|
o = bounds 1, 2, 3, 4, 5, 6
|
154
154
|
assert_equal bounds(7, 2, 3, 4, 5, 6), o.move_to( 7)
|
155
155
|
assert_equal bounds(7, 8, 3, 4, 5, 6), o.move_to( 7, 8)
|
@@ -169,7 +169,7 @@ class TestBounds < Test::Unit::TestCase
|
|
169
169
|
assert_equal bounds( 7, 8, 9, 4, 5, 6), o1
|
170
170
|
end
|
171
171
|
|
172
|
-
def test_move_by
|
172
|
+
def test_move_by()
|
173
173
|
o = bounds 1, 2, 3, 4, 5, 6
|
174
174
|
assert_equal bounds( 8, 2, 3, 4, 5, 6), o.move_by( 7)
|
175
175
|
assert_equal bounds( 8, 10, 3, 4, 5, 6), o.move_by( 7, 8)
|
@@ -192,7 +192,7 @@ class TestBounds < Test::Unit::TestCase
|
|
192
192
|
assert_equal bounds( 8, 10, 12, 4, 5, 6), o1
|
193
193
|
end
|
194
194
|
|
195
|
-
def test_resize_to
|
195
|
+
def test_resize_to()
|
196
196
|
o = bounds 1, 2, 3, 4, 5, 6
|
197
197
|
assert_equal bounds(1, 2, 3, 7, 5, 6), o.resize_to( 7)
|
198
198
|
assert_equal bounds(1, 2, 3, 7, 8, 6), o.resize_to( 7, 8)
|
@@ -212,7 +212,7 @@ class TestBounds < Test::Unit::TestCase
|
|
212
212
|
assert_equal bounds(1, 2, 3, 7, 8, 9), o1
|
213
213
|
end
|
214
214
|
|
215
|
-
def test_resize_by
|
215
|
+
def test_resize_by()
|
216
216
|
o = bounds 1, 2, 3, 4, 5, 6
|
217
217
|
assert_equal bounds(1, 2, 3, 11, 5, 6), o.resize_by( 7)
|
218
218
|
assert_equal bounds(1, 2, 3, 11, 13, 6), o.resize_by( 7, 8)
|
@@ -235,7 +235,7 @@ class TestBounds < Test::Unit::TestCase
|
|
235
235
|
assert_equal bounds(1, 2, 3, 11, 13, 15), o1
|
236
236
|
end
|
237
237
|
|
238
|
-
def test_inset_by
|
238
|
+
def test_inset_by()
|
239
239
|
o = bounds 1, 2, 3, 20, 30, 40
|
240
240
|
assert_equal bounds(8, 2, 3, 6, 30, 40), o.inset_by( 7)
|
241
241
|
assert_equal bounds(8, 10, 3, 6, 14, 40), o.inset_by( 7, 8)
|
@@ -255,7 +255,7 @@ class TestBounds < Test::Unit::TestCase
|
|
255
255
|
assert_equal bounds( 8, 10, 12, 6, 14, 22), o1
|
256
256
|
end
|
257
257
|
|
258
|
-
def test_to_a
|
258
|
+
def test_to_a()
|
259
259
|
o = bounds 1, 2, 3, 4, 5, 6
|
260
260
|
assert_equal [1, 2, 4, 5], o.to_a
|
261
261
|
assert_equal [1, 4], o.to_a(1)
|
@@ -266,7 +266,7 @@ class TestBounds < Test::Unit::TestCase
|
|
266
266
|
assert_raise(ArgumentError) {o.to_a(4)}
|
267
267
|
end
|
268
268
|
|
269
|
-
def test_index
|
269
|
+
def test_index()
|
270
270
|
o = bounds 1, 2, 3, 4, 5, 6
|
271
271
|
assert_equal point(1, 2, 3), o[0]
|
272
272
|
assert_equal point(4, 5, 6), o[1]
|
@@ -274,7 +274,7 @@ class TestBounds < Test::Unit::TestCase
|
|
274
274
|
assert_raise(IndexError) {o[2]}
|
275
275
|
end
|
276
276
|
|
277
|
-
def test_index_assign
|
277
|
+
def test_index_assign()
|
278
278
|
o = bounds 1, 2, 3, 4, 5, 6
|
279
279
|
o[0] = point 7, 8, 9
|
280
280
|
assert_equal bounds(7, 8, 9, 4, 5, 6), o
|
@@ -284,7 +284,7 @@ class TestBounds < Test::Unit::TestCase
|
|
284
284
|
assert_raise(IndexError) {o[2]}
|
285
285
|
end
|
286
286
|
|
287
|
-
def test_compare
|
287
|
+
def test_compare()
|
288
288
|
o = bounds 1, 2, 3, 4, 5, 6
|
289
289
|
assert o == bounds(1, 2, 3, 4, 5, 6)
|
290
290
|
assert_not o != bounds(1, 2, 3, 4, 5, 6)
|
@@ -304,7 +304,7 @@ class TestBounds < Test::Unit::TestCase
|
|
304
304
|
assert o > bounds(1, 2, 3, 4, 5, 5)
|
305
305
|
end
|
306
306
|
|
307
|
-
def test_operators
|
307
|
+
def test_operators()
|
308
308
|
assert_equal bounds(50, 60, 70, 60, 60, 60), bounds(10, 20, 30, 100, 100, 100) & bounds(50, 60, 70, 100, 100, 100)
|
309
309
|
assert_equal bounds(10, 20, 30, 140, 140, 140), bounds(10, 20, 30, 100, 100, 100) | bounds(50, 60, 70, 100, 100, 100)
|
310
310
|
assert_equal bounds(10, 20, 30, 20, 20, 20), bounds(20, 30, 40, 10, 10, 10) | point(10, 20, 30)
|
@@ -313,7 +313,7 @@ class TestBounds < Test::Unit::TestCase
|
|
313
313
|
assert_equal point(0), (bounds(10, 20, 30, 10, 10, 10) & bounds(50, 60, 70, 10, 10, 10)).size
|
314
314
|
end
|
315
315
|
|
316
|
-
def test_invalid
|
316
|
+
def test_invalid()
|
317
317
|
o = Rays::Bounds.invalid
|
318
318
|
assert_not o.valid?
|
319
319
|
|