ruby-miyako-mswin32 2.1.0 → 2.1.1

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 (59) hide show
  1. data/README +275 -20
  2. data/install_miyako.rb +5 -3
  3. data/lib/Miyako/API/audio.rb +11 -6
  4. data/lib/Miyako/API/basic_data.rb +0 -985
  5. data/lib/Miyako/API/bitmap.rb +19 -22
  6. data/lib/Miyako/API/choices.rb +203 -69
  7. data/lib/Miyako/API/collision.rb +451 -9
  8. data/lib/Miyako/API/color.rb +177 -0
  9. data/lib/Miyako/API/diagram.rb +18 -20
  10. data/lib/Miyako/API/fixedmap.rb +207 -73
  11. data/lib/Miyako/API/font.rb +111 -18
  12. data/lib/Miyako/API/i_yuki.rb +1201 -0
  13. data/lib/Miyako/API/input.rb +65 -0
  14. data/lib/Miyako/API/layout.rb +41 -29
  15. data/lib/Miyako/API/map.rb +202 -157
  16. data/lib/Miyako/API/map_event.rb +86 -19
  17. data/lib/Miyako/API/map_struct.rb +268 -0
  18. data/lib/Miyako/API/modules.rb +136 -37
  19. data/lib/Miyako/API/movie.rb +8 -8
  20. data/lib/Miyako/API/parts.rb +63 -20
  21. data/lib/Miyako/API/plane.rb +4 -4
  22. data/lib/Miyako/API/screen.rb +16 -8
  23. data/lib/Miyako/API/sprite.rb +290 -23
  24. data/lib/Miyako/API/sprite_animation.rb +23 -11
  25. data/lib/Miyako/API/sprite_list.rb +406 -183
  26. data/lib/Miyako/API/story.rb +4 -65
  27. data/lib/Miyako/API/struct_point.rb +157 -0
  28. data/lib/Miyako/API/struct_rect.rb +233 -0
  29. data/lib/Miyako/API/struct_segment.rb +641 -0
  30. data/lib/Miyako/API/struct_size.rb +158 -0
  31. data/lib/Miyako/API/struct_square.rb +253 -0
  32. data/lib/Miyako/API/textbox.rb +49 -35
  33. data/lib/Miyako/API/viewport.rb +5 -5
  34. data/lib/Miyako/API/wait_counter.rb +350 -0
  35. data/lib/Miyako/API/yuki.rb +95 -60
  36. data/lib/Miyako/EXT/raster_scroll.rb +30 -8
  37. data/lib/Miyako/EXT/slides.rb +6 -6
  38. data/lib/Miyako/miyako.rb +25 -11
  39. data/lib/Miyako/miyako_no_katana.so +0 -0
  40. data/lib/miyako.rb +28 -0
  41. data/lib/miyako_require_only.rb +35 -0
  42. data/sample/Diagram_sample/diagram_sample_yuki2.rb +30 -30
  43. data/sample/Room3/blue.rb +19 -19
  44. data/sample/Room3/green.rb +9 -9
  45. data/sample/Room3/main.rb +12 -12
  46. data/sample/Room3/red.rb +12 -12
  47. data/sample/Room3/title.rb +15 -10
  48. data/sample/collision_test2.rb +2 -1
  49. data/sample/fixed_map_test/fixed_map_sample.rb +7 -6
  50. data/sample/map_test/main_scene.rb +12 -10
  51. data/sample/map_test/map_manager.rb +14 -13
  52. data/sample/rasterscroll.rb +5 -5
  53. data/sample/takahashi.rb +3 -3
  54. data/sample/textbox_sample.rb +8 -5
  55. data/sample/transform.rb +2 -1
  56. data/uninstall_miyako.rb +4 -1
  57. metadata +13 -4
  58. data/lib/Miyako/EXT/miyako_cairo.rb +0 -62
  59. data/sample/cairo_sample.rb +0 -25
@@ -29,7 +29,6 @@ module Miyako
29
29
  class Story
30
30
 
31
31
  @@sub_scenes = [:sub_scene, :sub_routine]
32
- @@over_scenes = [:over_scene]
33
32
 
34
33
  def prev_label #:nodoc:
35
34
  return @prev_label
@@ -51,48 +50,15 @@ module Miyako
51
50
  @next_label = nil
52
51
 
53
52
  @stack = []
54
- @fibers = [nil]
55
53
 
56
54
  @scene_cache = Hash.new
