rays 0.1.20 → 0.1.24

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/test/test_polygon.rb CHANGED
@@ -7,42 +7,42 @@ require_relative 'helper'
7
7
  class TestPolygon < Test::Unit::TestCase
8
8
 
9
9
  class Rays::Polygon
10
- def dump ()
10
+ def dump()
11
11
  map {|l| l.map &:to_a}
12
12
  end
13
13
  end
14
14
 
15
- def polygon (*args)
16
- Rays::Polygon.new *args
15
+ def polygon(*args, **kwargs)
16
+ Rays::Polygon.new(*args, **kwargs)
17
17
  end
18
18
 
19
- def line (*args)
20
- Rays::Polygon::Line.new *args
19
+ def line(*args)
20
+ Rays::Polygon::Line.new(*args)
21
21
  end
22
22
 
23
- def polyline (*args)
24
- Rays::Polyline.new *args
23
+ def polyline(*args)
24
+ Rays::Polyline.new(*args)
25
25
  end
26
26
 
27
- def point (*args)
28
- Rays::Point.new *args
27
+ def point(*args)
28
+ Rays::Point.new(*args)
29
29
  end
30
30
 
31
- def bounds (*args)
32
- Rays::Bounds.new *args
31
+ def bounds(*args)
32
+ Rays::Bounds.new(*args)
33
33
  end
34
34
 
35
- def rect (*args)
36
- Rays::Polygon.rect *args
35
+ def rect(*args)
36
+ Rays::Polygon.rect(*args)
37
37
  end
38
38
 
39
- def assert_equal_polygon (poly1, poly2)
40
- assert_equal *[poly1, poly2].map {|poly|
39
+ def assert_equal_polygon(poly1, poly2)
40
+ assert_equal(*[poly1, poly2].map {|poly|
41
41
  poly.dump.map {|l| l.map {|p| p.map &:round}}.map(&:sort).sort.flatten
42
- }
42
+ })
43
43
  end
44
44
 
45
- def test_initialize ()
45
+ def test_initialize()
46
46
  assert_equal [[[1, 2], [3, 4]]], polygon( 1, 2, 3, 4, loop: false).dump
47
47
  assert_equal [[[5, 6], [7, 8]]], polygon( [5, 6], [7, 8], loop: false).dump
48
48
  assert_equal [[[1, 1], [2, 2]]], polygon( [1], [2], loop: false).dump
@@ -63,7 +63,7 @@ class TestPolygon < Test::Unit::TestCase
63
63
  assert_nothing_raised {polygon(1, 2, 3, 4, 5, 6, loop: false)}
64
64
  end
65
65
 
66
- def test_expand ()
66
+ def test_expand()
67
67
  polygon([10,10], [20,10], [30,20], loop: false).expand(1).tap {|o|
68
68
  assert_equal 1, o .size
69
69
  assert_equal 6, o[0].size
@@ -74,7 +74,7 @@ class TestPolygon < Test::Unit::TestCase
74
74
  }
75
75
  end
76
76
 
77
- def test_transform_with_matrix ()
77
+ def test_transform_with_matrix()
78
78
  m = Rays::Matrix.translate 10, 10
79
79
  assert_equal_polygon rect(20, 20, 50, 50), rect(10, 10, 50, 50).transform(m)
80
80
 
@@ -85,7 +85,7 @@ class TestPolygon < Test::Unit::TestCase
85
85
  assert_equal_polygon rect(-10, 0, 10, 10), rect(0, 0, 10, 10).transform(m)
86
86
  end
87
87
 
88
- def test_transform_block ()
88
+ def test_transform_block()
89
89
  o = rect(0, 0, 100, 100) - rect(10, 10, 50, 50)
90
90
  assert_equal 2, o.size
91
91
 
@@ -117,37 +117,37 @@ class TestPolygon < Test::Unit::TestCase
117
117
  }
118
118
  end
119
119
 
120
- def test_intersects ()
120
+ def test_intersects()
121
121
  assert rect(10, 10, 20, 20).intersects(rect 20, 20, 20, 20)
