rays 0.1.46 → 0.1.48

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.
Files changed (74) hide show
  1. checksums.yaml +4 -4
  2. data/.doc/ext/rays/bitmap.cpp +499 -0
  3. data/.doc/ext/rays/camera.cpp +2 -2
  4. data/.doc/ext/rays/defs.cpp +35 -11
  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 +111 -6
  8. data/.doc/ext/rays/polygon.cpp +152 -41
  9. data/.doc/ext/rays/polyline.cpp +89 -10
  10. data/.doc/ext/rays/rays.cpp +91 -11
  11. data/.doc/ext/rays/{noise.cpp → util.cpp} +2 -2
  12. data/.github/workflows/test.yml +0 -1
  13. data/ChangeLog.md +38 -0
  14. data/Rakefile +4 -4
  15. data/VERSION +1 -1
  16. data/ext/rays/bitmap.cpp +501 -0
  17. data/ext/rays/camera.cpp +2 -2
  18. data/ext/rays/defs.cpp +35 -11
  19. data/ext/rays/defs.h +56 -3
  20. data/ext/rays/font.cpp +56 -4
  21. data/ext/rays/native.cpp +2 -4
  22. data/ext/rays/painter.cpp +125 -11
  23. data/ext/rays/polygon.cpp +161 -41
  24. data/ext/rays/polyline.cpp +95 -9
  25. data/ext/rays/rays.cpp +91 -11
  26. data/ext/rays/{noise.cpp → util.cpp} +2 -2
  27. data/include/rays/defs.h +24 -0
  28. data/include/rays/font.h +17 -3
  29. data/include/rays/matrix.h +2 -0
  30. data/include/rays/painter.h +29 -1
  31. data/include/rays/polygon.h +57 -33
  32. data/include/rays/polyline.h +20 -1
  33. data/include/rays/ruby/polygon.h +0 -11
  34. data/include/rays/ruby/rays.h +4 -0
  35. data/include/rays/{noise.h → util.h} +2 -2
  36. data/lib/rays/color.rb +1 -1
  37. data/lib/rays/font.rb +1 -1
  38. data/lib/rays/image.rb +1 -1
  39. data/lib/rays/painter.rb +13 -2
  40. data/lib/rays/point.rb +1 -1
  41. data/lib/rays/polygon.rb +54 -16
  42. data/lib/rays/polyline.rb +54 -8
  43. data/lib/rays.rb +0 -1
  44. data/rays.gemspec +2 -2
  45. data/src/color_space.cpp +2 -2
  46. data/src/font.cpp +24 -2
  47. data/src/font.h +8 -1
  48. data/src/ios/font.mm +88 -27
  49. data/src/matrix.cpp +8 -0
  50. data/src/osx/font.mm +90 -28
  51. data/src/osx/helper.h +2 -2
  52. data/src/osx/helper.mm +2 -2
  53. data/src/painter.cpp +227 -90
  54. data/src/painter.h +11 -3
  55. data/src/polygon.cpp +588 -205
  56. data/src/polyline.cpp +154 -28
  57. data/src/polyline.h +3 -5
  58. data/src/shader.cpp +36 -4
  59. data/src/shader.h +1 -1
  60. data/src/texture.cpp +2 -2
  61. data/src/{noise.cpp → util.cpp} +1 -1
  62. data/src/win32/font.cpp +1 -1
  63. data/test/test_bitmap.rb +16 -2
  64. data/test/test_color.rb +4 -0
  65. data/test/test_font.rb +20 -2
  66. data/test/test_image.rb +18 -18
  67. data/test/test_point.rb +1 -1
  68. data/test/test_polygon.rb +52 -45
  69. data/test/test_polyline.rb +191 -72
  70. metadata +11 -17
  71. data/.doc/ext/rays/polygon_line.cpp +0 -97
  72. data/ext/rays/polygon_line.cpp +0 -100
  73. data/lib/rays/polygon_line.rb +0 -33
  74. data/test/test_polygon_line.rb +0 -164
@@ -1,33 +0,0 @@
1
- require 'rays/ext'
2
-
3
-
4
- module Rays
5
-
6
-
7
- class Polygon
8
-
9
-
10
- class Line < Polyline
11
-
12
- def initialize(*points, loop: true, hole: false)
13
- setup points, loop, hole
14
- end
15
-
16
- def transform(matrix = nil, loop: loop?, hole: hole?, &block)
17
- points = to_a
18
- points = points.map {|point| matrix * point} if matrix
19
- points = block.call points if block
20
- self.class.new(*points, loop: loop, hole: hole)
21
- end
22
-
23
- def inspect()
24
- "#<Rays::Polygon::Line #{to_a.join ', '}, loop: #{loop?}, hole: #{hole?}>"
25
- end
26
-
27
- end# Line
28
-
29
-
30
- end# Polygon
31
-
32
-
33
- end# Rays
@@ -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_raise(ArgumentError) {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_raise(ArgumentError) {line(1, 2, loop: true, hole: true )}
53
- assert_raise(ArgumentError) {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_raise(ArgumentError) {line(1, 2, 3, 4, loop: true, hole: true )}
61
- assert_raise(ArgumentError) {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