cyross-ruby-miyako 2.0.0 → 2.0.5.1.0

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 (102) hide show
  1. data/README +106 -154
  2. data/defines.h +144 -0
  3. data/{miyako_no_katana/extconf.rb → extconf.rb} +10 -0
  4. data/extern.h +29 -0
  5. data/install_miyako.rb +26 -14
  6. data/lib/Miyako/API/audio.rb +2 -2
  7. data/lib/Miyako/API/basic_data.rb +183 -41
  8. data/lib/Miyako/API/bitmap.rb +474 -2
  9. data/lib/Miyako/API/choices.rb +215 -48
  10. data/lib/Miyako/API/collision.rb +267 -251
  11. data/lib/Miyako/API/diagram.rb +58 -70
  12. data/lib/Miyako/API/drawing.rb +93 -52
  13. data/lib/Miyako/API/fixedmap.rb +233 -120
  14. data/lib/Miyako/API/font.rb +59 -40
  15. data/lib/Miyako/API/input.rb +34 -27
  16. data/lib/Miyako/API/layout.rb +154 -172
  17. data/lib/Miyako/API/map.rb +285 -159
  18. data/lib/Miyako/API/map_event.rb +4 -4
  19. data/lib/Miyako/API/modules.rb +1 -1
  20. data/lib/Miyako/API/movie.rb +8 -5
  21. data/lib/Miyako/API/parts.rb +44 -9
  22. data/lib/Miyako/API/plane.rb +37 -2
  23. data/lib/Miyako/API/screen.rb +90 -22
  24. data/lib/Miyako/API/shape.rb +118 -37
  25. data/lib/Miyako/API/sprite.rb +475 -61
  26. data/lib/Miyako/API/sprite_animation.rb +83 -63
  27. data/lib/Miyako/API/spriteunit.rb +47 -13
  28. data/lib/Miyako/API/story.rb +123 -47
  29. data/lib/Miyako/API/textbox.rb +361 -132
  30. data/lib/Miyako/API/utility.rb +388 -0
  31. data/lib/Miyako/API/viewport.rb +54 -349
  32. data/lib/Miyako/API/yuki.rb +570 -353
  33. data/lib/Miyako/EXT/miyako_cairo.rb +5 -3
  34. data/lib/Miyako/EXT/slides.rb +22 -1
  35. data/lib/Miyako/miyako.rb +12 -13
  36. data/logo/EGSR_logo.png +0 -0
  37. data/logo/EGSR_logo_bg.png +0 -0
  38. data/logo/EGSR_logo_fg.png +0 -0
  39. data/logo/EGSR_title_banner.png +0 -0
  40. data/logo/EGSR_title_logo.png +0 -0
  41. data/logo/miyako.png +0 -0
  42. data/logo/miyako_banner.png +0 -0
  43. data/logo/space.png +0 -0
  44. data/miyako_basicdata.c +590 -0
  45. data/miyako_bitmap.c +1225 -0
  46. data/miyako_collision.c +403 -0
  47. data/miyako_drawing.c +187 -0
  48. data/miyako_font.c +334 -0
  49. data/miyako_hsv.c +830 -0
  50. data/miyako_layout.c +191 -0
  51. data/miyako_no_katana.c +1074 -0
  52. data/miyako_transform.c +438 -0
  53. data/miyako_utility.c +288 -0
  54. data/sample/Animation1/m1ku.rb +10 -31
  55. data/sample/Animation1/readme.txt +6 -6
  56. data/sample/Animation2/lex.rb +1 -0
  57. data/sample/Animation2/readme.txt +6 -6
  58. data/sample/Diagram_sample/diagram_sample_yuki2.rb +152 -48
  59. data/sample/Diagram_sample/readme.txt +9 -6
  60. data/sample/Room3/blue.rb +234 -187
  61. data/sample/Room3/ending.rb +68 -63
  62. data/sample/Room3/green.rb +159 -124
  63. data/sample/Room3/main.rb +50 -32
  64. data/sample/Room3/main_component.rb +3 -2
  65. data/sample/Room3/readme.txt +6 -6
  66. data/sample/Room3/red.rb +161 -134
  67. data/sample/Room3/room3.rb +1 -0
  68. data/sample/Room3/title.rb +75 -62
  69. data/sample/ball_action_sample.rb +204 -0
  70. data/sample/blit_rop.rb +70 -0
  71. data/sample/cairo_sample.rb +25 -0
  72. data/sample/circle_collision_test.rb +66 -0
  73. data/sample/collision_test.rb +33 -0
  74. data/sample/collision_test2.rb +108 -0
  75. data/sample/fixed_map_test/fixed_map_sample.rb +23 -32
  76. data/sample/fixed_map_test/readme.txt +38 -38
  77. data/sample/map_test/chara.rb +17 -9
  78. data/sample/map_test/main_parts.rb +30 -9
  79. data/sample/map_test/main_scene.rb +57 -41
  80. data/sample/map_test/map_manager.rb +13 -30
  81. data/sample/map_test/map_test.rb +2 -2
  82. data/sample/map_test/oasis.rb +17 -11
  83. data/sample/map_test/readme.txt +50 -48
  84. data/sample/map_test/route.rb +46 -33
  85. data/sample/map_test/town.rb +19 -13
  86. data/sample/polygon_test.rb +35 -0
  87. data/sample/rasterscroll.rb +25 -0
  88. data/sample/takahashi.rb +42 -0
  89. data/sample/text.png +0 -0
  90. data/sample/textbox_sample.rb +190 -0
  91. data/sample/transform.rb +54 -0
  92. data/sample/utility_test.rb +73 -0
  93. data/sample/utility_test2.rb +61 -0
  94. data/sample/utility_test3.rb +64 -0
  95. data/sample/utility_test4.rb +73 -0
  96. data/uninstall_miyako.rb +19 -0
  97. data/win/miyako_no_katana.so +0 -0
  98. metadata +165 -148
  99. data/miyako.png +0 -0
  100. data/miyako_banner.png +0 -0
  101. data/miyako_no_katana/miyako_no_katana.c +0 -3301
  102. data/sample/fixed_map_test/map_sample.rb +0 -121