122
122
  assert_not rect(10, 10, 20, 20).intersects(rect 40, 40, 20, 20)
123
123
  end
124
124
 
125
- def test_bounds ()
125
+ def test_bounds()
126
126
  assert_equal bounds(10, 20, 0, 20, 10, 0), polygon(10, 20, 30, 20, 20, 30).bounds
127
127
 
128
128
  assert polygon(10, 20, 30, 20, 20, 30).bounds.valid?
129
129
  assert_not polygon() .bounds.valid?
130
130
  end
131
131
 
132
- def test_loop ()
132
+ def test_loop()
133
133
  assert_equal true, polygon(1, 2, 3, 4, 5, 6 ).first.loop?
134
134
  assert_equal true, polygon(1, 2, 3, 4, 5, 6, loop: true ).first.loop?
135
135
  assert_equal false, polygon(1, 2, 3, 4, 5, 6, loop: false).first.loop?
136
136
  end
137
137
 
138
- def test_size ()
138
+ def test_size()
139
139
  assert_equal 0, polygon( ).size
140
140
  assert_equal 1, polygon(1, 2, 3, 4, loop: false).size
141
141
  assert_equal 1, polygon(1, 2, 3, 4, 5, 6, loop: false).size
142
142
  assert_equal 2, (rect(0, 0, 5, 5) | rect(10, 0, 5, 5)).size
143
143
  end
144
144
 
145
- def test_empty? ()
145
+ def test_empty?()
146
146
  assert_equal true, polygon( ).empty?
147
147
  assert_equal false, polygon(1, 2, 3, 4, 5, 6).empty?
148
148
  end
149
149
 
150
- def test_index ()
150
+ def test_index()
151
151
  o1 = rect 0, 0, 10, 10
152
152
  o2 = rect 20, 0, 10, 10
153
153
  o3 = rect 40, 0, 10, 10
@@ -159,7 +159,7 @@ class TestPolygon < Test::Unit::TestCase
159
159
  assert_raise(IndexError) {o[-4]}
160
160
  end
161
161
 
162
- def test_sub ()
162
+ def test_sub()
163
163
  rect10 = rect 0, 0, 10, 10
164
164
 
165
165
  o = rect10 - rect(5, 0, 10, 10)
@@ -177,7 +177,7 @@ class TestPolygon < Test::Unit::TestCase
177
177
  assert_equal_polygon polygon(), rect10 - rect10
178
178
  end
179
179
 
180
- def test_and ()
180
+ def test_and()
181
181
  rect10 = rect 0, 0, 10, 10
182
182
 
183
183
  o = rect10 & rect(5, 0, 10, 10)
@@ -195,7 +195,7 @@ class TestPolygon < Test::Unit::TestCase
195
195
  assert_equal_polygon rect10, rect10 & rect10
196
196
  end
197
197
 
198
- def test_or ()
198
+ def test_or()
199
199
  rect10 = rect 0, 0, 10, 10
200
200
 
201
201
  o = rect10 | rect(5, 0, 10, 10)
@@ -213,7 +213,7 @@ class TestPolygon < Test::Unit::TestCase
213
213
  assert_equal_polygon rect10, rect10 | rect10
214
214
  end
215
215
 
216
- def test_xor ()
216
+ def test_xor()
217
217
  rect10 = rect 0, 0, 10, 10
218
218
 
219
219
  o = rect10 ^ rect(5, 0, 10, 10)
@@ -7,28 +7,28 @@ require_relative 'helper'
7
7
  class TestPolygonLine < Test::Unit::TestCase
8
8
 
9
9
  class Rays::Polygon::Line
10
- def dump ()
10
+ def dump()
11
11
  map &:to_a
12
12
  end
13
13
 
14
- def loop_hole ()
14
+ def loop_hole()
15
15
  [loop?, hole?]
16
16
  end
17
17
  end
18
18
 
19
- def line (*args)
20
- Rays::Polygon::Line.new *args
19
+ def line(*args, **kwargs)
20
+ Rays::Polygon::Line.new(*args, **kwargs)
21
21
  end
22
22
 
