rays 0.1.19 → 0.1.23

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 14424275a96e7500294e649629b7dfc654c1fa8a0c0f97ad89a8280481d40e31
4
- data.tar.gz: db50e1840c88b5a73039c268f55051a892f31d85692b99b699bada329e24efb4
3
+ metadata.gz: 040c0f759c8eb840cb1404ef8d4b784a2e8c65a0b4c45069dfc710ce4d82ea11
4
+ data.tar.gz: 5d23a768599e7f41c56e626077cc194e6160c9e9ce4d29755e52a7ed9125ab2a
5
5
  SHA512:
6
- metadata.gz: ce029251dbb42520c043ce038c6e906763451899da9198c089a78ec558995cc110edb201a42d115af9158898210444d71feba4849e7dd65f09d7c54040aa7db8
7
- data.tar.gz: 7f5d5c0d4dc84f0ec3298eeebd9fb17b7244f7f6f799c29d2cabc4eb7663a8999dc0d0e95d083e6b877797190a729071b9b2163fc158bd27d917153c1fade75a
6
+ metadata.gz: 3a073787bd50fa263eb8ea3a773a28a82bc4e5169f61957ac1497529b6a7ce7c31a18b2b65b4914c4f210e97290de286fb4a7293e52ce2aa8a89d14807f8e4a0
7
+ data.tar.gz: 4d3635baaa03a28cbc06461a0af483a757a117fe2d7cd0e56efd30070f215966ebd80242b97de661dcdf7615ebbfbdb66b5d14158f9808ad9485ae7077f0ec5f
@@ -87,7 +87,7 @@ VALUE initialize_copy(VALUE self, VALUE obj)
87
87
  }
88
88
 
89
89
  static