@@ -0,0 +1,73 @@
1
+ # Utility.product_linerサンプル(実数)
2
+ # 2009.4.24 Cyross Makoto
3
+
4
+ require 'Miyako/miyako'
5
+
6
+ # 色配列(Enumerator)
7
+ Colors = [[0,0,255], # 青色
8
+ [0,255,0], # 緑色
9
+ [0,255,255], # 水色
10
+ [255,0,0], # 赤色
11
+ [255,0,255], # 紫色
12
+ [255,255,0], # 黄色
13
+ [255,255,255] # 白色
14
+ ].cycle
15
+
16
+ # 線形配列生成メソッドを用意
17
+ def draw_liner(sprite, info)
18
+ # 画面の真ん中から指定の位置までの線形配列を、
19
+ # 1~16間ランダム値の刻みで作成する
20
+ square = Miyako::Square.new(
21
+ Miyako::Screen.w/2.0, Miyako::Screen.h/2.0,
22
+ rand*Miyako::Screen.w, rand*Miyako::Screen.h
23
+ )
24
+ amount = rand*16.0+1.0
25
+ # 線形配列を作成
26
+ array = Miyako::Utility.product_liner_by_square(square, amount)
27
+ # 画像内容の消去
28
+ sprite.fill([0,0,0,0])
29
+ # 配列の位置を元に矩形を描画
30
+ array.each{|pos| Miyako::Drawing.rect(sprite, pos+[amount,amount], Colors.next)}
31
+
32
+ info.dispose if info
33
+ info = Miyako::Shape.text(
34
+ :font => Miyako::Font.serif,
35
+ :text => "square = (#{square[0]}, #{square[1]})-(#{square[2]}, #{square[3]}), amount = #{amount}"
36
+ )
37
+
38
+ [sprite, info]
39
+ end
40
+
41
+ # 描画間隔の設定(ここでは2秒)
42
+ wait = Miyako::WaitCounter.new(2)
43
+
44
+ # 描画用スプライトの作成
45
+ screen = Miyako::Sprite.new(
46
+ :size=>Miyako::Screen.size,
47
+ :type=>:ac
48
+ )
49
+
50
+ # 情報表示用スプライト変数の用意
51
+ screen, info = draw_liner(screen, nil)
52
+
53
+ # メインループの開始
54
+ loop do
55
+ Miyako::Input.update
56
+ # Escキー押下もしくは×印クリックのときは終了
57
+ break if Miyako::Input.quit_or_escape?
58
+ # 時間が来たら画面内容の更新
59
+ if wait.finish?
60
+ screen, info = draw_liner(screen, info)
61
+ wait.start
62
+ end
63
+ # 画面の描画
64
+ # 画面の消去
65
+ Miyako::Screen.clear
66
+ # 線形配列結果の表示
67
+ screen.render
68
+ # 情報画像の表示
69
+ info.render
70
+ # 画面の更新
71
+ Miyako::Screen.render
72
+ end
73
+
@@ -0,0 +1,19 @@
1
+ # Miyako2.0 uninstall script
2
+ # 2009 Cyross Makoto
3
+
4
+ if RUBY_VERSION < '1.9.1'
5
+ puts 'Sorry. Miyako needs Ruby 1.9.1 or above...'
6
+ exit
7
+ end
8
+
9
+ require 'rbconfig'
10
+ require 'fileutils'
11
+
12
+ puts "Are you sure?(Y/else)"
13
+ exit unless $stdin.gets.split(//)[0].upcase == 'Y'
14
+
15
+ sitelibdir = Config::CONFIG["sitelibdir"] + "/Miyako"
16
+
17
+ FileUtils.remove_dir(sitelibdir, true)
18
+
19
+ puts "uninstall completed."
Binary file
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: cyross-ruby-miyako
3
3
  version: !ruby/object:Gem::Version
4
- version: 2.0.0
4
+ version: 2.0.5.1.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Cyross Makoto
@@ -9,7 +9,7 @@ autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
11
 
12
- date: 2008-12-13 00:00:00 -08:00
12
+ date: 2009-04-08 00:00:00 -07:00
13
13
  default_executable:
14
14
  dependencies: []
15
15
 
@@ -17,165 +17,182 @@ description: Miyako is Ruby library for programming game or rich client
17
17
  email: cyross@po.twin.ne.jp
18
18
  executables: []
19
19
 
20
- extensions: []
21
-
20
+ extensions:
21
+ - extconf.rb
22
22
  extra_rdoc_files: []
23
23
 
24
24
  files:
25
- - img/cursor.png
26
- - img/cursors.png
27
- - img/dice.png
28
- - img/wait_cursor.png
29
- - img/window.png
30
- - img/win_base.png
31
- - lib/Miyako
32
- - lib/Miyako/API
33
- - lib/Miyako/API/audio.rb
34
- - lib/Miyako/API/basic_data.rb
35
- - lib/Miyako/API/bitmap.rb
36
- - lib/Miyako/API/choices.rb
37
- - lib/Miyako/API/collision.rb
38
- - lib/Miyako/API/diagram.rb
39
- - lib/Miyako/API/drawing.rb
40
- - lib/Miyako/API/fixedmap.rb
41
- - lib/Miyako/API/font.rb
42
- - lib/Miyako/API/input.rb
43
- - lib/Miyako/API/layout.rb
44
- - lib/Miyako/API/map.rb
45
- - lib/Miyako/API/map_event.rb
46
- - lib/Miyako/API/modules.rb
47
- - lib/Miyako/API/movie.rb
48
- - lib/Miyako/API/parts.rb
49
- - lib/Miyako/API/plane.rb
50
- - lib/Miyako/API/screen.rb
51
- - lib/Miyako/API/shape.rb
52
- - lib/Miyako/API/sprite.rb
53
- - lib/Miyako/API/spriteunit.rb
54
- - lib/Miyako/API/sprite_animation.rb
55
- - lib/Miyako/API/story.rb
56
- - lib/Miyako/API/textbox.rb
57
- - lib/Miyako/API/viewport.rb
58
- - lib/Miyako/API/yuki.rb
59
- - lib/Miyako/EXT
60
- - lib/Miyako/EXT/miyako_cairo.rb
61
- - lib/Miyako/EXT/raster_scroll.rb
62
- - lib/Miyako/EXT/slides.rb
63
- - lib/Miyako/miyako.rb
64
- - miyako_no_katana/extconf.rb
65
- - miyako_no_katana/miyako_no_katana.c
66
- - sample/Animation1
67
- - sample/Animation1/m1ku.rb
68
- - sample/Animation1/m1ku_arm_0.png
69
- - sample/Animation1/m1ku_arm_1.png
70
- - sample/Animation1/m1ku_arm_2.png
71
- - sample/Animation1/m1ku_arm_3.png
72
- - sample/Animation1/m1ku_back.jpg
73
- - sample/Animation1/m1ku_body.png
74
- - sample/Animation1/m1ku_eye_0.png
75
- - sample/Animation1/m1ku_eye_1.png
76
- - sample/Animation1/m1ku_eye_2.png
77
- - sample/Animation1/m1ku_eye_3.png
78
- - sample/Animation1/m1ku_hair_front.png
79
- - sample/Animation1/m1ku_hair_rear.png
80
- - sample/Animation1/readme.txt
81
- - sample/Animation2
82
- - sample/Animation2/lex.rb
83
- - sample/Animation2/lex_back.png
84
- - sample/Animation2/lex_body.png
85
- - sample/Animation2/lex_roadroller.png
86
- - sample/Animation2/lex_wheel_0.png
87
- - sample/Animation2/lex_wheel_1.png
88
- - sample/Animation2/lex_wheel_2.png
89
- - sample/Animation2/readme.txt
90
- - sample/Animation2/song_title.png
91
- - sample/Diagram_sample
92
- - sample/Diagram_sample/back.png
93
- - sample/Diagram_sample/chr01.png
94
- - sample/Diagram_sample/chr02.png
95
- - sample/Diagram_sample/cursor.png
96
- - sample/Diagram_sample/diagram_sample_yuki2.rb
97
- - sample/Diagram_sample/readme.txt
98
- - sample/Diagram_sample/wait_cursor.png
99
- - sample/fixed_map_test
100
- - sample/fixed_map_test/cursor.png
101
- - sample/fixed_map_test/fixed_map_sample.rb
102
- - sample/fixed_map_test/map.csv
103
- - sample/fixed_map_test/mapchip.csv
104
- - sample/fixed_map_test/map_01.png
105
- - sample/fixed_map_test/map_sample.rb
106
- - sample/fixed_map_test/monster.png
107
- - sample/fixed_map_test/readme.txt
108
- - sample/map_test
109
- - sample/map_test/chara.rb
110
- - sample/map_test/chr1.png
111
- - sample/map_test/cursor.png
112
- - sample/map_test/main_parts.rb
113
- - sample/map_test/main_scene.rb
114
- - sample/map_test/map.png
115
- - sample/map_test/map2.png
116
- - sample/map_test/mapchip.csv
117
- - sample/map_test/map_layer.csv
118
- - sample/map_test/map_manager.rb
119
- - sample/map_test/map_test.rb
120
- - sample/map_test/oasis.rb
121
- - sample/map_test/readme.txt
122
- - sample/map_test/route.rb
123
- - sample/map_test/sea.png
124
- - sample/map_test/town.rb
125
- - sample/map_test/wait_cursor.png
126
- - sample/map_test/window.png
127
- - sample/Room3
128
- - sample/Room3/blue.rb
129
- - sample/Room3/ending.rb
130
- - sample/Room3/green.rb
131
- - sample/Room3/image
132
- - sample/Room3/image/akamatsu.png
133
- - sample/Room3/image/aoyama.png
134
- - sample/Room3/image/congra.png
135
- - sample/Room3/image/congratulation.png
136
- - sample/Room3/image/congratulation_bg.png
137
- - sample/Room3/image/cursor.png
138
- - sample/Room3/image/midori.png
139
- - sample/Room3/image/mittsu_no_oheya.png
140
- - sample/Room3/image/mittsu_no_oheya_logo.png
141
- - sample/Room3/image/room_blue.png
142
- - sample/Room3/image/room_green.png
143
- - sample/Room3/image/room_red.png
144
- - sample/Room3/image/start.png
145
- - sample/Room3/image/three_doors.png
146
- - sample/Room3/image/wait_cursor.png
147
- - sample/Room3/main.rb
148
- - sample/Room3/main_component.rb
149
- - sample/Room3/readme.txt
150
- - sample/Room3/red.rb
151
- - sample/Room3/room3.rb
152
- - sample/Room3/title.rb
153
- - win/miyako_no_katana.so
154
- - install_miyako.rb
155
- - README
156
- - miyako.png
157
- - miyako_banner.png
158
- - Rakefile
25
+ - ./defines.h
26
+ - ./extconf.rb
27
+ - ./extern.h
28
+ - ./img/cursor.png
29
+ - ./img/cursors.png
30
+ - ./img/dice.png
31
+ - ./img/wait_cursor.png
32
+ - ./img/window.png
33
+ - ./img/win_base.png
34
+ - ./install_miyako.rb
35
+ - ./lib/Miyako/API/audio.rb
36
+ - ./lib/Miyako/API/basic_data.rb
37
+ - ./lib/Miyako/API/bitmap.rb
38
+ - ./lib/Miyako/API/choices.rb
39
+ - ./lib/Miyako/API/collision.rb
40
+ - ./lib/Miyako/API/diagram.rb
41
+ - ./lib/Miyako/API/drawing.rb
42
+ - ./lib/Miyako/API/fixedmap.rb
43
+ - ./lib/Miyako/API/font.rb
44
+ - ./lib/Miyako/API/input.rb
45
+ - ./lib/Miyako/API/layout.rb
46
+ - ./lib/Miyako/API/map.rb
47
+ - ./lib/Miyako/API/map_event.rb
48
+ - ./lib/Miyako/API/modules.rb
49
+ - ./lib/Miyako/API/movie.rb
50
+ - ./lib/Miyako/API/parts.rb
51
+ - ./lib/Miyako/API/plane.rb
52
+ - ./lib/Miyako/API/screen.rb
53
+ - ./lib/Miyako/API/shape.rb
54
+ - ./lib/Miyako/API/sprite.rb
55
+ - ./lib/Miyako/API/spriteunit.rb
56
+ - ./lib/Miyako/API/sprite_animation.rb
57
+ - ./lib/Miyako/API/story.rb
58
+ - ./lib/Miyako/API/textbox.rb
59
+ - ./lib/Miyako/API/utility.rb
60
+ - ./lib/Miyako/API/viewport.rb
61
+ - ./lib/Miyako/API/yuki.rb
62
+ - ./lib/Miyako/EXT/miyako_cairo.rb
63
+ - ./lib/Miyako/EXT/raster_scroll.rb
64
+ - ./lib/Miyako/EXT/slides.rb
65
+ - ./lib/Miyako/miyako.rb
66
+ - ./logo/EGSR_logo.png
67
+ - ./logo/EGSR_logo_bg.png
68
+ - ./logo/EGSR_logo_fg.png
69
+ - ./logo/EGSR_title_banner.png
70
+ - ./logo/EGSR_title_logo.png
71
+ - ./logo/miyako.png
72
+ - ./logo/miyako_banner.png
73
+ - ./logo/space.png
74
+ - ./miyako_basicdata.c
75
+ - ./miyako_bitmap.c
76
+ - ./miyako_collision.c
77
+ - ./miyako_drawing.c
78
+ - ./miyako_font.c
79
+ - ./miyako_hsv.c
80
+ - ./miyako_layout.c
81
+ - ./miyako_no_katana.c
82
+ - ./miyako_transform.c
83
+ - ./miyako_utility.c
84
+ - ./Rakefile
85
+ - ./README
86
+ - ./sample/Animation1/m1ku.rb
87
+ - ./sample/Animation1/m1ku_arm_0.png
88
+ - ./sample/Animation1/m1ku_arm_1.png
89
+ - ./sample/Animation1/m1ku_arm_2.png
90
+ - ./sample/Animation1/m1ku_arm_3.png
91
+ - ./sample/Animation1/m1ku_back.jpg
92
+ - ./sample/Animation1/m1ku_body.png
93
+ - ./sample/Animation1/m1ku_eye_0.png
94
+ - ./sample/Animation1/m1ku_eye_1.png
95
+ - ./sample/Animation1/m1ku_eye_2.png
96
+ - ./sample/Animation1/m1ku_eye_3.png
97
+ - ./sample/Animation1/m1ku_hair_front.png
98
+ - ./sample/Animation1/m1ku_hair_rear.png
99
+ - ./sample/Animation1/readme.txt
100
+ - ./sample/Animation2/lex.rb
101
+ - ./sample/Animation2/lex_back.png
102
+ - ./sample/Animation2/lex_body.png
103
+ - ./sample/Animation2/lex_roadroller.png
104
+ - ./sample/Animation2/lex_wheel_0.png
105
+ - ./sample/Animation2/lex_wheel_1.png
106
+ - ./sample/Animation2/lex_wheel_2.png
107
+ - ./sample/Animation2/readme.txt
108
+ - ./sample/Animation2/song_title.png
109
+ - ./sample/ball_action_sample.rb
110
+ - ./sample/blit_rop.rb
111
+ - ./sample/cairo_sample.rb
112
+ - ./sample/circle_collision_test.rb
113
+ - ./sample/collision_test.rb
114
+ - ./sample/collision_test2.rb
115
+ - ./sample/Diagram_sample/back.png
116
+ - ./sample/Diagram_sample/chr01.png
117
+ - ./sample/Diagram_sample/chr02.png
118
+ - ./sample/Diagram_sample/cursor.png
119
+ - ./sample/Diagram_sample/diagram_sample_yuki2.rb
120
+ - ./sample/Diagram_sample/readme.txt
121
+ - ./sample/Diagram_sample/wait_cursor.png
122
+ - ./sample/fixed_map_test/cursor.png
123
+ - ./sample/fixed_map_test/fixed_map_sample.rb
124
+ - ./sample/fixed_map_test/map.csv
125
+ - ./sample/fixed_map_test/mapchip.csv
126
+ - ./sample/fixed_map_test/map_01.png
127
+ - ./sample/fixed_map_test/monster.png
128
+ - ./sample/fixed_map_test/readme.txt
129
+ - ./sample/map_test/chara.rb
130
+ - ./sample/map_test/chr1.png
131
+ - ./sample/map_test/cursor.png
132
+ - ./sample/map_test/main_parts.rb
133
+ - ./sample/map_test/main_scene.rb
134
+ - ./sample/map_test/map.png
135
+ - ./sample/map_test/map2.png
136
+ - ./sample/map_test/mapchip.csv
137
+ - ./sample/map_test/map_layer.csv
138
+ - ./sample/map_test/map_manager.rb
139
+ - ./sample/map_test/map_test.rb
140
+ - ./sample/map_test/oasis.rb
141
+ - ./sample/map_test/readme.txt
142
+ - ./sample/map_test/route.rb
143
+ - ./sample/map_test/sea.png
144
+ - ./sample/map_test/town.rb
145
+ - ./sample/map_test/wait_cursor.png
146
+ - ./sample/map_test/window.png
147
+ - ./sample/polygon_test.rb
148
+ - ./sample/rasterscroll.rb
149
+ - ./sample/Room3/blue.rb
150
+ - ./sample/Room3/ending.rb
151
+ - ./sample/Room3/green.rb
152
+ - ./sample/Room3/image/akamatsu.png
153
+ - ./sample/Room3/image/aoyama.png
154
+ - ./sample/Room3/image/congra.png
155
+ - ./sample/Room3/image/congratulation.png
156
+ - ./sample/Room3/image/congratulation_bg.png
157
+ - ./sample/Room3/image/cursor.png
158
+ - ./sample/Room3/image/midori.png
159
+ - ./sample/Room3/image/mittsu_no_oheya.png
160
+ - ./sample/Room3/image/mittsu_no_oheya_logo.png
161
+ - ./sample/Room3/image/room_blue.png
162
+ - ./sample/Room3/image/room_green.png
163
+ - ./sample/Room3/image/room_red.png
164
+ - ./sample/Room3/image/start.png
165
+ - ./sample/Room3/image/three_doors.png
166
+ - ./sample/Room3/image/wait_cursor.png
167
+ - ./sample/Room3/main.rb
168
+ - ./sample/Room3/main_component.rb
169
+ - ./sample/Room3/readme.txt
170
+ - ./sample/Room3/red.rb
171
+ - ./sample/Room3/room3.rb
172
+ - ./sample/Room3/title.rb
173
+ - ./sample/takahashi.rb
174
+ - ./sample/text.png
175
+ - ./sample/textbox_sample.rb
176
+ - ./sample/transform.rb
177
+ - ./sample/utility_test.rb
178
+ - ./sample/utility_test2.rb
179
+ - ./sample/utility_test3.rb
180
+ - ./sample/utility_test4.rb
181
+ - ./uninstall_miyako.rb
182
+ - ./win/miyako_no_katana.so
159
183
  has_rdoc: true
160
184
  homepage: http://www.twin.ne.jp/~cyross/Miyako/
161
- post_install_message: |+
162
-
163
- [[IMPORTANT]]
164
- please enter 'ruby install_miyako.rb' at installed path to complete installation of ruby-miyako.
165
-
166
- [Example]
167
- >cd (ruby-path)/lib/ruby/gems/1.8/gems/cyross-ruby-miyako-2.0.0
168
- ruby install_miyako.rb
169
-
185
+ post_install_message:
170
186
  rdoc_options:
171
187
  - -c utf-8
172
188
  require_paths:
189
+ - lib/Miyako
173
190
  - lib
174
191
  required_ruby_version: !ruby/object:Gem::Requirement
175
192
  requirements:
176
193
  - - ">="
177
194
  - !ruby/object:Gem::Version
178
- version: "0"
195
+ version: 1.9.1
179
196
  version:
180
197
  required_rubygems_version: !ruby/object:Gem::Requirement
181
198
  requirements:
data/miyako.png DELETED
Binary file
data/miyako_banner.png DELETED
Binary file
@@ -1,3301 +0,0 @@
1
- /*
2
- --
3
- Miyako v1.5 Extend Library "Miyako no Katana"
4
- Copyright (C) 2008 Cyross Makoto
5
-
6
- This library is free software; you can redistribute it and/or
7
- modify it under the terms of the GNU Lesser General Public
8
- License as published by the Free Software Foundation; either
9
- version 2.1 of the License, or (at your option) any later version.
10
-
11
- This library is distributed in the hope that it will be useful,
12
- but WITHOUT ANY WARRANTY; without even the implied warranty of
13
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14
- Lesser General Public License for more details.
15
-
16
- You should have received a copy of the GNU Lesser General Public
17
- License along with this library; if not, write to the Free Software
18
- Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
19
- ++
20
- */
21
-
22
- /*
23
- =拡張ライブラリmiyako_no_katana
24
- Authors:: サイロス誠
25
- Version:: 2.0
26
- Copyright:: 2007-2008 Cyross Makoto
27
- License:: LGPL2.1
28
- */
29
- #include <SDL.h>
30
- #include <stdlib.h>
31
- #include <math.h>
32
- #include "ruby.h"
33
-
34
- static VALUE mSDL = Qnil;
35
- static VALUE mMiyako = Qnil;
36
- static VALUE mScreen = Qnil;
37
- static VALUE mInput = Qnil;
38
- static VALUE mMapEvent = Qnil;
39
- static VALUE mLayout = Qnil;
40
- static VALUE mDiagram = Qnil;
41
- static VALUE eMiyakoError = Qnil;
42
- static VALUE cSurface = Qnil;
43
- static VALUE cEvent2 = Qnil;
44
- static VALUE cJoystick = Qnil;
45
- static VALUE cWaitCounter = Qnil;
46
- static VALUE cColor = Qnil;
47
- static VALUE cFont = Qnil;
48
- static VALUE cPixelFormat = Qnil;
49
- static VALUE cBitmap = Qnil;
50
- static VALUE cSprite = Qnil;
51
- static VALUE cSpriteAnimation = Qnil;
52
- static VALUE sSpriteUnit = Qnil;
53
- static VALUE cPlane = Qnil;
54
- static VALUE cParts = Qnil;
55
- static VALUE cTextBox = Qnil;
56
- static VALUE cMap = Qnil;
57
- static VALUE cMapLayer = Qnil;
58
- static VALUE cFixedMap = Qnil;
59
- static VALUE cFixedMapLayer = Qnil;
60
- static VALUE cCollision = Qnil;
61
- static VALUE cCollisions = Qnil;
62
- static VALUE cMovie = Qnil;
63
- static VALUE cProcessor = Qnil;
64
- static VALUE cYuki = Qnil;
65
- static VALUE cThread = Qnil;
66
- static VALUE nZero = Qnil;
67
- static VALUE nOne = Qnil;
68
- static volatile ID id_update = Qnil;
69
- static volatile ID id_kakko = Qnil;
70
- static volatile int zero = Qnil;
71
- static volatile int one = Qnil;
72
-
73
- typedef struct
74
- {
75
- SDL_Surface* surface;
76
- } Surface;
77
-
78
- typedef struct
79
- {
80
- Uint32 r;
81
- Uint32 g;
82
- Uint32 b;
83
- Uint32 a;
84
- } MiyakoColor;
85
-
86
- // from rubysdl.h
87
- #define GLOBAL_DEFINE_GET_STRUCT(struct_name, fun, klass, klassstr) \
88
- struct_name* fun(VALUE obj) \
89
- { \
90
- struct_name* st; \
91
- \
92
- if(!rb_obj_is_kind_of(obj, klass)){ \
93
- rb_raise(rb_eTypeError, "wrong argument type %s (expected " klassstr ")", \
94
- rb_obj_classname(obj)); \
95
- } \
96
- Data_Get_Struct(obj, struct_name, st); \
97
- return st; \
98
- }
99
-
100
- #define DEFINE_GET_STRUCT(struct_name, fun, klass, klassstr) \
101
- static GLOBAL_DEFINE_GET_STRUCT(struct_name, fun, klass, klassstr)
102
-
103
- // from rubysdl-video.c
104
- DEFINE_GET_STRUCT(Surface, GetSurface, cSurface, "SDL::Surface");
105
- DEFINE_GET_STRUCT(SDL_PixelFormat, Get_PixelFormat, cPixelFormat, "SDL::PixelFormat");
106
-
107
- #define MIYAKO_GETCOLOR(COLOR) \
108
- tmp = pixel & fmt->Rmask; \
109
- tmp >>= fmt->Rshift; \
110
- COLOR.r = (Uint32)(tmp << fmt->Rloss); \
111
- tmp = pixel & fmt->Gmask; \
112
- tmp >>= fmt->Gshift; \
113
- COLOR.g = (Uint32)(tmp << fmt->Gloss); \
114
- tmp = pixel & fmt->Bmask; \
115
- tmp >>= fmt->Bshift; \
116
- COLOR.b = (Uint32)(tmp << fmt->Bloss); \
117
- tmp = pixel & fmt->Amask; \
118
- tmp >>= fmt->Ashift; \
119
- COLOR.a = (Uint32)(tmp << fmt->Aloss);
120
-
121
- #define MIYAKO_SETCOLOR(COLOR) \
122
- pixel = 0; \
123
- tmp = COLOR.r >> fmt->Rloss; \
124
- tmp <<= fmt->Rshift; \
125
- pixel |= tmp; \
126
- tmp = COLOR.g >> fmt->Gloss; \
127
- tmp <<= fmt->Gshift; \
128
- pixel |= tmp; \
129
- tmp = COLOR.b >> fmt->Bloss; \
130
- tmp <<= fmt->Bshift; \
131
- pixel |= tmp; \
132
- tmp = COLOR.a >> fmt->Aloss; \
133
- tmp <<= fmt->Ashift; \
134
- pixel |= tmp; \
135
-
136
- #define MIYAKO_SET_RECT(RECT, BASE) \
137
- RECT.x = NUM2INT(*(RSTRUCT_PTR(BASE) + 1)); \
138
- RECT.y = NUM2INT(*(RSTRUCT_PTR(BASE) + 2)); \
139
- RECT.w = NUM2INT(*(RSTRUCT_PTR(BASE) + 3)); \
140
- RECT.h = NUM2INT(*(RSTRUCT_PTR(BASE) + 4));
141
-
142
- #define MIYAKO_GET_UNIT_1(SRC, SRCUNIT, SRCSURFACE) \
143
- VALUE SRCUNIT = SRC; \
144
- if(rb_obj_is_kind_of(SRCUNIT, sSpriteUnit)==Qfalse){ \
145
- SRCUNIT = rb_funcall(SRCUNIT, rb_intern("to_unit"), 0); \
146
- if(SRCUNIT == Qnil){ rb_raise(eMiyakoError, "Source instance has not SpriteUnit!"); } \
147
- } \
148
- if(rb_block_given_p() == Qtrue){ rb_yield(SRCUNIT); } \
149
- SDL_Surface *SRCSURFACE = GetSurface(*(RSTRUCT_PTR(SRCUNIT)))->surface;
150
-
151
- #define MIYAKO_GET_UNIT_2(SRC, DST, SRCUNIT, DSTUNIT, SRCSURFACE, DSTSURFACE) \
152
- VALUE SRCUNIT = SRC; \
153
- if(rb_obj_is_kind_of(SRCUNIT, sSpriteUnit)==Qfalse){ \
154
- SRCUNIT = rb_funcall(SRCUNIT, rb_intern("to_unit"), 0); \
155
- if(SRCUNIT == Qnil){ rb_raise(eMiyakoError, "Source instance has not SpriteUnit!"); } \
156
- } \
157
- VALUE DSTUNIT = DST; \
158
- if(rb_obj_is_kind_of(DSTUNIT, sSpriteUnit)==Qfalse){ \
159
- DSTUNIT = rb_funcall(DSTUNIT, rb_intern("to_unit"), 0); \
160
- if(DSTUNIT == Qnil){ rb_raise(eMiyakoError, "Destination instance has not SpriteUnit!"); }\
161
- } \
162
- if(rb_block_given_p() == Qtrue){ rb_yield_values(2, SRCUNIT, DSTUNIT); } \
163
- SDL_Surface *SRCSURFACE = GetSurface(*(RSTRUCT_PTR(SRCUNIT)))->surface; \
164
- SDL_Surface *DSTSURFACE = GetSurface(*(RSTRUCT_PTR(DSTUNIT)))->surface;
165
-
166
- #define MIYAKO_GET_UNIT_NO_SURFACE_1(SRC, SRCUNIT) \
167
- VALUE SRCUNIT = SRC; \
168
- if(rb_obj_is_kind_of(SRCUNIT, sSpriteUnit)==Qfalse){ \
169
- SRCUNIT = rb_funcall(SRCUNIT, rb_intern("to_unit"), 0); \
170
- if(SRCUNIT == Qnil){ rb_raise(eMiyakoError, "Source instance has not SpriteUnit!"); } \
171
- } \
172
- if(rb_block_given_p() == Qtrue){ rb_yield(SRCUNIT); }
173
-
174
- #define MIYAKO_GET_UNIT_NO_SURFACE_2(SRC, DST, SRCUNIT, DSTUNIT) \
175
- VALUE SRCUNIT = SRC; \
176
- if(rb_obj_is_kind_of(SRCUNIT, sSpriteUnit)==Qfalse){ \
177
- SRCUNIT = rb_funcall(SRCUNIT, rb_intern("to_unit"), 0); \
178
- if(SRCUNIT == Qnil){ rb_raise(eMiyakoError, "Source instance has not SpriteUnit!"); } \
179
- } \
180
- VALUE DSTUNIT = DST; \
181
- if(rb_obj_is_kind_of(DSTUNIT, sSpriteUnit)==Qfalse){ \
182
- DSTUNIT = rb_funcall(DSTUNIT, rb_intern("to_unit"), 0); \
183
- if(DSTUNIT == Qnil){ rb_raise(eMiyakoError, "Destination instance has not SpriteUnit!"); }\
184
- } \
185
- if(rb_block_given_p() == Qtrue){ rb_yield_values(2, SRCUNIT, DSTUNIT); }
186
-
187
- #define MIYAKO_INIT_RECT1 \
188
- int dlx = drect.x + x; \
189
- int dly = drect.y + y; \
190
- int dmx = dlx + srect.w; \
191
- int dmy = dly + srect.h; \
192
- int rx = dst->clip_rect.x + dst->clip_rect.w; \
193
- int ry = dst->clip_rect.y + dst->clip_rect.h; \
194
- if(dmx > drect.w) dmx = drect.w; \
195
- if(dmy > drect.h) dmy = drect.h; \
196
- if(dlx < dst->clip_rect.x) \
197
- { \
198
- srect.x += (dst->clip_rect.x - dlx); \
199
- dlx = dst->clip_rect.x; \
200
- } \
201
- if(dly < dst->clip_rect.y) \
202
- { \
203
- srect.y += (dst->clip_rect.y - dly); \
204
- dly = dst->clip_rect.y; \
205
- } \
206
- if(dmx > rx){ dmx = rx; } \
207
- if(dmy > ry){ dmy = ry; }
208
-
209
- #define MIYAKO_INIT_RECT2 \
210
- int dlx = drect.x; \
211
- int dly = drect.y; \
212
- int dmx = dlx + drect.w; \
213
- int dmy = dly + drect.h; \
214
- int rx = dst->clip_rect.x + dst->clip_rect.w; \
215
- int ry = dst->clip_rect.y + dst->clip_rect.h; \
216
- if(dlx < dst->clip_rect.x) \
217
- { \
218
- srect.x += (dst->clip_rect.x - dlx); \
219
- dlx = dst->clip_rect.x; \
220
- } \
221
- if(dly < dst->clip_rect.y) \
222
- { \
223
- srect.y += (dst->clip_rect.y - dly); \
224
- dly = dst->clip_rect.y; \
225
- } \
226
- if(dmx > rx){ dmx = rx; } \
227
- if(dmy > ry){ dmy = ry; }
228
-
229
- #define MIYAKO_PSET(XX,YY) \
230
- if(dcolor.a == 0){ \
231
- MIYAKO_SETCOLOR(scolor); \
232
- *(pdst + YY * dst->w + XX) = pixel; \
233
- continue; \
234
- } \
235
- if(scolor.a > 0) \
236
- { \
237
- dcolor.r = ((scolor.r * (scolor.a + 1)) >> 8) + ((dcolor.r * (256 - scolor.a)) >> 8); \
238
- if(dcolor.r > 255){ dcolor.r = 255; } \
239
- dcolor.g = ((scolor.g * (scolor.a + 1)) >> 8) + ((dcolor.g * (256 - scolor.a)) >> 8); \
240
- if(dcolor.g > 255){ dcolor.g = 255; } \
241
- dcolor.b = ((scolor.b * (scolor.a + 1)) >> 8) + ((dcolor.b * (256 - scolor.a)) >> 8); \
242
- if(dcolor.b > 255){ dcolor.b = 255; } \
243
- dcolor.a = scolor.a; \
244
- MIYAKO_SETCOLOR(dcolor); \
245
- *(pdst + YY * dst->w + XX) = pixel; \
246
- }
247
-
248
- /*
249
- ===画像をαチャネル付き画像へ転送する
250
- 範囲は、src側SpriteUnitの(ow,oh)の範囲で転送する。
251
- src==dstの場合、何も行わない
252
- ブロックを渡すと、src,dst側のSpriteUnitを更新して、それを実際の転送に反映させることが出来る。
253
- ブロックの引数は、|src側SpriteUnit,dst側SpriteUnit|となる。
254
- _src_:: 転送元ビットマップ(to_unitメソッドを呼び出すことが出来る/値がnilではないインスタンス)
255
- _dst_:: 転送先ビットマップ(to_unitメソッドを呼び出すことが出来る/値がnilではないインスタンス)
256
- _x_:: 転送先の転送開始位置(x方向・単位:ピクセル)
257
- _y_:: 転送先の転送開始位置(y方向・単位:ピクセル)
258
- 返却値:: なし
259
- */
260
- static VALUE bitmap_miyako_blit_aa(VALUE self, VALUE vsrc, VALUE vdst, VALUE vx, VALUE vy)
261
- {
262
- MIYAKO_GET_UNIT_2(vsrc, vdst, sunit, dunit, src, dst);
263
- Uint32 *psrc = (Uint32 *)(src->pixels);
264
- Uint32 *pdst = (Uint32 *)(dst->pixels);
265
- SDL_PixelFormat *fmt = src->format;
266
- MiyakoColor scolor, dcolor;
267
- Uint32 tmp;
268
- Uint32 pixel;
269
- SDL_Rect srect, drect;
270
- Uint32 src_a = 0;
271
- Uint32 dst_a = 0;
272
-
273
- if(psrc == pdst){ return Qnil; }
274
-
275
- SDL_Surface *scr = GetSurface(rb_iv_get(mScreen, "@@screen"))->surface;
276
- if(src == scr){ src_a = 255; }
277
- if(dst == scr){ dst_a = 255; }
278
-
279
- //SpriteUnit:
280
- //[0] -> :bitmap, [1] -> :ox, [2] -> :oy, [3] -> :ow, [4] -> :oh
281
- //[5] -> :x, [6] -> :y, [7] -> :dx, [8] -> :dy
282
- //[9] -> :angle, [10] -> :xscale, [11] -> :yscale
283
- //[12] -> :px, [13] -> :py, [14] -> :qx, [15] -> :qy
284
- MIYAKO_SET_RECT(srect, sunit);
285
- MIYAKO_SET_RECT(drect, dunit);
286
-
287
- int x = NUM2INT(vx);
288
- int y = NUM2INT(vy);
289
- MIYAKO_INIT_RECT1;
290
-
291
- SDL_LockSurface(src);
292
- SDL_LockSurface(dst);
293
-
294
- int px, py, sy;
295
- for(py = dly, sy = srect.y; py < dmy; py++, sy++)
296
- {
297
- Uint32 *ppsrc = psrc + sy * src->w + srect.x;
298
- Uint32 *ppdst = pdst + py * dst->w + dlx;
299
- for(px = dlx; px < dmx; px++)
300
- {
301
- pixel = *ppsrc;
302
- MIYAKO_GETCOLOR(scolor);
303
- scolor.a |= src_a;
304
- pixel = *ppdst;
305
- MIYAKO_GETCOLOR(dcolor);
306
- dcolor.a |= dst_a;
307
- if(dcolor.a == 0){
308
- MIYAKO_SETCOLOR(scolor);
309
- *ppdst = pixel;
310
- ppsrc++;
311
- ppdst++;
312
- continue;
313
- }
314
- if(scolor.a > 0)
315
- {
316
- dcolor.r = ((scolor.r * (scolor.a + 1)) >> 8) + ((dcolor.r * (256 - scolor.a)) >> 8);
317
- if(dcolor.r > 255){ dcolor.r = 255; }
318
- dcolor.g = ((scolor.g * (scolor.a + 1)) >> 8) + ((dcolor.g * (256 - scolor.a)) >> 8);
319
- if(dcolor.g > 255){ dcolor.g = 255; }
320
- dcolor.b = ((scolor.b * (scolor.a + 1)) >> 8) + ((dcolor.b * (256 - scolor.a)) >> 8);
321
- if(dcolor.b > 255){ dcolor.b = 255; }
322
- dcolor.a = scolor.a;
323
- MIYAKO_SETCOLOR(dcolor);
324
- *ppdst = pixel;
325
- }
326
- ppsrc++;
327
- ppdst++;
328
- }
329
- }
330
-
331
- SDL_UnlockSurface(src);
332
- SDL_UnlockSurface(dst);
333
-
334
- return Qnil;
335
- }
336
-
337
- /*
338
- ===画像をαチャネル付き画像へ転送する
339
- 引数で渡ってきた特定の色に対して、α値をゼロにする画像を生成する
340
- src==dstの場合、何も行わずすぐに呼びだし元に戻る
341
- 範囲は、src側SpriteUnitの(w,h)の範囲で転送する。
342
- ブロックを渡すと、src,dst側のSpriteUnitを更新して、それを実際の転送に反映させることが出来る。
343
- ブロックの引数は、|src側SpriteUnit,dst側SpriteUnit|となる。
344
- _src_:: 転送元ビットマップ(to_unitメソッドを呼び出すことが出来る/値がnilではないインスタンス)
345
- _dst_:: 転送先ビットマップ(to_unitメソッドを呼び出すことが出来る/値がnilではないインスタンス)
346
- _color_key_:: 透明にしたい色(各要素がr,g,bに対応している整数の配列(0~255))
347
- 返却値:: なし
348
- */
349
- static VALUE bitmap_miyako_colorkey_to_alphachannel(VALUE self, VALUE vsrc, VALUE vdst, VALUE vcolor_key)
350
- {
351
- MIYAKO_GET_UNIT_2(vsrc, vdst, sunit, dunit, src, dst);
352
- Uint32 *psrc = (Uint32 *)(src->pixels);
353
- Uint32 *pdst = (Uint32 *)(dst->pixels);
354
- SDL_PixelFormat *fmt = dst->format;
355
- MiyakoColor color_key, color;
356
- Uint32 tmp;
357
- Uint32 pixel;
358
-
359
- if(psrc == pdst){ return Qnil; }
360
-
361
- color_key.r = NUM2INT(*(RARRAY_PTR(vcolor_key) + 0));
362
- color_key.g = NUM2INT(*(RARRAY_PTR(vcolor_key) + 1));
363
- color_key.b = NUM2INT(*(RARRAY_PTR(vcolor_key) + 2));
364
-
365
- //SpriteUnit:
366
- //[0] -> :bitmap, [1] -> :ox, [2] -> :oy, [3] -> :ow, [4] -> :oh
367
- //[5] -> :x, [6] -> :y, [7] -> :dx, [8] -> :dy
368
- //[9] -> :angle, [10] -> :xscale, [11] -> :yscale
369
- //[12] -> :px, [13] -> :py, [14] -> :qx, [15] -> :qy
370
- int w = src->w;
371
- int h = src->h;
372
-
373
- if(w > dst->w) w = dst->w;
374
- if(h > dst->h) h = dst->h;
375
-
376
- SDL_LockSurface(src);
377
- SDL_LockSurface(dst);
378
-
379
- int sx, sy;
380
- for(sy = 0; sy < h; sy++)
381
- {
382
- Uint32 *ppsrc = psrc + sy * w;
383
- Uint32 *ppdst = pdst + sy * dst->w;
384
- for(sx = 0; sx < w; sx++)
385
- {
386
- pixel = *ppsrc++;
387
- MIYAKO_GETCOLOR(color);
388
- if(color.r == color_key.r && color.g == color_key.g && color.b == color_key.b) pixel = 0;
389
- else pixel |= (0xff >> fmt->Aloss) << fmt->Ashift;
390
- *ppdst++ = pixel;
391
- }
392
- }
393
-
394
- SDL_UnlockSurface(src);
395
- SDL_UnlockSurface(dst);
396
-
397
- return Qnil;
398
- }
399
-
400
- /*
401
- ===画像をαチャネル付き画像へ転送する
402
- 24ビット画像(αチャネルがゼロの画像)に対して、すべてのα値を255にする画像を生成する
403
- src==dstの場合、何も行わずすぐに呼びだし元に戻る
404
- 範囲は、src側SpriteUnitの(w,h)の範囲で転送する。
405
- ブロックを渡すと、src,dst側のSpriteUnitを更新して、それを実際の転送に反映させることが出来る。
406
- ブロックの引数は、|src側SpriteUnit,dst側SpriteUnit|となる。
407
- _src_:: 転送元ビットマップ(to_unitメソッドを呼び出すことが出来る/値がnilではないインスタンス)
408
- _dst_:: 転送先ビットマップ(to_unitメソッドを呼び出すことが出来る/値がnilではないインスタンス)
409
- 返却値:: なし
410
- */
411
- static VALUE bitmap_miyako_normal_to_alphachannel(VALUE self, VALUE vsrc, VALUE vdst)
412
- {
413
- MIYAKO_GET_UNIT_2(vsrc, vdst, sunit, dunit, src, dst);
414
- Uint32 *psrc = (Uint32 *)(src->pixels);
415
- Uint32 *pdst = (Uint32 *)(dst->pixels);
416
- SDL_PixelFormat *fmt = dst->format;
417
- Uint32 tmp;
418
- Uint32 pixel;
419
-
420
- if(psrc == pdst){ return Qnil; }
421
-
422
- //SpriteUnit:
423
- //[0] -> :bitmap, [1] -> :ox, [2] -> :oy, [3] -> :ow, [4] -> :oh
424
- //[5] -> :x, [6] -> :y, [7] -> :dx, [8] -> :dy
425
- //[9] -> :angle, [10] -> :xscale, [11] -> :yscale
426
- //[12] -> :px, [13] -> :py, [14] -> :qx, [15] -> :qy
427
- int w = src->w;
428
- int h = src->h;
429
-
430
- if(w > dst->w) w = dst->w;
431
- if(h > dst->h) h = dst->h;
432
-
433
- SDL_LockSurface(src);
434
- SDL_LockSurface(dst);
435
-
436
- int sx, sy;
437
- for(sy = 0; sy < h; sy++)
438
- {
439
- Uint32 *ppsrc = psrc + sy * w;
440
- Uint32 *ppdst = pdst + sy * dst->w;
441
- for(sx = 0; sx < w; sx++)
442
- {
443
- pixel = *ppsrc++;
444
- pixel |= (0xff >> fmt->Aloss) << fmt->Ashift;
445
- *ppdst++ = pixel;
446
- }
447
- }
448
-
449
- SDL_UnlockSurface(src);
450
- SDL_UnlockSurface(dst);
451
-
452
- return Qnil;
453
- }
454
-
455
- /*
456
- ===画面(αチャネル無し32bit画像)をαチャネル付き画像へ転送する
457
- α値がゼロの画像から、α値を255にする画像を生成する
458
- src==dstの場合、何も行わずすぐに呼びだし元に戻る
459
- 範囲は、src側SpriteUnitの(w,h)の範囲で転送する。
460
- ブロックを渡すと、src,dst側のSpriteUnitを更新して、それを実際の転送に反映させることが出来る。
461
- ブロックの引数は、|src側SpriteUnit,dst側SpriteUnit|となる。
462
- _src_:: 転送元ビットマップ(to_unitメソッドを呼び出すことが出来る/値がnilではないインスタンス)
463
- _dst_:: 転送先ビットマップ(to_unitメソッドを呼び出すことが出来る/値がnilではないインスタンス)
464
- _color_key_:: 透明にしたい色(各要素がr,g,bに対応している整数の配列(0~255))
465
- 返却値:: なし
466
- */
467
- static VALUE bitmap_miyako_screen_to_alphachannel(VALUE self, VALUE vsrc, VALUE vdst)
468
- {
469
- MIYAKO_GET_UNIT_2(vsrc, vdst, sunit, dunit, src, dst);
470
- Uint32 *psrc = (Uint32 *)(src->pixels);
471
- Uint32 *pdst = (Uint32 *)(dst->pixels);
472
- SDL_PixelFormat *fmt = dst->format;
473
- MiyakoColor color_key, color;
474
- Uint32 tmp;
475
- Uint32 pixel;
476
-
477
- if(psrc == pdst){ return Qnil; }
478
-
479
- //SpriteUnit:
480
- //[0] -> :bitmap, [1] -> :ox, [2] -> :oy, [3] -> :ow, [4] -> :oh
481
- //[5] -> :x, [6] -> :y, [7] -> :dx, [8] -> :dy
482
- //[9] -> :angle, [10] -> :xscale, [11] -> :yscale
483
- //[12] -> :px, [13] -> :py, [14] -> :qx, [15] -> :qy
484
- int w = src->w;
485
- int h = src->h;
486
-
487
- if(w > dst->w) w = dst->w;
488
- if(h > dst->h) h = dst->h;
489
-
490
- SDL_LockSurface(src);
491
- SDL_LockSurface(dst);
492
-
493
- int sx, sy;
494
- for(sy = 0; sy < h; sy++)
495
- {
496
- Uint32 *ppsrc = psrc + sy * w;
497
- Uint32 *ppdst = pdst + sy * dst->w;
498
- for(sx = 0; sx < w; sx++)
499
- {
500
- pixel = *ppsrc++;
501
- pixel |= (0xff >> fmt->Aloss) << fmt->Ashift;
502
- *ppdst++ = pixel;
503
- }
504
- }
505
-
506
- SDL_UnlockSurface(src);
507
- SDL_UnlockSurface(dst);
508
-
509
- return Qnil;
510
- }
511
-
512
- /*
513
- ===画像のαチャネルの値を一定の割合で変化させて転送する
514
- degreeの値が1.0に近づけば近づくほど透明に近づき、
515
- degreeの値が-1.0に近づけば近づくほど不透明に近づく(値が-1.0のときは完全不透明、値が0.0のときは変化なし、1.0のときは完全に透明になる)
516
- 但し、元々αの値がゼロの時は変化しない
517
- 範囲は、src側SpriteUnitの(ow,oh)の範囲で転送する。転送先の描画開始位置は、src側SpriteUnitの(x,y)を左上とする。
518
- 但しsrc==dstのときはx,yを無視する
519
- src == dst : 元の画像を変換した画像に置き換える
520
- src != dst : 元の画像を対象の画像に転送する(αチャネルの計算付き)
521
- ブロックを渡すと、src,dst側のSpriteUnitを更新して、それを実際の転送に反映させることが出来る。
522
- ブロックの引数は、|src側SpriteUnit,dst側SpriteUnit|となる。
523
- _src_:: 転送元ビットマップ(to_unitメソッドを呼び出すことが出来る/値がnilではないインスタンス)
524
- _dst_:: 転送先ビットマップ(to_unitメソッドを呼び出すことが出来る/値がnilではないインスタンス)
525
- _degree_:: 減少率。-1.0<=degree<=1.0までの実数
526
- */
527
- static VALUE bitmap_miyako_dec_alpha(VALUE self, VALUE vsrc, VALUE vdst, VALUE degree)
528
- {
529
- MIYAKO_GET_UNIT_2(vsrc, vdst, sunit, dunit, src, dst);
530
- Uint32 *psrc = (Uint32 *)(src->pixels);
531
- Uint32 *pdst = (Uint32 *)(dst->pixels);
532
- SDL_PixelFormat *fmt = src->format;
533
- double deg = NUM2DBL(degree);
534
- if(deg < -1.0 || deg > 1.0){
535
- char buf[256];
536
- sprintf(buf, "Illegal degree! : %.15g", deg);
537
- rb_raise(eMiyakoError, buf);
538
- }
539
- deg = 1.0 - deg;
540
- Uint32 da = (Uint32)(255.0 * deg);
541
-
542
- MiyakoColor scolor, dcolor;
543
- Uint32 tmp;
544
- Uint32 pixel;
545
-
546
- if(src != dst){
547
- Uint32 src_a = 0;
548
- Uint32 dst_a = 0;
549
-
550
- SDL_Surface *scr = GetSurface(rb_iv_get(mScreen, "@@screen"))->surface;
551
- if(src == scr){ src_a = 255; }
552
- if(dst == scr){ dst_a = 255; }
553
-
554
- SDL_Rect srect, drect;
555
- MIYAKO_SET_RECT(srect, sunit);
556
- MIYAKO_SET_RECT(drect, dunit);
557
- int x = NUM2INT(*(RSTRUCT_PTR(sunit) + 5));
558
- int y = NUM2INT(*(RSTRUCT_PTR(sunit) + 6));
559
- MIYAKO_INIT_RECT1;
560
-
561
- SDL_LockSurface(src);
562
- SDL_LockSurface(dst);
563
-
564
- int px, py, sx, sy;
565
- for(sy = srect.y, py = dly; py < dmy; sy++, py++)
566
- {
567
- for(sx = srect.x, px = dlx; px < dmx; sx++, px++)
568
- {
569
- pixel = *(psrc + sy * src->w + sx);
570
- MIYAKO_GETCOLOR(scolor);
571
- scolor.a |= src_a;
572
- pixel = *(pdst + py * dst->w + px);
573
- MIYAKO_GETCOLOR(dcolor);
574
- dcolor.a |= dst_a;
575
- scolor.a -= da;
576
- if(scolor.a > 0x80000000){ scolor.a = 0; }
577
- if(scolor.a > 255){ scolor.a = 255; }
578
- MIYAKO_PSET(px, py);
579
- }
580
- }
581
-
582
- SDL_UnlockSurface(src);
583
- SDL_UnlockSurface(dst);
584
- }
585
- else
586
- {
587
- int ox = NUM2INT(*(RSTRUCT_PTR(sunit) + 1));
588
- int oy = NUM2INT(*(RSTRUCT_PTR(sunit) + 2));
589
- int or = ox + NUM2INT(*(RSTRUCT_PTR(sunit) + 3));
590
- int ob = oy + NUM2INT(*(RSTRUCT_PTR(sunit) + 4));
591
-
592
- SDL_LockSurface(src);
593
-
594
- int x, y;
595
- for(y = oy; y < ob; y++)
596
- {
597
- for(x = ox; x < or; x++)
598
- {
599
- pixel = *(psrc + y * src->w + x);
600
- MIYAKO_GETCOLOR(scolor);
601
- Uint32 da = (Uint32)(255.0 * deg);
602
- scolor.a -= da;
603
- if(scolor.a > 0x80000000){ scolor.a = 0; }
604
- if(scolor.a > 255){ scolor.a = 255; }
605
- MIYAKO_SETCOLOR(scolor);
606
- *(pdst + y * dst->w + x) = pixel;
607
- }
608
- }
609
-
610
- SDL_UnlockSurface(src);
611
- }
612
-
613
- return Qnil;
614
- }
615
-
616
- /*
617
- ===画像の色を一定の割合で黒に近づける(ブラックアウト)
618
- 赤・青・緑の各要素を一定の割合で下げ、黒色に近づける。
619
- degreeの値が1.0に近づけば近づくほど黒色に近づく(値が0.0のときは変化なし、1.0のときは真っ黒になる)
620
- 但しαの値は変わらないことに注意!
621
- 範囲は、src側SpriteUnitの(ow,oh)の範囲で転送する。転送先の描画開始位置は、src側SpriteUnitの(x,y)を左上とする。
622
- 但しsrc==dstのときはx,yを無視する
623
- src == dst : 元の画像を変換した画像に置き換える
624
- src != dst : 元の画像を対象の画像に転送する(αチャネルの計算付き)
625
- ブロックを渡すと、src,dst側のSpriteUnitを更新して、それを実際の転送に反映させることが出来る。
626
- ブロックの引数は、|src側SpriteUnit,dst側SpriteUnit|となる。
627
- _src_:: 転送元ビットマップ(to_unitメソッドを呼び出すことが出来る/値がnilではないインスタンス)
628
- _dst_:: 転送先ビットマップ(to_unitメソッドを呼び出すことが出来る/値がnilではないインスタンス)
629
- _degree_:: 変化率。0.0<=degree<=1.0までの実数
630
- */
631
- static VALUE bitmap_miyako_black_out(VALUE self, VALUE vsrc, VALUE vdst, VALUE degree)
632
- {
633
- MIYAKO_GET_UNIT_2(vsrc, vdst, sunit, dunit, src, dst);
634
- Uint32 *psrc = (Uint32 *)(src->pixels);
635
- Uint32 *pdst = (Uint32 *)(dst->pixels);
636
- SDL_PixelFormat *fmt = src->format;
637
- double deg = NUM2DBL(degree);
638
- if(deg < 0.0 || deg > 1.0){
639
- char buf[256];
640
- sprintf(buf, "Illegal degree! : %.15g", deg);
641
- rb_raise(eMiyakoError, buf);
642
- }
643
- deg = 1.0 - deg;
644
-
645
- MiyakoColor scolor, dcolor;
646
- Uint32 tmp;
647
- Uint32 pixel;
648
-
649
- Uint32 d = (Uint32)(255.0 * deg);
650
- if(src != dst){
651
- Uint32 src_a = 0;
652
- Uint32 dst_a = 0;
653
-
654
- SDL_Surface *scr = GetSurface(rb_iv_get(mScreen, "@@screen"))->surface;
655
- if(src == scr){ src_a = 255; }
656
- if(dst == scr){ dst_a = 255; }
657
-
658
- SDL_Rect srect, drect;
659
- MIYAKO_SET_RECT(srect, sunit);
660
- MIYAKO_SET_RECT(drect, dunit);
661
- int x = NUM2INT(*(RSTRUCT_PTR(sunit) + 5));
662
- int y = NUM2INT(*(RSTRUCT_PTR(sunit) + 6));
663
- MIYAKO_INIT_RECT1;
664
-
665
- SDL_LockSurface(src);
666
- SDL_LockSurface(dst);
667
-
668
- int px, py, sx, sy;
669
- for(sy = srect.y, py = dly; py < dmy; sy++, py++)
670
- {
671
- for(sx = srect.x, px = dlx; px < dmx; sx++, px++)
672
- {
673
- pixel = *(psrc + sy * src->w + sx);
674
- MIYAKO_GETCOLOR(scolor);
675
- scolor.a |= src_a;
676
- pixel = *(pdst + py * dst->w + px);
677
- MIYAKO_GETCOLOR(dcolor);
678
- dcolor.a |= dst_a;
679
- scolor.r -= d;
680
- if(scolor.r > 0x80000000){ scolor.r = 0; }
681
- scolor.g -= d;
682
- if(scolor.g > 0x80000000){ scolor.g = 0; }
683
- scolor.b -= d;
684
- if(scolor.b > 0x80000000){ scolor.b = 0; }
685
- MIYAKO_PSET(px, py);
686
- }
687
- }
688
-
689
- SDL_UnlockSurface(src);
690
- SDL_UnlockSurface(dst);
691
- }
692
- else
693
- {
694
- int ox = NUM2INT(*(RSTRUCT_PTR(sunit) + 1));
695
- int oy = NUM2INT(*(RSTRUCT_PTR(sunit) + 2));
696
- int or = ox + NUM2INT(*(RSTRUCT_PTR(sunit) + 3));
697
- int ob = oy + NUM2INT(*(RSTRUCT_PTR(sunit) + 4));
698
-
699
- SDL_LockSurface(src);
700
-
701
- int x, y;
702
- for(y = oy; y < ob; y++)
703
- {
704
- for(x = ox; x < or; x++)
705
- {
706
- pixel = *(psrc + y * src->w + x);
707
- MIYAKO_GETCOLOR(scolor);
708
- scolor.r -= d;
709
- if(scolor.r > 0x80000000){ scolor.r = 0; }
710
- scolor.g -= d;
711
- if(scolor.g > 0x80000000){ scolor.g = 0; }
712
- scolor.b -= d;
713
- if(scolor.b > 0x80000000){ scolor.b = 0; }
714
- MIYAKO_SETCOLOR(scolor);
715
- *(pdst + y * dst->w + x) = pixel;
716
- }
717
- }
718
-
719
- SDL_UnlockSurface(src);
720
- }
721
-
722
- return Qnil;
723
- }
724
-
725
- /*
726
- ===画像の色を一定の割合で白に近づける(ホワイトアウト)
727
- 赤・青・緑の各要素を一定の割合で上げ、白色に近づける。
728
- degreeの値が1.0に近づけば近づくほど白色に近づく(値が0.0のときは変化なし、1.0のときは真っ白になる)
729
- 但しαの値は変わらないことに注意!
730
- 範囲は、src側SpriteUnitの(ow,oh)の範囲で転送する。転送先の描画開始位置は、src側SpriteUnitの(x,y)を左上とする。
731
- 但しsrc==dstのときはx,yを無視する
732
- src == dst : 元の画像を変換した画像に置き換える
733
- src != dst : 元の画像を対象の画像に転送する(αチャネルの計算付き)
734
- ブロックを渡すと、src,dst側のSpriteUnitを更新して、それを実際の転送に反映させることが出来る。
735
- ブロックの引数は、|src側SpriteUnit,dst側SpriteUnit|となる。
736
- _src_:: 転送元ビットマップ(to_unitメソッドを呼び出すことが出来る/値がnilではないインスタンス)
737
- _dst_:: 転送先ビットマップ(to_unitメソッドを呼び出すことが出来る/値がnilではないインスタンス)
738
- _degree_:: 変化率。0.0<=degree<=1.0までの実数
739
- */
740
- static VALUE bitmap_miyako_white_out(VALUE self, VALUE vsrc, VALUE vdst, VALUE degree)
741
- {
742
- MIYAKO_GET_UNIT_2(vsrc, vdst, sunit, dunit, src, dst);
743
- Uint32 *psrc = (Uint32 *)(src->pixels);
744
- Uint32 *pdst = (Uint32 *)(dst->pixels);
745
- SDL_PixelFormat *fmt = src->format;
746
- double deg = NUM2DBL(degree);
747
- if(deg < 0.0 || deg > 1.0){
748
- char buf[256];
749
- sprintf(buf, "Illegal degree! : %.15g", deg);
750
- rb_raise(eMiyakoError, buf);
751
- }
752
-
753
- MiyakoColor scolor, dcolor;
754
- Uint32 tmp;
755
- Uint32 pixel;
756
-
757
- Uint32 d = (Uint32)(255.0 * deg);
758
- if(src != dst){
759
- Uint32 src_a = 0;
760
- Uint32 dst_a = 0;
761
-
762
- SDL_Surface *scr = GetSurface(rb_iv_get(mScreen, "@@screen"))->surface;
763
- if(src == scr){ src_a = 255; }
764
- if(dst == scr){ dst_a = 255; }
765
-
766
- SDL_Rect srect, drect;
767
- MIYAKO_SET_RECT(srect, sunit);
768
- MIYAKO_SET_RECT(drect, dunit);
769
- int x = NUM2INT(*(RSTRUCT_PTR(sunit) + 5));
770
- int y = NUM2INT(*(RSTRUCT_PTR(sunit) + 6));
771
- MIYAKO_INIT_RECT1;
772
-
773
- SDL_LockSurface(src);
774
- SDL_LockSurface(dst);
775
-
776
- int px, py, sx, sy;
777
- for(sy = srect.y, py = dly; py < dmy; sy++, py++)
778
- {
779
- for(sx = srect.x, px = dlx; px < dmx; sx++, px++)
780
- {
781
- pixel = *(psrc + sy * src->w + sx);
782
- MIYAKO_GETCOLOR(scolor);
783
- scolor.a |= src_a;
784
- pixel = *(pdst + py * dst->w + px);
785
- MIYAKO_GETCOLOR(dcolor);
786
- dcolor.a |= dst_a;
787
- scolor.r += d;
788
- if(scolor.r > 255){ scolor.r = 255; }
789
- scolor.g += d;
790
- if(scolor.g > 255){ scolor.g = 255; }
791
- scolor.b += d;
792
- if(scolor.b > 255){ scolor.b = 255; }
793
- MIYAKO_PSET(px, py);
794
- }
795
- }
796
-
797
- SDL_UnlockSurface(src);
798
- SDL_UnlockSurface(dst);
799
- }
800
- else
801
- {
802
- int ox = NUM2INT(*(RSTRUCT_PTR(sunit) + 1));
803
- int oy = NUM2INT(*(RSTRUCT_PTR(sunit) + 2));
804
- int or = ox + NUM2INT(*(RSTRUCT_PTR(sunit) + 3));
805
- int ob = oy + NUM2INT(*(RSTRUCT_PTR(sunit) + 4));
806
-
807
- SDL_LockSurface(src);
808
-
809
- int x, y;
810
- for(y = oy; y < ob; y++)
811
- {
812
- for(x = ox; x < or; x++)
813
- {
814
- pixel = *(psrc + y * src->w + x);
815
- MIYAKO_GETCOLOR(scolor);
816
- scolor.r += d;
817
- if(scolor.r > 255){ scolor.r = 255; }
818
- scolor.g += d;
819
- if(scolor.g > 255){ scolor.g = 255; }
820
- scolor.b += d;
821
- if(scolor.b > 255){ scolor.b = 255; }
822
- MIYAKO_SETCOLOR(scolor);
823
- *(pdst + y * dst->w + x) = pixel;
824
- }
825
- }
826
-
827
- SDL_UnlockSurface(src);
828
- }
829
-
830
- return Qnil;
831
- }
832
-
833
- /*
834
- ===画像のRGB値を反転させる
835
- αチャネルの値は変更しない
836
- 範囲は、src側SpriteUnitの(ow,oh)の範囲で転送する。転送先の描画開始位置は、src側SpriteUnitの(x,y)を左上とする。
837
- 但しsrc==dstのときはx,yを無視する
838
- src == dst : 元の画像を変換した画像に置き換える
839
- src != dst : 元の画像を対象の画像に転送する(αチャネルの計算付き)
840
- ブロックを渡すと、src,dst側のSpriteUnitを更新して、それを実際の転送に反映させることが出来る。
841
- ブロックの引数は、|src側SpriteUnit,dst側SpriteUnit|となる。
842
- _src_:: 転送元ビットマップ(to_unitメソッドを呼び出すことが出来る/値がnilではないインスタンス)
843
- _dst_:: 転送先ビットマップ(to_unitメソッドを呼び出すことが出来る/値がnilではないインスタンス)
844
- */
845
- static VALUE bitmap_miyako_inverse(VALUE self, VALUE vsrc, VALUE vdst)
846
- {
847
- MIYAKO_GET_UNIT_2(vsrc, vdst, sunit, dunit, src, dst);
848
- Uint32 *psrc = (Uint32 *)(src->pixels);
849
- Uint32 *pdst = (Uint32 *)(dst->pixels);
850
- SDL_PixelFormat *fmt = src->format;
851
- MiyakoColor scolor, dcolor;
852
- Uint32 tmp;
853
- Uint32 pixel;
854
-
855
- if(src != dst){
856
- Uint32 src_a = 0;
857
- Uint32 dst_a = 0;
858
-
859
- SDL_Surface *scr = GetSurface(rb_iv_get(mScreen, "@@screen"))->surface;
860
- if(src == scr){ src_a = 255; }
861
- if(dst == scr){ dst_a = 255; }
862
-
863
- SDL_Rect srect, drect;
864
- MIYAKO_SET_RECT(srect, sunit);
865
- MIYAKO_SET_RECT(drect, dunit);
866
- int x = NUM2INT(*(RSTRUCT_PTR(sunit) + 5));
867
- int y = NUM2INT(*(RSTRUCT_PTR(sunit) + 6));
868
- MIYAKO_INIT_RECT1;
869
-
870
- SDL_LockSurface(src);
871
- SDL_LockSurface(dst);
872
-
873
- int px, py, sx, sy;
874
- for(sy = srect.y, py = dly; py < dmy; sy++, py++)
875
- {
876
- for(sx = srect.x, px = dlx; px < dmx; sx++, px++)
877
- {
878
- pixel = *(psrc + sy * src->w + sx);
879
- MIYAKO_GETCOLOR(scolor);
880
- scolor.a |= src_a;
881
- pixel = *(pdst + py * dst->w + px);
882
- MIYAKO_GETCOLOR(dcolor);
883
- dcolor.a |= dst_a;
884
- scolor.r ^= 0xff;
885
- scolor.g ^= 0xff;
886
- scolor.b ^= 0xff;
887
- MIYAKO_PSET(px, py);
888
- }
889
- }
890
-
891
- SDL_UnlockSurface(src);
892
- SDL_UnlockSurface(dst);
893
- }
894
- else
895
- {
896
- int ox = NUM2INT(*(RSTRUCT_PTR(sunit) + 1));
897
- int oy = NUM2INT(*(RSTRUCT_PTR(sunit) + 2));
898
- int or = ox + NUM2INT(*(RSTRUCT_PTR(sunit) + 3));
899
- int ob = oy + NUM2INT(*(RSTRUCT_PTR(sunit) + 4));
900
-
901
- SDL_LockSurface(src);
902
-
903
- int x, y;
904
- for(y = oy; y < ob; y++)
905
- {
906
- for(x = ox; x < or; x++)
907
- {
908
- pixel = *(psrc + y * src->w + x);
909
- MIYAKO_GETCOLOR(scolor);
910
- scolor.r ^= 0xff;
911
- scolor.g ^= 0xff;
912
- scolor.b ^= 0xff;
913
- MIYAKO_SETCOLOR(scolor);
914
- *(pdst + y * dst->w + x) = pixel;
915
- }
916
- }
917
-
918
- SDL_UnlockSurface(src);
919
- }
920
-
921
- return Qnil;
922
- }
923
-
924
- /*
925
- ===2枚の画像の加算合成を行う
926
- 範囲は、src側SpriteUnitの(ow,oh)の範囲で転送する。転送先の描画開始位置は、src側SpriteUnitの(x,y)を左上とする。
927
- ブロックを渡すと、src,dst側のSpriteUnitを更新して、それを実際の転送に反映させることが出来る。
928
- ブロックの引数は、|src側SpriteUnit,dst側SpriteUnit|となる。
929
- _src_:: 転送元ビットマップ(to_unitメソッドを呼び出すことが出来る/値がnilではないインスタンス)
930
- _dst_:: 転送先ビットマップ(to_unitメソッドを呼び出すことが出来る/値がnilではないインスタンス)
931
- */
932
- static VALUE bitmap_miyako_additive_synthesis(VALUE self, VALUE vsrc, VALUE vdst)
933
- {
934
- MIYAKO_GET_UNIT_2(vsrc, vdst, sunit, dunit, src, dst);
935
- Uint32 *psrc = (Uint32 *)(src->pixels);
936
- Uint32 *pdst = (Uint32 *)(dst->pixels);
937
- SDL_PixelFormat *fmt = src->format;
938
- MiyakoColor scolor, dcolor;
939
- Uint32 tmp;
940
- Uint32 pixel;
941
- SDL_Rect srect, drect;
942
- Uint32 src_a = 0;
943
- Uint32 dst_a = 0;
944
-
945
- if(psrc == pdst){ return Qnil; }
946
-
947
- SDL_Surface *scr = GetSurface(rb_iv_get(mScreen, "@@screen"))->surface;
948
- if(src == scr){ src_a = 255; }
949
- if(dst == scr){ dst_a = 255; }
950
-
951
- MIYAKO_SET_RECT(srect, vsrc);
952
- MIYAKO_SET_RECT(drect, vdst);
953
- int x = NUM2INT(*(RSTRUCT_PTR(vsrc) + 5));
954
- int y = NUM2INT(*(RSTRUCT_PTR(vsrc) + 6));
955
- MIYAKO_INIT_RECT1;
956
-
957
- SDL_LockSurface(src);
958
- SDL_LockSurface(dst);
959
-
960
- int px, py, sx, sy;
961
- for(sy = srect.y, py = dly; py < dmy; sy++, py++)
962
- {
963
- for(sx = srect.x, px = dlx; px < dmx; sx++, px++)
964
- {
965
- pixel = *(psrc + sy * src->w + sx);
966
- MIYAKO_GETCOLOR(scolor);
967
- scolor.a |= src_a;
968
- if(scolor.a > 0){
969
- pixel = *(pdst + py * dst->w + px);
970
- MIYAKO_GETCOLOR(dcolor);
971
- dcolor.a |= dst_a;
972
- dcolor.r += scolor.r;
973
- if(dcolor.r > 255){ dcolor.r = 255; }
974
- dcolor.g += scolor.g;
975
- if(dcolor.g > 255){ dcolor.g = 255; }
976
- dcolor.b += scolor.b;
977
- if(dcolor.b > 255){ dcolor.b = 255; }
978
- dcolor.a = (dcolor.a > scolor.a ? dcolor.a : scolor.a);
979
- MIYAKO_SETCOLOR(dcolor);
980
- *(pdst + py * dst->w + px) = pixel;
981
- }
982
- }
983
- }
984
-
985
- SDL_UnlockSurface(src);
986
- SDL_UnlockSurface(dst);
987
-
988
- return Qnil;
989
- }
990
-
991
- /*
992
- ===2枚の画像の減算合成を行う
993
- 範囲は、src側SpriteUnitの(ow,oh)の範囲で転送する。転送先の描画開始位置は、src側SpriteUnitの(x,y)を左上とする。
994
- ブロックを渡すと、src,dst側のSpriteUnitを更新して、それを実際の転送に反映させることが出来る。
995
- ブロックの引数は、|src側SpriteUnit,dst側SpriteUnit|となる。
996
- _src_:: 転送元ビットマップ(to_unitメソッドを呼び出すことが出来る/値がnilではないインスタンス)
997
- _dst_:: 転送先ビットマップ(to_unitメソッドを呼び出すことが出来る/値がnilではないインスタンス)
998
- */
999
- static VALUE bitmap_miyako_subtraction_synthesis(VALUE self, VALUE src, VALUE dst)
1000
- {
1001
- bitmap_miyako_inverse(self, dst, dst);
1002
- bitmap_miyako_additive_synthesis(self, src, dst);
1003
- bitmap_miyako_inverse(self, dst, dst);
1004
- return Qnil;
1005
- }
1006
-
1007
- /*
1008
- ===画像を回転させて貼り付ける
1009
- 転送元の描画範囲は、src側SpriteUnitの(ox,oy)を起点に、(ow,oh)の範囲で転送する。回転の中心は(ox,oy)を起点に、(cx,cy)が中心になるように設定する。
1010
- 転送先の描画範囲は、src側SpriteUnitの(x,y)を起点に、dst側SpriteUnitの(cx,cy)が中心になるように設定にする。
1011
- 回転角度は、src側SpriteUnitのangleを使用する
1012
- 回転角度が正だと右回り、負だと左回りに回転する
1013
- src==dstの場合、何も行わない
1014
- ブロックを渡すと、src,dst側のSpriteUnitを更新して、それを実際の転送に反映させることが出来る。
1015
- ブロックの引数は、|src側SpriteUnit,dst側SpriteUnit|となる。
1016
- _src_:: 転送元ビットマップ(to_unitメソッドを呼び出すことが出来る/値がnilではないインスタンス)
1017
- _dst_:: 転送先ビットマップ(to_unitメソッドを呼び出すことが出来る/値がnilではないインスタンス)
1018
- */
1019
- static VALUE bitmap_miyako_rotate(VALUE self, VALUE vsrc, VALUE vdst)
1020
- {
1021
- MIYAKO_GET_UNIT_2(vsrc, vdst, sunit, dunit, src, dst);
1022
- Uint32 *psrc = (Uint32 *)(src->pixels);
1023
- Uint32 *pdst = (Uint32 *)(dst->pixels);
1024
- Uint32 src_a = 0;
1025
- Uint32 dst_a = 0;
1026
-
1027
- SDL_Surface *scr = GetSurface(rb_iv_get(mScreen, "@@screen"))->surface;
1028
- if(src == scr){ src_a = 255; }
1029
- if(dst == scr){ dst_a = 255; }
1030
-
1031
- SDL_PixelFormat *fmt = src->format;
1032
- MiyakoColor scolor, dcolor;
1033
- Uint32 tmp;
1034
- Uint32 pixel;
1035
- SDL_Rect srect, drect;
1036
- SDL_Rect screct, dcrect;
1037
-
1038
- if(psrc == pdst){ return Qnil; }
1039
-
1040
- MIYAKO_SET_RECT(srect, sunit);
1041
- MIYAKO_SET_RECT(drect, dunit);
1042
-
1043
- if(drect.w >= 32768 || drect.h >= 32768){ return Qnil; }
1044
-
1045
- MIYAKO_INIT_RECT2;
1046
-
1047
- double rad = NUM2DBL(*(RSTRUCT_PTR(sunit)+7)) * -1.0;
1048
- long isin = (long)(sin(rad)*4096.0);
1049
- long icos = (long)(cos(rad)*4096.0);
1050
-
1051
- int px = srect.x + NUM2INT(*(RSTRUCT_PTR(sunit)+10));
1052
- int py = srect.y + NUM2INT(*(RSTRUCT_PTR(sunit)+11));
1053
- int qx = NUM2INT(*(RSTRUCT_PTR(sunit)+5)) + NUM2INT(*(RSTRUCT_PTR(dunit)+10));
1054
- int qy = NUM2INT(*(RSTRUCT_PTR(sunit)+6)) + NUM2INT(*(RSTRUCT_PTR(dunit)+11));
1055
-
1056
- SDL_LockSurface(src);
1057
- SDL_LockSurface(dst);
1058
-
1059
- int x, y;
1060
- for(y = dly; y < dmy; y++)
1061
- {
1062
- for(x = dlx; x < dmx; x++)
1063
- {
1064
- int nx = (((x-qx)*icos-(y-qy)*isin) >> 12) + px;
1065
- int ny = (((x-qx)*isin+(y-qy)*icos) >> 12) + py;
1066
- if(nx < srect.x || nx >= (srect.x+srect.w) || ny < srect.y || ny >= (srect.y+srect.h)){ continue; }
1067
- pixel = *(psrc + ny * src->w + nx);
1068
- MIYAKO_GETCOLOR(scolor);
1069
- scolor.a |= src_a;
1070
- pixel = *(pdst + y * dst->w + x);
1071
- MIYAKO_GETCOLOR(dcolor);
1072
- dcolor.a |= dst_a;
1073
- MIYAKO_PSET(x, y);
1074
- }
1075
- }
1076
-
1077
- SDL_UnlockSurface(src);
1078
- SDL_UnlockSurface(dst);
1079
-
1080
- return Qnil;
1081
- }
1082
-
1083
- /*
1084
- ===画像を拡大・縮小・鏡像(ミラー反転)させて貼り付ける
1085
- 転送元の描画範囲は、src側SpriteUnitの(ox,oy)を起点に、(ow,oh)の範囲で転送する。回転の中心は(ox,oy)を起点に、(cx,cy)が中心になるように設定する。
1086
- 転送先の描画範囲は、src側SpriteUnitの(x,y)を起点に、dst側SpriteUnitの(cx,cy)が中心になるように設定にする。
1087
- 変形の度合いは、src側SpriteUnitのxscale, yscaleを使用する(ともに実数で指定する)。それぞれ、x方向、y方向の度合いとなる
1088
- 度合いが scale > 1.0 だと拡大、 0 < scale < 1.0 だと縮小、scale < 0.0 負だと鏡像の拡大・縮小になる(scale == -1.0 のときはミラー反転になる)
1089
- 但し、拡大率が4096分の1以下だと、拡大/縮小しない可能性がある
1090
- src==dstの場合、何も行わない
1091
- ブロックを渡すと、src,dst側のSpriteUnitを更新して、それを実際の転送に反映させることが出来る。
1092
- ブロックの引数は、|src側SpriteUnit,dst側SpriteUnit|となる。
1093
- _src_:: 転送元ビットマップ(to_unitメソッドを呼び出すことが出来る/値がnilではないインスタンス)
1094
- _dst_:: 転送先ビットマップ(to_unitメソッドを呼び出すことが出来る/値がnilではないインスタンス)
1095
- */
1096
- static VALUE bitmap_miyako_scale(VALUE self, VALUE vsrc, VALUE vdst)
1097
- {
1098
- MIYAKO_GET_UNIT_2(vsrc, vdst, sunit, dunit, src, dst);
1099
- Uint32 *psrc = (Uint32 *)(src->pixels);
1100
- Uint32 *pdst = (Uint32 *)(dst->pixels);
1101
- Uint32 src_a = 0;
1102
- Uint32 dst_a = 0;
1103
-
1104
- SDL_Surface *scr = GetSurface(rb_iv_get(mScreen, "@@screen"))->surface;
1105
- if(src == scr){ src_a = 255; }
1106
- if(dst == scr){ dst_a = 255; }
1107
-
1108
- SDL_PixelFormat *fmt = src->format;
1109
- MiyakoColor scolor, dcolor;
1110
- Uint32 tmp;
1111
- Uint32 pixel;
1112
- SDL_Rect srect, drect;
1113
- SDL_Rect screct, dcrect;
1114
-
1115
- if(psrc == pdst){ return Qnil; }
1116
-
1117
- MIYAKO_SET_RECT(srect, sunit);
1118
- MIYAKO_SET_RECT(drect, dunit);
1119
-
1120
- if(drect.w >= 32768 || drect.h >= 32768){ return Qnil; }
1121
-
1122
- MIYAKO_INIT_RECT2;
1123
-
1124
- double tscx = NUM2DBL(*(RSTRUCT_PTR(sunit)+8));
1125
- double tscy = NUM2DBL(*(RSTRUCT_PTR(sunit)+9));
1126
-
1127
- if(tscx == 0.0 || tscy == 0.0){ return; }
1128
-
1129
- int scx = (int)(4096.0 / tscx);
1130
- int scy = (int)(4096.0 / tscy);
1131
-
1132
- int off_x = scx < 0 ? 1 : 0;
1133
- int off_y = scy < 0 ? 1 : 0;
1134
-
1135
- int px = srect.x + NUM2INT(*(RSTRUCT_PTR(sunit)+10));
1136
- int py = srect.y + NUM2INT(*(RSTRUCT_PTR(sunit)+11));
1137
- int qx = NUM2INT(*(RSTRUCT_PTR(sunit)+5)) + NUM2INT(*(RSTRUCT_PTR(sunit)+10));
1138
- int qy = NUM2INT(*(RSTRUCT_PTR(sunit)+6)) + NUM2INT(*(RSTRUCT_PTR(sunit)+11));
1139
-
1140
- SDL_LockSurface(src);
1141
- SDL_LockSurface(dst);
1142
-
1143
- int x, y;
1144
- for(y = dly; y < dmy; y++)
1145
- {
1146
- for(x = dlx; x < dmx; x++)
1147
- {
1148
- int nx = (((x-qx) * scx) >> 12) + px - off_x;
1149
- int ny = (((y-qy) * scy) >> 12) + py - off_y;
1150
- if(nx < srect.x || nx >= (srect.x+srect.w) || ny < srect.y || ny >= (srect.y+srect.h)){ continue; }
1151
- pixel = *(psrc + ny * src->w + nx);
1152
- MIYAKO_GETCOLOR(scolor);
1153
- scolor.a |= src_a;
1154
- pixel = *(pdst + y * dst->w + x);
1155
- MIYAKO_GETCOLOR(dcolor);
1156
- dcolor.a |= dst_a;
1157
- MIYAKO_PSET(x, y);
1158
- }
1159
- }
1160
-
1161
- SDL_UnlockSurface(src);
1162
- SDL_UnlockSurface(dst);
1163
-
1164
- return Qnil;
1165
- }
1166
-
1167
- /*
1168
- ===回転・拡大・縮小・鏡像用インナーメソッド
1169
- */
1170
- static void transform_inner(VALUE sunit, VALUE dunit)
1171
- {
1172
- SDL_Surface *src = GetSurface(*(RSTRUCT_PTR(sunit)))->surface;
1173
- SDL_Surface *dst = GetSurface(*(RSTRUCT_PTR(dunit)))->surface;
1174
- Uint32 *psrc = (Uint32 *)(src->pixels);
1175
- Uint32 *pdst = (Uint32 *)(dst->pixels);
1176
- Uint32 src_a = 0;
1177
- Uint32 dst_a = 0;
1178
-
1179
- SDL_Surface *scr = GetSurface(rb_iv_get(mScreen, "@@screen"))->surface;
1180
- if(src == scr){ src_a = 255; }
1181
- if(dst == scr){ dst_a = 255; }
1182
-
1183
- SDL_PixelFormat *fmt = src->format;
1184
- MiyakoColor scolor, dcolor;
1185
- Uint32 tmp;
1186
- Uint32 pixel;
1187
- SDL_Rect srect, drect;
1188
- SDL_Rect screct, dcrect;
1189
-
1190
- if(psrc == pdst){ return; }
1191
-
1192
- MIYAKO_SET_RECT(srect, sunit);
1193
- MIYAKO_SET_RECT(drect, dunit);
1194
-
1195
- if(drect.w >= 32768 || drect.h >= 32768){ return; }
1196
-
1197
- MIYAKO_INIT_RECT2;
1198
-
1199
- double rad = NUM2DBL(*(RSTRUCT_PTR(sunit)+7)) * -1.0;
1200
- long isin = (long)(sin(rad)*4096.0);
1201
- long icos = (long)(cos(rad)*4096.0);
1202
-
1203
- double tscx = NUM2DBL(*(RSTRUCT_PTR(sunit)+8));
1204
- double tscy = NUM2DBL(*(RSTRUCT_PTR(sunit)+9));
1205
-
1206
- if(tscx == 0.0 || tscy == 0.0){ return; }
1207
-
1208
- int scx = (int)(4096.0 / tscx);
1209
- int scy = (int)(4096.0 / tscy);
1210
-
1211
- int off_x = scx < 0 ? 1 : 0;
1212
- int off_y = scy < 0 ? 1 : 0;
1213
-
1214
- int px = srect.x + NUM2INT(*(RSTRUCT_PTR(sunit)+10));
1215
- int py = srect.y + NUM2INT(*(RSTRUCT_PTR(sunit)+11));
1216
- int qx = NUM2INT(*(RSTRUCT_PTR(sunit)+5)) + NUM2INT(*(RSTRUCT_PTR(sunit)+10));
1217
- int qy = NUM2INT(*(RSTRUCT_PTR(sunit)+6)) + NUM2INT(*(RSTRUCT_PTR(sunit)+11));
1218
-
1219
- SDL_LockSurface(src);
1220
- SDL_LockSurface(dst);
1221
-
1222
- int x, y;
1223
- for(y = dly; y < dmy; y++)
1224
- {
1225
- for(x = dlx; x < dmx; x++)
1226
- {
1227
- int nx = (((((x-qx)*icos-(y-qy)*isin) >> 12) * scx) >> 12) + px - off_x;
1228
- int ny = (((((x-qx)*isin+(y-qy)*icos) >> 12) * scy) >> 12) + py - off_y;
1229
- if(nx < srect.x || nx >= (srect.x+srect.w) || ny < srect.y || ny >= (srect.y+srect.h)){ continue; }
1230
- pixel = *(psrc + ny * src->w + nx);
1231
- MIYAKO_GETCOLOR(scolor);
1232
- scolor.a |= src_a;
1233
- pixel = *(pdst + y * dst->w + x);
1234
- MIYAKO_GETCOLOR(dcolor);
1235
- dcolor.a |= dst_a;
1236
- MIYAKO_PSET(x, y);
1237
- }
1238
- }
1239
-
1240
- SDL_UnlockSurface(src);
1241
- SDL_UnlockSurface(dst);
1242
- }
1243
-
1244
- /*
1245
- ===画像を変形(回転・拡大・縮小・鏡像)させて貼り付ける
1246
- 転送元の描画範囲は、src側SpriteUnitの(ox,oy)を起点に、src側(ow,oh)の範囲で転送する。回転の中心はsrc側(ox,oy)を起点に、src側(cx,cy)が中心になるように設定する。
1247
- 転送先の描画範囲は、src側SpriteUnitの(x,y)を起点に、dst側SpriteUnitの(cx,cy)が中心になるように設定にする。
1248
- 回転角度は、src側SpriteUnitのangleを使用する
1249
- 回転角度が正だと右回り、負だと左回りに回転する
1250
- 変形の度合いは、src側SpriteUnitのxscale, yscaleを使用する(ともに実数で指定する)。それぞれ、x方向、y方向の度合いとなる
1251
- 度合いが scale > 1.0 だと拡大、 0 < scale < 1.0 だと縮小、scale < 0.0 負だと鏡像の拡大・縮小になる(scale == -1.0 のときはミラー反転になる)
1252
- 但し、拡大率が4096分の1以下だと、拡大/縮小しない可能性がある
1253
- src==dstの場合、何も行わない
1254
- ブロックを渡すと、src,dst側のSpriteUnitを更新して、それを実際の転送に反映させることが出来る。
1255
- ブロックの引数は、|src側SpriteUnit,dst側SpriteUnit|となる。
1256
- _src_:: 転送元ビットマップ(to_unitメソッドを呼び出すことが出来る/値がnilではないインスタンス)
1257
- _dst_:: 転送先ビットマップ(to_unitメソッドを呼び出すことが出来る/値がnilではないインスタンス)
1258
- */
1259
- static VALUE bitmap_miyako_transform(VALUE self, VALUE vsrc, VALUE vdst)
1260
- {
1261
- MIYAKO_GET_UNIT_NO_SURFACE_2(vsrc, vdst, sunit, dunit);
1262
- transform_inner(sunit, dunit);
1263
- return Qnil;
1264
- }
1265
-
1266
- #define MIYAKO_RGB2HSV(RGBSTRUCT, HSVH, HSVS, HSVV) \
1267
- r = (double)(RGBSTRUCT.r) / 255.0; \
1268
- g = (double)(RGBSTRUCT.g) / 255.0; \
1269
- b = (double)(RGBSTRUCT.b) / 255.0; \
1270
- max = r; \
1271
- min = max; \
1272
- max = max < g ? g : max; \
1273
- max = max < b ? b : max; \
1274
- min = min > g ? g : min; \
1275
- min = min > b ? b : min; \
1276
- HSVV = max; \
1277
- if(HSVV == 0.0){ HSVH = 0.0; HSVS = 0.0; return; } \
1278
- HSVS = (max - min) / max; \
1279
- if(HSVS == 0.0){ HSVH = 0.0; return; } \
1280
- cr = (max - r)/(max - min); \
1281
- cg = (max - g)/(max - min); \
1282
- cb = (max - b)/(max - min); \
1283
- if(max == r){ HSVH = cb - cg; } \
1284
- if(max == g){ HSVH = 2.0 + cr - cb; } \
1285
- if(max == b){ HSVH = 4.0 + cg - cr; } \
1286
- HSVH *= 60.0; \
1287
- if(HSVH < 0){ HSVH += 360.0; }
1288
-
1289
- #define MIYAKO_HSV2RGB(HSVH, HSVS, HSVV, RGBSTRUCT) \
1290
- if(HSVS == 0.0){ RGBSTRUCT.r = RGBSTRUCT.g = RGBSTRUCT.b = (Uint32)(HSVV * 255.0); return; } \
1291
- i = HSVH / 60.0; \
1292
- if( i < 1.0){ i = 0.0; } \
1293
- else if(i < 2.0){ i = 1.0; } \
1294
- else if(i < 3.0){ i = 2.0; } \
1295
- else if(i < 4.0){ i = 3.0; } \
1296
- else if(i < 5.0){ i = 4.0; } \
1297
- else if(i < 6.0){ i = 5.0; } \
1298
- f = HSVH / 60.0 - i; \
1299
- m = HSVV * (1 - HSVS); \
1300
- n = HSVV * (1 - HSVS * f); \
1301
- k = HSVV * (1 - HSVS * (1 - f)); \
1302
- if( i == 0.0){ r = HSVV; g = k, b = m; } \
1303
- else if(i == 1.0){ r = n; g = HSVV, b = m; } \
1304
- else if(i == 2.0){ r = m; g = HSVV, b = k; } \
1305
- else if(i == 3.0){ r = m; g = n, b = HSVV; } \
1306
- else if(i == 4.0){ r = k; g = m, b = HSVV; } \
1307
- else if(i == 5.0){ r = HSVV; g = m, b = n; } \
1308
- RGBSTRUCT.r = (Uint32)(r * 255.0); \
1309
- RGBSTRUCT.g = (Uint32)(g * 255.0); \
1310
- RGBSTRUCT.b = (Uint32)(b * 255.0); \
1311
-
1312
- /*
1313
- ===画像の色相を変更する
1314
- 範囲は、srcの(ow,oh)の範囲で転送する。転送先の描画開始位置は、srcの(x,y)を左上とする。但しsrc==dstのときはx,yを無視する
1315
- src == dst : 元の画像を変換した画像に置き換える
1316
- src != dst : 元の画像を対象の画像に転送する(αチャネルの計算付き)
1317
- ブロックを渡すと、src,dst側のSpriteUnitを更新して、それを実際の転送に反映させることが出来る。
1318
- ブロックの引数は、|src側SpriteUnit,dst側SpriteUnit|となる。
1319
- _src_:: 転送元ビットマップ(to_unitメソッドを呼び出すことが出来る/値がnilではないインスタンス)
1320
- _dst_:: 転送先ビットマップ(to_unitメソッドを呼び出すことが出来る/値がnilではないインスタンス)
1321
- _degree_:: 色相の変更量。単位は度(実数)。範囲は、-360.0<degree<360.0
1322
- 返却値:: 変更後の画像インスタンス
1323
- */
1324
- static VALUE bitmap_miyako_hue(VALUE self, VALUE vsrc, VALUE vdst, VALUE degree)
1325
- {
1326
- MIYAKO_GET_UNIT_2(vsrc, vdst, sunit, dunit, src, dst);
1327
- Uint32 *psrc = (Uint32 *)(src->pixels);
1328
- Uint32 *pdst = (Uint32 *)(dst->pixels);
1329
- SDL_PixelFormat *fmt = src->format;
1330
- double deg = NUM2DBL(degree);
1331
- MiyakoColor scolor, dcolor;
1332
- Uint32 tmp;
1333
- Uint32 pixel;
1334
- double ph, ps, pv;
1335
- double d_pi = 360.0;
1336
- double r, g, b, max, min, cr, cg, cb;
1337
- double i, f, m, n, k;
1338
-
1339
- if(deg <= -360.0 || deg >= 360.0){ return Qnil; }
1340
-
1341
- if(src != dst){
1342
- SDL_Rect srect, drect;
1343
- MIYAKO_SET_RECT(srect, sunit);
1344
- MIYAKO_SET_RECT(drect, dunit);
1345
- int x = NUM2INT(*(RSTRUCT_PTR(sunit) + 5));
1346
- int y = NUM2INT(*(RSTRUCT_PTR(sunit) + 6));
1347
- MIYAKO_INIT_RECT1;
1348
-
1349
- Uint32 src_a = 0;
1350
- Uint32 dst_a = 0;
1351
-
1352
- SDL_Surface *scr = GetSurface(rb_iv_get(mScreen, "@@screen"))->surface;
1353
- if(src == scr){ src_a = 255; }
1354
- if(dst == scr){ dst_a = 255; }
1355
-
1356
- SDL_LockSurface(src);
1357
- SDL_LockSurface(dst);
1358
-
1359
- int px, py, sx, sy;
1360
- for(sy = srect.y, py = dly; py < dmy; sy++, py++)
1361
- {
1362
- for(sx = srect.x, px = dlx; px < dmx; sx++, px++)
1363
- {
1364
- pixel = *(psrc + sy * src->w + sx);
1365
- MIYAKO_GETCOLOR(scolor);
1366
- pixel = *(pdst + py * dst->w + px);
1367
- MIYAKO_GETCOLOR(dcolor);
1368
- MIYAKO_RGB2HSV(scolor, ph, ps, pv);
1369
- ph += deg;
1370
- if(ph < 0.0){ ph += d_pi; }
1371
- if(ph >= d_pi){ ph -= d_pi; }
1372
- MIYAKO_HSV2RGB(ph, ps, pv, scolor);
1373
- if(dcolor.a == 0){
1374
- MIYAKO_SETCOLOR(scolor);
1375
- *(pdst + py * dst->w + px) = pixel;
1376
- continue;
1377
- }
1378
- if(scolor.a > 0)
1379
- {
1380
- dcolor.r = ((scolor.r * (scolor.a + 1)) >> 8) + ((dcolor.r * (256 - scolor.a)) >> 8);
1381
- if(dcolor.r > 255){ dcolor.r = 255; }
1382
- dcolor.g = ((scolor.g * (scolor.a + 1)) >> 8) + ((dcolor.g * (256 - scolor.a)) >> 8);
1383
- if(dcolor.g > 255){ dcolor.g = 255; }
1384
- dcolor.b = ((scolor.b * (scolor.a + 1)) >> 8) + ((dcolor.b * (256 - scolor.a)) >> 8);
1385
- if(dcolor.b > 255){ dcolor.b = 255; }
1386
- dcolor.a = scolor.a;
1387
- MIYAKO_SETCOLOR(dcolor);
1388
- *(pdst + py * dst->w + px) = pixel;
1389
- }
1390
- }
1391
- }
1392
-
1393
- SDL_UnlockSurface(src);
1394
- SDL_UnlockSurface(dst);
1395
- }
1396
- else
1397
- {
1398
- int ox = NUM2INT(*(RSTRUCT_PTR(sunit) + 1));
1399
- int oy = NUM2INT(*(RSTRUCT_PTR(sunit) + 2));
1400
- int or = ox + NUM2INT(*(RSTRUCT_PTR(sunit) + 3));
1401
- int ob = oy + NUM2INT(*(RSTRUCT_PTR(sunit) + 4));
1402
-
1403
- SDL_LockSurface(src);
1404
-
1405
- int x, y;
1406
- for(y = oy; y < ob; y++)
1407
- {
1408
- for(x = ox; x < or; x++)
1409
- {
1410
- pixel = *(psrc + y * src->w + x);
1411
- MIYAKO_GETCOLOR(scolor);
1412
- MIYAKO_RGB2HSV(scolor, ph, ps, pv);
1413
- ph += deg;
1414
- if(ph < 0.0){ ph += d_pi; }
1415
- if(ph >= d_pi){ ph -= d_pi; }
1416
- MIYAKO_HSV2RGB(ph, ps, pv, dcolor);
1417
- MIYAKO_SETCOLOR(dcolor);
1418
- *(pdst + y * dst->w + x) = pixel;
1419
- }
1420
- }
1421
-
1422
- SDL_UnlockSurface(src);
1423
- }
1424
-
1425
- return Qnil;
1426
- }
1427
-
1428
- /*
1429
- ===画像の彩度を変更する
1430
- 範囲は、srcの(ow,oh)の範囲で転送する。転送先の描画開始位置は、srcの(x,y)を左上とする。但しsrc==dstのときはx,yを無視する
1431
- src == dst : 元の画像を変換した画像に置き換える
1432
- src != dst : 元の画像を対象の画像に転送する(αチャネルの計算付き)
1433
- ブロックを渡すと、src,dst側のSpriteUnitを更新して、それを実際の転送に反映させることが出来る。
1434
- ブロックの引数は、|src側SpriteUnit,dst側SpriteUnit|となる。
1435
- _src_:: 転送元ビットマップ(to_unitメソッドを呼び出すことが出来る/値がnilではないインスタンス)
1436
- _dst_:: 転送先ビットマップ(to_unitメソッドを呼び出すことが出来る/値がnilではないインスタンス)
1437
- _saturation_:: 彩度の変更量。範囲は0.0〜1.0の実数
1438
- */
1439
- static VALUE bitmap_miyako_saturation(VALUE self, VALUE vsrc, VALUE vdst, VALUE saturation)
1440
- {
1441
- MIYAKO_GET_UNIT_2(vsrc, vdst, sunit, dunit, src, dst);
1442
- Uint32 *psrc = (Uint32 *)(src->pixels);
1443
- Uint32 *pdst = (Uint32 *)(dst->pixels);
1444
- SDL_PixelFormat *fmt = src->format;
1445
- double sat = NUM2DBL(saturation);
1446
- MiyakoColor scolor, dcolor;
1447
- Uint32 tmp;
1448
- Uint32 pixel;
1449
- double ph, ps, pv;
1450
- double r, g, b, max, min, cr, cg, cb;
1451
- double i, f, m, n, k;
1452
-
1453
- if(src != dst){
1454
- SDL_Rect srect, drect;
1455
- MIYAKO_SET_RECT(srect, sunit);
1456
- MIYAKO_SET_RECT(drect, dunit);
1457
- int x = NUM2INT(*(RSTRUCT_PTR(sunit) + 5));
1458
- int y = NUM2INT(*(RSTRUCT_PTR(sunit) + 6));
1459
- MIYAKO_INIT_RECT1;
1460
-
1461
- Uint32 src_a = 0;
1462
- Uint32 dst_a = 0;
1463
-
1464
- SDL_Surface *scr = GetSurface(rb_iv_get(mScreen, "@@screen"))->surface;
1465
- if(src == scr){ src_a = 255; }
1466
- if(dst == scr){ dst_a = 255; }
1467
-
1468
- SDL_LockSurface(src);
1469
- SDL_LockSurface(dst);
1470
-
1471
- int px, py, sx, sy;
1472
- for(sy = srect.y, py = dly; py < dmy; sy++, py++)
1473
- {
1474
- for(sx = srect.x, px = dlx; px < dmx; sx++, px++)
1475
- {
1476
- pixel = *(psrc + sy * src->w + sx);
1477
- MIYAKO_GETCOLOR(scolor);
1478
- pixel = *(pdst + py * dst->w + px);
1479
- MIYAKO_GETCOLOR(dcolor);
1480
- MIYAKO_RGB2HSV(scolor, ph, ps, pv);
1481
- ps += sat;
1482
- if(ps < 0.0){ ps = 0.0; }
1483
- if(ps > 1.0){ ps = 1.0; }
1484
- MIYAKO_HSV2RGB(ph, ps, pv, scolor);
1485
- if(dcolor.a == 0){
1486
- MIYAKO_SETCOLOR(scolor);
1487
- *(pdst + py * dst->w + px) = pixel;
1488
- continue;
1489
- }
1490
- if(scolor.a > 0)
1491
- {
1492
- dcolor.r = ((scolor.r * (scolor.a + 1)) >> 8) + ((dcolor.r * (256 - scolor.a)) >> 8);
1493
- if(dcolor.r > 255){ dcolor.r = 255; }
1494
- dcolor.g = ((scolor.g * (scolor.a + 1)) >> 8) + ((dcolor.g * (256 - scolor.a)) >> 8);
1495
- if(dcolor.g > 255){ dcolor.g = 255; }
1496
- dcolor.b = ((scolor.b * (scolor.a + 1)) >> 8) + ((dcolor.b * (256 - scolor.a)) >> 8);
1497
- if(dcolor.b > 255){ dcolor.b = 255; }
1498
- dcolor.a = scolor.a;
1499
- MIYAKO_SETCOLOR(dcolor);
1500
- *(pdst + py * dst->w + px) = pixel;
1501
- }
1502
- }
1503
- }
1504
-
1505
- SDL_UnlockSurface(src);
1506
- SDL_UnlockSurface(dst);
1507
- }
1508
- else
1509
- {
1510
- int ox = NUM2INT(*(RSTRUCT_PTR(sunit) + 1));
1511
- int oy = NUM2INT(*(RSTRUCT_PTR(sunit) + 2));
1512
- int or = ox + NUM2INT(*(RSTRUCT_PTR(sunit) + 3));
1513
- int ob = oy + NUM2INT(*(RSTRUCT_PTR(sunit) + 4));
1514
-
1515
- SDL_LockSurface(src);
1516
-
1517
- int x, y;
1518
- for(y = oy; y < ob; y++)
1519
- {
1520
- for(x = ox; x < or; x++)
1521
- {
1522
- pixel = *(psrc + y * src->w + x);
1523
- MIYAKO_GETCOLOR(scolor);
1524
- MIYAKO_RGB2HSV(scolor, ph, ps, pv);
1525
- ps += sat;
1526
- if(ps < 0.0){ ps = 0.0; }
1527
- if(ps > 1.0){ ps = 1.0; }
1528
- MIYAKO_HSV2RGB(ph, ps, pv, dcolor);
1529
- MIYAKO_SETCOLOR(dcolor)
1530
- *(pdst + y * dst->w + x) = pixel;
1531
- }
1532
- }
1533
-
1534
- SDL_UnlockSurface(src);
1535
- }
1536
-
1537
- return Qnil;
1538
- }
1539
-
1540
- /*
1541
- ===画像の明度を変更する
1542
- 範囲は、srcの(ow,oh)の範囲で転送する。転送先の描画開始位置は、srcの(x,y)を左上とする。但しsrc==dstのときはx,yを無視する
1543
- src == dst : 元の画像を変換した画像に置き換える
1544
- src != dst : 元の画像を対象の画像に転送する(αチャネルの計算付き)
1545
- ブロックを渡すと、src,dst側のSpriteUnitを更新して、それを実際の転送に反映させることが出来る。
1546
- ブロックの引数は、|src側SpriteUnit,dst側SpriteUnit|となる。
1547
- _src_:: 転送元ビットマップ(to_unitメソッドを呼び出すことが出来る/値がnilではないインスタンス)
1548
- _dst_:: 転送先ビットマップ(to_unitメソッドを呼び出すことが出来る/値がnilではないインスタンス)
1549
- _value_:: 明度の変更量。範囲は0.0〜1.0の実数
1550
- 返却値:: 変更後の画像インスタンス
1551
- */
1552
- static VALUE bitmap_miyako_value(VALUE self, VALUE vsrc, VALUE vdst, VALUE value)
1553
- {
1554
- MIYAKO_GET_UNIT_2(vsrc, vdst, sunit, dunit, src, dst);
1555
- Uint32 *psrc = (Uint32 *)(src->pixels);
1556
- Uint32 *pdst = (Uint32 *)(dst->pixels);
1557
- SDL_PixelFormat *fmt = src->format;
1558
- double val = NUM2DBL(value);
1559
- MiyakoColor scolor, dcolor;
1560
- Uint32 tmp;
1561
- Uint32 pixel;
1562
- double ph, ps, pv;
1563
- double r, g, b, max, min, cr, cg, cb;
1564
- double i, f, m, n, k;
1565
-
1566
- if(src != dst){
1567
- SDL_Rect srect, drect;
1568
- MIYAKO_SET_RECT(srect, sunit);
1569
- MIYAKO_SET_RECT(drect, dunit);
1570
- int x = NUM2INT(*(RSTRUCT_PTR(sunit) + 5));
1571
- int y = NUM2INT(*(RSTRUCT_PTR(sunit) + 6));
1572
- MIYAKO_INIT_RECT1;
1573
-
1574
- Uint32 src_a = 0;
1575
- Uint32 dst_a = 0;
1576
-
1577
- SDL_Surface *scr = GetSurface(rb_iv_get(mScreen, "@@screen"))->surface;
1578
- if(src == scr){ src_a = 255; }
1579
- if(dst == scr){ dst_a = 255; }
1580
-
1581
- SDL_LockSurface(src);
1582
- SDL_LockSurface(dst);
1583
-
1584
- int px, py, sx, sy;
1585
- for(sy = srect.y, py = dly; py < dmy; sy++, py++)
1586
- {
1587
- for(sx = srect.x, px = dlx; px < dmx; sx++, px++)
1588
- {
1589
- pixel = *(psrc + sy * src->w + sx);
1590
- MIYAKO_GETCOLOR(scolor);
1591
- pixel = *(pdst + py * dst->w + px);
1592
- MIYAKO_GETCOLOR(dcolor);
1593
- MIYAKO_RGB2HSV(scolor, ph, ps, pv);
1594
- pv += val;
1595
- if(pv < 0.0){ pv = 0.0; }
1596
- if(pv > 1.0){ pv = 1.0; }
1597
- MIYAKO_HSV2RGB(ph, ps, pv, scolor);
1598
- if(dcolor.a == 0){
1599
- MIYAKO_SETCOLOR(scolor);
1600
- *(pdst + py * dst->w + px) = pixel;
1601
- continue;
1602
- }
1603
- if(scolor.a > 0)
1604
- {
1605
- dcolor.r = ((scolor.r * (scolor.a + 1)) >> 8) + ((dcolor.r * (256 - scolor.a)) >> 8);
1606
- if(dcolor.r > 255){ dcolor.r = 255; }
1607
- dcolor.g = ((scolor.g * (scolor.a + 1)) >> 8) + ((dcolor.g * (256 - scolor.a)) >> 8);
1608
- if(dcolor.g > 255){ dcolor.g = 255; }
1609
- dcolor.b = ((scolor.b * (scolor.a + 1)) >> 8) + ((dcolor.b * (256 - scolor.a)) >> 8);
1610
- if(dcolor.b > 255){ dcolor.b = 255; }
1611
- dcolor.a = scolor.a;
1612
- MIYAKO_SETCOLOR(dcolor);
1613
- *(pdst + py * dst->w + px) = pixel;
1614
- }
1615
- }
1616
- }
1617
-
1618
- SDL_UnlockSurface(src);
1619
- SDL_UnlockSurface(dst);
1620
- }
1621
- else
1622
- {
1623
- int ox = NUM2INT(*(RSTRUCT_PTR(sunit) + 1));
1624
- int oy = NUM2INT(*(RSTRUCT_PTR(sunit) + 2));
1625
- int or = ox + NUM2INT(*(RSTRUCT_PTR(sunit) + 3));
1626
- int ob = oy + NUM2INT(*(RSTRUCT_PTR(sunit) + 4));
1627
-
1628
- SDL_LockSurface(src);
1629
-
1630
- int x, y;
1631
- for(y = oy; y < ob; y++)
1632
- {
1633
- for(x = ox; x < or; x++)
1634
- {
1635
- pixel = *(psrc + y * src->w + x);
1636
- MIYAKO_GETCOLOR(scolor);
1637
- MIYAKO_RGB2HSV(scolor, ph, ps, pv);
1638
- pv += val;
1639
- if(pv < 0.0){ pv = 0.0; }
1640
- if(pv > 1.0){ pv = 1.0; }
1641
- MIYAKO_HSV2RGB(ph, ps, pv, dcolor);
1642
- MIYAKO_SETCOLOR(dcolor);
1643
- *(pdst + y * dst->w + x) = pixel;
1644
- }
1645
- }
1646
-
1647
- SDL_UnlockSurface(src);
1648
- }
1649
-
1650
- return Qnil;
1651
- }
1652
-
1653
- /*
1654
- ===画像の色相・彩度・明度を変更する
1655
- 範囲は、srcの(ow,oh)の範囲で転送する。転送先の描画開始位置は、srcの(x,y)を左上とする。但しsrc==dstのときはx,yを無視する
1656
- src == dst : 元の画像を変換した画像に置き換える
1657
- src != dst : 元の画像を対象の画像に転送する(αチャネルの計算付き)
1658
- ブロックを渡すと、src,dst側のSpriteUnitを更新して、それを実際の転送に反映させることが出来る。
1659
- ブロックの引数は、|src側SpriteUnit,dst側SpriteUnit|となる。
1660
- _src_:: 転送元ビットマップ(to_unitメソッドを呼び出すことが出来る/値がnilではないインスタンス)
1661
- _dst_:: 転送先ビットマップ(to_unitメソッドを呼び出すことが出来る/値がnilではないインスタンス)
1662
- _degree_:: 色相の変更量。単位は度(実数)。範囲は、-360.0<degree<360.0
1663
- _saturation_:: 彩度の変更量。範囲は0.0〜1.0の実数
1664
- _value_:: 明度の変更量。範囲は0.0〜1.0の実数
1665
- 返却値:: 変更後の画像インスタンス
1666
- */
1667
- static VALUE bitmap_miyako_hsv(VALUE self, VALUE vsrc, VALUE vdst, VALUE degree, VALUE saturation, VALUE value)
1668
- {
1669
- MIYAKO_GET_UNIT_2(vsrc, vdst, sunit, dunit, src, dst);
1670
- Uint32 *psrc = (Uint32 *)(src->pixels);
1671
- Uint32 *pdst = (Uint32 *)(dst->pixels);
1672
- SDL_PixelFormat *fmt = src->format;
1673
- double deg = NUM2DBL(degree);
1674
- double sat = NUM2DBL(saturation);
1675
- double val = NUM2DBL(value);
1676
- MiyakoColor scolor, dcolor;
1677
- Uint32 tmp;
1678
- Uint32 pixel;
1679
- double ph, ps, pv;
1680
- double d_pi = 360.0;
1681
- double r, g, b, max, min, cr, cg, cb;
1682
- double i, f, m, n, k;
1683
-
1684
- if(deg <= -360.0 || deg >= 360.0){ return Qnil; }
1685
-
1686
- if(src != dst){
1687
- SDL_Rect srect, drect;
1688
- MIYAKO_SET_RECT(srect, sunit);
1689
- MIYAKO_SET_RECT(drect, dunit);
1690
- int x = NUM2INT(*(RSTRUCT_PTR(sunit) + 5));
1691
- int y = NUM2INT(*(RSTRUCT_PTR(sunit) + 6));
1692
- MIYAKO_INIT_RECT1;
1693
-
1694
- Uint32 src_a = 0;
1695
- Uint32 dst_a = 0;
1696
-
1697
- SDL_Surface *scr = GetSurface(rb_iv_get(mScreen, "@@screen"))->surface;
1698
- if(src == scr){ src_a = 255; }
1699
- if(dst == scr){ dst_a = 255; }
1700
-
1701
- SDL_LockSurface(src);
1702
- SDL_LockSurface(dst);
1703
-
1704
- int px, py, sx, sy;
1705
- for(sy = srect.y, py = dly; py < dmy; sy++, py++)
1706
- {
1707
- for(sx = srect.x, px = dlx; px < dmx; sx++, px++)
1708
- {
1709
- pixel = *(psrc + sy * src->w + sx);
1710
- MIYAKO_GETCOLOR(scolor);
1711
- pixel = *(pdst + py * dst->w + px);
1712
- MIYAKO_GETCOLOR(dcolor);
1713
- MIYAKO_RGB2HSV(scolor, ph, ps, pv);
1714
- ph += deg;
1715
- if(ph < 0.0){ ph += d_pi; }
1716
- if(ph >= d_pi){ ph -= d_pi; }
1717
- ps += sat;
1718
- if(ps < 0.0){ ps = 0.0; }
1719
- if(ps > 1.0){ ps = 1.0; }
1720
- pv += val;
1721
- if(pv < 0.0){ pv = 0.0; }
1722
- if(pv > 1.0){ pv = 1.0; }
1723
- MIYAKO_HSV2RGB(ph, ps, pv, scolor);
1724
- if(dcolor.a == 0){
1725
- MIYAKO_SETCOLOR(scolor);
1726
- *(pdst + py * dst->w + px) = pixel;
1727
- continue;
1728
- }
1729
- if(scolor.a > 0)
1730
- {
1731
- dcolor.r = ((scolor.r * (scolor.a + 1)) >> 8) + ((dcolor.r * (256 - scolor.a)) >> 8);
1732
- if(dcolor.r > 255){ dcolor.r = 255; }
1733
- dcolor.g = ((scolor.g * (scolor.a + 1)) >> 8) + ((dcolor.g * (256 - scolor.a)) >> 8);
1734
- if(dcolor.g > 255){ dcolor.g = 255; }
1735
- dcolor.b = ((scolor.b * (scolor.a + 1)) >> 8) + ((dcolor.b * (256 - scolor.a)) >> 8);
1736
- if(dcolor.b > 255){ dcolor.b = 255; }
1737
- dcolor.a = scolor.a;
1738
- MIYAKO_SETCOLOR(dcolor);
1739
- *(pdst + py * dst->w + px) = pixel;
1740
- }
1741
- }
1742
- }
1743
-
1744
- SDL_UnlockSurface(src);
1745
- SDL_UnlockSurface(dst);
1746
- }
1747
- else
1748
- {
1749
- int ox = NUM2INT(*(RSTRUCT_PTR(sunit) + 1));
1750
- int oy = NUM2INT(*(RSTRUCT_PTR(sunit) + 2));
1751
- int or = ox + NUM2INT(*(RSTRUCT_PTR(sunit) + 3));
1752
- int ob = oy + NUM2INT(*(RSTRUCT_PTR(sunit) + 4));
1753
-
1754
- SDL_LockSurface(src);
1755
-
1756
- int x, y;
1757
- for(y = oy; y < ob; y++)
1758
- {
1759
- for(x = ox; x < or; x++)
1760
- {
1761
- pixel = *(psrc + y * src->w + x);
1762
- MIYAKO_GETCOLOR(scolor);
1763
- MIYAKO_RGB2HSV(scolor, ph, ps, pv);
1764
- ph += deg;
1765
- if(ph < 0.0){ ph += d_pi; }
1766
- if(ph >= d_pi){ ph -= d_pi; }
1767
- ps += sat;
1768
- if(ps < 0.0){ ps = 0.0; }
1769
- if(ps > 1.0){ ps = 1.0; }
1770
- pv += val;
1771
- if(pv < 0.0){ pv = 0.0; }
1772
- if(pv > 1.0){ pv = 1.0; }
1773
- MIYAKO_HSV2RGB(ph, ps, pv, dcolor);
1774
- MIYAKO_SETCOLOR(dcolor);
1775
- *(pdst + y * dst->w + x) = pixel;
1776
- }
1777
- }
1778
-
1779
- SDL_UnlockSurface(src);
1780
- }
1781
-
1782
- return Qnil;
1783
- }
1784
-
1785
- /*
1786
- :nodoc:
1787
- */
1788
- static VALUE sprite_update(VALUE self)
1789
- {
1790
- VALUE update = rb_iv_get(self, "@update");
1791
-
1792
- if(update != Qnil){ rb_funcall(update, rb_intern("call"), 1, self); }
1793
- if(rb_block_given_p() == Qtrue){ rb_yield(self); }
1794
-
1795
- return self;
1796
- }
1797
-
1798
- /*
1799
- ===内部用レンダメソッド
1800
- */
1801
- static void render_to_inner(VALUE sunit, VALUE dunit)
1802
- {
1803
- SDL_Surface *src = GetSurface(*(RSTRUCT_PTR(sunit)))->surface;
1804
- SDL_Surface *dst = GetSurface(*(RSTRUCT_PTR(dunit)))->surface;
1805
-
1806
- Uint32 *psrc = (Uint32 *)(src->pixels);
1807
- Uint32 *pdst = (Uint32 *)(dst->pixels);
1808
- SDL_PixelFormat *fmt = src->format;
1809
- MiyakoColor scolor, dcolor;
1810
- Uint32 tmp;
1811
- Uint32 pixel;
1812
- SDL_Rect srect, drect;
1813
- Uint32 src_a = 0;
1814
- Uint32 dst_a = 0;
1815
-
1816
- if(psrc == pdst){ return; }
1817
-
1818
- SDL_Surface *scr = GetSurface(rb_iv_get(mScreen, "@@screen"))->surface;
1819
- if(src == scr){ src_a = 255; }
1820
- if(dst == scr){ dst_a = 255; }
1821
-
1822
- //SpriteUnit:
1823
- //[0] -> :bitmap, [1] -> :ox, [2] -> :oy, [3] -> :ow, [4] -> :oh
1824
- //[5] -> :x, [6] -> :y, [7] -> :dx, [8] -> :dy
1825
- //[9] -> :angle, [10] -> :xscale, [11] -> :yscale
1826
- //[12] -> :px, [13] -> :py, [14] -> :qx, [15] -> :qy
1827
- MIYAKO_SET_RECT(srect, sunit);
1828
- MIYAKO_SET_RECT(drect, dunit);
1829
-
1830
- int x = NUM2INT(*(RSTRUCT_PTR(sunit) + 5));
1831
- int y = NUM2INT(*(RSTRUCT_PTR(sunit) + 6));
1832
- MIYAKO_INIT_RECT1;
1833
-
1834
- SDL_LockSurface(src);
1835
- SDL_LockSurface(dst);
1836
-
1837
- int px, py, sy;
1838
- for(py = dly, sy = srect.y; py < dmy; py++, sy++)
1839
- {
1840
- Uint32 *ppsrc = psrc + sy * src->w + srect.x;
1841
- Uint32 *ppdst = pdst + py * dst->w + dlx;
1842
- for(px = dlx; px < dmx; px++)
1843
- {
1844
- pixel = *ppsrc;
1845
- MIYAKO_GETCOLOR(scolor);
1846
- scolor.a |= src_a;
1847
- pixel = *ppdst;
1848
- MIYAKO_GETCOLOR(dcolor);
1849
- dcolor.a |= dst_a;
1850
- if(dcolor.a == 0){
1851
- MIYAKO_SETCOLOR(scolor);
1852
- *ppdst = pixel;
1853
- ppsrc++;
1854
- ppdst++;
1855
- continue;
1856
- }
1857
- if(scolor.a > 0)
1858
- {
1859
- dcolor.r = ((scolor.r * (scolor.a + 1)) >> 8) + ((dcolor.r * (256 - scolor.a)) >> 8);
1860
- if(dcolor.r > 255){ dcolor.r = 255; }
1861
- dcolor.g = ((scolor.g * (scolor.a + 1)) >> 8) + ((dcolor.g * (256 - scolor.a)) >> 8);
1862
- if(dcolor.g > 255){ dcolor.g = 255; }
1863
- dcolor.b = ((scolor.b * (scolor.a + 1)) >> 8) + ((dcolor.b * (256 - scolor.a)) >> 8);
1864
- if(dcolor.b > 255){ dcolor.b = 255; }
1865
- dcolor.a = scolor.a;
1866
- MIYAKO_SETCOLOR(dcolor);
1867
- *ppdst = pixel;
1868
- }
1869
- ppsrc++;
1870
- ppdst++;
1871
- }
1872
- }
1873
-
1874
- SDL_UnlockSurface(src);
1875
- SDL_UnlockSurface(dst);
1876
- }
1877
-
1878
- /*
1879
- ===内部用レンダメソッド
1880
- */
1881
- static void render_inner(VALUE sunit, VALUE dunit)
1882
- {
1883
- SDL_Surface *src = GetSurface(*(RSTRUCT_PTR(sunit)))->surface;
1884
- SDL_Surface *dst = GetSurface(*(RSTRUCT_PTR(dunit)))->surface;
1885
- SDL_Rect srect;
1886
- SDL_Rect drect;
1887
-
1888
- MIYAKO_SET_RECT(srect, sunit);
1889
- drect.x = NUM2INT(*(RSTRUCT_PTR(dunit) + 1))
1890
- + NUM2INT(*(RSTRUCT_PTR(sunit) + 5));
1891
- drect.y = NUM2INT(*(RSTRUCT_PTR(dunit) + 2))
1892
- + NUM2INT(*(RSTRUCT_PTR(sunit) + 6));
1893
-
1894
- SDL_BlitSurface(src, &srect, dst, &drect);
1895
- }
1896
-
1897
- /*
1898
- ===インスタンスの内容を別のインスタンスに描画する
1899
- 転送元の描画範囲は、src側SpriteUnitの(ox,oy)を起点に、src側(ow,oh)の範囲で転送する。
1900
- 画面の描画範囲は、src側SpriteUnitの(x,y)を起点に設定にする。
1901
- ブロック付きで呼び出し可能(レシーバに対応したSpriteUnit構造体が引数として得られるので、補正をかけることが出来る。
1902
- ブロックの引数は、|転送元のSpriteUnit,転送先のSpriteUnit|となる。
1903
- _src_:: 転送元ビットマップ(to_unitメソッドを呼び出すことが出来る/値がnilではないインスタンス)
1904
- _dst_:: 転送先ビットマップ(to_unitメソッドを呼び出すことが出来る/値がnilではないインスタンス)
1905
- 返却値:: 自分自身を返す
1906
- */
1907
- static VALUE sprite_c_render_to_sprite(VALUE self, VALUE vsrc, VALUE vdst)
1908
- {
1909
- MIYAKO_GET_UNIT_NO_SURFACE_2(vsrc, vdst, sunit, dunit);
1910
- render_to_inner(sunit, dunit);
1911
- return self;
1912
- }
1913
-
1914
- /*
1915
- ===インスタンスの内容を画面に描画する
1916
- 現在の画像を、現在の状態で描画するよう指示する
1917
- ブロック付きで呼び出し可能(レシーバに対応したSpriteUnit構造体が引数として得られるので、補正をかけることが出来る。
1918
- ブロックの引数は、|インスタンスのSpriteUnit, 画面のSpriteUnit|となる。
1919
- 返却値:: 自分自身を返す
1920
- */
1921
- static VALUE sprite_render(VALUE self)
1922
- {
1923
- MIYAKO_GET_UNIT_NO_SURFACE_2(self, mScreen, sunit, dunit);
1924
- render_inner(sunit, dunit);
1925
- return self;
1926
- }
1927
-
1928
- /*
1929
- ===インスタンスの内容を別のインスタンスに描画する
1930
- 転送元の描画範囲は、src側SpriteUnitの(ox,oy)を起点に、src側(ow,oh)の範囲で転送する。
1931
- 画面の描画範囲は、src側SpriteUnitの(x,y)を起点に設定にする。
1932
- ブロック付きで呼び出し可能(レシーバに対応したSpriteUnit構造体が引数として得られるので、補正をかけることが出来る。
1933
- ブロックの引数は、|インスタンスのSpriteUnit,転送先のSpriteUnit|となる。
1934
- _dst_:: 転送先ビットマップ(to_unitメソッドを呼び出すことが出来る/値がnilではないインスタンス)
1935
- 返却値:: 自分自身を返す
1936
- */
1937
- static VALUE sprite_render_to_sprite(VALUE self, VALUE vdst)
1938
- {
1939
- MIYAKO_GET_UNIT_NO_SURFACE_2(self, vdst, sunit, dunit);
1940
- render_to_inner(sunit, dunit);
1941
- return self;
1942
- }
1943
-
1944
- /*
1945
- ===インスタンスの内容を画面に描画する(回転/拡大/縮小/鏡像付き)
1946
- 転送元の描画範囲は、src側SpriteUnitの(ox,oy)を起点に、src側(ow,oh)の範囲で転送する。回転の中心はsrc側(ox,oy)を起点に、src側(cx,cy)が中心になるように設定する。
1947
- 画面の描画範囲は、src側SpriteUnitの(x,y)を起点に、画面側SpriteUnitの(cx,cy)が中心になるように設定にする。
1948
- 回転角度は、src側SpriteUnitのangleを使用する
1949
- 回転角度が正だと右回り、負だと左回りに回転する
1950
- 変形の度合いは、src側SpriteUnitのxscale, yscaleを使用する(ともに実数で指定する)。それぞれ、x方向、y方向の度合いとなる
1951
- 度合いが scale > 1.0 だと拡大、 0 < scale < 1.0 だと縮小、scale < 0.0 負だと鏡像の拡大・縮小になる(scale == -1.0 のときはミラー反転になる)
1952
- また、変形元の幅・高さのいずれかが32768以上の時は回転・転送を行わない
1953
- ブロック付きで呼び出し可能(レシーバに対応したSpriteUnit構造体が引数として得られるので、補正をかけることが出来る。
1954
- ブロックの引数は、|インスタンスのSpriteUnit,画面のSpriteUnit|となる。
1955
- 返却値:: 自分自身を返す
1956
- */
1957
- static VALUE sprite_render_transform(VALUE self)
1958
- {
1959
- MIYAKO_GET_UNIT_NO_SURFACE_2(self, mScreen, sunit, dunit);
1960
- transform_inner(sunit, dunit);
1961
- return self;
1962
- }
1963
-
1964
- /*
1965
- ===インスタンスの内容を画面に描画する(回転/拡大/縮小/鏡像付き)
1966
- 転送元の描画範囲は、src側SpriteUnitの(ox,oy)を起点に、src側(ow,oh)の範囲で転送する。回転の中心はsrc側(ox,oy)を起点に、src側(cx,cy)が中心になるように設定する。
1967
- 画面の描画範囲は、src側SpriteUnitの(x,y)を起点に、画面側SpriteUnitの(cx,cy)が中心になるように設定にする。
1968
- 回転角度は、src側SpriteUnitのangleを使用する
1969
- 回転角度が正だと右回り、負だと左回りに回転する
1970
- 変形の度合いは、src側SpriteUnitのxscale, yscaleを使用する(ともに実数で指定する)。それぞれ、x方向、y方向の度合いとなる
1971
- 度合いが scale > 1.0 だと拡大、 0 < scale < 1.0 だと縮小、scale < 0.0 負だと鏡像の拡大・縮小になる(scale == -1.0 のときはミラー反転になる)
1972
- また、変形元の幅・高さのいずれかが32768以上の時は回転・転送を行わない
1973
- ブロック付きで呼び出し可能(レシーバに対応したSpriteUnit構造体が引数として得られるので、補正をかけることが出来る。
1974
- ブロックの引数は、|インスタンスのSpriteUnit,転送先のSpriteUnit|となる。
1975
- _dst_:: 転送先ビットマップ(to_unitメソッドを呼び出すことが出来る/値がnilではないインスタンス)
1976
- 返却値:: 自分自身を返す
1977
- */
1978
- static VALUE sprite_render_to_sprite_transform(VALUE self, VALUE vdst)
1979
- {
1980
- MIYAKO_GET_UNIT_NO_SURFACE_2(self, vdst, sunit, dunit);
1981
- transform_inner(sunit, dunit);
1982
- return self;
1983
- }
1984
-
1985
- /*
1986
- :nodoc:
1987
- */
1988
- static VALUE screen_update_tick(VALUE self)
1989
- {
1990
- int t = NUM2INT(rb_funcall(mSDL, rb_intern("getTicks"), 0));
1991
- int tt = NUM2INT(rb_iv_get(mScreen, "@@t"));
1992
- int interval = t - tt;
1993
- int fps_cnt = NUM2INT(rb_iv_get(mScreen, "@@fpscnt"));
1994
-
1995
- while(interval < fps_cnt){
1996
- t = NUM2INT(rb_funcall(mSDL, rb_intern("getTicks"), 0));
1997
- interval = t - tt;
1998
- }
1999
-
2000
- rb_iv_set(mScreen, "@@t", INT2NUM(t));
2001
- rb_iv_set(mScreen, "@@interval", INT2NUM(interval));
2002
-
2003
- return Qnil;
2004
- }
2005
-
2006
- /*
2007
- ===画面を更新する
2008
- 画面に画像を貼り付けた時は、実際の描画領域は隠れているため、このメソッドを呼び出して、実際の画面表示に反映させる。
2009
- */
2010
- static VALUE screen_render(VALUE self)
2011
- {
2012
- VALUE dst = rb_iv_get(mScreen, "@@unit");
2013
- SDL_Surface *pdst = GetSurface(*(RSTRUCT_PTR(dst)))->surface;
2014
- VALUE fps_view = rb_iv_get(mScreen, "@@fpsView");
2015
-
2016
- if(fps_view == Qtrue){
2017
- char str[256];
2018
- int interval = NUM2INT(rb_iv_get(mScreen, "@@interval"));
2019
- int fps_max = NUM2INT(rb_const_get(mScreen, rb_intern("FpsMax")));
2020
- VALUE sans_serif = rb_funcall(cFont, rb_intern("sans_serif"), 0);
2021
- VALUE fps_sprite = Qnil;
2022
-
2023
- if(interval == 0){ interval = 1; }
2024
-
2025
- sprintf(str, "%d fps", fps_max / interval);
2026
- VALUE fps_str = rb_str_new2((const char *)str);
2027
-
2028
- fps_sprite = rb_funcall(fps_str, rb_intern("to_sprite"), 1, sans_serif);
2029
- rb_funcall(fps_sprite, rb_intern("render"), 0);
2030
- }
2031
-
2032
- screen_update_tick(self);
2033
-
2034
- SDL_Flip(pdst);
2035
-
2036
- return Qnil;
2037
- }
2038
-
2039
- /*
2040
- ===インスタンスの内容を画面に描画する
2041
- 転送元の描画範囲は、src側SpriteUnitの(ox,oy)を起点に、src側(ow,oh)の範囲で転送する。
2042
- 画面の描画範囲は、src側SpriteUnitの(x,y)を起点に設定にする。
2043
- ブロック付きで呼び出し可能(レシーバに対応したSpriteUnit構造体が引数として得られるので、補正をかけることが出来る。
2044
- ブロックの引数は、|インスタンスのSpriteUnit,画面のSpriteUnit|となる。
2045
- _src_:: 転送元ビットマップ(to_unitメソッドを呼び出すことが出来る/値がnilではないインスタンス)
2046
- 返却値:: 自分自身を返す
2047
- */
2048
- static VALUE screen_render_screen(VALUE self, VALUE vsrc)
2049
- {
2050
- MIYAKO_GET_UNIT_NO_SURFACE_2(vsrc, mScreen, sunit, dunit);
2051
- render_inner(sunit, dunit);
2052
- return self;
2053
- }
2054
-
2055
- /*
2056
- :nodoc:
2057
- */
2058
- static VALUE counter_start(VALUE self)
2059
- {
2060
- rb_iv_set(self, "@st", rb_funcall(mSDL, rb_intern("getTicks"), 0));
2061
- rb_iv_set(self, "@counting", Qtrue);
2062
- return self;
2063
- }
2064
-
2065
- /*
2066
- :nodoc:
2067
- */
2068
- static VALUE counter_stop(VALUE self)
2069
- {
2070
- rb_iv_set(self, "@st", INT2NUM(0));
2071
- rb_iv_set(self, "@counting", Qfalse);
2072
- return self;
2073
- }
2074
-
2075
- /*
2076
- :nodoc:
2077
- */
2078
- static VALUE counter_wait_inner(VALUE self, VALUE f)
2079
- {
2080
- VALUE counting = rb_iv_set(self, "@counting", Qtrue);
2081
- if(counting == Qfalse){ return f == Qtrue ? Qfalse : Qtrue; }
2082
-
2083
- int t = NUM2INT(rb_funcall(mSDL, rb_intern("getTicks"), 0));
2084
- int st = NUM2INT(rb_iv_get(self, "@st"));
2085
- int wait = NUM2INT(rb_iv_get(self, "@wait"));
2086
- if((t - st) < wait){ return f; }
2087
-
2088
- rb_iv_set(cWaitCounter, "@counting", Qfalse);
2089
-
2090
- return f == Qtrue ? Qfalse : Qtrue;
2091
- }
2092
-
2093
- /*
2094
- :nodoc:
2095
- */
2096
- static VALUE counter_waiting(VALUE self)
2097
- {
2098
- return counter_wait_inner(self, Qtrue);
2099
- }
2100
-
2101
- /*
2102
- :nodoc:
2103
- */
2104
- static VALUE counter_finish(VALUE self)
2105
- {
2106
- return counter_wait_inner(self, Qfalse);
2107
- }
2108
-
2109
- /*
2110
- :nodoc:
2111
- */
2112
- static VALUE counter_wait(VALUE self)
2113
- {
2114
- int t = NUM2INT(rb_funcall(mSDL, rb_intern("getTicks"), 0));
2115
- int st = NUM2INT(rb_funcall(mSDL, rb_intern("getTicks"), 0));
2116
- int wait = NUM2INT(rb_iv_get(self, "@wait"));
2117
- while((t - st) < wait){
2118
- t = NUM2INT(rb_funcall(mSDL, rb_intern("getTicks"), 0));
2119
- }
2120
- return self;
2121
- }
2122
-
2123
-
2124
- /*
2125
- ===マップレイヤー転送インナーメソッド
2126
- */
2127
- static void maplayer_render_inner(VALUE self, VALUE dunit)
2128
- {
2129
- int cw = NUM2INT(rb_iv_get(self, "@cw"));
2130
- int ch = NUM2INT(rb_iv_get(self, "@ch"));
2131
- int ow = NUM2INT(rb_iv_get(self, "@ow"));
2132
- int oh = NUM2INT(rb_iv_get(self, "@oh"));
2133
-
2134
- VALUE pos = rb_iv_get(self, "@pos");
2135
- VALUE margin = rb_iv_get(self, "@margin");
2136
- int pos_x = NUM2INT(*(RSTRUCT_PTR(pos) + 0)) + NUM2INT(*(RSTRUCT_PTR(margin) + 0));
2137
- int pos_y = NUM2INT(*(RSTRUCT_PTR(pos) + 1)) + NUM2INT(*(RSTRUCT_PTR(margin) + 1));
2138
-
2139
- VALUE size = rb_iv_get(self, "@size");
2140
- int size_w = NUM2INT(*(RSTRUCT_PTR(size) + 0));
2141
- int size_h = NUM2INT(*(RSTRUCT_PTR(size) + 1));
2142
-
2143
- VALUE real_size = rb_iv_get(self, "@real_size");
2144
- int real_size_w = NUM2INT(*(RSTRUCT_PTR(real_size) + 0));
2145
- int real_size_h = NUM2INT(*(RSTRUCT_PTR(real_size) + 1));
2146
-
2147
- VALUE param = rb_iv_get(self, "@mapchip");
2148
- VALUE mc_chip_size = *(RSTRUCT_PTR(param) + 3);
2149
- int mc_chip_size_w = NUM2INT(*(RSTRUCT_PTR(mc_chip_size) + 0));
2150
- int mc_chip_size_h = NUM2INT(*(RSTRUCT_PTR(mc_chip_size) + 1));
2151
-
2152
- VALUE munits = rb_iv_get(self, "@mapchip_units");
2153
- VALUE mapdat = rb_iv_get(self, "@mapdat");
2154
-
2155
- if(pos_x < 0){ pos_x = real_size_w + (pos_x % real_size_w); }
2156
- if(pos_y < 0){ pos_y = real_size_h + (pos_y % real_size_h); }
2157
- if(pos_x >= real_size_w){ pos_x %= real_size_w; }
2158
- if(pos_y >= real_size_h){ pos_y %= real_size_h; }
2159
-
2160
- int dx = pos_x / mc_chip_size_w;
2161
- int mx = pos_x % mc_chip_size_w;
2162
- int dy = pos_y / mc_chip_size_h;
2163
- int my = pos_y % mc_chip_size_h;
2164
-
2165
- int x, y, idx1, idx2;
2166
- for(y = 0; y < ch; y++){
2167
- idx1 = (y + dy) % size_h;
2168
- VALUE mapdat2 = *(RARRAY_PTR(mapdat) + idx1);
2169
- for(x = 0; x < cw; x++){
2170
- idx2 = (x + dx) % size_w;
2171
- int code = NUM2INT(*(RARRAY_PTR(mapdat2) + idx2));
2172
- if(code == -1){ continue; }
2173
- VALUE unit = *(RARRAY_PTR(munits) + code);
2174
- unit = rb_funcall(unit, rb_intern("to_unit"), 0);
2175
- *(RSTRUCT_PTR(unit) + 5) = INT2NUM(x * ow - mx);
2176
- *(RSTRUCT_PTR(unit) + 6) = INT2NUM(y * oh - my);
2177
- render_inner(unit, dunit);
2178
- }
2179
- }
2180
- }
2181
-
2182
- /*
2183
- ===固定マップレイヤー転送インナーメソッド
2184
- */
2185
- static void fixedmaplayer_render_inner(VALUE self, VALUE dunit)
2186
- {
2187
- int cw = NUM2INT(rb_iv_get(self, "@cw"));
2188
- int ch = NUM2INT(rb_iv_get(self, "@ch"));
2189
- int ow = NUM2INT(rb_iv_get(self, "@ow"));
2190
- int oh = NUM2INT(rb_iv_get(self, "@oh"));
2191
-
2192
- VALUE pos = rb_iv_get(self, "@pos");
2193
- int pos_x = NUM2INT(*(RSTRUCT_PTR(pos) + 0));
2194
- int pos_y = NUM2INT(*(RSTRUCT_PTR(pos) + 1));
2195
-
2196
- VALUE size = rb_iv_get(self, "@size");
2197
- int size_w = NUM2INT(*(RSTRUCT_PTR(size) + 0));
2198
- int size_h = NUM2INT(*(RSTRUCT_PTR(size) + 1));
2199
-
2200
- VALUE munits = rb_iv_get(self, "@mapchip_units");
2201
- VALUE mapdat = rb_iv_get(self, "@mapdat");
2202
-
2203
- int x, y, idx1, idx2;
2204
- for(y = 0; y < ch; y++){
2205
- idx1 = y % size_h;
2206
- VALUE mapdat2 = *(RARRAY_PTR(mapdat) + idx1);
2207
- for(x = 0; x < cw; x++){
2208
- idx2 = x % size_w;
2209
- int code = NUM2INT(*(RARRAY_PTR(mapdat2) + idx2));
2210
- if(code == -1){ continue; }
2211
- VALUE unit = *(RARRAY_PTR(munits) + code);
2212
- unit = rb_funcall(unit, rb_intern("to_unit"), 0);
2213
- *(RSTRUCT_PTR(unit) + 5) = INT2NUM(pos_x + x * ow);
2214
- *(RSTRUCT_PTR(unit) + 6) = INT2NUM(pos_y + y * oh);
2215
- render_inner(unit, dunit);
2216
- }
2217
- }
2218
- }
2219
-
2220
- /*
2221
- ===マップレイヤー転送インナーメソッド
2222
- */
2223
- static void maplayer_render_to_inner(VALUE self, VALUE dunit)
2224
- {
2225
- int cw = NUM2INT(rb_iv_get(self, "@cw"));
2226
- int ch = NUM2INT(rb_iv_get(self, "@ch"));
2227
- int ow = NUM2INT(rb_iv_get(self, "@ow"));
2228
- int oh = NUM2INT(rb_iv_get(self, "@oh"));
2229
-
2230
- VALUE pos = rb_iv_get(self, "@pos");
2231
- VALUE margin = rb_iv_get(self, "@margin");
2232
- int pos_x = NUM2INT(*(RSTRUCT_PTR(pos) + 0)) + NUM2INT(*(RSTRUCT_PTR(margin) + 0));
2233
- int pos_y = NUM2INT(*(RSTRUCT_PTR(pos) + 1)) + NUM2INT(*(RSTRUCT_PTR(margin) + 1));
2234
-
2235
- VALUE size = rb_iv_get(self, "@size");
2236
- int size_w = NUM2INT(*(RSTRUCT_PTR(size) + 0));
2237
- int size_h = NUM2INT(*(RSTRUCT_PTR(size) + 1));
2238
-
2239
- VALUE real_size = rb_iv_get(self, "@real_size");
2240
- int real_size_w = NUM2INT(*(RSTRUCT_PTR(real_size) + 0));
2241
- int real_size_h = NUM2INT(*(RSTRUCT_PTR(real_size) + 1));
2242
-
2243
- VALUE param = rb_iv_get(self, "@mapchip");
2244
- VALUE mc_chip_size = *(RSTRUCT_PTR(param) + 3);
2245
- int mc_chip_size_w = NUM2INT(*(RSTRUCT_PTR(mc_chip_size) + 0));
2246
- int mc_chip_size_h = NUM2INT(*(RSTRUCT_PTR(mc_chip_size) + 1));
2247
-
2248
- VALUE munits = rb_iv_get(self, "@mapchip_units");
2249
- VALUE mapdat = rb_iv_get(self, "@mapdat");
2250
-
2251
- if(pos_x < 0){ pos_x = real_size_w + (pos_x % real_size_w); }
2252
- if(pos_y < 0){ pos_y = real_size_h + (pos_y % real_size_h); }
2253
- if(pos_x >= real_size_w){ pos_x %= real_size_w; }
2254
- if(pos_y >= real_size_h){ pos_y %= real_size_h; }
2255
-
2256
- int dx = pos_x / mc_chip_size_w;
2257
- int mx = pos_x % mc_chip_size_w;
2258
- int dy = pos_y / mc_chip_size_h;
2259
- int my = pos_y % mc_chip_size_h;
2260
-
2261
- int x, y, idx1, idx2;
2262
- for(y = 0; y < ch; y++){
2263
- idx1 = (y + dy) % size_h;
2264
- VALUE mapdat2 = *(RARRAY_PTR(mapdat) + idx1);
2265
- for(x = 0; x < cw; x++){
2266
- idx2 = (x + dx) % size_w;
2267
- int code = NUM2INT(*(RARRAY_PTR(mapdat2) + idx2));
2268
- if(code == -1){ continue; }
2269
- VALUE unit = *(RARRAY_PTR(munits) + code);
2270
- unit = rb_funcall(unit, rb_intern("to_unit"), 0);
2271
- *(RSTRUCT_PTR(unit) + 5) = INT2NUM(x * ow - mx);
2272
- *(RSTRUCT_PTR(unit) + 6) = INT2NUM(y * oh - my);
2273
- render_to_inner(unit, dunit);
2274
- }
2275
- }
2276
- }
2277
-
2278
- /*
2279
- ===固定マップレイヤー転送インナーメソッド
2280
- */
2281
- static void fixedmaplayer_render_to_inner(VALUE self, VALUE dunit)
2282
- {
2283
- int cw = NUM2INT(rb_iv_get(self, "@cw"));
2284
- int ch = NUM2INT(rb_iv_get(self, "@ch"));
2285
- int ow = NUM2INT(rb_iv_get(self, "@ow"));
2286
- int oh = NUM2INT(rb_iv_get(self, "@oh"));
2287
-
2288
- VALUE pos = rb_iv_get(self, "@pos");
2289
- int pos_x = NUM2INT(*(RSTRUCT_PTR(pos) + 0));
2290
- int pos_y = NUM2INT(*(RSTRUCT_PTR(pos) + 1));
2291
-
2292
- VALUE size = rb_iv_get(self, "@size");
2293
- int size_w = NUM2INT(*(RSTRUCT_PTR(size) + 0));
2294
- int size_h = NUM2INT(*(RSTRUCT_PTR(size) + 1));
2295
-
2296
- VALUE munits = rb_iv_get(self, "@mapchip_units");
2297
- VALUE mapdat = rb_iv_get(self, "@mapdat");
2298
-
2299
- int x, y, idx1, idx2;
2300
- for(y = 0; y < ch; y++){
2301
- idx1 = y % size_h;
2302
- VALUE mapdat2 = *(RARRAY_PTR(mapdat) + idx1);
2303
- for(x = 0; x < cw; x++){
2304
- idx2 = x % size_w;
2305
- int code = NUM2INT(*(RARRAY_PTR(mapdat2) + idx2));
2306
- if(code == -1){ continue; }
2307
- VALUE unit = *(RARRAY_PTR(munits) + code);
2308
- unit = rb_funcall(unit, rb_intern("to_unit"), 0);
2309
- *(RSTRUCT_PTR(unit) + 5) = INT2NUM(pos_x + x * ow);
2310
- *(RSTRUCT_PTR(unit) + 6) = INT2NUM(pos_y + y * oh);
2311
- render_to_inner(unit, dunit);
2312
- }
2313
- }
2314
- }
2315
-
2316
- /*
2317
- ===マップレイヤーを画面に描画する
2318
- 転送する画像は、マップ上のから(-margin.x, -margin.y)(単位:ピクセル)の位置に対応するチップを左上にして描画する
2319
- ブロック付きで呼び出し可能(レシーバに対応したSpriteUnit構造体が引数として得られるので、補正をかけることが出来る。
2320
- ブロックの引数は、|画面のSpriteUnit|となる。
2321
- 返却値:: 自分自身を返す
2322
- */
2323
- static VALUE maplayer_render(VALUE self)
2324
- {
2325
- MIYAKO_GET_UNIT_NO_SURFACE_1(mScreen, dunit);
2326
- maplayer_render_inner(self, dunit);
2327
- return Qnil;
2328
- }
2329
-
2330
- /*
2331
- ===マップレイヤーを画面に描画する
2332
- すべてのマップチップを画面に描画する
2333
- ブロック付きで呼び出し可能(レシーバに対応したSpriteUnit構造体が引数として得られるので、補正をかけることが出来る。
2334
- ブロックの引数は、|画面のSpriteUnit|となる。
2335
- 返却値:: 自分自身を返す
2336
- */
2337
- static VALUE fixedmaplayer_render(VALUE self)
2338
- {
2339
- MIYAKO_GET_UNIT_NO_SURFACE_1(mScreen, dunit);
2340
- fixedmaplayer_render_inner(self, dunit);
2341
- return Qnil;
2342
- }
2343
-
2344
- /*
2345
- ===マップレイヤーを画像に転送する
2346
- 転送する画像は、マップ上のから(-margin.x, -margin.y)(単位:ピクセル)の位置に対応するチップを左上にして描画する
2347
- ブロック付きで呼び出し可能(レシーバに対応したSpriteUnit構造体が引数として得られるので、補正をかけることが出来る。
2348
- ブロックの引数は、|転送先のSpriteUnit|となる。
2349
- _dst_:: 転送先ビットマップ(to_unitメソッドを呼び出すことが出来る/値がnilではないインスタンス)
2350
- 返却値:: 自分自身を返す
2351
- */
2352
- static VALUE maplayer_render_to_sprite(VALUE self, VALUE vdst)
2353
- {
2354
- MIYAKO_GET_UNIT_NO_SURFACE_1(vdst, dunit);
2355
- maplayer_render_to_inner(self, dunit);
2356
- return Qnil;
2357
- }
2358
-
2359
- /*
2360
- ===マップレイヤーを画像に転送する
2361
- すべてのマップチップを画像に描画する
2362
- ブロック付きで呼び出し可能(レシーバに対応したSpriteUnit構造体が引数として得られるので、補正をかけることが出来る。
2363
- ブロックの引数は、|転送先のSpriteUnit|となる。
2364
- _dst_:: 転送先ビットマップ(to_unitメソッドを呼び出すことが出来る/値がnilではないインスタンス)
2365
- 返却値:: 自分自身を返す
2366
- */
2367
- static VALUE fixedmaplayer_render_to_sprite(VALUE self, VALUE vdst)
2368
- {
2369
- MIYAKO_GET_UNIT_NO_SURFACE_1(vdst, dunit);
2370
- fixedmaplayer_render_to_inner(self, dunit);
2371
- return Qnil;
2372
- }
2373
-
2374
- /*
2375
- ===マップを画面に描画する
2376
- 転送する画像は、マップ上のから(-margin.x, -margin.y)(単位:ピクセル)の位置に対応するチップを左上にして描画する
2377
- 各レイヤ-を、レイヤーインデックス番号の若い順に描画する
2378
- 但し、マップイベントは描画しない
2379
- ブロック付きで呼び出し可能(レシーバに対応したSpriteUnit構造体が引数として得られるので、補正をかけることが出来る。
2380
- ブロックの引数は、|画面のSpriteUnit|となる。
2381
- 返却値:: 自分自身を返す
2382
- */
2383
- static VALUE map_render(VALUE self)
2384
- {
2385
- MIYAKO_GET_UNIT_NO_SURFACE_1(mScreen, dunit);
2386
- VALUE map_layers = rb_iv_get(self, "@map_layers");
2387
- int i;
2388
- for(i=0; i<RARRAY_LEN(map_layers); i++){
2389
- maplayer_render_inner(*(RARRAY_PTR(map_layers) + i), dunit);
2390
- }
2391
-
2392
- return Qnil;
2393
- }
2394
-
2395
- /*
2396
- ===マップを画面に描画する
2397
- すべてのマップチップを画面に描画する
2398
- 各レイヤ-を、レイヤーインデックス番号の若い順に描画する
2399
- 但し、マップイベントは描画しない
2400
- ブロック付きで呼び出し可能(レシーバに対応したSpriteUnit構造体が引数として得られるので、補正をかけることが出来る。
2401
- ブロックの引数は、|画面のSpriteUnit|となる。
2402
- 返却値:: 自分自身を返す
2403
- */
2404
- static VALUE fixedmap_render(VALUE self)
2405
- {
2406
- MIYAKO_GET_UNIT_NO_SURFACE_1(mScreen, dunit);
2407
- VALUE map_layers = rb_iv_get(self, "@map_layers");
2408
- int i;
2409
- for(i=0; i<RARRAY_LEN(map_layers); i++){
2410
- fixedmaplayer_render_inner(*(RARRAY_PTR(map_layers) + i), dunit);
2411
- }
2412
-
2413
- return Qnil;
2414
- }
2415
-
2416
- /*
2417
- ===マップを画像に描画する
2418
- 転送する画像は、マップ上のから(-margin.x, -margin.y)(単位:ピクセル)の位置に対応するチップを左上にして描画する
2419
- 各レイヤ-を、レイヤーインデックス番号の若い順に描画する
2420
- 但し、マップイベントは描画しない
2421
- ブロック付きで呼び出し可能(レシーバに対応したSpriteUnit構造体が引数として得られるので、補正をかけることが出来る。
2422
- ブロックの引数は、|転送先のSpriteUnit|となる。
2423
- _dst_:: 転送先ビットマップ(to_unitメソッドを呼び出すことが出来る/値がnilではないインスタンス)
2424
- 返却値:: 自分自身を返す
2425
- */
2426
- static VALUE map_render_to_sprite(VALUE self, VALUE vdst)
2427
- {
2428
- MIYAKO_GET_UNIT_NO_SURFACE_1(vdst, dunit);
2429
-
2430
- VALUE map_layers = rb_iv_get(self, "@map_layers");
2431
- int i;
2432
- for(i=0; i<RARRAY_LEN(map_layers); i++){
2433
- maplayer_render_inner(*(RARRAY_PTR(map_layers) + i), dunit);
2434
- }
2435
-
2436
- return Qnil;
2437
- }
2438
-
2439
- /*
2440
- ===マップを画像に描画する
2441
- すべてのマップチップを画像に描画する
2442
- 各レイヤ-を、レイヤーインデックス番号の若い順に描画する
2443
- 但し、マップイベントは描画しない
2444
- ブロック付きで呼び出し可能(レシーバに対応したSpriteUnit構造体が引数として得られるので、補正をかけることが出来る。
2445
- ブロックの引数は、|転送先のSpriteUnit|となる。
2446
- _dst_:: 転送先ビットマップ(to_unitメソッドを呼び出すことが出来る/値がnilではないインスタンス)
2447
- 返却値:: 自分自身を返す
2448
- */
2449
- static VALUE fixedmap_render_to_sprite(VALUE self, VALUE vdst)
2450
- {
2451
- MIYAKO_GET_UNIT_NO_SURFACE_1(vdst, dunit);
2452
-
2453
- VALUE map_layers = rb_iv_get(self, "@map_layers");
2454
- int i;
2455
- for(i=0; i<RARRAY_LEN(map_layers); i++){
2456
- fixedmaplayer_render_inner(*(RARRAY_PTR(map_layers) + i), dunit);
2457
- }
2458
-
2459
- return Qnil;
2460
- }
2461
-
2462
- /*
2463
- :nodoc:
2464
- */
2465
- static VALUE sa_set_pat(VALUE self)
2466
- {
2467
- VALUE num = rb_iv_get(self, "@pnum");
2468
- VALUE plist = rb_iv_get(self, "@plist");
2469
- VALUE units = rb_iv_get(self, "@units");
2470
- rb_iv_set(self, "@now", *(RARRAY_PTR(units) + NUM2INT(*(RARRAY_PTR(plist) + NUM2INT(num)))));
2471
- return self;
2472
- }
2473
-
2474
- /*
2475
- :nodoc:
2476
- */
2477
- static VALUE sa_update_frame(VALUE self)
2478
- {
2479
- int cnt = NUM2INT(rb_iv_get(self, "@cnt"));
2480
- if(cnt == 0){
2481
- VALUE num = rb_iv_get(self, "@pnum");
2482
- VALUE loop = rb_iv_get(self, "@loop");
2483
-
2484
- int pnum = NUM2INT(num);
2485
- int pats = NUM2INT(rb_iv_get(self, "@pats"));
2486
- pnum = (pnum + 1) % pats;
2487
-
2488
- rb_iv_set(self, "@pnum", INT2NUM(pnum));
2489
-
2490
- if(loop == Qfalse && pnum == 0){
2491
- rb_funcall(self, rb_intern("stop"), 0);
2492
- return Qnil;
2493
- }
2494
-
2495
- sa_set_pat(self);
2496
- VALUE plist = rb_iv_get(self, "@plist");
2497
- VALUE waits = rb_iv_get(self, "@waits");
2498
- rb_iv_set(self, "@cnt", *(RARRAY_PTR(waits) + NUM2INT(*(RARRAY_PTR(plist) + pnum))));
2499
- }
2500
- else{
2501
- cnt--;
2502
- rb_iv_set(self, "@cnt", INT2NUM(cnt));
2503
- }
2504
- return Qnil;
2505
- }
2506
-
2507
- /*
2508
- :nodoc:
2509
- */
2510
- static VALUE sa_update_wait_counter(VALUE self)
2511
- {
2512
- VALUE cnt = rb_iv_get(self, "@cnt");
2513
- VALUE waiting = rb_funcall(cnt, rb_intern("waiting?"), 0);
2514
- if(waiting == Qfalse){
2515
- VALUE num = rb_iv_get(self, "@pnum");
2516
- VALUE loop = rb_iv_get(self, "@loop");
2517
-
2518
- int pnum = NUM2INT(num);
2519
- int pats = NUM2INT(rb_iv_get(self, "@pats"));
2520
- pnum = (pnum + 1) % pats;
2521
-
2522
- rb_iv_set(self, "@pnum", INT2NUM(pnum));
2523
-
2524
- if(loop == Qfalse && pnum == 0){
2525
- rb_funcall(self, rb_intern("stop"), 0);
2526
- return Qnil;
2527
- }
2528
-
2529
- sa_set_pat(self);
2530
- VALUE plist = rb_iv_get(self, "@plist");
2531
- VALUE waits = rb_iv_get(self, "@waits");
2532
- cnt = *(RARRAY_PTR(waits) + NUM2INT(*(RARRAY_PTR(plist) + pnum)));
2533
- rb_iv_set(self, "@cnt", cnt);
2534
- rb_funcall(cnt, rb_intern("start"), 0);
2535
- }
2536
- return Qnil;
2537
- }
2538
-
2539
- /*
2540
- :nodoc:
2541
- */
2542
- static VALUE sa_update(VALUE self)
2543
- {
2544
- VALUE exec = rb_iv_get(self, "@exec");
2545
- if(exec == Qfalse){ return Qnil; }
2546
-
2547
- VALUE polist = rb_iv_get(self, "@pos_offset");
2548
- VALUE dir = rb_iv_get(self, "@dir");
2549
-
2550
- VALUE now = rb_iv_get(self, "@now");
2551
- VALUE num = rb_iv_get(self, "@pnum");
2552
- VALUE pos_off = *(RARRAY_PTR(polist) + NUM2INT(num));
2553
-
2554
- int didx1 = (rb_to_id(dir) == rb_intern("h") ? 3 : 2);
2555
- int didx2 = didx1 - 1;
2556
-
2557
- *(RSTRUCT_PTR(now) + didx1) = INT2NUM(NUM2INT(*(RSTRUCT_PTR(now) + didx1)) - NUM2INT(pos_off));
2558
-
2559
- if(rb_obj_is_kind_of(rb_iv_get(self, "@cnt"), rb_cInteger) == Qtrue)
2560
- sa_update_frame(self);
2561
- else
2562
- sa_update_wait_counter(self);
2563
-
2564
- now = rb_iv_get(self, "@now");
2565
- num = rb_iv_get(self, "@pnum");
2566
-
2567
- VALUE slist = rb_iv_get(self, "@slist");
2568
- VALUE plist = rb_iv_get(self, "@plist");
2569
- VALUE molist = rb_iv_get(self, "@move_offset");
2570
-
2571
- VALUE s = *(RARRAY_PTR(slist) + NUM2INT(*(RARRAY_PTR(plist) + NUM2INT(num))));
2572
- VALUE move_off = *(RARRAY_PTR(molist) + NUM2INT(num));
2573
-
2574
- *(RSTRUCT_PTR(now) + 5) = INT2NUM(NUM2INT(rb_funcall(s, rb_intern("x"), 0)) + NUM2INT(rb_funcall(move_off, id_kakko, 1, nZero)));
2575
- *(RSTRUCT_PTR(now) + 6) = INT2NUM(NUM2INT(rb_funcall(s, rb_intern("y"), 0)) + NUM2INT(rb_funcall(move_off, id_kakko, 1, nOne)));
2576
-
2577
- pos_off = *(RARRAY_PTR(polist) + NUM2INT(num));
2578
-
2579
- *(RSTRUCT_PTR(now) + didx2) = INT2NUM(NUM2INT(*(RSTRUCT_PTR(now) + didx2)) + NUM2INT(pos_off));
2580
-
2581
- return Qnil;
2582
- }
2583
-
2584
- /*
2585
- ===アニメーションの現在の画像を画面に描画する
2586
- 転送元の描画範囲は、src側SpriteUnitの(ox,oy)を起点に、src側(ow,oh)の範囲で転送する。
2587
- 画面の描画範囲は、src側SpriteUnitの(x,y)を起点に設定にする。
2588
- ブロック付きで呼び出し可能(レシーバに対応したSpriteUnit構造体が引数として得られるので、補正をかけることが出来る。
2589
- ブロックの引数は、|インスタンスのSpriteUnit|となる。
2590
- */
2591
- static VALUE sa_render(VALUE self)
2592
- {
2593
- VALUE vsrc = rb_iv_get(self, "@now");
2594
- MIYAKO_GET_UNIT_NO_SURFACE_2(vsrc, mScreen, sunit, dunit);
2595
- render_inner(sunit, dunit);
2596
- return Qnil;
2597
- }
2598
-
2599
- /*
2600
- ===アニメーションの現在の画像を画像に描画する
2601
- 転送元の描画範囲は、src側SpriteUnitの(ox,oy)を起点に、src側(ow,oh)の範囲で転送する。
2602
- 転送先の描画範囲は、src側SpriteUnitの(x,y)を起点に設定にする。
2603
- ブロック付きで呼び出し可能(レシーバに対応したSpriteUnit構造体が引数として得られるので、補正をかけることが出来る。
2604
- ブロックの引数は、|インスタンスのSpriteUnit,転送先のSpriteUnit|となる。
2605
- _dst_:: 転送先ビットマップ(to_unitメソッドを呼び出すことが出来る/値がnilではないインスタンス)
2606
- */
2607
- static VALUE sa_render_to_sprite(VALUE self, VALUE vdst)
2608
- {
2609
- VALUE vsrc = rb_iv_get(self, "@now");
2610
- MIYAKO_GET_UNIT_NO_SURFACE_2(vsrc, vdst, sunit, dunit);
2611
- render_to_inner(sunit, dunit);
2612
- return Qnil;
2613
- }
2614
-
2615
- /*
2616
- ===プレーンを画面に描画する
2617
- 転送元の描画範囲は、src側SpriteUnitの(ox,oy)を起点にする。
2618
- 画面の描画範囲は、src側SpriteUnitの(x,y)を起点に、タイリングを行いながら貼り付ける。
2619
- */
2620
- static VALUE plane_render(VALUE self)
2621
- {
2622
- VALUE sprite = rb_iv_get(self, "@sprite");
2623
- MIYAKO_GET_UNIT_NO_SURFACE_2(sprite, mScreen, sunit, dunit);
2624
-
2625
- VALUE ssize = rb_iv_get(mScreen, "@@size");
2626
- int ssw = NUM2INT(*(RSTRUCT_PTR(ssize) + 0));
2627
- int ssh = NUM2INT(*(RSTRUCT_PTR(ssize) + 1));
2628
- VALUE pos = rb_iv_get(self, "@pos");
2629
- VALUE size = rb_iv_get(self, "@size");
2630
- int w = NUM2INT(*(RSTRUCT_PTR(size) + 0));
2631
- int h = NUM2INT(*(RSTRUCT_PTR(size) + 1));
2632
- int pos_x = NUM2INT(*(RSTRUCT_PTR(pos) + 0));
2633
- int pos_y = NUM2INT(*(RSTRUCT_PTR(pos) + 1));
2634
-
2635
- int sw = NUM2INT(*(RSTRUCT_PTR(sunit) + 3));
2636
- int sh = NUM2INT(*(RSTRUCT_PTR(sunit) + 4));
2637
-
2638
- int x, y;
2639
- for(y = 0; y < h; y++){
2640
- for(x = 0; x < w; x++){
2641
- int x2 = (x-1) * sw + pos_x;
2642
- int y2 = (y-1) * sh + pos_y;
2643
- if(x2 > 0 || y2 > 0
2644
- || (x2+sw) <= ssw || (y2+sh) <= ssh){
2645
- *(RSTRUCT_PTR(sunit) + 5) = INT2NUM(x2);
2646
- *(RSTRUCT_PTR(sunit) + 6) = INT2NUM(y2);
2647
- render_inner(sunit, dunit);
2648
- }
2649
- }
2650
- }
2651
-
2652
- return Qnil;
2653
- }
2654
-
2655
- /*
2656
- ===プレーンを画像に描画する
2657
- 転送元の描画範囲は、src側SpriteUnitの(ox,oy)を起点にする。
2658
- 転送先の描画範囲は、src側SpriteUnitの(x,y)を起点に、タイリングを行いながら貼り付ける。
2659
- _dst_:: 転送先ビットマップ(to_unitメソッドを呼び出すことが出来る/値がnilではないインスタンス)
2660
- */
2661
- static VALUE plane_render_to_sprite(VALUE self, VALUE vdst)
2662
- {
2663
- VALUE sprite = rb_iv_get(self, "@sprite");
2664
- MIYAKO_GET_UNIT_NO_SURFACE_2(sprite, vdst, sunit, dunit);
2665
-
2666
- VALUE ssize = rb_iv_get(mScreen, "@@size");
2667
- int ssw = NUM2INT(*(RSTRUCT_PTR(ssize) + 0));
2668
- int ssh = NUM2INT(*(RSTRUCT_PTR(ssize) + 1));
2669
- VALUE pos = rb_iv_get(self, "@pos");
2670
- VALUE size = rb_iv_get(self, "@size");
2671
- int w = NUM2INT(*(RSTRUCT_PTR(size) + 0));
2672
- int h = NUM2INT(*(RSTRUCT_PTR(size) + 1));
2673
- int pos_x = NUM2INT(*(RSTRUCT_PTR(pos) + 0));
2674
- int pos_y = NUM2INT(*(RSTRUCT_PTR(pos) + 1));
2675
-
2676
- int sw = NUM2INT(*(RSTRUCT_PTR(sunit) + 3));
2677
- int sh = NUM2INT(*(RSTRUCT_PTR(sunit) + 4));
2678
-
2679
- int x, y;
2680
- for(y = 0; y < h; y++){
2681
- for(x = 0; x < w; x++){
2682
- int x2 = (x-1) * sw + pos_x;
2683
- int y2 = (y-1) * sh + pos_y;
2684
- if(x2 > 0 || y2 > 0
2685
- || (x2+sw) <= ssw || (y2+sh) <= ssh){
2686
- *(RSTRUCT_PTR(sunit) + 5) = INT2NUM(x2);
2687
- *(RSTRUCT_PTR(sunit) + 6) = INT2NUM(y2);
2688
- render_to_inner(sunit, dunit);
2689
- }
2690
- }
2691
- }
2692
-
2693
- return Qnil;
2694
- }
2695
-
2696
- /*
2697
- ===パーツを画面に描画する
2698
- 各パーツの描画範囲は、それぞれのSpriteUnitの(ox,oy)を起点にする。
2699
- 画面の描画範囲は、src側SpriteUnitの(x,y)を起点に、各パーツを貼り付ける。
2700
- ブロック付きで呼び出し可能(レシーバに対応したSpriteUnit構造体が引数として得られるので、補正をかけることが出来る。
2701
- ブロックの引数は、|パーツのSpriteUnit|となる。
2702
- デフォルトでは、描画順は登録順となる。順番を変更したいときは、renderメソッドをオーバーライドする必要がある
2703
- */
2704
- static VALUE parts_render(VALUE self)
2705
- {
2706
- VALUE parts_list = rb_iv_get(self, "@parts_list");
2707
- VALUE parts_hash = rb_iv_get(self, "@parts");
2708
- VALUE dunit = rb_funcall(mScreen, rb_intern("to_unit"), 0);
2709
-
2710
- int i;
2711
- for(i=0; i<RARRAY_LEN(parts_list); i++)
2712
- {
2713
- VALUE parts = rb_hash_aref(parts_hash, *(RARRAY_PTR(parts_list) + i));
2714
- #if 0
2715
- MIYAKO_GET_UNIT_NO_SURFACE_1(parts, sunit);
2716
- render_inner(sunit, dunit);
2717
- #else
2718
- rb_funcall(parts, rb_intern("render"), 0);
2719
- #endif
2720
- }
2721
-
2722
- return Qnil;
2723
- }
2724
-
2725
- /*
2726
- ===パーツを画面に描画する
2727
- 各パーツの描画範囲は、それぞれのSpriteUnitの(ox,oy)を起点にする。
2728
- 転送先の描画範囲は、src側SpriteUnitの(x,y)を起点に、タイリングを行いながら貼り付ける。
2729
- ブロック付きで呼び出し可能(レシーバに対応したSpriteUnit構造体が引数として得られるので、補正をかけることが出来る。
2730
- ブロックの引数は、|パーツのSpriteUnit|となる。
2731
- デフォルトでは、描画順は登録順となる。順番を変更したいときは、render_toメソッドをオーバーライドする必要がある
2732
- _dst_:: 転送先ビットマップ(to_unitメソッドを呼び出すことが出来る/値がnilではないインスタンス)
2733
- */
2734
- static VALUE parts_render_to_sprite(VALUE self, VALUE vdst)
2735
- {
2736
- VALUE parts_list = rb_iv_get(self, "@parts_list");
2737
- VALUE parts_hash = rb_iv_get(self, "@parts");
2738
- VALUE dunit = rb_funcall(vdst, rb_intern("to_unit"), 0);
2739
-
2740
- int i;
2741
- for(i=0; i<RARRAY_LEN(parts_list); i++)
2742
- {
2743
- VALUE parts = rb_hash_aref(parts_hash, *(RARRAY_PTR(parts_list) + i));
2744
- #if 0
2745
- MIYAKO_GET_UNIT_NO_SURFACE_1(parts, sunit);
2746
- render_to_inner(sunit, dunit);
2747
- #else
2748
- rb_funcall(parts, rb_intern("render_to"), 1, vdst);
2749
- #endif
2750
- }
2751
-
2752
- return Qnil;
2753
- }
2754
-
2755
- /*
2756
- :nodoc:
2757
- */
2758
- static VALUE collision_c_collision(VALUE self, VALUE c1, VALUE c2)
2759
- {
2760
- VALUE rect1 = rb_funcall(c1, rb_intern("rect"), 0);
2761
- VALUE rect2 = rb_funcall(c2, rb_intern("rect"), 0);
2762
- VALUE pos1 = rb_funcall(c1, rb_intern("pos"), 0);
2763
- VALUE pos2 = rb_funcall(c2, rb_intern("pos"), 0);
2764
- int l1 = NUM2INT(rb_funcall(pos1, id_kakko, 1, nZero))
2765
- + NUM2INT(rb_funcall(rect1, id_kakko, 1, nZero));
2766
- int t1 = NUM2INT(rb_funcall(pos1, id_kakko, 1, nOne))
2767
- + NUM2INT(rb_funcall(rect1, id_kakko, 1, nOne));
2768
- int r1 = l1 + NUM2INT(rb_funcall(rect1, id_kakko, 1, INT2NUM(2))) - 1;
2769
- int b1 = t1 + NUM2INT(rb_funcall(rect1, id_kakko, 1, INT2NUM(3))) - 1;
2770
- int l2 = NUM2INT(rb_funcall(pos2, id_kakko, 1, nZero))
2771
- + NUM2INT(rb_funcall(rect2, id_kakko, 1, nZero));
2772
- int t2 = NUM2INT(rb_funcall(pos2, id_kakko, 1, nOne))
2773
- + NUM2INT(rb_funcall(rect2, id_kakko, 1, nOne));
2774
- int r2 = l2 + NUM2INT(rb_funcall(rect2, id_kakko, 1, INT2NUM(2))) - 1;
2775
- int b2 = t2 + NUM2INT(rb_funcall(rect2, id_kakko, 1, INT2NUM(3))) - 1;
2776
-
2777
- int v = 0;
2778
- if(l1 <= l2 && l2 <= r1) v |= 1;
2779
- if(l1 <= r2 && r2 <= r1) v |= 1;
2780
- if(t1 <= t2 && t2 <= b1) v |= 2;
2781
- if(t1 <= b2 && b2 <= b1) v |= 2;
2782
-
2783
- if(v == 3) return Qtrue;
2784
- return Qfalse;
2785
- }
2786
-
2787
- /*
2788
- :nodoc:
2789
- */
2790
- static VALUE collision_c_collision_with_move(VALUE self, VALUE c1, VALUE c2)
2791
- {
2792
- VALUE rect1 = rb_funcall(c1, rb_intern("rect"), 0);
2793
- VALUE rect2 = rb_funcall(c2, rb_intern("rect"), 0);
2794
- VALUE pos1 = rb_funcall(c1, rb_intern("pos"), 0);
2795
- VALUE pos2 = rb_funcall(c2, rb_intern("pos"), 0);
2796
- VALUE dir1 = rb_funcall(c1, rb_intern("direction"), 0);
2797
- VALUE dir2 = rb_funcall(c2, rb_intern("direction"), 0);
2798
- VALUE amt1 = rb_funcall(c1, rb_intern("amount"), 0);
2799
- VALUE amt2 = rb_funcall(c2, rb_intern("amount"), 0);
2800
- int l1 = NUM2INT(rb_funcall(pos1, id_kakko, 1, nZero))
2801
- + NUM2INT(rb_funcall(rect1, id_kakko, 1, nZero))
2802
- + NUM2INT(rb_funcall(dir1, id_kakko, 1, nZero))
2803
- * NUM2INT(rb_funcall(amt1, id_kakko, 1, nZero));
2804
- int t1 = NUM2INT(rb_funcall(pos1, id_kakko, 1, nOne))
2805
- + NUM2INT(rb_funcall(rect1, id_kakko, 1, nOne))
2806
- + NUM2INT(rb_funcall(dir1, id_kakko, 1, nOne))
2807
- * NUM2INT(rb_funcall(amt1, id_kakko, 1, nOne));
2808
- int r1 = l1 + NUM2INT(rb_funcall(rect1, id_kakko, 1, INT2NUM(2))) - 1;
2809
- int b1 = t1 + NUM2INT(rb_funcall(rect1, id_kakko, 1, INT2NUM(3))) - 1;
2810
- int l2 = NUM2INT(rb_funcall(pos2, id_kakko, 1, nZero))
2811
- + NUM2INT(rb_funcall(rect2, id_kakko, 1, nZero))
2812
- + NUM2INT(rb_funcall(dir2, id_kakko, 1, nZero))
2813
- * NUM2INT(rb_funcall(amt2, id_kakko, 1, nZero));
2814
- int t2 = NUM2INT(rb_funcall(pos2, id_kakko, 1, nOne))
2815
- + NUM2INT(rb_funcall(rect2, id_kakko, 1, nOne))
2816
- + NUM2INT(rb_funcall(dir2, id_kakko, 1, nOne))
2817
- * NUM2INT(rb_funcall(amt2, id_kakko, 1, nOne));
2818
- int r2 = l2 + NUM2INT(rb_funcall(rect2, id_kakko, 1, INT2NUM(2))) - 1;
2819
- int b2 = t2 + NUM2INT(rb_funcall(rect2, id_kakko, 1, INT2NUM(3))) - 1;
2820
-
2821
- int v = 0;
2822
- if(l1 <= l2 && l2 <= r1) v |= 1;
2823
- if(l1 <= r2 && r2 <= r1) v |= 1;
2824
- if(t1 <= t2 && t2 <= b1) v |= 2;
2825
- if(t1 <= b2 && b2 <= b1) v |= 2;
2826
-
2827
- if(v == 3) return Qtrue;
2828
- return Qfalse;
2829
- }
2830
-
2831
- /*
2832
- :nodoc:
2833
- */
2834
- static VALUE collision_c_meet(VALUE self, VALUE c1, VALUE c2)
2835
- {
2836
- VALUE rect1 = rb_funcall(c1, rb_intern("rect"), 0);
2837
- VALUE rect2 = rb_funcall(c2, rb_intern("rect"), 0);
2838
- VALUE pos1 = rb_funcall(c1, rb_intern("pos"), 0);
2839
- VALUE pos2 = rb_funcall(c2, rb_intern("pos"), 0);
2840
- int l1 = NUM2INT(rb_funcall(pos1, id_kakko, 1, nZero))
2841
- + NUM2INT(rb_funcall(rect1, id_kakko, 1, nZero));
2842
- int t1 = NUM2INT(rb_funcall(pos1, id_kakko, 1, nOne))
2843
- + NUM2INT(rb_funcall(rect1, id_kakko, 1, nOne));
2844
- int r1 = l1 + NUM2INT(rb_funcall(rect1, id_kakko, 1, INT2NUM(2)));
2845
- int b1 = t1 + NUM2INT(rb_funcall(rect1, id_kakko, 1, INT2NUM(3)));
2846
- int l2 = NUM2INT(rb_funcall(pos2, id_kakko, 1, nZero))
2847
- + NUM2INT(rb_funcall(rect2, id_kakko, 1, nZero));
2848
- int t2 = NUM2INT(rb_funcall(pos2, id_kakko, 1, nOne))
2849
- + NUM2INT(rb_funcall(rect2, id_kakko, 1, nOne));
2850
- int r2 = l2 + NUM2INT(rb_funcall(rect2, id_kakko, 1, INT2NUM(2)));
2851
- int b2 = t2 + NUM2INT(rb_funcall(rect2, id_kakko, 1, INT2NUM(3)));
2852
-
2853
- int v = 0;
2854
- if(r1 == l2) v |= 1;
2855
- if(b1 == t2) v |= 1;
2856
- if(l1 == r2) v |= 1;
2857
- if(t1 == b2) v |= 1;
2858
-
2859
- if(v == 1) return Qtrue;
2860
- return Qfalse;
2861
- }
2862
-
2863
- /*
2864
- :nodoc:
2865
- */
2866
- static VALUE collision_c_into(VALUE self, VALUE c1, VALUE c2)
2867
- {
2868
- VALUE f1 = collision_c_collision(self, c1, c2);
2869
- VALUE f2 = collision_c_collision_with_move(self, c1, c2);
2870
- if(f1 == Qfalse && f2 == Qtrue) return Qtrue;
2871
- return Qfalse;
2872
- }
2873
-
2874
- /*
2875
- :nodoc:
2876
- */
2877
- static VALUE collision_c_out(VALUE self, VALUE c1, VALUE c2)
2878
- {
2879
- VALUE f1 = collision_c_collision(self, c1, c2);
2880
- VALUE f2 = collision_c_collision_with_move(self, c1, c2);
2881
- if(f1 == Qtrue && f2 == Qfalse) return Qtrue;
2882
- return Qfalse;
2883
- }
2884
-
2885
- /*
2886
- :nodoc:
2887
- */
2888
- static VALUE collision_c_cover(VALUE self, VALUE c1, VALUE c2)
2889
- {
2890
- VALUE rect1 = rb_funcall(c1, rb_intern("rect"), 0);
2891
- VALUE rect2 = rb_funcall(c2, rb_intern("rect"), 0);
2892
- VALUE pos1 = rb_funcall(c1, rb_intern("pos"), 0);
2893
- VALUE pos2 = rb_funcall(c2, rb_intern("pos"), 0);
2894
- int l1 = NUM2INT(rb_funcall(pos1, id_kakko, 1, nZero))
2895
- + NUM2INT(rb_funcall(rect1, id_kakko, 1, nZero));
2896
- int t1 = NUM2INT(rb_funcall(pos1, id_kakko, 1, nOne))
2897
- + NUM2INT(rb_funcall(rect1, id_kakko, 1, nOne));
2898
- int r1 = l1 + NUM2INT(rb_funcall(rect1, id_kakko, 1, INT2NUM(2))) - 1;
2899
- int b1 = t1 + NUM2INT(rb_funcall(rect1, id_kakko, 1, INT2NUM(3))) - 1;
2900
- int l2 = NUM2INT(rb_funcall(pos2, id_kakko, 1, nZero))
2901
- + NUM2INT(rb_funcall(rect2, id_kakko, 1, nZero));
2902
- int t2 = NUM2INT(rb_funcall(pos2, id_kakko, 1, nOne))
2903
- + NUM2INT(rb_funcall(rect2, id_kakko, 1, nOne));
2904
- int r2 = l2 + NUM2INT(rb_funcall(rect2, id_kakko, 1, INT2NUM(2))) - 1;
2905
- int b2 = t2 + NUM2INT(rb_funcall(rect2, id_kakko, 1, INT2NUM(3))) - 1;
2906
-
2907
- int v = 0;
2908
- if(l1 <= l2 && r2 <= r1) v |= 1;
2909
- if(t1 <= t2 && b2 <= b1) v |= 2;
2910
- if(l2 <= l1 && r1 <= r2) v |= 4;
2911
- if(t2 <= t1 && b1 <= b2) v |= 8;
2912
-
2913
- if(v == 3 || v == 12) return Qtrue;
2914
- return Qfalse;
2915
- }
2916
-
2917
- /*
2918
- :nodoc:
2919
- */
2920
- static VALUE collision_collision(VALUE self, VALUE c2)
2921
- {
2922
- return collision_c_collision(cCollision, self, c2);
2923
- }
2924
-
2925
- /*
2926
- :nodoc:
2927
- */
2928
- static VALUE collision_meet(VALUE self, VALUE c2)
2929
- {
2930
- return collision_c_meet(cCollision, self, c2);
2931
- }
2932
-
2933
- /*
2934
- :nodoc:
2935
- */
2936
- static VALUE collision_into(VALUE self, VALUE c2)
2937
- {
2938
- return collision_c_into(cCollision, self, c2);
2939
- }
2940
-
2941
- /*
2942
- :nodoc:
2943
- */
2944
- static VALUE collision_out(VALUE self, VALUE c2)
2945
- {
2946
- return collision_c_out(cCollision, self, c2);
2947
- }
2948
-
2949
- /*
2950
- :nodoc:
2951
- */
2952
- static VALUE collision_cover(VALUE self, VALUE c2)
2953
- {
2954
- return collision_c_cover(cCollision, self, c2);
2955
- }
2956
-
2957
- /*
2958
- :nodoc:
2959
- */
2960
- static VALUE collisions_collision(VALUE self, VALUE c)
2961
- {
2962
- VALUE collisions = rb_iv_get(self, "@collisions");
2963
- int i=0;
2964
- for(i=0; i<RARRAY_LEN(collisions); i++){
2965
- VALUE cs = *(RARRAY_PTR(collisions) + i);
2966
- VALUE cc = *(RARRAY_PTR(cs) + 0);
2967
- if(collision_collision(c, cc) == Qtrue){ return cs; }
2968
- }
2969
- return Qnil;
2970
- }
2971
-
2972
- /*
2973
- :nodoc:
2974
- */
2975
- static VALUE collisions_meet(VALUE self, VALUE c)
2976
- {
2977
- VALUE collisions = rb_iv_get(self, "@collisions");
2978
- int i=0;
2979
- for(i=0; i<RARRAY_LEN(collisions); i++){
2980
- VALUE cs = *(RARRAY_PTR(collisions) + i);
2981
- VALUE cc = *(RARRAY_PTR(cs) + 0);
2982
- if(collision_meet(c, cc) == Qtrue){ return cs; }
2983
- }
2984
- return Qnil;
2985
- }
2986
-
2987
- /*
2988
- :nodoc:
2989
- */
2990
- static VALUE collisions_into(VALUE self, VALUE c)
2991
- {
2992
- VALUE collisions = rb_iv_get(self, "@collisions");
2993
- int i=0;
2994
- for(i=0; i<RARRAY_LEN(collisions); i++){
2995
- VALUE cs = *(RARRAY_PTR(collisions) + i);
2996
- VALUE cc = *(RARRAY_PTR(cs) + 0);
2997
- if(collision_into(c, cc) == Qtrue){ return cs; }
2998
- }
2999
- return Qnil;
3000
- }
3001
-
3002
- /*
3003
- :nodoc:
3004
- */
3005
- static VALUE collisions_out(VALUE self, VALUE c)
3006
- {
3007
- VALUE collisions = rb_iv_get(self, "@collisions");
3008
- int i=0;
3009
- for(i=0; i<RARRAY_LEN(collisions); i++){
3010
- VALUE cs = *(RARRAY_PTR(collisions) + i);
3011
- VALUE cc = *(RARRAY_PTR(cs) + 0);
3012
- if(collision_out(c, cc) == Qtrue){ return cs; }
3013
- }
3014
- return Qnil;
3015
- }
3016
-
3017
- /*
3018
- :nodoc:
3019
- */
3020
- static VALUE collisions_cover(VALUE self, VALUE c)
3021
- {
3022
- VALUE collisions = rb_iv_get(self, "@collisions");
3023
- int i=0;
3024
- for(i=0; i<RARRAY_LEN(collisions); i++){
3025
- VALUE cs = *(RARRAY_PTR(collisions) + i);
3026
- VALUE cc = *(RARRAY_PTR(cs) + 0);
3027
- if(collision_cover(c, cc) == Qtrue){ return cs; }
3028
- }
3029
- return Qnil;
3030
- }
3031
-
3032
- /*
3033
- :nodoc:
3034
- */
3035
- static VALUE collisions_collision_all(VALUE self, VALUE c)
3036
- {
3037
- VALUE collisions = rb_iv_get(self, "@collisions");
3038
- VALUE ret = rb_ary_new();
3039
- int i=0;
3040
- for(i=0; i<RARRAY_LEN(collisions); i++){
3041
- VALUE cs = *(RARRAY_PTR(collisions) + i);
3042
- VALUE cc = *(RARRAY_PTR(cs) + 0);
3043
- if(collision_collision(c, cc) == Qtrue){ rb_ary_push(ret, cs); }
3044
- }
3045
- if(RARRAY_LEN(ret) == 0){ return Qnil; }
3046
- return ret;
3047
- }
3048
-
3049
- /*
3050
- :nodoc:
3051
- */
3052
- static VALUE collisions_meet_all(VALUE self, VALUE c)
3053
- {
3054
- VALUE collisions = rb_iv_get(self, "@collisions");
3055
- VALUE ret = rb_ary_new();
3056
- int i=0;
3057
- for(i=0; i<RARRAY_LEN(collisions); i++){
3058
- VALUE cs = *(RARRAY_PTR(collisions) + i);
3059
- VALUE cc = *(RARRAY_PTR(cs) + 0);
3060
- if(collision_meet(c, cc) == Qtrue){ rb_ary_push(ret, cs); }
3061
- }
3062
- if(RARRAY_LEN(ret) == 0){ return Qnil; }
3063
- return ret;
3064
- }
3065
-
3066
- /*
3067
- :nodoc:
3068
- */
3069
- static VALUE collisions_into_all(VALUE self, VALUE c)
3070
- {
3071
- VALUE collisions = rb_iv_get(self, "@collisions");
3072
- VALUE ret = rb_ary_new();
3073
- int i=0;
3074
- for(i=0; i<RARRAY_LEN(collisions); i++){
3075
- VALUE cs = *(RARRAY_PTR(collisions) + i);
3076
- VALUE cc = *(RARRAY_PTR(cs) + 0);
3077
- if(collision_into(c, cc) == Qtrue){ rb_ary_push(ret, cs); }
3078
- }
3079
- if(RARRAY_LEN(ret) == 0){ return Qnil; }
3080
- return ret;
3081
- }
3082
-
3083
- /*
3084
- :nodoc:
3085
- */
3086
- static VALUE collisions_out_all(VALUE self, VALUE c)
3087
- {
3088
- VALUE collisions = rb_iv_get(self, "@collisions");
3089
- VALUE ret = rb_ary_new();
3090
- int i=0;
3091
- for(i=0; i<RARRAY_LEN(collisions); i++){
3092
- VALUE cs = *(RARRAY_PTR(collisions) + i);
3093
- VALUE cc = *(RARRAY_PTR(cs) + 0);
3094
- if(collision_out(c, cc) == Qtrue){ rb_ary_push(ret, cs); }
3095
- }
3096
- if(RARRAY_LEN(ret) == 0){ return Qnil; }
3097
- return ret;
3098
- }
3099
-
3100
- /*
3101
- :nodoc:
3102
- */
3103
- static VALUE collisions_cover_all(VALUE self, VALUE c)
3104
- {
3105
- VALUE collisions = rb_iv_get(self, "@collisions");
3106
- VALUE ret = rb_ary_new();
3107
- int i=0;
3108
- for(i=0; i<RARRAY_LEN(collisions); i++){
3109
- VALUE cs = *(RARRAY_PTR(collisions) + i);
3110
- VALUE cc = *(RARRAY_PTR(cs) + 0);
3111
- if(collision_cover(c, cc) == Qtrue){ rb_ary_push(ret, cs); }
3112
- }
3113
- if(RARRAY_LEN(ret) == 0){ return Qnil; }
3114
- return ret;
3115
- }
3116
-
3117
- /*
3118
- :nodoc:
3119
- */
3120
- static VALUE processor_mainloop(VALUE self)
3121
- {
3122
- VALUE diagram = rb_iv_get(self, "@diagram");
3123
- VALUE states = rb_iv_get(self, "@states");
3124
- VALUE mutex = rb_iv_get(self, "@mutex");
3125
- VALUE str_execute = rb_str_new2("execute");
3126
- VALUE sym_execute = rb_funcall(str_execute, rb_intern("to_sym"), 0);
3127
- VALUE str_pause = rb_str_new2("pause");
3128
- VALUE sym_pause = rb_funcall(str_pause, rb_intern("to_sym"), 0);
3129
- rb_funcall(diagram, rb_intern("start"), 0);
3130
- VALUE executing = rb_funcall(states, id_kakko, 1, sym_execute);
3131
- while(executing == Qtrue){
3132
- VALUE pausing = rb_funcall(states, id_kakko, 1, sym_pause);
3133
- if(pausing == Qfalse){
3134
- rb_funcall(mutex, rb_intern("lock"), 0);
3135
- rb_funcall(diagram, id_update, 0);
3136
- rb_funcall(mutex, rb_intern("unlock"), 0);
3137
- rb_funcall(cThread, rb_intern("pass"), 0);
3138
- VALUE is_finish = rb_funcall(diagram, rb_intern("finish?"), 0);
3139
- if(is_finish == Qtrue){ rb_funcall(states, rb_intern("[]="), 2, sym_execute, Qfalse); }
3140
- }
3141
- executing = rb_funcall(states, id_kakko, 1, sym_execute);
3142
- }
3143
- rb_funcall(diagram, rb_intern("stop"), 0);
3144
- return self;
3145
- }
3146
-
3147
- /*
3148
- :nodoc:
3149
- */
3150
- static VALUE yuki_update_plot_thread(VALUE self)
3151
- {
3152
- VALUE yuki = rb_iv_get(self, "@yuki");
3153
- VALUE str_exec = rb_str_new2("exec_plot");
3154
- VALUE sym_exec = rb_funcall(str_exec, rb_intern("to_sym"), 0);
3155
- VALUE str_pausing = rb_str_new2("pausing");
3156
- VALUE sym_pausing = rb_funcall(str_pausing, rb_intern("to_sym"), 0);
3157
- VALUE str_selecting = rb_str_new2("exec_selecting");
3158
- VALUE sym_selecting = rb_funcall(str_selecting, rb_intern("to_sym"), 0);
3159
- VALUE str_waiting = rb_str_new2("waiting");
3160
- VALUE sym_waiting = rb_funcall(str_waiting, rb_intern("to_sym"), 0);
3161
- VALUE exec = rb_funcall(yuki, id_kakko, 1, sym_exec);
3162
- while(exec == Qtrue){
3163
- VALUE pausing = rb_funcall(yuki, id_kakko, 1, sym_pausing);
3164
- if(pausing == Qtrue){ rb_funcall(self, rb_intern("pausing"), 0); }
3165
- VALUE selecting = rb_funcall(yuki, id_kakko, 1, sym_selecting);
3166
- if(selecting == Qtrue){ rb_funcall(self, rb_intern("selecting"), 0); }
3167
- VALUE waiting = rb_funcall(yuki, id_kakko, 1, sym_waiting);
3168
- if(waiting == Qtrue){ rb_funcall(self, rb_intern("waiting"), 0); }
3169
- rb_funcall(cThread, rb_intern("pass"), 0);
3170
- exec = rb_funcall(yuki, id_kakko, 1, sym_exec);
3171
- }
3172
- return self;
3173
- }
3174
-
3175
- void Init_miyako_no_katana()
3176
- {
3177
- mSDL = rb_define_module("SDL");
3178
- mMiyako = rb_define_module("Miyako");
3179
- mScreen = rb_define_module_under(mMiyako, "Screen");
3180
- mInput = rb_define_module_under(mMiyako, "Input");
3181
- mMapEvent = rb_define_module_under(mMiyako, "MapEvent");
3182
- mLayout = rb_define_module_under(mMiyako, "Layout");
3183
- mDiagram = rb_define_module_under(mMiyako, "Diagram");
3184
- eMiyakoError = rb_define_class_under(mMiyako, "MiyakoError", rb_eException);
3185
- cSurface = rb_define_class_under(mSDL, "Surface", rb_cObject);
3186
- cEvent2 = rb_define_class_under(mSDL, "Event2", rb_cObject);
3187
- cJoystick = rb_define_class_under(mSDL, "Joystick", rb_cObject);
3188
- cWaitCounter = rb_define_class_under(mMiyako, "WaitCounter", rb_cObject);
3189
- cFont = rb_define_class_under(mMiyako, "Font", rb_cObject);
3190
- cColor = rb_define_class_under(mMiyako, "Color", rb_cObject);
3191
- cBitmap = rb_define_class_under(mMiyako, "Bitmap", rb_cObject);
3192
- cSprite = rb_define_class_under(mMiyako, "Sprite", rb_cObject);
3193
- cSpriteAnimation = rb_define_class_under(mMiyako, "SpriteAnimation", rb_cObject);
3194
- sSpriteUnit = rb_define_class_under(mMiyako, "SpriteUnitBase", rb_cStruct);
3195
- cPlane = rb_define_class_under(mMiyako, "Plane", rb_cObject);
3196
- cParts = rb_define_class_under(mMiyako, "Parts", rb_cObject);
3197
- cTextBox = rb_define_class_under(mMiyako, "TextBox", rb_cObject);
3198
- cMap = rb_define_class_under(mMiyako, "Map", rb_cObject);
3199
- cMapLayer = rb_define_class_under(cMap, "MapLayer", rb_cObject);
3200
- cFixedMap = rb_define_class_under(mMiyako, "FixedMap", rb_cObject);
3201
- cFixedMapLayer = rb_define_class_under(cFixedMap, "FixedMapLayer", rb_cObject);
3202
- cCollision = rb_define_class_under(mMiyako, "Collision", rb_cObject);
3203
- cCollisions = rb_define_class_under(mMiyako, "Collisions", rb_cObject);
3204
- cMovie = rb_define_class_under(mMiyako, "Movie", rb_cObject);
3205
- cProcessor = rb_define_class_under(mDiagram, "Processor", rb_cObject);
3206
- cYuki = rb_define_class_under(mMiyako, "Yuki", rb_cObject);
3207
- cThread = rb_define_class("Thread", rb_cObject);
3208
-
3209
- id_update = rb_intern("update");
3210
- id_kakko = rb_intern("[]");
3211
-
3212
- zero = 0;
3213
- nZero = INT2NUM(zero);
3214
- one = 1;
3215
- nOne = INT2NUM(one);
3216
-
3217
- rb_define_singleton_method(cBitmap, "blit_aa!", bitmap_miyako_blit_aa, 4);
3218
- rb_define_singleton_method(cBitmap, "ck_to_ac!", bitmap_miyako_colorkey_to_alphachannel, 3);
3219
- rb_define_singleton_method(cBitmap, "normal_to_ac!", bitmap_miyako_normal_to_alphachannel, 2);
3220
- rb_define_singleton_method(cBitmap, "screen_to_ac!", bitmap_miyako_screen_to_alphachannel, 2);
3221
- rb_define_singleton_method(cBitmap, "dec_alpha!", bitmap_miyako_dec_alpha, 3);
3222
- rb_define_singleton_method(cBitmap, "black_out!", bitmap_miyako_black_out, 3);
3223
- rb_define_singleton_method(cBitmap, "white_out!", bitmap_miyako_white_out, 3);
3224
- rb_define_singleton_method(cBitmap, "inverse!", bitmap_miyako_inverse, 3);
3225
- rb_define_singleton_method(cBitmap, "additive!", bitmap_miyako_additive_synthesis, 2);
3226
- rb_define_singleton_method(cBitmap, "subtraction!", bitmap_miyako_subtraction_synthesis, 2);
3227
- rb_define_singleton_method(cBitmap, "subtraction!", bitmap_miyako_subtraction_synthesis, 2);
3228
-
3229
- rb_define_singleton_method(cBitmap, "rotate", bitmap_miyako_rotate, 2);
3230
- rb_define_singleton_method(cBitmap, "scale", bitmap_miyako_scale, 2);
3231
- rb_define_singleton_method(cBitmap, "transform", bitmap_miyako_transform, 2);
3232
-
3233
- rb_define_singleton_method(cBitmap, "hue!", bitmap_miyako_hue, 3);
3234
- rb_define_singleton_method(cBitmap, "saturation!", bitmap_miyako_saturation, 3);
3235
- rb_define_singleton_method(cBitmap, "value!", bitmap_miyako_value, 3);
3236
- rb_define_singleton_method(cBitmap, "hsv!", bitmap_miyako_hsv, 5);
3237
-
3238
- rb_define_module_function(mScreen, "update_tick", screen_update_tick, 0);
3239
- rb_define_module_function(mScreen, "render", screen_render, 0);
3240
- rb_define_module_function(mScreen, "render_screen", screen_render_screen, 1);
3241
-
3242
- rb_define_method(cWaitCounter, "start", counter_start, 0);
3243
- rb_define_method(cWaitCounter, "stop", counter_stop, 0);
3244
- rb_define_method(cWaitCounter, "wait_inner", counter_wait_inner, 1);
3245
- rb_define_method(cWaitCounter, "waiting?", counter_waiting, 0);
3246
- rb_define_method(cWaitCounter, "finish?", counter_finish, 0);
3247
- rb_define_method(cWaitCounter, "wait", counter_wait, 0);
3248
-
3249
- rb_define_method(cSpriteAnimation, "update_animation", sa_update, 0);
3250
- rb_define_method(cSpriteAnimation, "update_frame", sa_update_frame, 0);
3251
- rb_define_method(cSpriteAnimation, "update_wait_counter", sa_update_wait_counter, 0);
3252
- rb_define_method(cSpriteAnimation, "set_pat", sa_set_pat, 0);
3253
- rb_define_method(cSpriteAnimation, "render", sa_render, 0);
3254
- rb_define_method(cSpriteAnimation, "render_to", sa_render_to_sprite, 1);
3255
-
3256
- rb_define_singleton_method(cSprite, "render_to", sprite_c_render_to_sprite, 2);
3257
- rb_define_method(cSprite, "render", sprite_render, 0);
3258
- rb_define_method(cSprite, "render_to", sprite_render_to_sprite, 1);
3259
- rb_define_method(cSprite, "render_transform", sprite_render_transform, 0);
3260
- rb_define_method(cSprite, "render_to_transform", sprite_render_to_sprite_transform, 1);
3261
-
3262
- rb_define_method(cPlane, "render", plane_render, 0);
3263
- rb_define_method(cPlane, "render_to", plane_render_to_sprite, 1);
3264
-
3265
- rb_define_method(cParts, "render", parts_render, 0);
3266
- rb_define_method(cParts, "render_to", parts_render_to_sprite, 1);
3267
-
3268
- rb_define_singleton_method(cCollision, "collision?", collision_c_collision, 2);
3269
- rb_define_singleton_method(cCollision, "meet?", collision_c_meet, 2);
3270
- rb_define_singleton_method(cCollision, "into?", collision_c_into, 2);
3271
- rb_define_singleton_method(cCollision, "out?", collision_c_out, 2);
3272
- rb_define_singleton_method(cCollision, "cover?", collision_c_cover, 2);
3273
- rb_define_method(cCollision, "collision?", collision_collision, 1);
3274
- rb_define_method(cCollision, "meet?", collision_meet, 1);
3275
- rb_define_method(cCollision, "into?", collision_into, 1);
3276
- rb_define_method(cCollision, "out?", collision_out, 1);
3277
- rb_define_method(cCollision, "cover?", collision_cover, 1);
3278
-
3279
- rb_define_method(cCollisions, "collision?", collisions_collision, 1);
3280
- rb_define_method(cCollisions, "meet?", collisions_meet, 1);
3281
- rb_define_method(cCollisions, "into?", collisions_into, 1);
3282
- rb_define_method(cCollisions, "out?", collisions_out, 1);
3283
- rb_define_method(cCollisions, "cover?", collisions_cover, 1);
3284
- rb_define_method(cCollisions, "collision_all?", collisions_collision_all, 1);
3285
- rb_define_method(cCollisions, "meet_all?", collisions_meet_all, 1);
3286
- rb_define_method(cCollisions, "into_all?", collisions_into_all, 1);
3287
- rb_define_method(cCollisions, "out_all?", collisions_out_all, 1);
3288
- rb_define_method(cCollisions, "cover_all?", collisions_cover_all, 1);
3289
-
3290
- rb_define_method(cProcessor, "main_loop", processor_mainloop, 0);
3291
- rb_define_method(cYuki, "update_plot_thread", yuki_update_plot_thread, 0);
3292
-
3293
- rb_define_method(cMapLayer, "render", maplayer_render, 0);
3294
- rb_define_method(cFixedMapLayer, "render", fixedmaplayer_render, 0);
3295
- rb_define_method(cMap, "render", map_render, 0);
3296
- rb_define_method(cFixedMap, "render", fixedmap_render, 0);
3297
- rb_define_method(cMap, "render_to", map_render_to_sprite, 1);
3298
- rb_define_method(cFixedMap, "render_to", fixedmap_render_to_sprite, 1);
3299
- rb_define_method(cMapLayer, "render_to", maplayer_render_to_sprite, 1);
3300
- rb_define_method(cFixedMapLayer, "render_to", fixedmaplayer_render_to_sprite, 1);
3301
- }