23
- def point (*args)
24
- Rays::Point.new *args
23
+ def point(*args)
24
+ Rays::Point.new(*args)
25
25
  end
26
26
 
27
- def rect (*args)
28
- Rays::Polygon.rect *args
27
+ def rect(*args)
28
+ Rays::Polygon.rect(*args)
29
29
  end
30
30
 
31
- def test_initialize ()
31
+ def test_initialize()
32
32
  assert_equal [[1, 2], [3, 4], [5, 6]], line( 1, 2, 3, 4 , 5, 6 ).dump
33
33
  assert_equal [[1, 2], [3, 4], [5, 6]], line( [1, 2], [3, 4], [5, 6]).dump
34
34
  assert_equal [[1, 1], [2, 2], [3, 3]], line( [1], [2], [3]).dump
@@ -74,7 +74,7 @@ class TestPolygonLine < Test::Unit::TestCase
74
74
  assert_nothing_raised {line(1, 2, 3, 4, 5, 6, loop: false, hole: false)}
75
75
  end
76
76
 
77
- def test_transform_with_materix ()
77
+ def test_transform_with_materix()
78
78
  m = Rays::Matrix.translate 100, 200
79
79
  line([10,10], [20,20], loop: false).transform(m).tap {|o|
80
80
  assert_equal [[110,210], [120,220]], o.dump
@@ -91,7 +91,7 @@ class TestPolygonLine < Test::Unit::TestCase
91
91
  }
92
92
  end
93
93
 
94
- def test_transform_with_block ()
94
+ def test_transform_with_block()
95
95
  line([10,10], [20,20], loop: false).transform {|points|
96
96
  points.map {|p| p + [10, 20]}
97
97
  }.tap {|o|
@@ -149,7 +149,7 @@ class TestPolygonLine < Test::Unit::TestCase
149
149
  }
150
150
  end
151
151
 
152
- def test_hole ()
152
+ def test_hole()
153
153
  (rect(0, 0, 10, 10) - rect(1, 1, 2, 2)).tap {|o|
154
154
  assert_equal 1, o.select {|line| line.hole?}.size
155
155
  }
@@ -158,7 +158,7 @@ class TestPolygonLine < Test::Unit::TestCase
158
158
  }
159
159
  end
160
160
 
161
- def test_inspect ()
161
+ def test_inspect()
162
162
  assert_equal(
163
163
  "#<Rays::Polygon::Line [1.0, 2.0], [3.0, 4.0], [5.0, 6.0], loop: true, hole: false>",
164
164
  line(1, 2, 3, 4, 5, 6).inspect)
@@ -7,24 +7,24 @@ require_relative 'helper'
7
7
  class TestPolyline < Test::Unit::TestCase
8
8
 
9
9
  class Rays::Polyline
10
- def dump ()
10
+ def dump()
11
11
  map &:to_a
12
12
  end
13
13
  end
14
14
 
15
- def polyline (*args)
16
- Rays::Polyline.new *args
15
+ def polyline(*args, **kwargs)
16
+ Rays::Polyline.new(*args, **kwargs)
17
17
  end
18
18
 
19
- def point (*args)
20
- Rays::Point.new *args
19
+ def point(*args)
20
+ Rays::Point.new(*args)
21
21
  end
22
22
 
23
- def bounds (*args)
24
- Rays::Bounds.new *args
23
+ def bounds(*args)
24
+ Rays::Bounds.new(*args)
25
25
  end
26
26
 
27
- def test_initialize ()
27
+ def test_initialize()
28
28
  assert_equal [[1, 2], [3, 4]], polyline( 1, 2, 3, 4 ).dump
29
29
  assert_equal [[1, 2], [3, 4]], polyline( [1, 2], [3, 4]).dump
30
30
  assert_equal [[1, 1], [2, 2]], polyline( [1], [2]).dump
@@ -52,7 +52,7 @@ class TestPolyline < Test::Unit::TestCase
52
52
  assert_nothing_raised {polyline(1, 2, 3, 4, 5, 6, loop: false)}
53
53
  end
54
54
 