90
- VALUE type(VALUE self)
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(type), 0);
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);
@@ -127,9 +127,10 @@ void get_ellipse_args (
127
127
  assert(x && y && w && h && hole_size && from && to_ && nseg && argv);
128
128
 
129
129
  if (argc <= 0)
130
- argument_error(__FILE__, __LINE__);
131
-
132
- if (argv[0].is_kind_of(Rays::bounds_class()))
130
+ {
131
+ *x = *y = *w = *h = 0;
132
+ }
133
+ else if (argv[0].is_kind_of(Rays::bounds_class()))
133
134
  {
134
135
  const Rays::Bounds& b = to<Rays::Bounds&>(argv[0]);
135
136
  *x = b.x;
@@ -162,13 +163,6 @@ void get_ellipse_args (
162
163
  *h = argc >= 4 ? to<coord>(argv[3]) : *w;
163
164
  }
164
165
 
165
- if (center)
166
- {
167
- Rays::Point p = to<Rays::Point>(center);
168
- *x = p.x;
169
- *y = p.y;
170
- }
171
-
172
166
  if (radius)
173
167
  {
174
168
  Rays::Point p = to<Rays::Point>(radius);
@@ -176,6 +170,13 @@ void get_ellipse_args (
176
170
  *h = p.y * 2;
177
171
  }
178
172
 
173
+ if (center)
174
+ {
175
+ Rays::Point p = to<Rays::Point>(center);
176
+ *x = p.x - *w / 2;
177
+ *y = p.y - *h / 2;
178
+ }
179
+
179
180
  *hole_size = hole ? to<Rays::Point>(hole) : 0;
180
181
  *from = angle_from ? to<float>(angle_from) : 0;
181
182
  *to_ = angle_to ? to<float>(angle_to) : 360;
@@ -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.19
1
+ 0.1.23
@@ -90,7 +90,7 @@ RUCY_DEF1(initialize_copy, obj)
90
90
  RUCY_END
91
91
 
92
92
  static
93
- RUCY_DEF0(type)
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", 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/defs.cpp CHANGED
@@ -127,9 +127,10 @@ void get_ellipse_args (
127
127
  assert(x && y && w && h && hole_size && from && to_ && nseg && argv);
128
128
 
129
129
  if (argc <= 0)
130
- argument_error(__FILE__, __LINE__);
131
-
132
- if (argv[0].is_kind_of(Rays::bounds_class()))
130
+ {
131
+ *x = *y = *w = *h = 0;
132
+ }
133
+ else if (argv[0].is_kind_of(Rays::bounds_class()))
133
134
  {
134
135
  const Rays::Bounds& b = to<Rays::Bounds&>(argv[0]);
135
136
  *x = b.x;
@@ -162,13 +163,6 @@ void get_ellipse_args (
162
163
  *h = argc >= 4 ? to<coord>(argv[3]) : *w;
163
164
  }
164
165
 
165
- if (center)
166
- {
167
- Rays::Point p = to<Rays::Point>(center);
168
- *x = p.x;
169
- *y = p.y;
170
- }
171
-
172
166
  if (radius)
173
167
  {
174
168
  Rays::Point p = to<Rays::Point>(radius);
@@ -176,6 +170,13 @@ void get_ellipse_args (
176
170
  *h = p.y * 2;
177
171
  }
178
172
 
173
+ if (center)
174
+ {
175
+ Rays::Point p = to<Rays::Point>(center);
176
+ *x = p.x - *w / 2;
177
+ *y = p.y - *h / 2;
178
+ }
179
+
179
180
  *hole_size = hole ? to<Rays::Point>(hole) : 0;
180
181
  *from = angle_from ? to<float>(angle_from) : 0;
181
182
  *to_ = angle_to ? to<float>(angle_to) : 360;
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
@@ -4,7 +4,7 @@
4
4
  require 'rays/ext'
5
5
 
6
6
 
7
- unless $RAYS_NOAUTOINIT
7
+ unless defined?($RAYS_NOAUTOINIT) && $RAYS_NOAUTOINIT
8
8
  Rays.init!
9
9
  at_exit {Rays.fin!}
10
10
  end
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 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
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= (*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
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 (*args)
48
- dup.move_to! *args
47
+ def move_to(*args)
48
+ dup.move_to!(*args)
49
49
  end
50
50
 
51
- def move_by (*args)
52
- dup.move_by! *args
51
+ def move_by(*args)
52
+ dup.move_by!(*args)
53
53
  end
54
54
 
55
- def resize_to (*args)
56
- dup.resize_to! *args
55
+ def resize_to(*args)
56
+ dup.resize_to!(*args)
57
57
  end
58
58
 
59
- def resize_by (*args)
60
- dup.resize_by! *args
59
+ def resize_by(*args)
60
+ dup.resize_by!(*args)
61
61
  end
62
62
 
63
- def inset_by (*args)
64
- dup.inset_by! *args
63
+ def inset_by(*args)
64
+ dup.inset_by!(*args)
65
65
  end
66
66
 
67
- def each (dimension = 2, &block)
68
- to_a(dimension).each &block
67
+ def each(dimension = 2, &block)
68
+ to_a(dimension).each(&block)
69
69
  end
70
70
 
71
- def to_a (dimension = 2)
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 <=> (o)
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
@@ -10,7 +10,7 @@ module Rays
10
10
 
11
11
  class Camera
12
12
 
13
- def initialize (
13
+ def initialize(
14
14
  min_width = -1, min_height = -1,
15
15
  device_name: nil, resize: true, crop: true, &block)
16
16
 
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 (&block)
41
- to_a.each &block
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 [] (index)
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 []= (index, val)
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 <=> (o)
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? (o)
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
 
@@ -11,19 +11,19 @@ module Rays
11
11
 
12
12
  include Comparable
13
13
 
14
- def <=> (o)
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? (o)
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 <=> (o)
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 (&block)
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 (&block)
16
- to_a.each &block
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 (path = '')
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 (*types, **attributes, &block)
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 *types
39
+ pop(*types)
40
40
  end
41
41
  end
42
42
 
43
- def pop (*types)
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 (*args, &block)
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 (*args, loop: false)
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 (*args, round: nil, lt: nil, rt: nil, lb: nil, rb: nil)
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 (*args, center: nil, radius: nil, hole: nil, from: nil, to: nil)
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 (*args, loop: false)
77
+ def curve(*args, loop: false)
78
78
  draw_curve args, loop
79
79
  end
80
80
 
81
- def bezier (*args, loop: false)
81
+ def bezier(*args, loop: false)
82
82
  draw_bezier args, loop
83
83
  end
84
84
 
85
- def color= (fill, stroke = nil)
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= (shader, **uniforms)
95
- shader.uniform **uniforms if shader && !uniforms.empty?
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 (types, reverse: false, &block)
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 &block
120
+ types.each(&block)
121
121
  end
122
122
 
123
123
  end# Painter
data/lib/rays/point.rb CHANGED
@@ -12,23 +12,23 @@ module Rays
12
12
  include Comparable
13
13
  include Enumerable
14
14
 
15
- def move_to (*args)
16
- dup.move_to! *args
15
+ def move_to(*args)
16
+ dup.move_to!(*args)
17
17
  end
18
18
 
19
- def move_by (*args)
20
- dup.move_by! *args
19
+ def move_by(*args)
20
+ dup.move_by!(*args)
21
21
  end
22
22
 
23
- def zero? ()
23
+ def zero?()
24
24
  length == 0
25
25
  end
26
26
 
27
- def each (&block)
28
- to_a.each &block
27
+ def each(&block)
28
+ to_a.each(&block)
29
29
  end
30
30
 
31
- def to_a (dimension = 2)
31
+ def to_a(dimension = 2)
32
32
  case dimension
33
33
  when 1 then [x]
34
34
  when 2 then [x, y]
@@ -37,17 +37,17 @@ module Rays
37
37
  end
38
38
  end
39
39
 
40
- def to_s (dimension = 2)
40
+ def to_s(dimension = 2)
41
41
  to_a(dimension).to_s
42
42
  end
43
43
 
44
- def <=> (o)
44
+ def <=>(o)
45
45
  ret = x <=> o.x; return ret if ret != 0
46
46
  ret = y <=> o.y; return ret if ret != 0
47
47
  z <=> o.z
48
48
  end
49
49
 
50
- def inspect ()
50
+ def inspect()
51
51
  "#<Rays::Point #{to_a(3).join ', '}>"
52
52
  end
53
53