57
55
  @scene_cache_list = Array.new
58
56
  @scene_cache_max = 20
59
57
 
60
- @fiber = Proc.new{|sc, num|
61
- raise MiyakoValueError, "Illegal Script-label name! : #{sc}" unless Scene.has_scene?(sc.to_s)
62
- fnum = nil
63
- bk_nn = sc
64
- uu = sc.new(self)
65
- uu.init_inner(@prev_label, self.upper_label)
66
- uu.setup
67
- ret = true
68
- while ret do
69
- nn = uu.update
70
- uu.render
71
- if fnum && @fibers[fnum]
72
- @fibers[fnum].resume(true)
73
- elsif nn && !(nn.eql?(uu.class)) && @@over_scenes.include?(nn.scene_type)
74
- @fibers << Fiber.new(&@fiber)
75
- fnum = @fibers.length - 1
76
- @fibers[fnum].resume(nn, fnum)
77
- n = bk_nn
78
- end
79
- break unless nn
80
- ret = Fiber.yield
81
- end
82
- uu.final
83
- uu.dispose
84
- if (fnum && @fibers[fnum])
85
- @fibers[fnum].resume(nil)
86
- @fibers[fnum] = nil
87
- fnum = nil
88
- end
89
- @fibers[num] = nil
90
- }
91
58
  end
92
-
59
+
93
60
  def initialize_copy(obj) #:nodoc:
94
61
  @stack = @stack.dup
95
- @fibers = @fibers.dup
96
62
  @scene_cache = @scene_cache.dup
97
63
  @scene_cache_list = @scene_cache_list.dup
98
64
  end
@@ -128,23 +94,10 @@ module Miyako
128
94
  u.init_inner(@prev_label, self.upper_label)
129
95
  u.setup
130
96
 
131
- loop do
132
- Audio.update
133
- Input.update
134
- Screen.clear
97
+ Miyako.main_loop do
135
98
  bk_n = on
136
99
  n = u.update
137
100
  u.render
138
- if @fibers.first
139
- raise MiyakoError, "Double over scene from root!" if n && @@over_scenes.include?(n.scene_type)
140
- @fibers.first.resume(true, 0)
141
- elsif n && @@over_scenes.include?(n.scene_type)
142
- @fibers.clear
143
- @fibers << Fiber.new(&@fiber)
144
- @fibers.first.resume(n, 0)
145
- n = bk_n
146
- end
147
- Screen.render
148
101
  break unless n && on.eql?(n)
149
102
  end
150
103
  u.next = n
@@ -163,18 +116,11 @@ module Miyako
163
116
  u = nil
164
117
  end
165
118
  end
166
- @fibers.each{|fiber| fiber.resume(nil) if fiber } if @fibers.length > 0
167
119
  @scene_cache_list.each{|sy| @scene_cache[sy].dispose }
168
120
  @scene_cache.clear
169
121
  @scene_cache_list.clear
170
122
  end
171
123
 
172
- #==="over_scene"形式のシーンが実行中かどうか判別する
173
- #返却値:: "over_scene"形式のシーンが実行中の時はtrueを返す
174
- def over_scene_execute?
175
- return @now_fiber != nil
176
- end
177
-
178
124
  #===内部の情報を解放する
179
125
  def dispose
180
126
  @scene_cache.keys.each{|k| @scene_cache[del_symbol].dispose }
@@ -182,7 +128,7 @@ module Miyako
182
128
 
183
129
  #==シーン情報格納のための構造体
184
130
  ScenePool = Struct.new(:story, :prev, :next, :upper)
185
-
131
+
186
132
  #==シーンモジュール
187
133
  #本モジュールをmixinすることにより、シーンを示すインスタンスを作成することができる
188
134
  #mixinするときに気をつけなければいけないのは、本モジュールでは以下の
@@ -198,8 +144,7 @@ module Miyako
198
144
  #判別は、scene_typeクラスメソッドを呼び出すことで可能。デフォルトは、
199
145
  #通常シーンを示すシンボル":scene"が返る。
200
146
  #形式を変えるには、scene_typeクラスメソッドをオーバーライドし、返却値を変える。
201
- #サブシーンの時はシンボル":sub_scene"、オーバーシーンのときは
202
- #シンボル":over_scene"を返すように実装する
147
+ #サブシーンの時はシンボル":sub_scene"を返すように実装する
203
148
  #(注1)同じクラス名のシーンを繰り返し実行したいときは、いったん別のダミーシーンを