55
- def test_expand ()
55
+ def test_expand()
56
56
  polyline([10,10], [20,20], loop: false).expand(1).tap {|o|
57
57
  assert_equal 1, o .size
58
58
  assert_equal 4, o[0].size
@@ -68,33 +68,33 @@ class TestPolyline < Test::Unit::TestCase
68
68
  }
69
69
  end
70
70
 
71
- def test_expand_with_cap ()
72
- def pl; polyline [10,10], [20,20]; end
73
- assert_nothing_raised {pl.expand 1, Rays::CAP_ROUND}
74
- assert_nothing_raised {pl.expand 1, 'ROUND'}
75
- assert_nothing_raised {pl.expand 1, :ROUND}
76
- assert_nothing_raised {pl.expand 1, :round}
77
- assert_nothing_raised {pl.expand 1, 1}
78
- assert_raise(ArgumentError) {pl.expand 1, -1}
79
- assert_raise(ArgumentError) {pl.expand 1, 99}
80
- assert_raise(ArgumentError) {pl.expand 1, 'hoge'}
81
- assert_raise(ArgumentError) {pl.expand 1, :hoge}
71
+ def test_expand_with_cap()
72
+ pl = -> {polyline [10,10], [20,20]}
73
+ assert_nothing_raised {pl[].expand 1, Rays::CAP_ROUND}
74
+ assert_nothing_raised {pl[].expand 1, 'ROUND'}
75
+ assert_nothing_raised {pl[].expand 1, :ROUND}
76
+ assert_nothing_raised {pl[].expand 1, :round}
77
+ assert_nothing_raised {pl[].expand 1, 1}
78
+ assert_raise(ArgumentError) {pl[].expand 1, -1}
79
+ assert_raise(ArgumentError) {pl[].expand 1, 99}
80
+ assert_raise(ArgumentError) {pl[].expand 1, 'hoge'}
81
+ assert_raise(ArgumentError) {pl[].expand 1, :hoge}
82
82
  end
83
83
 
84
- def test_expand_with_join ()
85
- def pl; polyline [10,10], [20,20]; end
86
- assert_nothing_raised {pl.expand 1, Rays::JOIN_ROUND}
87
- assert_nothing_raised {pl.expand 1, 'ROUND'}
88
- assert_nothing_raised {pl.expand 1, :ROUND}
89
- assert_nothing_raised {pl.expand 1, :round}
90
- assert_nothing_raised {pl.expand 1, 1}
91
- assert_raise(ArgumentError) {pl.expand 1, 'hoge'}
92
- assert_raise(ArgumentError) {pl.expand 1, :hoge}
93
- assert_raise(ArgumentError) {pl.expand 1, -1}
94
- assert_raise(ArgumentError) {pl.expand 1, 99}
84
+ def test_expand_with_join()
85
+ pl = -> {polyline [10,10], [20,20]}
86
+ assert_nothing_raised {pl[].expand 1, Rays::JOIN_ROUND}
87
+ assert_nothing_raised {pl[].expand 1, 'ROUND'}
88
+ assert_nothing_raised {pl[].expand 1, :ROUND}
89
+ assert_nothing_raised {pl[].expand 1, :round}
90
+ assert_nothing_raised {pl[].expand 1, 1}
91
+ assert_raise(ArgumentError) {pl[].expand 1, 'hoge'}
92
+ assert_raise(ArgumentError) {pl[].expand 1, :hoge}
93
+ assert_raise(ArgumentError) {pl[].expand 1, -1}
94
+ assert_raise(ArgumentError) {pl[].expand 1, 99}
95
95
  end
96
96
 
97
- def test_transform_with_materix ()
97
+ def test_transform_with_materix()
98
98
  m = Rays::Matrix.translate 100, 200
99
99
  polyline([10,10], [20,20]).transform(m).tap {|o|
100
100
  assert_equal [[110,210], [120,220]], o.dump
@@ -111,7 +111,7 @@ class TestPolyline < Test::Unit::TestCase
111
111
  }
112
112
  end
113
113
 
