rays 0.1.47 → 0.1.48
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/bitmap.cpp +287 -46
- data/.doc/ext/rays/camera.cpp +2 -2
- data/.doc/ext/rays/defs.cpp +32 -8
- data/.doc/ext/rays/font.cpp +50 -2
- data/.doc/ext/rays/native.cpp +2 -4
- data/.doc/ext/rays/painter.cpp +73 -3
- data/.doc/ext/rays/polygon.cpp +131 -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 +23 -0
- data/VERSION +1 -1
- data/ext/rays/bitmap.cpp +288 -46
- data/ext/rays/camera.cpp +2 -2
- data/ext/rays/defs.cpp +32 -8
- data/ext/rays/defs.h +56 -3
- data/ext/rays/font.cpp +56 -4
- data/ext/rays/native.cpp +2 -4
- data/ext/rays/painter.cpp +80 -3
- data/ext/rays/polygon.cpp +134 -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/defs.h +24 -26
- data/include/rays/font.h +17 -3
- data/include/rays/painter.h +14 -0
- data/include/rays/polygon.h +56 -37
- 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 +1 -1
- data/lib/rays/font.rb +1 -1
- data/lib/rays/image.rb +1 -1
- data/lib/rays/painter.rb +12 -1
- data/lib/rays/point.rb +1 -1
- data/lib/rays/polygon.rb +44 -35
- data/lib/rays/polyline.rb +54 -8
- data/lib/rays.rb +0 -1
- data/rays.gemspec +1 -1
- data/src/font.cpp +24 -2
- data/src/font.h +8 -1
- data/src/ios/font.mm +88 -27
- data/src/osx/font.mm +90 -28
- data/src/osx/helper.h +2 -2
- data/src/osx/helper.mm +2 -2
- data/src/painter.cpp +155 -85
- data/src/painter.h +11 -3
- data/src/polygon.cpp +404 -315
- 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 +2 -2
- 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 +4 -0
- data/test/test_font.rb +20 -2
- data/test/test_image.rb +18 -18
- data/test/test_point.rb +1 -1
- data/test/test_polygon.rb +52 -45
- data/test/test_polyline.rb +191 -72
- metadata +9 -15
- 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_polygon_line.rb
DELETED
@@ -1,164 +0,0 @@
|
|
1
|
-
require_relative 'helper'
|
2
|
-
|
3
|
-
|
4
|
-
class TestPolygonLine < Test::Unit::TestCase
|
5
|
-
|
6
|
-
class Rays::Polygon::Line
|
7
|
-
def dump()
|
8
|
-
map &:to_a
|
9
|
-
end
|
10
|
-
|
11
|
-
def loop_hole()
|
12
|
-
[loop?, hole?]
|
13
|
-
end
|
14
|
-
end
|
15
|
-
|
16
|
-
def line(*args, **kwargs)
|
17
|
-
Rays::Polygon::Line.new(*args, **kwargs)
|
18
|
-
end
|
19
|
-
|
20
|
-
def point(*args)
|
21
|
-
Rays::Point.new(*args)
|
22
|
-
end
|
23
|
-
|
24
|
-
def rect(*args)
|
25
|
-
Rays::Polygon.rect(*args)
|
26
|
-
end
|
27
|
-
|
28
|
-
def test_initialize()
|
29
|
-
assert_equal [[1, 2], [3, 4], [5, 6]], line( 1, 2, 3, 4 , 5, 6 ).dump
|
30
|
-
assert_equal [[1, 2], [3, 4], [5, 6]], line( [1, 2], [3, 4], [5, 6]).dump
|
31
|
-
assert_equal [[1, 1], [2, 2], [3, 3]], line( [1], [2], [3]).dump
|
32
|
-
assert_equal [[1, 1], [2, 2], [3, 3]], line(point(1), point(2), point(3)).dump
|
33
|
-
|
34
|
-
assert_equal [true, false], line(1, 2, 3, 4, 5, 6 ).loop_hole
|
35
|
-
assert_equal [true, false], line(1, 2, 3, 4, 5, 6, loop: true ).loop_hole
|
36
|
-
assert_equal [false, false], line(1, 2, 3, 4, 5, 6, loop: false ).loop_hole
|
37
|
-
assert_equal [true, true ], line(1, 2, 3, 4, 5, 6, hole: true ).loop_hole
|
38
|
-
assert_equal [true, false], line(1, 2, 3, 4, 5, 6, hole: false).loop_hole
|
39
|
-
assert_equal [true, true ], line(1, 2, 3, 4, 5, 6, loop: true, hole: true ).loop_hole
|
40
|
-
assert_equal [true, false], line(1, 2, 3, 4, 5, 6, loop: true, hole: false).loop_hole
|
41
|
-
assert_raise(ArgumentError) {line(1, 2, 3, 4, 5, 6, loop: false, hole: true ).loop_hole}
|
42
|
-
assert_equal [false, false], line(1, 2, 3, 4, 5, 6, loop: false, hole: false).loop_hole
|
43
|
-
|
44
|
-
assert_nothing_raised {line( loop: true, hole: true )}
|
45
|
-
assert_nothing_raised {line( loop: true, hole: false)}
|
46
|
-
assert_raise(ArgumentError) {line( loop: false, hole: true )}
|
47
|
-
assert_nothing_raised {line( loop: false, hole: false)}
|
48
|
-
assert_raise(ArgumentError) {line(1, loop: true, hole: true )}
|
49
|
-
assert_raise(ArgumentError) {line(1, loop: true, hole: false)}
|
50
|
-
assert_raise(ArgumentError) {line(1, loop: false, hole: true )}
|
51
|
-
assert_raise(ArgumentError) {line(1, loop: false, hole: false)}
|
52
|
-
assert_nothing_raised {line(1, 2, loop: true, hole: true )}
|
53
|
-
assert_nothing_raised {line(1, 2, loop: true, hole: false)}
|
54
|
-
assert_raise(ArgumentError) {line(1, 2, loop: false, hole: true )}
|
55
|
-
assert_nothing_raised {line(1, 2, loop: false, hole: false)}
|
56
|
-
assert_raise(ArgumentError) {line(1, 2, 3, loop: true, hole: true )}
|
57
|
-
assert_raise(ArgumentError) {line(1, 2, 3, loop: true, hole: false)}
|
58
|
-
assert_raise(ArgumentError) {line(1, 2, 3, loop: false, hole: true )}
|
59
|
-
assert_raise(ArgumentError) {line(1, 2, 3, loop: false, hole: false)}
|
60
|
-
assert_nothing_raised {line(1, 2, 3, 4, loop: true, hole: true )}
|
61
|
-
assert_nothing_raised {line(1, 2, 3, 4, loop: true, hole: false)}
|
62
|
-
assert_raise(ArgumentError) {line(1, 2, 3, 4, loop: false, hole: true )}
|
63
|
-
assert_nothing_raised {line(1, 2, 3, 4, loop: false, hole: false)}
|
64
|
-
assert_raise(ArgumentError) {line(1, 2, 3, 4, 5, loop: true, hole: true )}
|
65
|
-
assert_raise(ArgumentError) {line(1, 2, 3, 4, 5, loop: true, hole: false)}
|
66
|
-
assert_raise(ArgumentError) {line(1, 2, 3, 4, 5, loop: false, hole: true )}
|
67
|
-
assert_raise(ArgumentError) {line(1, 2, 3, 4, 5, loop: false, hole: false)}
|
68
|
-
assert_nothing_raised {line(1, 2, 3, 4, 5, 6, loop: true, hole: true )}
|
69
|
-
assert_nothing_raised {line(1, 2, 3, 4, 5, 6, loop: true, hole: false)}
|
70
|
-
assert_raise(ArgumentError) {line(1, 2, 3, 4, 5, 6, loop: false, hole: true )}
|
71
|
-
assert_nothing_raised {line(1, 2, 3, 4, 5, 6, loop: false, hole: false)}
|
72
|
-
end
|
73
|
-
|
74
|
-
def test_transform_with_materix()
|
75
|
-
m = Rays::Matrix.translate 100, 200
|
76
|
-
line([10,10], [20,20], loop: false).transform(m).tap {|o|
|
77
|
-
assert_equal [[110,210], [120,220]], o.dump
|
78
|
-
}
|
79
|
-
|
80
|
-
m = Rays::Matrix.scale 2
|
81
|
-
line([10,10], [20,20], loop: false).transform(m).tap {|o|
|
82
|
-
assert_equal [[20,20], [40,40]], o.dump
|
83
|
-
}
|
84
|
-
|
85
|
-
m = Rays::Matrix.rotate 90
|
86
|
-
line([10,10], [20,20], loop: false).transform(m).tap {|o|
|
87
|
-
assert_equal [[-10,10], [-20,20]], o.dump
|
88
|
-
}
|
89
|
-
end
|
90
|
-
|
91
|
-
def test_transform_with_block()
|
92
|
-
line([10,10], [20,20], loop: false).transform {|points|
|
93
|
-
points.map {|p| p + [10, 20]}
|
94
|
-
}.tap {|o|
|
95
|
-
assert_equal [[20,30], [30,40]], o.dump
|
96
|
-
}
|
97
|
-
|
98
|
-
line([10,10], [20,20], [30,30], loop: false).transform {|points|
|
99
|
-
points.reject {|p| p == point(20, 20)}
|
100
|
-
}.tap {|o|
|
101
|
-
assert_equal [[10,10], [30,30]], o.dump
|
102
|
-
}
|
103
|
-
|
104
|
-
line([10,10], [20,20], loop: false).transform {|points|
|
105
|
-
points + [[30, 30]]
|
106
|
-
}.tap {|o|
|
107
|
-
assert_equal [[10,10], [20,20], [30,30]], o.dump
|
108
|
-
}
|
109
|
-
|
110
|
-
points = [1, 2, 3, 4, 5, 6]
|
111
|
-
line(*points, loop: false, hole: false).transform(loop: true ).tap {|o|
|
112
|
-
assert_equal points, o.dump.flatten
|
113
|
-
assert_equal [true, false], o.loop_hole
|
114
|
-
}
|
115
|
-
assert_raise(ArgumentError) {
|
116
|
-
line(*points, loop: false, hole: false).transform( hole: true )
|
117
|
-
}
|
118
|
-
assert_raise(ArgumentError) {
|
119
|
-
line(*points, loop: false, hole: false).transform(loop: false, hole: true )
|
120
|
-
}
|
121
|
-
line(*points, loop: false, hole: false).transform(loop: true, hole: true ).tap {|o|
|
122
|
-
assert_equal points, o.dump.flatten
|
123
|
-
assert_equal [true, true ], o.loop_hole
|
124
|
-
}
|
125
|
-
line(*points, loop: true, hole: false).transform(loop: false ).tap {|o|
|
126
|
-
assert_equal points, o.dump.flatten
|
127
|
-
assert_equal [false, false], o.loop_hole
|
128
|
-
}
|
129
|
-
line(*points, loop: true, hole: false).transform( hole: true ).tap {|o|
|
130
|
-
assert_equal points, o.dump.flatten
|
131
|
-
assert_equal [true, true ], o.loop_hole
|
132
|
-
}
|
133
|
-
assert_raise(ArgumentError) {
|
134
|
-
line(*points, loop: true, hole: false).transform(loop: false, hole: true )
|
135
|
-
}
|
136
|
-
assert_raise(ArgumentError) {
|
137
|
-
line(*points, loop: true, hole: true ).transform(loop: false )
|
138
|
-
}
|
139
|
-
line(*points, loop: true, hole: true ).transform( hole: false).tap {|o|
|
140
|
-
assert_equal points, o.dump.flatten
|
141
|
-
assert_equal [true, false], o.loop_hole
|
142
|
-
}
|
143
|
-
line(*points, loop: true, hole: true ).transform(loop: false, hole: false).tap {|o|
|
144
|
-
assert_equal points, o.dump.flatten
|
145
|
-
assert_equal [false, false], o.loop_hole
|
146
|
-
}
|
147
|
-
end
|
148
|
-
|
149
|
-
def test_hole()
|
150
|
-
(rect(0, 0, 10, 10) - rect(1, 1, 2, 2)).tap {|o|
|
151
|
-
assert_equal 1, o.select {|line| line.hole?}.size
|
152
|
-
}
|
153
|
-
(rect(0, 0, 10, 10) - rect(100, 1, 2, 2)).tap {|o|
|
154
|
-
assert_equal 0, o.select {|line| line.hole?}.size
|
155
|
-
}
|
156
|
-
end
|
157
|
-
|
158
|
-
def test_inspect()
|
159
|
-
assert_equal(
|
160
|
-
"#<Rays::Polygon::Line [1.0, 2.0], [3.0, 4.0], [5.0, 6.0], loop: true, hole: false>",
|
161
|
-
line(1, 2, 3, 4, 5, 6).inspect)
|
162
|
-
end
|
163
|
-
|
164
|
-
end# TestPolygonLine
|