rays 0.1.17 → 0.1.22
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/color_space.cpp +2 -2
- data/.doc/ext/rays/point.cpp +0 -8
- data/VERSION +1 -1
- data/ext/rays/color_space.cpp +2 -2
- data/ext/rays/point.cpp +0 -9
- data/lib/rays/autoinit.rb +1 -1
- data/lib/rays/bitmap.rb +3 -3
- data/lib/rays/bounds.rb +22 -22
- data/lib/rays/camera.rb +1 -1
- data/lib/rays/color.rb +13 -13
- data/lib/rays/color_space.rb +4 -4
- data/lib/rays/font.rb +2 -2
- data/lib/rays/image.rb +3 -3
- data/lib/rays/matrix.rb +3 -3
- data/lib/rays/module.rb +5 -5
- data/lib/rays/painter.rb +17 -17
- data/lib/rays/point.rb +11 -11
- data/lib/rays/polygon.rb +10 -10
- data/lib/rays/polygon_line.rb +4 -4
- data/lib/rays/polyline.rb +4 -4
- data/lib/rays/shader.rb +3 -3
- data/rays.gemspec +2 -2
- data/src/ios/camera.mm +14 -7
- data/src/osx/camera.mm +3 -2
- data/test/helper.rb +2 -2
- data/test/test_bitmap.rb +7 -7
- data/test/test_bounds.rb +26 -26
- data/test/test_color.rb +19 -19
- data/test/test_color_space.rb +10 -10
- data/test/test_font.rb +6 -6
- data/test/test_image.rb +14 -14
- data/test/test_matrix.rb +20 -20
- data/test/test_painter.rb +18 -18
- data/test/test_painter_shape.rb +10 -10
- data/test/test_point.rb +20 -20
- data/test/test_polygon.rb +30 -30
- data/test/test_polygon_line.rb +13 -13
- data/test/test_polyline.rb +38 -38
- data/test/test_rays.rb +1 -1
- data/test/test_shader.rb +7 -7
- metadata +6 -6
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 4a5b43fa2ac1f3b56d89da34aa5d6bd36e3d6711888357602e161e63a2bbbebc
|
4
|
+
data.tar.gz: a98432edc8510d81fa8e941995102b33ad0438d40281b30c52af3cfbf8c89b2d
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 8a8a50e771070c66bdb4a58dad84ad4f10b29cfa53d7f4a2257e161cbc4708f9ebbe6def647f5fb888035be1ed69aeb2f522856e1ca87eaf76319391643a0b64
|
7
|
+
data.tar.gz: 5e6fbf805d49667fb567c8439c7356a52dee00819db6f1779b7b111649381df0f5bbf3c72af390a1b15332c1a7fe25505dde8a09e74677571e9bc76d58fe63c2
|
@@ -87,7 +87,7 @@ VALUE initialize_copy(VALUE self, VALUE obj)
|
|
87
87
|
}
|
88
88
|
|
89
89
|
static
|
90
|
-
VALUE
|
90
|
+
VALUE get_type(VALUE self)
|
91
91
|
{
|
92
92
|
CHECK;
|
93
93
|
|
@@ -188,7 +188,7 @@ Init_color_space ()
|
|
188
188
|
rb_define_alloc_func(cColorSpace, alloc);
|
189
189
|
rb_define_private_method(cColorSpace, "initialize", RUBY_METHOD_FUNC(initialize), -1);
|
190
190
|
rb_define_private_method(cColorSpace, "initialize_copy", RUBY_METHOD_FUNC(initialize_copy), 1);
|
191
|
-
rb_define_method(cColorSpace, "type", RUBY_METHOD_FUNC(
|
191
|
+
rb_define_method(cColorSpace, "type", RUBY_METHOD_FUNC(get_type), 0);
|
192
192
|
cColorSpace.define_method("gray?", is_gray);
|
193
193
|
cColorSpace.define_method("alpha?", is_alpha);
|
194
194
|
cColorSpace.define_method("rgb?", is_rgb);
|
data/.doc/ext/rays/point.cpp
CHANGED
@@ -231,13 +231,6 @@ VALUE get_at(VALUE self, VALUE index)
|
|
231
231
|
return value((*THIS)[i]);
|
232
232
|
}
|
233
233
|
|
234
|
-
static
|
235
|
-
VALUE inspect(VALUE self)
|
236
|
-
{
|
237
|
-
CHECK;
|
238
|
-
return value(Xot::stringf("#<Rays::Point %s>", THIS->inspect().c_str()));
|
239
|
-
}
|
240
|
-
|
241
234
|
static
|
242
235
|
VALUE dot(VALUE self, VALUE p1, VALUE p2)
|
243
236
|
{
|
@@ -282,7 +275,6 @@ Init_point ()
|
|
282
275
|
cPoint.define_method("/", div);
|
283
276
|
cPoint.define_method("[]=", set_at);
|
284
277
|
cPoint.define_method("[]", get_at);
|
285
|
-
rb_define_method(cPoint, "inspect", RUBY_METHOD_FUNC(inspect), 0);
|
286
278
|
rb_define_module_function(cPoint, "dot", RUBY_METHOD_FUNC(dot), 2);
|
287
279
|
rb_define_module_function(cPoint, "cross", RUBY_METHOD_FUNC(cross), 2);
|
288
280
|
}
|
data/VERSION
CHANGED
@@ -1 +1 @@
|
|
1
|
-
0.1.
|
1
|
+
0.1.22
|
data/ext/rays/color_space.cpp
CHANGED
@@ -90,7 +90,7 @@ RUCY_DEF1(initialize_copy, obj)
|
|
90
90
|
RUCY_END
|
91
91
|
|
92
92
|
static
|
93
|
-
RUCY_DEF0(
|
93
|
+
RUCY_DEF0(get_type)
|
94
94
|
{
|
95
95
|
CHECK;
|
96
96
|
|
@@ -201,7 +201,7 @@ Init_color_space ()
|
|
201
201
|
cColorSpace.define_alloc_func(alloc);
|
202
202
|
cColorSpace.define_private_method("initialize", initialize);
|
203
203
|
cColorSpace.define_private_method("initialize_copy", initialize_copy);
|
204
|
-
cColorSpace.define_method("type",
|
204
|
+
cColorSpace.define_method("type", get_type);
|
205
205
|
cColorSpace.define_method("gray?", is_gray);
|
206
206
|
cColorSpace.define_method("alpha?", is_alpha);
|
207
207
|
cColorSpace.define_method("rgb?", is_rgb);
|
data/ext/rays/point.cpp
CHANGED
@@ -254,14 +254,6 @@ RUCY_DEF1(get_at, index)
|
|
254
254
|
}
|
255
255
|
RUCY_END
|
256
256
|
|
257
|
-
static
|
258
|
-
RUCY_DEF0(inspect)
|
259
|
-
{
|
260
|
-
CHECK;
|
261
|
-
return value(Xot::stringf("#<Rays::Point %s>", THIS->inspect().c_str()));
|
262
|
-
}
|
263
|
-
RUCY_END
|
264
|
-
|
265
257
|
static
|
266
258
|
RUCY_DEF2(dot, p1, p2)
|
267
259
|
{
|
@@ -308,7 +300,6 @@ Init_point ()
|
|
308
300
|
cPoint.define_method("/", div);
|
309
301
|
cPoint.define_method("[]=", set_at);
|
310
302
|
cPoint.define_method("[]", get_at);
|
311
|
-
cPoint.define_method("inspect", inspect);
|
312
303
|
cPoint.define_module_function("dot", dot);
|
313
304
|
cPoint.define_module_function("cross", cross);
|
314
305
|
}
|
data/lib/rays/autoinit.rb
CHANGED
data/lib/rays/bitmap.rb
CHANGED
@@ -11,7 +11,7 @@ module Rays
|
|
11
11
|
|
12
12
|
include Enumerable
|
13
13
|
|
14
|
-
def each
|
14
|
+
def each()
|
15
15
|
height.times do |y|
|
16
16
|
width.times do |x|
|
17
17
|
yield self[x, y], x, y
|
@@ -19,11 +19,11 @@ module Rays
|
|
19
19
|
end
|
20
20
|
end
|
21
21
|
|
22
|
-
def bounds
|
22
|
+
def bounds()
|
23
23
|
Bounds.new 0, 0, width, height
|
24
24
|
end
|
25
25
|
|
26
|
-
def to_a
|
26
|
+
def to_a()
|
27
27
|
map {|o| o}
|
28
28
|
end
|
29
29
|
|
data/lib/rays/bounds.rb
CHANGED
@@ -25,15 +25,15 @@ module Rays
|
|
25
25
|
alias pos= position=
|
26
26
|
alias pos position
|
27
27
|
|
28
|
-
alias left_top
|
29
|
-
def right_top
|
30
|
-
def left_bottom
|
31
|
-
def right_bottom
|
28
|
+
alias left_top position
|
29
|
+
def right_top() position .move_by(w - 1, 0) end
|
30
|
+
def left_bottom() position .move_by( 0, h - 1) end
|
31
|
+
def right_bottom() (position + size).move_by!( -1, -1) end
|
32
32
|
|
33
|
-
def left_top=
|
34
|
-
def right_top=
|
35
|
-
def left_bottom=
|
36
|
-
def right_bottom=
|
33
|
+
def left_top=(*args) p = Point.new(*args); self.left, self.top = p.x, p.y; left_top end
|
34
|
+
def right_top=(*args) p = Point.new(*args); self.right, self.top = p.x, p.y; right_top end
|
35
|
+
def left_bottom=(*args) p = Point.new(*args); self.left, self.bottom = p.x, p.y; left_bottom end
|
36
|
+
def right_bottom=(*args) p = Point.new(*args); self.right, self.bottom = p.x, p.y; right_bottom end
|
37
37
|
|
38
38
|
alias lt left_top
|
39
39
|
alias lt= left_top=
|
@@ -44,31 +44,31 @@ module Rays
|
|
44
44
|
alias rb right_bottom
|
45
45
|
alias rb= right_bottom=
|
46
46
|
|
47
|
-
def move_to
|
48
|
-
dup.move_to!
|
47
|
+
def move_to(*args)
|
48
|
+
dup.move_to!(*args)
|
49
49
|
end
|
50
50
|
|
51
|
-
def move_by
|
52
|
-
dup.move_by!
|
51
|
+
def move_by(*args)
|
52
|
+
dup.move_by!(*args)
|
53
53
|
end
|
54
54
|
|
55
|
-
def resize_to
|
56
|
-
dup.resize_to!
|
55
|
+
def resize_to(*args)
|
56
|
+
dup.resize_to!(*args)
|
57
57
|
end
|
58
58
|
|
59
|
-
def resize_by
|
60
|
-
dup.resize_by!
|
59
|
+
def resize_by(*args)
|
60
|
+
dup.resize_by!(*args)
|
61
61
|
end
|
62
62
|
|
63
|
-
def inset_by
|
64
|
-
dup.inset_by!
|
63
|
+
def inset_by(*args)
|
64
|
+
dup.inset_by!(*args)
|
65
65
|
end
|
66
66
|
|
67
|
-
def each
|
68
|
-
to_a(dimension).each
|
67
|
+
def each(dimension = 2, &block)
|
68
|
+
to_a(dimension).each(&block)
|
69
69
|
end
|
70
70
|
|
71
|
-
def to_a
|
71
|
+
def to_a(dimension = 2)
|
72
72
|
# TODO: return [lt, rb]
|
73
73
|
case dimension
|
74
74
|
when 1 then [x, w]
|
@@ -78,7 +78,7 @@ module Rays
|
|
78
78
|
end
|
79
79
|
end
|
80
80
|
|
81
|
-
def <=>
|
81
|
+
def <=>(o)
|
82
82
|
ret = x <=> o.x; return ret if ret != 0
|
83
83
|
ret = y <=> o.y; return ret if ret != 0
|
84
84
|
ret = z <=> o.z; return ret if ret != 0
|
data/lib/rays/camera.rb
CHANGED
data/lib/rays/color.rb
CHANGED
@@ -24,32 +24,32 @@ module Rays
|
|
24
24
|
alias a= alpha=
|
25
25
|
alias a alpha
|
26
26
|
|
27
|
-
def opaque?
|
27
|
+
def opaque?()
|
28
28
|
alpha >= 1
|
29
29
|
end
|
30
30
|
|
31
|
-
def transparent?
|
31
|
+
def transparent?()
|
32
32
|
alpha <= 0
|
33
33
|
end
|
34
34
|
|
35
|
-
def translucent?
|
35
|
+
def translucent?()
|
36
36
|
a = alpha
|
37
37
|
0 < a && a < 1
|
38
38
|
end
|
39
39
|
|
40
|
-
def each
|
41
|
-
to_a.each
|
40
|
+
def each(&block)
|
41
|
+
to_a.each(&block)
|
42
42
|
end
|
43
43
|
|
44
|
-
def to_a
|
44
|
+
def to_a()
|
45
45
|
[red, green, blue, alpha]
|
46
46
|
end
|
47
47
|
|
48
|
-
def to_s
|
48
|
+
def to_s()
|
49
49
|
to_a.to_s
|
50
50
|
end
|
51
51
|
|
52
|
-
def []
|
52
|
+
def [](index)
|
53
53
|
case index
|
54
54
|
when 0 then red
|
55
55
|
when 1 then green
|
@@ -59,7 +59,7 @@ module Rays
|
|
59
59
|
end
|
60
60
|
end
|
61
61
|
|
62
|
-
def []=
|
62
|
+
def []=(index, val)
|
63
63
|
case index
|
64
64
|
when 0 then self.red = val
|
65
65
|
when 1 then self.green = val
|
@@ -69,22 +69,22 @@ module Rays
|
|
69
69
|
end
|
70
70
|
end
|
71
71
|
|
72
|
-
def <=>
|
72
|
+
def <=>(o)
|
73
73
|
ret = red <=> o.red; return ret if ret != 0
|
74
74
|
ret = green <=> o.green; return ret if ret != 0
|
75
75
|
ret = blue <=> o.blue; return ret if ret != 0
|
76
76
|
alpha <=> o.alpha
|
77
77
|
end
|
78
78
|
|
79
|
-
def hash
|
79
|
+
def hash()
|
80
80
|
red.hash + green.hash + blue.hash + alpha.hash
|
81
81
|
end
|
82
82
|
|
83
|
-
def eql?
|
83
|
+
def eql?(o)
|
84
84
|
self == o
|
85
85
|
end
|
86
86
|
|
87
|
-
def inspect
|
87
|
+
def inspect()
|
88
88
|
"#<#{self.class.name} #{to_s}>"
|
89
89
|
end
|
90
90
|
|
data/lib/rays/color_space.rb
CHANGED
@@ -11,19 +11,19 @@ module Rays
|
|
11
11
|
|
12
12
|
include Comparable
|
13
13
|
|
14
|
-
def <=>
|
14
|
+
def <=>(o)
|
15
15
|
type <=> o.type
|
16
16
|
end
|
17
17
|
|
18
|
-
def hash
|
18
|
+
def hash()
|
19
19
|
type.hash
|
20
20
|
end
|
21
21
|
|
22
|
-
def eql?
|
22
|
+
def eql?(o)
|
23
23
|
self == o
|
24
24
|
end
|
25
25
|
|
26
|
-
def inspect
|
26
|
+
def inspect()
|
27
27
|
"#<#{self.class.name} #{to_s}>"
|
28
28
|
end
|
29
29
|
|
data/lib/rays/font.rb
CHANGED
@@ -14,12 +14,12 @@ module Rays
|
|
14
14
|
alias w width
|
15
15
|
alias h height
|
16
16
|
|
17
|
-
def <=>
|
17
|
+
def <=>(o)
|
18
18
|
ret = name <=> o.name; return ret if ret != 0
|
19
19
|
size <=> o.size
|
20
20
|
end
|
21
21
|
|
22
|
-
def inspect
|
22
|
+
def inspect()
|
23
23
|
"#<Rays::Font name=#{name}, size=#{size}>"
|
24
24
|
end
|
25
25
|
|
data/lib/rays/image.rb
CHANGED
@@ -14,16 +14,16 @@ module Rays
|
|
14
14
|
|
15
15
|
def_delegators :bitmap, :[], :[]=
|
16
16
|
|
17
|
-
def paint
|
17
|
+
def paint(&block)
|
18
18
|
painter.paint self, &block
|
19
19
|
self
|
20
20
|
end
|
21
21
|
|
22
|
-
def size
|
22
|
+
def size()
|
23
23
|
return width, height
|
24
24
|
end
|
25
25
|
|
26
|
-
def bounds
|
26
|
+
def bounds()
|
27
27
|
Bounds.new 0, 0, width, height
|
28
28
|
end
|
29
29
|
|
data/lib/rays/matrix.rb
CHANGED
@@ -12,13 +12,13 @@ module Rays
|
|
12
12
|
include Comparable
|
13
13
|
include Enumerable
|
14
14
|
|
15
|
-
def each
|
16
|
-
to_a.each
|
15
|
+
def each(&block)
|
16
|
+
to_a.each(&block)
|
17
17
|
end
|
18
18
|
|
19
19
|
alias inspect_org inspect
|
20
20
|
|
21
|
-
def inspect
|
21
|
+
def inspect()
|
22
22
|
inspect_org.gsub(/\.?0+([^\.\d]|$)/) {$1}
|
23
23
|
end
|
24
24
|
|
data/lib/rays/module.rb
CHANGED
@@ -8,23 +8,23 @@ module Rays
|
|
8
8
|
|
9
9
|
module_function
|
10
10
|
|
11
|
-
def name
|
11
|
+
def name()
|
12
12
|
super.split('::')[-2]
|
13
13
|
end
|
14
14
|
|
15
|
-
def version
|
15
|
+
def version()
|
16
16
|
open(root_dir 'VERSION') {|f| f.readline.chomp}
|
17
17
|
end
|
18
18
|
|
19
|
-
def root_dir
|
19
|
+
def root_dir(path = '')
|
20
20
|
File.expand_path "../../#{path}", __dir__
|
21
21
|
end
|
22
22
|
|
23
|
-
def inc_dir
|
23
|
+
def inc_dir()
|
24
24
|
root_dir 'include'
|
25
25
|
end
|
26
26
|
|
27
|
-
def lib_dir
|
27
|
+
def lib_dir()
|
28
28
|
root_dir 'lib'
|
29
29
|
end
|
30
30
|
|
data/lib/rays/painter.rb
CHANGED
@@ -12,7 +12,7 @@ module Rays
|
|
12
12
|
|
13
13
|
class Painter
|
14
14
|
|
15
|
-
def push
|
15
|
+
def push(*types, **attributes, &block)
|
16
16
|
each_type types do |type|
|
17
17
|
case type
|
18
18
|
when :state then push_state
|
@@ -36,11 +36,11 @@ module Rays
|
|
36
36
|
__send__ key, *value
|
37
37
|
end
|
38
38
|
|
39
|
-
pop
|
39
|
+
pop(*types)
|
40
40
|
end
|
41
41
|
end
|
42
42
|
|
43
|
-
def pop
|
43
|
+
def pop(*types)
|
44
44
|
each_type types, reverse: true do |type|
|
45
45
|
case type
|
46
46
|
when :state then pop_state
|
@@ -50,7 +50,7 @@ module Rays
|
|
50
50
|
end
|
51
51
|
end
|
52
52
|
|
53
|
-
def paint
|
53
|
+
def paint(*args, &block)
|
54
54
|
begin_paint
|
55
55
|
Xot::BlockUtil.instance_eval_or_block_call self, *args, &block
|
56
56
|
self
|
@@ -58,7 +58,7 @@ module Rays
|
|
58
58
|
end_paint
|
59
59
|
end
|
60
60
|
|
61
|
-
def line
|
61
|
+
def line(*args, loop: false)
|
62
62
|
if args.first.kind_of?(Polyline)
|
63
63
|
draw_polyline args.first
|
64
64
|
else
|
@@ -66,43 +66,43 @@ module Rays
|
|
66
66
|
end
|
67
67
|
end
|
68
68
|
|
69
|
-
def rect
|
69
|
+
def rect(*args, round: nil, lt: nil, rt: nil, lb: nil, rb: nil)
|
70
70
|
draw_rect args, round, lt, rt, lb, rb
|
71
71
|
end
|
72
72
|
|
73
|
-
def ellipse
|
73
|
+
def ellipse(*args, center: nil, radius: nil, hole: nil, from: nil, to: nil)
|
74
74
|
draw_ellipse args, center, radius, hole, from, to
|
75
75
|
end
|
76
76
|
|
77
|
-
def curve
|
77
|
+
def curve(*args, loop: false)
|
78
78
|
draw_curve args, loop
|
79
79
|
end
|
80
80
|
|
81
|
-
def bezier
|
81
|
+
def bezier(*args, loop: false)
|
82
82
|
draw_bezier args, loop
|
83
83
|
end
|
84
84
|
|
85
|
-
def color=
|
85
|
+
def color=(fill, stroke = nil)
|
86
86
|
self.fill fill
|
87
87
|
self.stroke stroke
|
88
88
|
end
|
89
89
|
|
90
|
-
def color
|
90
|
+
def color()
|
91
91
|
return fill, stroke
|
92
92
|
end
|
93
93
|
|
94
|
-
def shader=
|
95
|
-
shader.uniform
|
94
|
+
def shader=(shader, **uniforms)
|
95
|
+
shader.uniform(**uniforms) if shader && !uniforms.empty?
|
96
96
|
set_shader shader
|
97
97
|
end
|
98
98
|
|
99
|
-
const_symbol_accessor :stroke_cap, {
|
99
|
+
const_symbol_accessor :stroke_cap, **{
|
100
100
|
butt: CAP_BUTT,
|
101
101
|
round: CAP_ROUND,
|
102
102
|
square: CAP_SQUARE
|
103
103
|
}
|
104
104
|
|
105
|
-
const_symbol_accessor :stroke_join, {
|
105
|
+
const_symbol_accessor :stroke_join, **{
|
106
106
|
miter: JOIN_MITER,
|
107
107
|
round: JOIN_ROUND,
|
108
108
|
square: JOIN_SQUARE
|
@@ -114,10 +114,10 @@ module Rays
|
|
114
114
|
|
115
115
|
private
|
116
116
|
|
117
|
-
def each_type
|
117
|
+
def each_type(types, reverse: false, &block)
|
118
118
|
types = [:state, :matrix] if types.empty? || types.include?(:all)
|
119
119
|
types = types.reverse if reverse
|
120
|
-
types.each
|
120
|
+
types.each(&block)
|
121
121
|
end
|
122
122
|
|
123
123
|
end# Painter
|