114
- def test_transform_with_block ()
114
+ def test_transform_with_block()
115
115
  polyline([10,10], [20,20] ).transform {|points|
116
116
  points.map {|p| p + [10, 20]}
117
117
  }.tap {|o|
@@ -136,24 +136,24 @@ class TestPolyline < Test::Unit::TestCase
136
136
  }
137
137
  end
138
138
 
139
- def test_bounds ()
139
+ def test_bounds()
140
140
  assert_equal bounds(10, 20, 0, 20, 10, 0), polyline(10, 20, 30, 20, 20, 30).bounds
141
141
 
142
142
  assert polyline(10, 20, 30, 20, 20, 30).bounds.valid?
143
143
  assert_not polyline() .bounds.valid?
144
144
  end
145
145
 
146
- def test_size ()
146
+ def test_size()
147
147
  assert_equal 2, polyline(1, 2, 3, 4, ).size
148
148
  assert_equal 3, polyline(1, 2, 3, 4, 5, 6).size
149
149
  end
150
150
 
151
- def test_empty? ()
151
+ def test_empty?()
152
152
  assert_equal true, polyline( ).empty?
153
153
  assert_equal false, polyline(1, 2, 3, 4).empty?
154
154
  end
155
155
 
156
- def test_index ()
156
+ def test_index()
157
157
  o = polyline 1, 2, 3, 4, 5, 6
158
158
  assert_equal [1, 2], o[ 0].to_a
159
159
  assert_equal [3, 4], o[ 1].to_a
@@ -162,7 +162,7 @@ class TestPolyline < Test::Unit::TestCase
162
162
  assert_raise(IndexError) {o[-4]}
163
163
  end
164
164
 
165
- def test_inspect ()
165
+ def test_inspect()
166
166
  assert_equal(
167
167
  "#<Rays::Polyline [1.0, 2.0], [3.0, 4.0], loop: false>",
168
168
  polyline(1, 2, 3, 4).inspect)
data/test/test_rays.rb CHANGED
@@ -8,7 +8,7 @@ require_relative 'helper'
8
8
 
9
9
  class TestRays < Test::Unit::TestCase
10
10
 
11
- def test_init! ()
11
+ def test_init!()
12
12
  assert_raise(Rucy::NativeError) {Rays.fin!}
13
13
  assert Rays.init!
14
14
  assert_raise(Rucy::NativeError) {Rays.init!}
data/test/test_shader.rb CHANGED
@@ -6,30 +6,30 @@ require_relative 'helper'
6
6
 
7
7
  class TestShader < Test::Unit::TestCase
8
8
 
9
- def shader (src)
9
+ def shader(src)
10
10
  Rays::Shader.new src
11
11
  end
12
12
 
13
- def img (w = 10, h = 10, &block)
13
+ def img(w = 10, h = 10, &block)
14
14
  Rays::Image.new w, h
15
15
  end
16
16
 
17
- def color (*args)
18
- Rays::Color.new *args
17
+ def color(*args)
18
+ Rays::Color.new(*args)
19
19
  end
20
20
 
21
- def test_initialize ()
21
+ def test_initialize()
22
22
  assert_raise(Rucy::NativeError) {shader "foo"}
23
23
  assert_raise(ArgumentError) {shader}
24
24
  #assert_raise(TypeError) {shader nil}
25
25
  assert shader("void main() {gl_FragColor = vec4(1, 0, 0, 1);}")
26
26
  end
27
27
 
28
- def test_shader ()
28
+ def test_shader()
29
29
  i = img.paint do
30
30
  shader "void main () {gl_FragColor = vec4(1.0, 0.0, 0.0, 1.0);}"
31
31
  fill 0, 1, 0, 1
32
- rect *bounds.move_to(0, 0).to_a
32
+ rect(*bounds.move_to(0, 0).to_a)
33
33
  end
34
34
  assert_equal color(1, 0, 0, 1), i[0, 0]
35
35
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: rays
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.20
4
+ version: 0.1.24
5
5
  platform: ruby
6
6
  authors:
7
7
  - xordog
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2020-12-10 00:00:00.000000000 Z
11
+ date: 2021-12-04 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: xot
@@ -16,52 +16,52 @@ dependencies:
16
16
  requirements:
