rays 0.1.47 → 0.1.48

Sign up to get free protection for your applications and to get access to all the features.
Files changed (69) hide show
  1. checksums.yaml +4 -4
  2. data/.doc/ext/rays/bitmap.cpp +287 -46
  3. data/.doc/ext/rays/camera.cpp +2 -2
  4. data/.doc/ext/rays/defs.cpp +32 -8
  5. data/.doc/ext/rays/font.cpp +50 -2
  6. data/.doc/ext/rays/native.cpp +2 -4
  7. data/.doc/ext/rays/painter.cpp +73 -3
  8. data/.doc/ext/rays/polygon.cpp +131 -97
  9. data/.doc/ext/rays/polyline.cpp +89 -10
  10. data/.doc/ext/rays/rays.cpp +80 -0
  11. data/.doc/ext/rays/{noise.cpp → util.cpp} +2 -2
  12. data/ChangeLog.md +23 -0
  13. data/VERSION +1 -1
  14. data/ext/rays/bitmap.cpp +288 -46
  15. data/ext/rays/camera.cpp +2 -2
  16. data/ext/rays/defs.cpp +32 -8
  17. data/ext/rays/defs.h +56 -3
  18. data/ext/rays/font.cpp +56 -4
  19. data/ext/rays/native.cpp +2 -4
  20. data/ext/rays/painter.cpp +80 -3
  21. data/ext/rays/polygon.cpp +134 -99
  22. data/ext/rays/polyline.cpp +95 -9
  23. data/ext/rays/rays.cpp +80 -0
  24. data/ext/rays/{noise.cpp → util.cpp} +2 -2
  25. data/include/rays/defs.h +24 -26
  26. data/include/rays/font.h +17 -3
  27. data/include/rays/painter.h +14 -0
  28. data/include/rays/polygon.h +56 -37
  29. data/include/rays/polyline.h +17 -2
  30. data/include/rays/ruby/polygon.h +0 -11
  31. data/include/rays/ruby/rays.h +4 -0
  32. data/include/rays/{noise.h → util.h} +2 -2
  33. data/lib/rays/color.rb +1 -1
  34. data/lib/rays/font.rb +1 -1
  35. data/lib/rays/image.rb +1 -1
  36. data/lib/rays/painter.rb +12 -1
  37. data/lib/rays/point.rb +1 -1
  38. data/lib/rays/polygon.rb +44 -35
  39. data/lib/rays/polyline.rb +54 -8
  40. data/lib/rays.rb +0 -1
  41. data/rays.gemspec +1 -1
  42. data/src/font.cpp +24 -2
  43. data/src/font.h +8 -1
  44. data/src/ios/font.mm +88 -27
  45. data/src/osx/font.mm +90 -28
  46. data/src/osx/helper.h +2 -2
  47. data/src/osx/helper.mm +2 -2
  48. data/src/painter.cpp +155 -85
  49. data/src/painter.h +11 -3
  50. data/src/polygon.cpp +404 -315
  51. data/src/polyline.cpp +138 -27
  52. data/src/polyline.h +3 -5
  53. data/src/shader.cpp +36 -4
  54. data/src/shader.h +1 -1
  55. data/src/texture.cpp +2 -2
  56. data/src/{noise.cpp → util.cpp} +1 -1
  57. data/src/win32/font.cpp +1 -1
  58. data/test/test_bitmap.rb +12 -5
  59. data/test/test_color.rb +4 -0
  60. data/test/test_font.rb +20 -2
  61. data/test/test_image.rb +18 -18
  62. data/test/test_point.rb +1 -1
  63. data/test/test_polygon.rb +52 -45
  64. data/test/test_polyline.rb +191 -72
  65. metadata +9 -15
  66. data/.doc/ext/rays/polygon_line.cpp +0 -97
  67. data/ext/rays/polygon_line.cpp +0 -100
  68. data/lib/rays/polygon_line.rb +0 -33
  69. data/test/test_polygon_line.rb +0 -164
@@ -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