204
149
  #介してから元のシーンへ移動する必要がある
205
150
  #(注2)オーバーシーン内では、シーンの移動が出来ないが、入れ子形式で
@@ -312,12 +257,6 @@ module Miyako
312
257
  @@pool[self.object_id].next = label
313
258
  end
314
259
 
315
- #==="over_scene"形式のシーンが実行中かどうか判別する
316
- #返却値:: "over_scene"形式のシーンが実行中の時はtrueを返す
317
- def over_scene_execute?
318
- return @story.over_scene_execute?
319
- end
320
-
321
260
  #===シーンの解説を返す(テンプレートメソッド)
322
261
  #Sceneモジュールをmixinしたとき、解説文を返す実装をしておくと、
323
262
  #Scene.#lisutupメソッドを呼び出したときに、noticeメソッドの結果を取得できる
@@ -0,0 +1,157 @@
1
+ # -*- encoding: utf-8 -*-
2
+ =begin
3
+ --
4
+ Miyako v2.1
5
+ Copyright (C) 2007-2009 Cyross Makoto
6
+
7
+ This library is free software; you can redistribute it and/or
8
+ modify it under the terms of the GNU Lesser General Public
9
+ License as published by the Free Software Foundation; either
10
+ version 2.1 of the License, or (at your option) any later version.
11
+
12
+ This library is distributed in the hope that it will be useful,
13
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
14
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
15
+ Lesser General Public License for more details.
16
+
17
+ You should have received a copy of the GNU Lesser General Public
18
+ License along with this library; if not, write to the Free Software
19
+ Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
20
+ ++
21
+ =end
22
+
23
+ module Miyako
24
+ #==位置情報のための構造体クラス
25
+ #位置変更メソッドを追加
26
+ class PointStruct < Struct
27
+ #===位置を変更する(変化量を指定)
28
+ #ブロックを渡したとき、ブロックの評価した結果、偽になったときは移動させた値を元に戻す
29
+ #_dx_:: 移動量(x方向)。単位はピクセル
30
+ #_dy_:: 移動量(y方向)。単位はピクセル
31
+ #返却値:: 自分自身を返す
32
+ def move!(dx, dy)
33
+ end
34
+
35
+ #===位置を変更する(位置指定)
36
+ #ブロックを渡したとき、ブロックの評価した結果、偽になったときは移動させた値を元に戻す
37
+ #_x_:: 移動先位置(x方向)。単位はピクセル
38
+ #_y_:: 移動先位置(y方向)。単位はピクセル
39
+ #返却値:: 自分自身を返す
40
+ def move_to!(x, y)
41
+ end
42
+
43
+ #===位置を変更したインスタンスを返す(変化量を指定)
44
+ #引数で指定したぶん移動させたときの位置を新しくインスタンスを生成して返す
45
+ #自分自身の値は変わらない
46
+ #_dx_:: 移動量(x方向)。単位はピクセル
47
+ #_dy_:: 移動量(y方向)。単位はピクセル
48
+ #返却値:: 自分自身の複製を更新したインスタンス
49
+ def move(dx, dy)
50
+ self.dup.move!(dx, dy)
51
+ end
52
+
53
+ #===位置を変更したインスタンスを返す(位置指定)
54
+ #引数で指定したぶん移動させたときの位置を新しくインスタンスを生成して返す
55
+ #自分自身の値は変わらない
56
+ #_x_:: 移動先位置(x方向)。単位はピクセル
57
+ #_y_:: 移動先位置(y方向)。単位はピクセル
58
+ #返却値:: 自分自身の複製を更新したインスタンス
59
+ def move_to(x, y)
60
+ self.dup.move_to!(x, y)
61
+ end
62
+
63
+ #===インスタンスの足し算
64
+ #もう一方が整数のとき、x,yにotherを足したものを返す
65
+ #Point構造体や配列など、[]メソッドがつかえるもののとき、x,y同士を足したものを返す
66
+ #それ以外の時は例外が発生する
67
+ #自分自身の値は変わらない
68
+ #_other_:: 整数もしくはPoint構造体
69
+ #返却値:: Point構造体
70
+ def +(other)
71
+ ret = self.dup
72
+ if other.kind_of?(Numeric)
73
+ ret[0] += other
74
+ ret[1] += other
75
+ elsif other.methods.include?(:[])
76
+ ret[0] += other[0]
77
+ ret[1] += other[1]
78
+ else
79
+ raise MiyakoError, "this parameter cannot access!"
80
+ end
81
+ ret
82
+ end
83
+
84
+ #===インスタンスの引き算
85
+ #もう一方が整数のとき、x,yからotherを引いたものを返す
86
+ #Point構造体や配列など、[]メソッドがつかえるもののとき、x,y同士を引いたものを返す
87
+ #それ以外の時は例外が発生する
88
+ #自分自身の値は変わらない
89
+ #_other_:: 整数もしくはPoint構造体
90
+ #返却値:: Point構造体
91
+ def -(other)
92
+ ret = self.dup
93
+ if other.kind_of?(Numeric)
94
+ ret[0] -= other
95
+ ret[1] -= other
96
+ elsif other.methods.include?(:[])
97
+ ret[0] -= other[0]
98
+ ret[1] -= other[1]
99
+ else
100
+ raise MiyakoError, "this parameter cannot access!"
101
+ end
102
+ ret
103
+ end
104
+
105
+ #===インスタンスのかけ算
106
+ #もう一方が整数のとき、x,yにotherを掛けたものを返す
107
+ #Point構造体や配列など、[]メソッドがつかえるもののとき、x,y同士を掛けたものを返す
108
+ #それ以外の時は例外が発生する
109
+ #自分自身の値は変わらない
110
+ #_other_:: 整数もしくはPoint構造体
111
+ #返却値:: Point構造体
112
+ def *(other)
113
+ ret = self.dup
114
+ if other.kind_of?(Numeric)
115
+ ret[0] *= other
116
+ ret[1] *= other
117
+ elsif other.methods.include?(:[])
118
+ ret[0] *= other[0]
119
+ ret[1] *= other[1]
120
+ else
121
+ raise MiyakoError, "this parameter cannot access!"
122
+ end
123
+ ret
124
+ end
125
+
126
+ #===インスタンスの割り算
127
+ #もう一方が整数のとき、x,yからotherを割ったものを返す
128
+ #Point構造体や配列など、[]メソッドがつかえるもののとき、x,y同士を割ったものを返す
129
+ #それ以外の時は例外が発生する
130
+ #自分自身の値は変わらない
131
+ #_other_:: 整数もしくはPoint構造体
132
+ #返却値:: Point構造体
133
+ def /(other)
134
+ ret = self.dup
135
+ if other.kind_of?(Numeric)
136
+ raise MiyakoValueError, "0 div!" if other == 0
137
+ ret[0] /= other
138
+ ret[1] /= other
139
+ elsif other.methods.include?(:[])
140
+ ret[0] /= other[0]
141
+ ret[1] /= other[1]
142
+ else
143
+ raise MiyakoError, "this parameter cannot access!"
144
+ end
145
+ ret
146
+ end
147
+
148
+ def to_ary #:nodoc:
149
+ [self[0], self[1]]
150
+ end
151
+ end
152
+
153
+ #==座標などを構成するために使用する構造体
154
+ #_x_:: X座標の値
155
+ #_y_:: Y座標の値
156
+ Point = PointStruct.new(:x, :y)
157
+ end
@@ -0,0 +1,233 @@
1
+ # -*- encoding: utf-8 -*-
2
+ =begin
3
+ --
4
+ Miyako v2.1
5
+ Copyright (C) 2007-2009 Cyross Makoto
6
+
7
+ This library is free software; you can redistribute it and/or
8
+ modify it under the terms of the GNU Lesser General Public
9
+ License as published by the Free Software Foundation; either
10
+ version 2.1 of the License, or (at your option) any later version.
11
+
12
+ This library is distributed in the hope that it will be useful,
13
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
14
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
15
+ Lesser General Public License for more details.
16
+
17
+ You should have received a copy of the GNU Lesser General Public
18
+ License along with this library; if not, write to the Free Software
19
+ Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
20
+ ++
21
+ =end
22
+
23
+ module Miyako
24
+ #==矩形情報のための構造体クラス
25
+ #矩形変更メソッドを追加
26
+ class RectStruct < Struct
27
+ #===位置を変更する(変化量を指定)
28
+ # ブロックを渡したとき、ブロックの評価した結果、偽になったときは移動させた値を元に戻す
29
+ #_dx_:: 移動量(x方向)。単位はピクセル
30
+ #_dy_:: 移動量(y方向)。単位はピクセル
31
+ #返却値:: 自分自身を返す
32
+ def move!(dx, dy)
33
+ end
34
+
35
+ #===位置を変更する(位置指定)
36
+ # ブロックを渡したとき、ブロックの評価した結果、偽になったときは移動させた値を元に戻す
37
+ #_x_:: 移動先位置(x方向)。単位はピクセル
38
+ #_y_:: 移動先位置(y方向)。単位はピクセル
39
+ #返却値:: 自分自身を返す
40
+ def move_to!(x, y)
41
+ end
42
+
43
+ #===位置を変更したインスタンスを返す(変化量を指定)
44
+ #引数で指定したぶん移動させたときの位置を新しくインスタンスを生成して返す
45
+ #自分自身の値は変わらない
46
+ #_dx_:: 移動量(x方向)。単位はピクセル
47
+ #_dy_:: 移動量(y方向)。単位はピクセル
48
+ #返却値:: 自分自身の複製を更新したインスタンス
49
+ def move(dx, dy)
50
+ self.dup.move!(dx, dy)
51
+ end
52
+
53
+ #===位置を変更したインスタンスを返す(位置指定)
54
+ #引数で指定したぶん移動させたときの位置を新しくインスタンスを生成して返す
55
+ #自分自身の値は変わらない
56
+ #_x_:: 移動先位置(x方向)。単位はピクセル
57
+ #_y_:: 移動先位置(y方向)。単位はピクセル
58
+ #返却値:: 自分自身の複製を更新したインスタンス
59
+ def move_to(x, y)
60
+ self.dup.move_to!(x, y)
61
+ end
62
+
63
+ #===サイズを変更する(変化量を指定)
64
+ # ブロックを渡したとき、ブロックの評価した結果、偽になったときは移動させた値を元に戻す
65
+ #_dw_:: 幅変更。単位はピクセル
66
+ #_dh_:: 高さ変更。単位はピクセル
67
+ #返却値:: 自分自身を返す
68
+ def resize!(dw, dh)
69
+ end
70
+
71
+ #===サイズを変更する
72
+ # ブロックを渡したとき、ブロックの評価した結果、偽になったときは移動させた値を元に戻す
73
+ #_w_:: 幅変更。単位はピクセル
74
+ #_h_:: 高さ変更。単位はピクセル
75
+ #返却値:: 自分自身を返す
76
+ def resize_to!(w, h)
77
+ end
78
+
79
+ #===サイズを変更したインスタンスを返す(変化量を指定)
80
+ #引数で指定したぶん変えたときの大きさを新しくインスタンスを生成して返す
81
+ #自分自身の値は変わらない
82
+ #_dw_:: 幅変更。単位はピクセル
83
+ #_dh_:: 高さ変更。単位はピクセル
84
+ #返却値:: 自分自身の複製を更新したインスタンス
85
+ def resize(dw, dh)
86
+ self.dup.resize!(dw,dh)
87
+ end
88
+
89
+ #===サイズを変更したインスタンスを返す
90
+ #引数で指定したぶん変えたときの大きさを新しくインスタンスを生成して返す
91
+ #自分自身の値は変わらない
92
+ #_w_:: 幅変更。単位はピクセル
93
+ #_h_:: 高さ変更。単位はピクセル
94
+ #返却値:: 自分自身の複製を更新したインスタンス
95
+ def resize_to(w, h)
96
+ self.dup.resize_to!(w,h)
97
+ end
98
+
99
+ #===インスタンスの足し算
100
+ #もう一方が整数のとき、x,yにotherを足したものを返す
101
+ #Point構造体や配列など、[]メソッドがつかえるもののとき、x,y同士を足したものを返す
102
+ #それ以外の時は例外が発生する
103
+ #自分自身の値は変わらない
104
+ #_other_:: 整数もしくはPoint構造体
105
+ #返却値:: Point構造体
106
+ def +(other)
107
+ ret = self.dup
108
+ if other.kind_of?(Numeric)
109
+ ret[0] += other
110
+ ret[1] += other
111
+ elsif other.methods.include?(:[])
112
+ ret[0] += other[0]
113
+ ret[1] += other[1]
114
+ else
115
+ raise MiyakoError, "this parameter cannot access!"
116
+ end
117
+ ret
118
+ end
119
+
120
+ #===インスタンスの引き算
121
+ #もう一方が整数のとき、x,yからotherを引いたものを返す
122
+ #Point構造体や配列など、[]メソッドがつかえるもののとき、x,y同士を引いたものを返す
123
+ #それ以外の時は例外が発生する
124
+ #自分自身の値は変わらない
125
+ #_other_:: 整数もしくはPoint構造体
126
+ #返却値:: Point構造体
127
+ def -(other)
128
+ ret = self.dup
129
+ if other.kind_of?(Numeric)
130
+ ret[0] -= other
131
+ ret[1] -= other
132
+ elsif other.methods.include?(:[])
133
+ ret[0] -= other[0]
134
+ ret[1] -= other[1]
135
+ else
136
+ raise MiyakoError, "this parameter cannot access!"
137
+ end
138
+ ret
139
+ end
140
+
141
+ #===インスタンスのかけ算
142
+ #もう一方が整数のとき、x,yにotherを掛けたものを返す
143
+ #Point構造体や配列など、[]メソッドがつかえるもののとき、x,y同士を掛けたものを返す
144
+ #それ以外の時は例外が発生する
145
+ #自分自身の値は変わらない
146
+ #_other_:: 整数もしくはPoint構造体
147
+ #返却値:: Point構造体
148
+ def *(other)
149
+ ret = self.dup
150
+ if other.kind_of?(Numeric)
151
+ ret[0] *= other
152
+ ret[1] *= other
153
+ elsif other.methods.include?(:[])
154
+ ret[0] *= other[0]
155
+ ret[1] *= other[1]
156
+ else
157
+ raise MiyakoError, "this parameter cannot access!"
158
+ end
159
+ ret
160
+ end
161
+
162
+ #===インスタンスの割り算
163
+ #もう一方が整数のとき、x,yからotherを割ったものを返す
164
+ #Point構造体や配列など、[]メソッドがつかえるもののとき、x,y同士を割ったものを返す
165
+ #それ以外の時は例外が発生する
166
+ #自分自身の値は変わらない
167
+ #_other_:: 整数もしくはPoint構造体
168
+ #返却値:: Point構造体
169
+ def /(other)
170
+ ret = self.dup
171
+ if other.kind_of?(Numeric)
172
+ raise MiyakoValueError, "0 div!" if other == 0
173
+ ret[0] /= other
174
+ ret[1] /= other
175
+ elsif other.methods.include?(:[])
176
+ raise MiyakoValueError, "0 div!" if (other[0] == 0 || other[1] == 0)
177
+ ret[0] /= other[0]
178
+ ret[1] /= other[1]
179
+ else
180
+ raise MiyakoError, "this parameter cannot access!"
181
+ end
182
+ ret
183
+ end
184
+
185
+ #===指定の座標が矩形の範囲内かを問い合わせる
186
+ #_x_:: 指定のx座標
187
+ #_y_:: 指定のy座標
188
+ #返却値:: 座標が矩形の範囲内ならtrueを返す
189
+ def in_range?(x, y)
190
+ return (x >= self[0] && y >= self[1] && x < self[0] + self[2] && y < self[1] + self[3])
191
+ end
192
+
193
+ #===指定の座標が矩形の範囲内かを問い合わせる
194
+ #_x_:: 指定のx座標
195
+ #_y_:: 指定のy座標
196
+ #返却値:: 座標が矩形の範囲内ならtrueを返す
197
+ def between?(x, y)
198
+ return in_range?(x, y)
199
+ end
200
+
201
+ #===矩形の左上位置部分のみ返す
202
+ #返却値:: Position構造体のインスタンス
203
+ def pos
204
+ return Point.new(self[0], self[1])
205
+ end
206
+
207
+ #===矩形の大きさのみ返す
208
+ #返却値:: Size構造体のインスタンス
209
+ def size
210
+ return Size.new(self[2], self[3])
211
+ end
212
+
213
+ #===矩形情報を配列に変換する
214
+ #[left, top, width, height]の配列を生成して返す。
215
+ #返却値:: 生成した配列
216
+ def to_ary
217
+ [self[0], self[1], self[2], self[3]]
218
+ end
219
+
220
+ #===矩形情報をSquare構造体に変換する
221
+ #返却値:: 生成したSquare構造体
222
+ def to_square
223
+ Square.new(self[0], self[1], self[2]+self[0]-1, self[3]+self[1]-1)
224
+ end
225
+ end
226
+
227
+ #==矩形などを構成するために使用する構造体
228
+ #_x_:: X座標の値
229
+ #_y_:: Y座標の値
230
+ #_w_:: 横幅
231
+ #_h_:: 高さ
232
+ Rect = RectStruct.new(:x, :y, :w, :h)
233
+ end