17
17
  - - "~>"
18
18
  - !ruby/object:Gem::Version
19
- version: 0.1.20
19
+ version: 0.1.24
20
20
  type: :runtime
21
21
  prerelease: false
22
22
  version_requirements: !ruby/object:Gem::Requirement
23
23
  requirements:
24
24
  - - "~>"
25
25
  - !ruby/object:Gem::Version
26
- version: 0.1.20
26
+ version: 0.1.24
27
27
  - !ruby/object:Gem::Dependency
28
28
  name: rucy
29
29
  requirement: !ruby/object:Gem::Requirement
30
30
  requirements:
31
31
  - - "~>"
32
32
  - !ruby/object:Gem::Version
33
- version: 0.1.20
33
+ version: 0.1.24
34
34
  type: :runtime
35
35
  prerelease: false
36
36
  version_requirements: !ruby/object:Gem::Requirement
37
37
  requirements:
38
38
  - - "~>"
39
39
  - !ruby/object:Gem::Version
40
- version: 0.1.20
40
+ version: 0.1.24
41
41
  description: This library helps you to develop graphics application with OpenGL.
42
42
  email: xordog@gmail.com
43
43
  executables: []
44
44
  extensions:
45
45
  - Rakefile
46
46
  extra_rdoc_files:
47
- - ".doc/ext/rays/defs.cpp"
48
- - ".doc/ext/rays/image.cpp"
49
47
  - ".doc/ext/rays/bitmap.cpp"
48
+ - ".doc/ext/rays/bounds.cpp"
50
49
  - ".doc/ext/rays/camera.cpp"
51
- - ".doc/ext/rays/rays.cpp"
52
- - ".doc/ext/rays/font.cpp"
53
- - ".doc/ext/rays/color_space.cpp"
54
- - ".doc/ext/rays/polygon_line.cpp"
55
- - ".doc/ext/rays/painter.cpp"
56
- - ".doc/ext/rays/noise.cpp"
57
50
  - ".doc/ext/rays/color.cpp"
58
- - ".doc/ext/rays/shader.cpp"
51
+ - ".doc/ext/rays/color_space.cpp"
52
+ - ".doc/ext/rays/defs.cpp"
53
+ - ".doc/ext/rays/font.cpp"
54
+ - ".doc/ext/rays/image.cpp"
55
+ - ".doc/ext/rays/matrix.cpp"
59
56
  - ".doc/ext/rays/native.cpp"
57
+ - ".doc/ext/rays/noise.cpp"
58
+ - ".doc/ext/rays/painter.cpp"
60
59
  - ".doc/ext/rays/point.cpp"
61
- - ".doc/ext/rays/matrix.cpp"
62
60
  - ".doc/ext/rays/polygon.cpp"
61
+ - ".doc/ext/rays/polygon_line.cpp"
63
62
  - ".doc/ext/rays/polyline.cpp"
64
- - ".doc/ext/rays/bounds.cpp"
63
+ - ".doc/ext/rays/rays.cpp"
64
+ - ".doc/ext/rays/shader.cpp"
65
65
  files:
66
66
  - ".doc/ext/rays/bitmap.cpp"
67
67
  - ".doc/ext/rays/bounds.cpp"
@@ -243,16 +243,16 @@ require_paths:
243
243
  - lib
244
244
  required_ruby_version: !ruby/object:Gem::Requirement
245
245
  requirements:
246
- - - "~>"
246
+ - - ">="
247
247
  - !ruby/object:Gem::Version
248
- version: '2'
248
+ version: 2.6.0
249
249
  required_rubygems_version: !ruby/object:Gem::Requirement
250
250
  requirements:
251
251
  - - ">="
252
252
  - !ruby/object:Gem::Version
253
253
  version: '0'
254
254
  requirements: []
255
- rubygems_version: 3.0.3
255
+ rubygems_version: 3.2.32
256
256
  signing_key:
257
257
  specification_version: 4
258
258
  summary: A Drawing Engine using OpenGL.