rays 0.1.47 → 0.1.49
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 +4 -4
- data/.doc/ext/rays/bitmap.cpp +287 -46
- data/.doc/ext/rays/camera.cpp +2 -2
- data/.doc/ext/rays/color.cpp +11 -0
- data/.doc/ext/rays/defs.cpp +32 -8
- data/.doc/ext/rays/font.cpp +50 -2
- data/.doc/ext/rays/image.cpp +3 -3
- data/.doc/ext/rays/matrix.cpp +65 -7
- data/.doc/ext/rays/native.cpp +2 -4
- data/.doc/ext/rays/painter.cpp +117 -9
- data/.doc/ext/rays/point.cpp +1 -11
- data/.doc/ext/rays/polygon.cpp +133 -97
- data/.doc/ext/rays/polyline.cpp +89 -10
- data/.doc/ext/rays/rays.cpp +80 -0
- data/.doc/ext/rays/{noise.cpp → util.cpp} +2 -2
- data/ChangeLog.md +46 -0
- data/VERSION +1 -1
- data/ext/rays/bitmap.cpp +288 -46
- data/ext/rays/camera.cpp +2 -2
- data/ext/rays/color.cpp +13 -1
- data/ext/rays/defs.cpp +32 -8
- data/ext/rays/defs.h +56 -3
- data/ext/rays/font.cpp +56 -4
- data/ext/rays/image.cpp +3 -3
- data/ext/rays/matrix.cpp +69 -7
- data/ext/rays/native.cpp +2 -4
- data/ext/rays/painter.cpp +132 -13
- data/ext/rays/point.cpp +1 -12
- data/ext/rays/polygon.cpp +136 -99
- data/ext/rays/polyline.cpp +95 -9
- data/ext/rays/rays.cpp +80 -0
- data/ext/rays/{noise.cpp → util.cpp} +2 -2
- data/include/rays/color.h +3 -1
- data/include/rays/defs.h +24 -26
- data/include/rays/font.h +17 -3
- data/include/rays/image.h +1 -1
- data/include/rays/matrix.h +24 -0
- data/include/rays/painter.h +24 -0
- data/include/rays/polygon.h +68 -43
- data/include/rays/polyline.h +17 -2
- data/include/rays/ruby/polygon.h +0 -11
- data/include/rays/ruby/rays.h +4 -0
- data/include/rays/{noise.h → util.h} +2 -2
- data/lib/rays/color.rb +7 -1
- data/lib/rays/font.rb +1 -1
- data/lib/rays/image.rb +11 -1
- data/lib/rays/matrix.rb +16 -0
- data/lib/rays/painter.rb +18 -7
- data/lib/rays/point.rb +5 -1
- data/lib/rays/polygon.rb +44 -35
- data/lib/rays/polyline.rb +54 -8
- data/lib/rays.rb +0 -1
- data/rays.gemspec +2 -2
- data/src/color.cpp +11 -2
- data/src/font.cpp +37 -18
- data/src/font.h +6 -5
- data/src/image.cpp +58 -14
- data/src/ios/font.mm +89 -32
- data/src/ios/helper.h +2 -2
- data/src/ios/helper.mm +2 -2
- data/src/matrix.cpp +45 -0
- data/src/osx/font.mm +93 -33
- data/src/osx/helper.h +2 -2
- data/src/osx/helper.mm +2 -2
- data/src/painter.cpp +246 -114
- data/src/painter.h +11 -3
- data/src/polygon.cpp +431 -332
- data/src/polyline.cpp +138 -27
- data/src/polyline.h +3 -5
- data/src/shader.cpp +36 -4
- data/src/shader.h +1 -1
- data/src/texture.cpp +23 -4
- data/src/texture.h +2 -0
- data/src/{noise.cpp → util.cpp} +1 -1
- data/src/win32/font.cpp +1 -1
- data/test/test_bitmap.rb +12 -5
- data/test/test_color.rb +25 -4
- data/test/test_font.rb +23 -2
- data/test/test_image.rb +44 -18
- data/test/test_matrix.rb +22 -0
- data/test/test_painter.rb +27 -0
- data/test/test_point.rb +1 -1
- data/test/test_polygon.rb +52 -45
- data/test/test_polyline.rb +191 -72
- metadata +12 -18
- data/.doc/ext/rays/polygon_line.cpp +0 -97
- data/ext/rays/polygon_line.cpp +0 -100
- data/lib/rays/polygon_line.rb +0 -33
- data/test/test_polygon_line.rb +0 -164
data/test/test_point.rb
CHANGED
data/test/test_polygon.rb
CHANGED
@@ -13,12 +13,8 @@ class TestPolygon < Test::Unit::TestCase
|
|
13
13
|
Rays::Polygon.new(*args, **kwargs)
|
14
14
|
end
|
15
15
|
|
16
|
-
def
|
17
|
-
Rays::
|
18
|
-
end
|
19
|
-
|
20
|
-
def polyline(*args)
|
21
|
-
Rays::Polyline.new(*args)
|
16
|
+
def polyline(*args, **kwargs)
|
17
|
+
Rays::Polyline.new(*args, **kwargs)
|
22
18
|
end
|
23
19
|
|
24
20
|
def point(*args)
|
@@ -44,20 +40,23 @@ class TestPolygon < Test::Unit::TestCase
|
|
44
40
|
assert_equal [[[5, 6], [7, 8]]], polygon( [5, 6], [7, 8], loop: false).dump
|
45
41
|
assert_equal [[[1, 1], [2, 2]]], polygon( [1], [2], loop: false).dump
|
46
42
|
assert_equal [[[3, 3], [4, 4]]], polygon(point(3), point(4), loop: false).dump
|
47
|
-
|
48
|
-
assert_nothing_raised {polygon(
|
49
|
-
|
50
|
-
assert_raise(ArgumentError) {polygon(1,
|
51
|
-
|
52
|
-
assert_nothing_raised {polygon(1,
|
53
|
-
|
54
|
-
assert_raise(ArgumentError) {polygon(1,
|
55
|
-
|
56
|
-
assert_nothing_raised {polygon(1,
|
57
|
-
|
58
|
-
assert_raise(ArgumentError) {polygon(1,
|
59
|
-
|
60
|
-
assert_nothing_raised {polygon(1,
|
43
|
+
|
44
|
+
assert_nothing_raised {polygon( loop: true)}
|
45
|
+
assert_nothing_raised {polygon( loop: false)}
|
46
|
+
assert_raise(ArgumentError) {polygon(1, loop: true)}
|
47
|
+
assert_raise(ArgumentError) {polygon(1, loop: false)}
|
48
|
+
assert_nothing_raised {polygon(1,2, loop: true)}
|
49
|
+
assert_nothing_raised {polygon(1,2, loop: false)}
|
50
|
+
assert_raise(ArgumentError) {polygon(1,2, 3, loop: true)}
|
51
|
+
assert_raise(ArgumentError) {polygon(1,2, 3, loop: false)}
|
52
|
+
assert_nothing_raised {polygon(1,2, 3,4, loop: true)}
|
53
|
+
assert_nothing_raised {polygon(1,2, 3,4, loop: false)}
|
54
|
+
assert_raise(ArgumentError) {polygon(1,2, 3,4, 5, loop: true)}
|
55
|
+
assert_raise(ArgumentError) {polygon(1,2, 3,4, 5, loop: false)}
|
56
|
+
assert_nothing_raised {polygon(1,2, 3,4, 5,6, loop: true)}
|
57
|
+
assert_nothing_raised {polygon(1,2, 3,4, 5,6, loop: false)}
|
58
|
+
|
59
|
+
assert_raise(ArgumentError) {polygon(polyline(1,2, 3,4, 5,6, loop: true, hole: true))}
|
61
60
|
end
|
62
61
|
|
63
62
|
def test_expand()
|
@@ -71,43 +70,26 @@ class TestPolygon < Test::Unit::TestCase
|
|
71
70
|
}
|
72
71
|
end
|
73
72
|
|
74
|
-
def
|
75
|
-
m = Rays::Matrix.translate 10, 10
|
76
|
-
assert_equal_polygon rect(20, 20, 50, 50), rect(10, 10, 50, 50).transform(m)
|
77
|
-
|
78
|
-
m = Rays::Matrix.scale 2
|
79
|
-
assert_equal_polygon rect(20, 20, 40, 40), rect(10, 10, 20, 20).transform(m)
|
80
|
-
|
81
|
-
m = Rays::Matrix.rotate 90
|
82
|
-
assert_equal_polygon rect(-10, 0, 10, 10), rect(0, 0, 10, 10).transform(m)
|
83
|
-
end
|
84
|
-
|
85
|
-
def test_transform_block()
|
73
|
+
def test_transform()
|
86
74
|
o = rect(0, 0, 100, 100) - rect(10, 10, 50, 50)
|
87
75
|
assert_equal 2, o.size
|
88
76
|
|
89
|
-
o.transform {|
|
90
|
-
|
77
|
+
o.transform {|polylines|
|
78
|
+
m = Rays::Matrix.translate 10, 10
|
79
|
+
polylines.map {|pl| pl.with points: pl.points.map {|p| m * p}}
|
91
80
|
}.tap {|x|
|
92
81
|
assert_equal_polygon (rect(10, 10, 100, 100) - rect(20, 20, 50, 50)), x
|
93
82
|
}
|
94
83
|
|
95
|
-
o.transform {|
|
96
|
-
|
84
|
+
o.transform {|polylines|
|
85
|
+
polylines.reject {|pl| pl.to_a.include? point(10, 10)}
|
97
86
|
}.tap {|x|
|
98
87
|
assert_equal 1, x.size
|
99
88
|
assert_equal 2, o.size
|
100
89
|
}
|
101
90
|
|
102
|
-
o.transform {|
|
103
|
-
|
104
|
-
}.tap {|x|
|
105
|
-
assert_equal 1, x.size
|
106
|
-
assert_equal 2, o.size
|
107
|
-
}
|
108
|
-
|
109
|
-
o.transform {|lines|
|
110
|
-
lines + [line(1, 2, 3, 4, 5, 6)]
|
91
|
+
o.transform {|polylines|
|
92
|
+
polylines + [polyline(1, 2, 3, 4, 5, 6)]
|
111
93
|
}.tap {|x|
|
112
94
|
assert_equal 3, x.size
|
113
95
|
assert_equal 2, o.size
|
@@ -156,6 +138,31 @@ class TestPolygon < Test::Unit::TestCase
|
|
156
138
|
assert_raise(IndexError) {o[-4]}
|
157
139
|
end
|
158
140
|
|
141
|
+
def test_add()
|
142
|
+
assert_equal_polygon(
|
143
|
+
polygon(*rect(0, 0, 10, 10).to_a, *rect(5, 0, 10, 10).to_a),
|
144
|
+
rect(0, 0, 10, 10) + rect(5, 0, 10, 10))
|
145
|
+
|
146
|
+
assert_equal_polygon(
|
147
|
+
polygon(*rect(0, 0, 10, 10).to_a, *rect(5, 0, 10, 10).to_a, *rect(10, 0, 10, 10).to_a),
|
148
|
+
rect(0, 0, 10, 10) + [rect(5, 0, 10, 10), rect(10, 0, 10, 10)])
|
149
|
+
|
150
|
+
o = rect(0, 0, 10, 10)
|
151
|
+
assert_equal_polygon(
|
152
|
+
polygon(*rect(0, 0, 10, 10).to_a, *rect(0, 0, 10, 10).to_a),
|
153
|
+
o + o)
|
154
|
+
|
155
|
+
assert_equal_polygon rect(0, 0, 10, 10), rect(0, 0, 10, 10) + polygon()
|
156
|
+
assert_equal_polygon rect(0, 0, 10, 10), polygon() + rect(0, 0, 10, 10)
|
157
|
+
assert_equal_polygon rect(0, 0, 10, 10), rect(0, 0, 10, 10) + []
|
158
|
+
|
159
|
+
assert_equal(
|
160
|
+
polygon(
|
161
|
+
polyline(0,0, 0,10, 10,10, 10,0, loop: true, fill: true),
|
162
|
+
polyline(1,1, 2,1, 2,2, 1,2, loop: true, fill: true, hole: true)),
|
163
|
+
polygon(0,0, 0,10, 10,10, 10,0) + polyline(1,1, 2,1, 2,2, 1,2, loop: true, hole: true))
|
164
|
+
end
|
165
|
+
|
159
166
|
def test_sub()
|
160
167
|
rect10 = rect 0, 0, 10, 10
|
161
168
|
|
data/test/test_polyline.rb
CHANGED
@@ -3,12 +3,6 @@ require_relative 'helper'
|
|
3
3
|
|
4
4
|
class TestPolyline < Test::Unit::TestCase
|
5
5
|
|
6
|
-
class Rays::Polyline
|
7
|
-
def dump()
|
8
|
-
map &:to_a
|
9
|
-
end
|
10
|
-
end
|
11
|
-
|
12
6
|
def polyline(*args, **kwargs)
|
13
7
|
Rays::Polyline.new(*args, **kwargs)
|
14
8
|
end
|
@@ -21,32 +15,101 @@ class TestPolyline < Test::Unit::TestCase
|
|
21
15
|
Rays::Bounds.new(*args)
|
22
16
|
end
|
23
17
|
|
24
|
-
def
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
-
|
38
|
-
|
39
|
-
|
40
|
-
|
41
|
-
|
42
|
-
|
43
|
-
|
44
|
-
|
45
|
-
|
46
|
-
|
47
|
-
|
48
|
-
|
49
|
-
|
18
|
+
def color(*args)
|
19
|
+
Rays::Color.new(*args)
|
20
|
+
end
|
21
|
+
|
22
|
+
def dump(pl, name = :points)
|
23
|
+
pl.send(name).map(&:to_a)
|
24
|
+
end
|
25
|
+
|
26
|
+
def test_initialize_points()
|
27
|
+
assert_equal [[1,2], [3,4]], dump(polyline( 1,2, 3,4 ))
|
28
|
+
assert_equal [[1,2], [3,4]], dump(polyline( [1,2], [3,4]))
|
29
|
+
assert_equal [[1,1], [2,2]], dump(polyline( [1], [2]))
|
30
|
+
assert_equal [[1,1], [2,2]], dump(polyline(point(1), point(2)))
|
31
|
+
end
|
32
|
+
|
33
|
+
def test_initialize_colors()
|
34
|
+
assert_equal( [[1,2,3,1], [4,5,6,1]],
|
35
|
+
dump(polyline(1,2, 3,4, colors: [ 1,2,3, 4,5,6 ]), :colors))
|
36
|
+
assert_equal( [[1,2,3,1], [4,5,6,1]],
|
37
|
+
dump(polyline(1,2, 3,4, colors: [[1,2,3], [4,5,6] ]), :colors))
|
38
|
+
assert_equal( [[1,1,1,1], [2,2,2,1]],
|
39
|
+
dump(polyline(1,2, 3,4, colors: [[1], [2] ]), :colors))
|
40
|
+
assert_equal( [[1,1,1,1], [2,2,2,1]],
|
41
|
+
dump(polyline(1,2, 3,4, colors: [color(1), color(2) ]), :colors))
|
42
|
+
|
43
|
+
assert_raise(ArgumentError) {polyline([1,2, 3,4], colors: [[1,2,3]])}
|
44
|
+
end
|
45
|
+
|
46
|
+
def test_initialize_texcoords()
|
47
|
+
assert_equal( [[1,2], [3,4]],
|
48
|
+
dump(polyline(1,2, 3,4, texcoords: [ 1,2, 3,4 ]), :texcoords))
|
49
|
+
assert_equal( [[1,2], [3,4]],
|
50
|
+
dump(polyline(1,2, 3,4, texcoords: [[1,2], [3,4]]), :texcoords))
|
51
|
+
assert_equal( [[1,1], [2,2]],
|
52
|
+
dump(polyline(1,2, 3,4, texcoords: [[1], [2] ]), :texcoords))
|
53
|
+
assert_equal( [[1,2], [3,4]],
|
54
|
+
dump(polyline(1,2, 3,4, texcoords: [point(1,2), point(3,4)]), :texcoords))
|
55
|
+
|
56
|
+
assert_raise(ArgumentError) {polyline([1,2, 3,4], texcoords: [[1,2]])}
|
57
|
+
end
|
58
|
+
|
59
|
+
def test_initialize_loop_fill()
|
60
|
+
get = -> pl {[pl.loop?, pl.fill?]}
|
61
|
+
|
62
|
+
assert_equal [false, false], get[polyline(1,2, 3,4, 5,6)]
|
63
|
+
|
64
|
+
assert_equal [true, true], get[polyline(1,2, 3,4, 5,6, loop: true)]
|
65
|
+
assert_equal [false, false], get[polyline(1,2, 3,4, 5,6, loop: false)]
|
66
|
+
assert_equal [false, true], get[polyline(1,2, 3,4, 5,6, fill: true)]
|
67
|
+
assert_equal [false, false], get[polyline(1,2, 3,4, 5,6, fill: false)]
|
68
|
+
|
69
|
+
assert_equal [true, true], get[polyline(1,2, 3,4, 5,6, loop: true, fill: true)]
|
70
|
+
assert_equal [true, false], get[polyline(1,2, 3,4, 5,6, loop: true, fill: false)]
|
71
|
+
assert_equal [false, true], get[polyline(1,2, 3,4, 5,6, loop: false, fill: true)]
|
72
|
+
assert_equal [false, false], get[polyline(1,2, 3,4, 5,6, loop: false, fill: false)]
|
73
|
+
|
74
|
+
assert_equal [true, true], get[polyline( loop: true, fill: true)]
|
75
|
+
assert_equal [true, false], get[polyline( loop: true, fill: false)]
|
76
|
+
assert_equal [false, true], get[polyline( loop: false, fill: true)]
|
77
|
+
assert_equal [false, false], get[polyline( loop: false, fill: false)]
|
78
|
+
end
|
79
|
+
|
80
|
+
def test_initialize_hole()
|
81
|
+
assert_false polyline(1,2, 3,4, 5,6, loop: true).hole?
|
82
|
+
|
83
|
+
assert_true polyline(1,2, 3,4, 5,6, loop: true, hole: true) .hole?
|
84
|
+
assert_false polyline(1,2, 3,4, 5,6, loop: true, hole: false).hole?
|
85
|
+
|
86
|
+
assert_true polyline( loop: true, hole: true) .hole?
|
87
|
+
assert_false polyline( loop: true, hole: false).hole?
|
88
|
+
end
|
89
|
+
|
90
|
+
def test_initialize_errors()
|
91
|
+
assert_nothing_raised {polyline( loop: true, hole: true)}
|
92
|
+
assert_nothing_raised {polyline( loop: true, hole: false)}
|
93
|
+
assert_raise(ArgumentError) {polyline( loop: false, hole: true)}
|
94
|
+
assert_nothing_raised {polyline( loop: false, hole: false)}
|
95
|
+
assert_raise(ArgumentError) {polyline(1, loop: true)}
|
96
|
+
assert_raise(ArgumentError) {polyline(1, loop: false)}
|
97
|
+
assert_nothing_raised {polyline(1,2, loop: true, hole: true)}
|
98
|
+
assert_nothing_raised {polyline(1,2, loop: true, hole: false)}
|
99
|
+
assert_raise(ArgumentError) {polyline(1,2, loop: false, hole: true)}
|
100
|
+
assert_nothing_raised {polyline(1,2, loop: false, hole: false)}
|
101
|
+
assert_raise(ArgumentError) {polyline(1,2, 3, loop: true)}
|
102
|
+
assert_raise(ArgumentError) {polyline(1,2, 3, loop: false)}
|
103
|
+
assert_nothing_raised {polyline(1,2, 3,4, loop: true, hole: true)}
|
104
|
+
assert_nothing_raised {polyline(1,2, 3,4, loop: true, hole: false)}
|
105
|
+
assert_raise(ArgumentError) {polyline(1,2, 3,4, loop: false, hole: true)}
|
106
|
+
assert_nothing_raised {polyline(1,2, 3,4, loop: false, hole: false)}
|
107
|
+
assert_raise(ArgumentError) {polyline(1,2, 3,4, 5, loop: true)}
|
108
|
+
assert_raise(ArgumentError) {polyline(1,2, 3,4, 5, loop: false)}
|
109
|
+
assert_nothing_raised {polyline(1,2, 3,4, 5,6, loop: true, hole: true)}
|
110
|
+
assert_nothing_raised {polyline(1,2, 3,4, 5,6, loop: true, hole: false)}
|
111
|
+
assert_raise(ArgumentError) {polyline(1,2, 3,4, 5,6, loop: false, hole: true)}
|
112
|
+
assert_nothing_raised {polyline(1,2, 3,4, 5,6, loop: false, hole: false)}
|
50
113
|
end
|
51
114
|
|
52
115
|
def test_expand()
|
@@ -91,46 +154,74 @@ class TestPolyline < Test::Unit::TestCase
|
|
91
154
|
assert_raise(ArgumentError) {pl[].expand 1, 99}
|
92
155
|
end
|
93
156
|
|
94
|
-
def
|
95
|
-
|
96
|
-
polyline(
|
97
|
-
assert_equal [[110,210], [120,220]], o.dump
|
98
|
-
}
|
157
|
+
def test_with_points()
|
158
|
+
assert_equal polyline(5,6, 7,8), polyline(1,2, 3,4).with(points: [5,6, 7,8])
|
159
|
+
assert_equal polyline(5,6), polyline(1,2, 3,4).with(points: [5,6])
|
99
160
|
|
100
|
-
|
101
|
-
|
102
|
-
|
103
|
-
|
161
|
+
assert_raise(ArgumentError) do
|
162
|
+
polyline(1,2, 3,4, colors: [[1], [2]]).with(points: [1,2])
|
163
|
+
end
|
164
|
+
end
|
104
165
|
|
105
|
-
|
106
|
-
|
107
|
-
|
108
|
-
|
166
|
+
def test_with_loop_fill()
|
167
|
+
assert_equal(
|
168
|
+
polyline(1,2, 3,4, 5,6, loop: false, fill: false),
|
169
|
+
polyline(1,2, 3,4, 5,6))
|
170
|
+
assert_equal(
|
171
|
+
polyline(1,2, 3,4, 5,6, loop: true, fill: false),
|
172
|
+
polyline(1,2, 3,4, 5,6).with(loop: true))
|
173
|
+
assert_equal(
|
174
|
+
polyline(1,2, 3,4, 5,6, loop: false, fill: true),
|
175
|
+
polyline(1,2, 3,4, 5,6).with( fill: true))
|
109
176
|
end
|
110
177
|
|
111
|
-
def
|
112
|
-
|
113
|
-
|
114
|
-
|
115
|
-
|
116
|
-
|
178
|
+
def test_with_colors()
|
179
|
+
assert_equal(
|
180
|
+
polyline(1,2, 3,4, texcoords: [1,2, 3,4]),
|
181
|
+
polyline(1,2, 3,4).with(texcoords: [1,2, 3,4]))
|
182
|
+
assert_equal(
|
183
|
+
polyline(1,2, 3,4, texcoords: [5,6, 7,8]),
|
184
|
+
polyline(1,2, 3,4, texcoords: [1,2, 3,4]).with(texcoords: [5,6, 7,8]))
|
117
185
|
|
118
|
-
polyline(
|
119
|
-
|
120
|
-
}.tap {|o|
|
121
|
-
assert_equal [[10,10], [30,30]], o.dump
|
122
|
-
}
|
186
|
+
assert_raise(ArgumentError) {polyline(1,2, 3,4).with(colors: [[1]])}
|
187
|
+
end
|
123
188
|
|
124
|
-
|
125
|
-
|
126
|
-
|
127
|
-
|
128
|
-
|
189
|
+
def test_with_texcoords()
|
190
|
+
assert_equal(
|
191
|
+
polyline(1,2, 3,4, colors: [[1], [2]]),
|
192
|
+
polyline(1,2, 3,4).with(colors: [[1], [2]]))
|
193
|
+
assert_equal(
|
194
|
+
polyline(1,2, 3,4, colors: [[3], [4]]),
|
195
|
+
polyline(1,2, 3,4, colors: [[1], [2]]).with(colors: [[3], [4]]))
|
129
196
|
|
130
|
-
polyline(
|
131
|
-
|
132
|
-
|
133
|
-
|
197
|
+
assert_raise(ArgumentError) {polyline(1,2, 3,4).with(colors: [[1]])}
|
198
|
+
end
|
199
|
+
|
200
|
+
def test_with_hole()
|
201
|
+
assert_equal(
|
202
|
+
polyline(1,2, 3,4, 5,6, loop: true, hole: false),
|
203
|
+
polyline(1,2, 3,4, 5,6, loop: true))
|
204
|
+
assert_equal(
|
205
|
+
polyline(1,2, 3,4, 5,6, loop: true, hole: true),
|
206
|
+
polyline(1,2, 3,4, 5,6, loop: true).with(hole: true))
|
207
|
+
end
|
208
|
+
|
209
|
+
def test_equal()
|
210
|
+
assert_false polyline(1,2, 3,4) == polyline(1,2)
|
211
|
+
|
212
|
+
assert_true polyline(1,2, 3,4) == polyline(1,2, 3,4)
|
213
|
+
assert_false polyline(1,2, 3,4) == polyline(1,2, 3,9)
|
214
|
+
|
215
|
+
assert_true polyline(1,2, 3,4, loop: true, fill: true) == polyline(1,2, 3,4, loop: true, fill: true)
|
216
|
+
assert_true polyline(1,2, 3,4, loop: false, fill: false) == polyline(1,2, 3,4, loop: false, fill: false)
|
217
|
+
assert_false polyline(1,2, 3,4, loop: false, fill: false) == polyline(1,2, 3,4, loop: true, fill: false)
|
218
|
+
assert_false polyline(1,2, 3,4, loop: false, fill: false) == polyline(1,2, 3,4, loop: false, fill: true)
|
219
|
+
|
220
|
+
assert_true polyline(1,2, 3,4, colors: [[1], [2]]) == polyline(1,2, 3,4, colors: [[1], [2]])
|
221
|
+
assert_false polyline(1,2, 3,4, colors: [[1], [2]]) == polyline(1,2, 3,4, colors: [[1], [9]])
|
222
|
+
|
223
|
+
assert_true polyline(1,2, 3,4, texcoords: [1,2, 3,4]) == polyline(1,2, 3,4, texcoords: [1,2, 3,4])
|
224
|
+
assert_false polyline(1,2, 3,4, texcoords: [1,2, 3,4]) == polyline(1,2, 3,4, texcoords: [1,2, 3,9])
|
134
225
|
end
|
135
226
|
|
136
227
|
def test_bounds()
|
@@ -140,18 +231,34 @@ class TestPolyline < Test::Unit::TestCase
|
|
140
231
|
assert_not polyline() .bounds.valid?
|
141
232
|
end
|
142
233
|
|
234
|
+
def test_loop_fill()
|
235
|
+
get = -> pl {[pl.loop?, pl.fill?]}
|
236
|
+
|
237
|
+
assert_equal [false, false], get[polyline(1,2, 3,4)]
|
238
|
+
assert_equal [true, true], get[polyline(1,2, 3,4, loop: true)]
|
239
|
+
assert_equal [false, false], get[polyline(1,2, 3,4, loop: false)]
|
240
|
+
assert_equal [false, true], get[polyline(1,2, 3,4, fill: true)]
|
241
|
+
assert_equal [false, false], get[polyline(1,2, 3,4, fill: false)]
|
242
|
+
assert_equal [true, true], get[polyline(1,2, 3,4, loop: true, fill: true)]
|
243
|
+
assert_equal [false, false], get[polyline(1,2, 3,4, loop: false, fill: false)]
|
244
|
+
assert_equal [true, false], get[polyline(1,2, 3,4, loop: true, fill: false)]
|
245
|
+
assert_equal [false, true], get[polyline(1,2, 3,4, loop: false, fill: true)]
|
246
|
+
end
|
247
|
+
|
143
248
|
def test_size()
|
144
|
-
assert_equal
|
145
|
-
assert_equal
|
249
|
+
assert_equal 0, polyline() .size
|
250
|
+
assert_equal 1, polyline(1,2) .size
|
251
|
+
assert_equal 2, polyline(1,2, 3,4) .size
|
252
|
+
assert_equal 3, polyline(1,2, 3,4, 5,6).size
|
146
253
|
end
|
147
254
|
|
148
255
|
def test_empty?()
|
149
|
-
assert_equal true, polyline(
|
150
|
-
assert_equal false, polyline(1,
|
256
|
+
assert_equal true, polyline() .empty?
|
257
|
+
assert_equal false, polyline(1,2, 3,4).empty?
|
151
258
|
end
|
152
259
|
|
153
260
|
def test_index()
|
154
|
-
o = polyline 1,
|
261
|
+
o = polyline 1,2, 3,4, 5,6
|
155
262
|
assert_equal [1, 2], o[ 0].to_a
|
156
263
|
assert_equal [3, 4], o[ 1].to_a
|
157
264
|
assert_equal [5, 6], o[-1].to_a
|
@@ -161,8 +268,20 @@ class TestPolyline < Test::Unit::TestCase
|
|
161
268
|
|
162
269
|
def test_inspect()
|
163
270
|
assert_equal(
|
164
|
-
"#<Rays::Polyline [1.0,
|
165
|
-
polyline(1,
|
271
|
+
"#<Rays::Polyline [1.0,2.0, 3.0,4.0] loop:false fill:false hole:false colors:0 texcoords:0>",
|
272
|
+
polyline(1,2, 3,4).inspect)
|
273
|
+
assert_equal(
|
274
|
+
"#<Rays::Polyline [1.0,2.0, 3.0,4.0] loop:true fill:false hole:false colors:0 texcoords:0>",
|
275
|
+
polyline(1,2, 3,4, loop: true, fill: false).inspect)
|
276
|
+
assert_equal(
|
277
|
+
"#<Rays::Polyline [1.0,2.0, 3.0,4.0] loop:false fill:true hole:false colors:0 texcoords:0>",
|
278
|
+
polyline(1,2, 3,4, loop: false, fill: true).inspect)
|
279
|
+
assert_equal(
|
280
|
+
"#<Rays::Polyline [1.0,2.0, 3.0,4.0] loop:false fill:false hole:false colors:2 texcoords:0>",
|
281
|
+
polyline(1,2, 3,4, colors: [[1], [2]]).inspect)
|
282
|
+
assert_equal(
|
283
|
+
"#<Rays::Polyline [1.0,2.0, 3.0,4.0] loop:false fill:false hole:false colors:0 texcoords:2>",
|
284
|
+
polyline(1,2, 3,4, texcoords: [1,2, 3,4]).inspect)
|
166
285
|
end
|
167
286
|
|
168
287
|
end# TestPolyline
|
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.
|
4
|
+
version: 0.1.49
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- xordog
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2024-02-06 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: xot
|
@@ -16,28 +16,28 @@ dependencies:
|
|
16
16
|
requirements:
|
17
17
|
- - "~>"
|
18
18
|
- !ruby/object:Gem::Version
|
19
|
-
version: 0.1.
|
19
|
+
version: 0.1.42
|
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.
|
26
|
+
version: 0.1.42
|
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.
|
33
|
+
version: 0.1.44
|
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.
|
40
|
+
version: 0.1.44
|
41
41
|
description: This library helps you to develop graphics application with OpenGL.
|
42
42
|
email: xordog@gmail.com
|
43
43
|
executables: []
|
@@ -55,14 +55,13 @@ extra_rdoc_files:
|
|
55
55
|
- ".doc/ext/rays/image.cpp"
|
56
56
|
- ".doc/ext/rays/matrix.cpp"
|
57
57
|
- ".doc/ext/rays/native.cpp"
|
58
|
-
- ".doc/ext/rays/noise.cpp"
|
59
58
|
- ".doc/ext/rays/painter.cpp"
|
60
59
|
- ".doc/ext/rays/point.cpp"
|
61
60
|
- ".doc/ext/rays/polygon.cpp"
|
62
|
-
- ".doc/ext/rays/polygon_line.cpp"
|
63
61
|
- ".doc/ext/rays/polyline.cpp"
|
64
62
|
- ".doc/ext/rays/rays.cpp"
|
65
63
|
- ".doc/ext/rays/shader.cpp"
|
64
|
+
- ".doc/ext/rays/util.cpp"
|
66
65
|
files:
|
67
66
|
- ".doc/ext/rays/bitmap.cpp"
|
68
67
|
- ".doc/ext/rays/bounds.cpp"
|
@@ -75,14 +74,13 @@ files:
|
|
75
74
|
- ".doc/ext/rays/image.cpp"
|
76
75
|
- ".doc/ext/rays/matrix.cpp"
|
77
76
|
- ".doc/ext/rays/native.cpp"
|
78
|
-
- ".doc/ext/rays/noise.cpp"
|
79
77
|
- ".doc/ext/rays/painter.cpp"
|
80
78
|
- ".doc/ext/rays/point.cpp"
|
81
79
|
- ".doc/ext/rays/polygon.cpp"
|
82
|
-
- ".doc/ext/rays/polygon_line.cpp"
|
83
80
|
- ".doc/ext/rays/polyline.cpp"
|
84
81
|
- ".doc/ext/rays/rays.cpp"
|
85
82
|
- ".doc/ext/rays/shader.cpp"
|
83
|
+
- ".doc/ext/rays/util.cpp"
|
86
84
|
- ".github/workflows/release-gem.yml"
|
87
85
|
- ".github/workflows/tag.yml"
|
88
86
|
- ".github/workflows/test.yml"
|
@@ -107,14 +105,13 @@ files:
|
|
107
105
|
- ext/rays/image.cpp
|
108
106
|
- ext/rays/matrix.cpp
|
109
107
|
- ext/rays/native.cpp
|
110
|
-
- ext/rays/noise.cpp
|
111
108
|
- ext/rays/painter.cpp
|
112
109
|
- ext/rays/point.cpp
|
113
110
|
- ext/rays/polygon.cpp
|
114
|
-
- ext/rays/polygon_line.cpp
|
115
111
|
- ext/rays/polyline.cpp
|
116
112
|
- ext/rays/rays.cpp
|
117
113
|
- ext/rays/shader.cpp
|
114
|
+
- ext/rays/util.cpp
|
118
115
|
- include/rays.h
|
119
116
|
- include/rays/bitmap.h
|
120
117
|
- include/rays/bounds.h
|
@@ -128,7 +125,6 @@ files:
|
|
128
125
|
- include/rays/font.h
|
129
126
|
- include/rays/image.h
|
130
127
|
- include/rays/matrix.h
|
131
|
-
- include/rays/noise.h
|
132
128
|
- include/rays/opengl.h
|
133
129
|
- include/rays/painter.h
|
134
130
|
- include/rays/point.h
|
@@ -153,6 +149,7 @@ files:
|
|
153
149
|
- include/rays/ruby/rays.h
|
154
150
|
- include/rays/ruby/shader.h
|
155
151
|
- include/rays/shader.h
|
152
|
+
- include/rays/util.h
|
156
153
|
- lib/rays.rb
|
157
154
|
- lib/rays/autoinit.rb
|
158
155
|
- lib/rays/bitmap.rb
|
@@ -168,7 +165,6 @@ files:
|
|
168
165
|
- lib/rays/painter.rb
|
169
166
|
- lib/rays/point.rb
|
170
167
|
- lib/rays/polygon.rb
|
171
|
-
- lib/rays/polygon_line.rb
|
172
168
|
- lib/rays/polyline.rb
|
173
169
|
- lib/rays/shader.rb
|
174
170
|
- rays.gemspec
|
@@ -196,7 +192,6 @@ files:
|
|
196
192
|
- src/ios/rays.mm
|
197
193
|
- src/matrix.cpp
|
198
194
|
- src/matrix.h
|
199
|
-
- src/noise.cpp
|
200
195
|
- src/opengl.cpp
|
201
196
|
- src/opengl.h
|
202
197
|
- src/osx/bitmap.h
|
@@ -224,6 +219,7 @@ files:
|
|
224
219
|
- src/shader_source.h
|
225
220
|
- src/texture.cpp
|
226
221
|
- src/texture.h
|
222
|
+
- src/util.cpp
|
227
223
|
- src/win32/bitmap.cpp
|
228
224
|
- src/win32/font.cpp
|
229
225
|
- src/win32/font.h
|
@@ -242,7 +238,6 @@ files:
|
|
242
238
|
- test/test_painter_shape.rb
|
243
239
|
- test/test_point.rb
|
244
240
|
- test/test_polygon.rb
|
245
|
-
- test/test_polygon_line.rb
|
246
241
|
- test/test_polyline.rb
|
247
242
|
- test/test_rays_init.rb
|
248
243
|
- test/test_shader.rb
|
@@ -265,7 +260,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
265
260
|
- !ruby/object:Gem::Version
|
266
261
|
version: '0'
|
267
262
|
requirements: []
|
268
|
-
rubygems_version: 3.4.
|
263
|
+
rubygems_version: 3.4.19
|
269
264
|
signing_key:
|
270
265
|
specification_version: 4
|
271
266
|
summary: A Drawing Engine using OpenGL.
|
@@ -282,7 +277,6 @@ test_files:
|
|
282
277
|
- test/test_painter_shape.rb
|
283
278
|
- test/test_point.rb
|
284
279
|
- test/test_polygon.rb
|
285
|
-
- test/test_polygon_line.rb
|
286
280
|
- test/test_polyline.rb
|
287
281
|
- test/test_rays_init.rb
|
288
282
|
- test/test_shader.rb
|