cyross-ruby-miyako 2.0.5.1.0 → 2.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 (91) hide show
  1. data/README +1092 -929
  2. data/Rakefile +7 -7
  3. data/defines.h +144 -144
  4. data/extern.h +29 -29
  5. data/install_miyako.rb +87 -87
  6. data/lib/Miyako/API/audio.rb +572 -198
  7. data/lib/Miyako/API/basic_data.rb +825 -573
  8. data/lib/Miyako/API/bitmap.rb +534 -507
  9. data/lib/Miyako/API/choices.rb +481 -475
  10. data/lib/Miyako/API/collision.rb +486 -460
  11. data/lib/Miyako/API/diagram.rb +586 -561
  12. data/lib/Miyako/API/drawing.rb +151 -151
  13. data/lib/Miyako/API/exceptions.rb +105 -0
  14. data/lib/Miyako/API/fixedmap.rb +462 -428
  15. data/lib/Miyako/API/font.rb +430 -403
  16. data/lib/Miyako/API/input.rb +456 -447
  17. data/lib/Miyako/API/layout.rb +636 -433
  18. data/lib/Miyako/API/map.rb +583 -529
  19. data/lib/Miyako/API/map_event.rb +222 -198
  20. data/lib/Miyako/API/modules.rb +357 -109
  21. data/lib/Miyako/API/movie.rb +166 -154
  22. data/lib/Miyako/API/parts.rb +276 -189
  23. data/lib/Miyako/API/plane.rb +205 -166
  24. data/lib/Miyako/API/screen.rb +341 -325
  25. data/lib/Miyako/API/shape.rb +443 -443
  26. data/lib/Miyako/API/sprite.rb +771 -752
  27. data/lib/Miyako/API/sprite_animation.rb +490 -481
  28. data/lib/Miyako/API/sprite_list.rb +1135 -0
  29. data/lib/Miyako/API/spriteunit.rb +168 -147
  30. data/lib/Miyako/API/story.rb +350 -300
  31. data/lib/Miyako/API/textbox.rb +770 -725
  32. data/lib/Miyako/API/utility.rb +419 -388
  33. data/lib/Miyako/API/viewport.rb +189 -139
  34. data/lib/Miyako/API/yuki.rb +1226 -996
  35. data/lib/Miyako/EXT/miyako_cairo.rb +62 -62
  36. data/lib/Miyako/EXT/raster_scroll.rb +138 -138
  37. data/lib/Miyako/EXT/slides.rb +157 -157
  38. data/lib/Miyako/miyako.rb +201 -171
  39. data/lib/Miyako/miyako_require_only.rb +35 -0
  40. data/miyako_basicdata.c +590 -590
  41. data/miyako_bitmap.c +1225 -1225
  42. data/miyako_collision.c +403 -403
  43. data/miyako_drawing.c +187 -187
  44. data/miyako_font.c +334 -334
  45. data/miyako_hsv.c +830 -830
  46. data/miyako_input_audio.c +254 -0
  47. data/miyako_layout.c +191 -191
  48. data/miyako_no_katana.c +1078 -1074
  49. data/miyako_sprite2.c +431 -0
  50. data/miyako_transform.c +438 -438
  51. data/miyako_utility.c +288 -288
  52. data/sample/Animation1/m1ku.rb +68 -68
  53. data/sample/Animation2/lex.rb +96 -96
  54. data/sample/Diagram_sample/diagram_sample_yuki2.rb +328 -386
  55. data/sample/Room3/blue.rb +297 -297
  56. data/sample/Room3/ending.rb +180 -180
  57. data/sample/Room3/green.rb +220 -220
  58. data/sample/Room3/main.rb +119 -119
  59. data/sample/Room3/main_component.rb +59 -59
  60. data/sample/Room3/red.rb +227 -227
  61. data/sample/Room3/room3.rb +25 -27
  62. data/sample/Room3/title.rb +184 -184
  63. data/sample/ball_action_sample.rb +204 -204
  64. data/sample/blit_rop.rb +70 -70
  65. data/sample/cairo_sample.rb +25 -25
  66. data/sample/circle_collision_test.rb +66 -66
  67. data/sample/collision_test.rb +33 -33
  68. data/sample/collision_test2.rb +108 -108
  69. data/sample/fixed_map_test/fixed_map_sample.rb +140 -140
  70. data/sample/fixed_map_test/readme.txt +72 -72
  71. data/sample/map_test/chara.rb +58 -58
  72. data/sample/map_test/main_parts.rb +69 -69
  73. data/sample/map_test/main_scene.rb +153 -153
  74. data/sample/map_test/map_manager.rb +75 -75
  75. data/sample/map_test/map_test.rb +23 -23
  76. data/sample/map_test/oasis.rb +71 -71
  77. data/sample/map_test/readme.txt +89 -89
  78. data/sample/map_test/route.rb +157 -157
  79. data/sample/map_test/town.rb +74 -74
  80. data/sample/polygon_test.rb +35 -35
  81. data/sample/rasterscroll.rb +24 -24
  82. data/sample/takahashi.rb +42 -42
  83. data/sample/textbox_sample.rb +189 -189
  84. data/sample/transform.rb +54 -54
  85. data/sample/utility_test.rb +73 -73
  86. data/sample/utility_test2.rb +61 -61
  87. data/sample/utility_test3.rb +64 -64
  88. data/sample/utility_test4.rb +73 -73
  89. data/uninstall_miyako.rb +19 -19
  90. data/win/miyako_no_katana.so +0 -0
  91. metadata +7 -2
data/miyako_transform.c CHANGED
@@ -1,438 +1,438 @@
1
- /*
2
- --
3
- Miyako v2.0 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 "defines.h"
30
- #include "extern.h"
31
-
32
- static VALUE mSDL = Qnil;
33
- static VALUE mMiyako = Qnil;
34
- static VALUE mScreen = Qnil;
35
- static VALUE cSurface = Qnil;
36
- static VALUE cBitmap = Qnil;
37
- static VALUE cSprite = Qnil;
38
- static VALUE nZero = Qnil;
39
- static VALUE nOne = Qnil;
40
- static volatile ID id_update = Qnil;
41
- static volatile ID id_kakko = Qnil;
42
- static volatile ID id_render = Qnil;
43
- static volatile ID id_to_a = Qnil;
44
- static volatile int zero = Qnil;
45
- static volatile int one = Qnil;
46
-
47
- // from rubysdl_video.c
48
- static GLOBAL_DEFINE_GET_STRUCT(Surface, GetSurface, cSurface, "SDL::Surface");
49
-
50
- /*
51
- 画像を回転させて貼り付ける
52
- */
53
- static VALUE bitmap_miyako_rotate(VALUE self, VALUE vsrc, VALUE vdst, VALUE radian)
54
- {
55
- MiyakoBitmap src, dst;
56
- MiyakoSize size;
57
- SDL_Surface *scr = GetSurface(rb_iv_get(mScreen, "@@screen"))->surface;
58
-
59
- _miyako_setup_unit_2(vsrc, vdst, scr, &src, &dst, Qnil, Qnil, 1);
60
-
61
- size.w = dst.rect.w;
62
- size.h = dst.rect.h;
63
-
64
- if(src.surface == dst.surface){ return Qnil; }
65
-
66
- if(dst.rect.w >= 32768 || dst.rect.h >= 32768){ return Qnil; }
67
-
68
- double rad = NUM2DBL(radian) * -1.0;
69
- long isin = (long)(sin(rad)*4096.0);
70
- long icos = (long)(cos(rad)*4096.0);
71
-
72
- int px = -(NUM2INT(*(RSTRUCT_PTR(src.unit)+7)));
73
- int py = -(NUM2INT(*(RSTRUCT_PTR(src.unit)+8)));
74
- int pr = src.rect.w + px;
75
- int pb = src.rect.h + py;
76
- int qx = -(NUM2INT(*(RSTRUCT_PTR(dst.unit)+7)));
77
- int qy = -(NUM2INT(*(RSTRUCT_PTR(dst.unit)+8)));
78
- int qr = dst.rect.w + qx;
79
- int qb = dst.rect.h + qy;
80
-
81
- SDL_LockSurface(src.surface);
82
- SDL_LockSurface(dst.surface);
83
-
84
- int x, y;
85
- for(y = qy; y < qb; y++)
86
- {
87
- Uint32 *tp = dst.ptr + (dst.rect.y + y - qy) * dst.surface->w + dst.rect.x;
88
- for(x = qx; x < qr; x++)
89
- {
90
- int nx = (x*icos-y*isin) >> 12;
91
- if(nx < px || nx >= pr){ tp++; continue; }
92
- int ny = (x*isin+y*icos) >> 12;
93
- if(ny < py || ny >= pb){ tp++; continue; }
94
- #if SDL_BYTEORDER == SDL_LIL_ENDIAN
95
- dst.color.r = (*tp >> 16) & 0xff;
96
- dst.color.g = (*tp >> 8) & 0xff;
97
- dst.color.b = (*tp ) & 0xff;
98
- dst.color.a = (*tp >> 24) & 0xff | dst.a255;
99
- Uint32 *psrc = src.ptr + (src.rect.x + ny - py) * src.surface->w + src.rect.x + nx - px;
100
- src.color.a = (*psrc >> 24) & 0xff | src.a255;
101
- if(src.color.a == 0){ tp++; continue; }
102
- if(dst.color.a == 0 || src.color.a == 255)
103
- {
104
- *tp = *psrc;
105
- tp++;
106
- continue;
107
- }
108
- int a1 = src.color.a + 1;
109
- int a2 = 256 - src.color.a;
110
- src.color.r = (*psrc >> 16) & 0xff;
111
- src.color.g = (*psrc >> 8) & 0xff;
112
- src.color.b = (*psrc ) & 0xff;
113
- *tp = ((src.color.r * a1 + dst.color.r * a2) >> 8) << 16 |
114
- ((src.color.g * a1 + dst.color.g * a2) >> 8) << 8 |
115
- ((src.color.b * a1 + dst.color.b * a2) >> 8) |
116
- 0xff << 24;
117
- #else
118
- dst.color.r = (*tp & dst.fmt->Rmask) >> dst.fmt->Rshift;
119
- dst.color.g = (*tp & dst.fmt->Gmask) >> dst.fmt->Gshift;
120
- dst.color.b = (*tp & dst.fmt->Bmask) >> dst.fmt->Bshift;
121
- dst.color.a = (*tp & dst.fmt->Amask) | dst.a255;
122
- Uint32 *psrc = src.ptr + (src.rect.x + ny - py) * src.surface->w + src.rect.x + nx - px;
123
- src.color.a = (*psrc & src.fmt->Amask) | src.a255;
124
- if(src.color.a == 0){ tp++; continue; }
125
- if(dst.color.a == 0 || src.color.a == 255)
126
- {
127
- *tp = *psrc;
128
- tp++;
129
- continue;
130
- }
131
- int a1 = src.color.a + 1;
132
- int a2 = 256 - src.color.a;
133
- src.color.r = (*psrc & src.fmt->Rmask) >> src.fmt->Rshift;
134
- src.color.g = (*psrc & src.fmt->Gmask) >> src.fmt->Gshift;
135
- src.color.b = (*psrc & src.fmt->Bmask) >> src.fmt->Bshift;
136
- *tp = (((src.color.r * a1 + dst.color.r * a2) >> 8)) << dst.fmt->Rshift |
137
- (((src.color.g * a1 + dst.color.g * a2) >> 8)) << dst.fmt->Gshift |
138
- (((src.color.b * a1 + dst.color.b * a2) >> 8)) << dst.fmt->Bshift |
139
- 0xff;
140
- #endif
141
- tp++;
142
- }
143
- }
144
-
145
- SDL_UnlockSurface(src.surface);
146
- SDL_UnlockSurface(dst.surface);
147
-
148
- return vdst;
149
- }
150
-
151
- /*
152
- 画像を拡大・縮小・鏡像(ミラー反転)させて貼り付ける
153
- */
154
- static VALUE bitmap_miyako_scale(VALUE self, VALUE vsrc, VALUE vdst, VALUE xscale, VALUE yscale)
155
- {
156
- MiyakoBitmap src, dst;
157
- MiyakoSize size;
158
- SDL_Surface *scr = GetSurface(rb_iv_get(mScreen, "@@screen"))->surface;
159
-
160
- _miyako_setup_unit_2(vsrc, vdst, scr, &src, &dst, Qnil, Qnil, 1);
161
-
162
- if(_miyako_init_rect(&src, &dst, &size) == 0) return Qnil;
163
-
164
- if(src.surface == dst.surface){ return Qnil; }
165
-
166
- if(dst.rect.w >= 32768 || dst.rect.h >= 32768){ return Qnil; }
167
-
168
- double tscx = NUM2DBL(xscale);
169
- double tscy = NUM2DBL(yscale);
170
-
171
- if(tscx == 0.0 || tscy == 0.0){ return Qnil; }
172
-
173
- int scx = (int)(4096.0 / tscx);
174
- int scy = (int)(4096.0 / tscy);
175
-
176
- int off_x = scx < 0 ? 1 : 0;
177
- int off_y = scy < 0 ? 1 : 0;
178
-
179
- int px = -(NUM2INT(*(RSTRUCT_PTR(src.unit)+7)));
180
- int py = -(NUM2INT(*(RSTRUCT_PTR(src.unit)+8)));
181
- int pr = src.rect.w + px;
182
- int pb = src.rect.h + py;
183
- int qx = -(NUM2INT(*(RSTRUCT_PTR(dst.unit)+7)));
184
- int qy = -(NUM2INT(*(RSTRUCT_PTR(dst.unit)+8)));
185
- int qr = dst.rect.w + qx;
186
- int qb = dst.rect.h + qy;
187
-
188
- SDL_LockSurface(src.surface);
189
- SDL_LockSurface(dst.surface);
190
-
191
- int x, y;
192
- for(y = qy; y < qb; y++)
193
- {
194
- Uint32 *tp = dst.ptr + (dst.rect.y + y - qy) * dst.surface->w + dst.rect.x;
195
- for(x = qx; x < qr; x++)
196
- {
197
- int nx = (x*scx) >> 12 - off_x;
198
- if(nx < px || nx >= pr){ tp++; continue; }
199
- int ny = (y*scy) >> 12 - off_y;
200
- if(ny < py || ny >= pb){ tp++; continue; }
201
- #if SDL_BYTEORDER == SDL_LIL_ENDIAN
202
- dst.color.r = (*tp >> 16) & 0xff;
203
- dst.color.g = (*tp >> 8) & 0xff;
204
- dst.color.b = (*tp ) & 0xff;
205
- dst.color.a = (*tp >> 24) & 0xff | dst.a255;
206
- Uint32 *psrc = src.ptr + (src.rect.x + ny - py) * src.surface->w + src.rect.x + nx - px;
207
- src.color.a = (*psrc >> 24) & 0xff | src.a255;
208
- if(src.color.a == 0){ tp++; continue; }
209
- if(dst.color.a == 0 || src.color.a == 255)
210
- {
211
- *tp = *psrc;
212
- tp++;
213
- continue;
214
- }
215
- int a1 = src.color.a + 1;
216
- int a2 = 256 - src.color.a;
217
- src.color.r = (*psrc >> 16) & 0xff;
218
- src.color.g = (*psrc >> 8) & 0xff;
219
- src.color.b = (*psrc ) & 0xff;
220
- *tp = ((src.color.r * a1 + dst.color.r * a2) >> 8) << 16 |
221
- ((src.color.g * a1 + dst.color.g * a2) >> 8) << 8 |
222
- ((src.color.b * a1 + dst.color.b * a2) >> 8) |
223
- 0xff << 24;
224
- #else
225
- dst.color.r = (*tp & dst.fmt->Rmask) >> dst.fmt->Rshift;
226
- dst.color.g = (*tp & dst.fmt->Gmask) >> dst.fmt->Gshift;
227
- dst.color.b = (*tp & dst.fmt->Bmask) >> dst.fmt->Bshift;
228
- dst.color.a = (*tp & dst.fmt->Amask) | dst.a255;
229
- Uint32 *psrc = src.ptr + (src.rect.x + ny - py) * src.surface->w + src.rect.x + nx - px;
230
- src.color.a = (*psrc & src.fmt->Amask) | src.a255;
231
- if(src.color.a == 0){ tp++; continue; }
232
- if(dst.color.a == 0 || src.color.a == 255)
233
- {
234
- *tp = *psrc;
235
- tp++;
236
- continue;
237
- }
238
- int a1 = src.color.a + 1;
239
- int a2 = 256 - src.color.a;
240
- src.color.r = (*psrc & src.fmt->Rmask) >> src.fmt->Rshift;
241
- src.color.g = (*psrc & src.fmt->Gmask) >> src.fmt->Gshift;
242
- src.color.b = (*psrc & src.fmt->Bmask) >> src.fmt->Bshift;
243
- *tp = ((src.color.r * a1 + dst.color.r * a2) >> 8) << dst.fmt->Rshift |
244
- ((src.color.g * a1 + dst.color.g * a2) >> 8) << dst.fmt->Gshift |
245
- ((src.color.b * a1 + dst.color.b * a2) >> 8) << dst.fmt->Bshift |
246
- 0xff;
247
- #endif
248
- tp++;
249
- }
250
- }
251
-
252
- SDL_UnlockSurface(src.surface);
253
- SDL_UnlockSurface(dst.surface);
254
-
255
- return vdst;
256
- }
257
-
258
- /*
259
- ===回転・拡大・縮小・鏡像用インナーメソッド
260
- */
261
- static void transform_inner(MiyakoBitmap *src, MiyakoBitmap *dst, VALUE radian, VALUE xscale, VALUE yscale)
262
- {
263
- if(dst->rect.w >= 32768 || dst->rect.h >= 32768) return;
264
-
265
- MiyakoSize size;
266
-
267
- if(_miyako_init_rect(src, dst, &size) == 0) return;
268
-
269
- double rad = NUM2DBL(radian) * -1.0;
270
- long isin = (long)(sin(rad)*4096.0);
271
- long icos = (long)(cos(rad)*4096.0);
272
-
273
- double tscx = NUM2DBL(xscale);
274
- double tscy = NUM2DBL(yscale);
275
-
276
- if(tscx == 0.0 || tscy == 0.0) return;
277
-
278
- int scx = (int)(4096.0 / tscx);
279
- int scy = (int)(4096.0 / tscy);
280
-
281
- int off_x = scx < 0 ? 1 : 0;
282
- int off_y = scy < 0 ? 1 : 0;
283
-
284
- int px = -(NUM2INT(*(RSTRUCT_PTR(src->unit)+7)));
285
- int py = -(NUM2INT(*(RSTRUCT_PTR(src->unit)+8)));
286
- int pr = src->rect.w + px;
287
- int pb = src->rect.h + py;
288
- int qx = -(NUM2INT(*(RSTRUCT_PTR(dst->unit)+7)));
289
- int qy = -(NUM2INT(*(RSTRUCT_PTR(dst->unit)+8)));
290
- int qr = dst->rect.w + qx;
291
- int qb = dst->rect.h + qy;
292
-
293
- SDL_LockSurface(src->surface);
294
- SDL_LockSurface(dst->surface);
295
-
296
- int x, y;
297
- for(y = qy; y < qb; y++)
298
- {
299
- Uint32 *tp = dst->ptr + (dst->rect.y + y - qy) * dst->surface->w + dst->rect.x;
300
- for(x = qx; x < qr; x++)
301
- {
302
- int nx = (((x*icos-y*isin) >> 12) * scx) >> 12 - off_x;
303
- if(nx < px || nx >= pr){ tp++; continue; }
304
- int ny = (((x*isin+y*icos) >> 12) * scy) >> 12 - off_y;
305
- if(ny < py || ny >= pb){ tp++; continue; }
306
- #if SDL_BYTEORDER == SDL_LIL_ENDIAN
307
- dst->color.r = (*tp >> 16) & 0xff;
308
- dst->color.g = (*tp >> 8) & 0xff;
309
- dst->color.b = (*tp ) & 0xff;
310
- dst->color.a = (*tp >> 24) & 0xff | dst->a255;
311
- Uint32 *psrc = src->ptr + (src->rect.x + ny - py) * src->surface->w + src->rect.x + nx - px;
312
- src->color.a = (*psrc >> 24) & 0xff | src->a255;
313
- if(src->color.a == 0){ tp++; continue; }
314
- if(dst->color.a == 0 || src->color.a == 255)
315
- {
316
- *tp = *psrc;
317
- tp++;
318
- continue;
319
- }
320
- int a1 = src->color.a + 1;
321
- int a2 = 256 - src->color.a;
322
- src->color.r = (*psrc >> 16) & 0xff;
323
- src->color.g = (*psrc >> 8) & 0xff;
324
- src->color.b = (*psrc ) & 0xff;
325
- *tp = ((src->color.r * a1 + dst->color.r * a2) >> 8) << 16 |
326
- ((src->color.g * a1 + dst->color.g * a2) >> 8) << 8 |
327
- ((src->color.b * a1 + dst->color.b * a2) >> 8) |
328
- 0xff << 24;
329
- #else
330
- dst->color.r = (*tp & dst->fmt->Rmask) >> dst->fmt->Rshift;
331
- dst->color.g = (*tp & dst->fmt->Gmask) >> dst->fmt->Gshift;
332
- dst->color.b = (*tp & dst->fmt->Bmask) >> dst->fmt->Bshift;
333
- dst->color.a = (*tp & dst->fmt->Amask) | dst->a255;
334
- Uint32 *psrc = src->ptr + (src->rect.x + ny - py) * src->surface->w + src->rect.x + nx - px;
335
- src->color.a = (*psrc & src->fmt->Amask) | src->a255;
336
- if(src->color.a == 0){ tp++; continue; }
337
- if(dst->color.a == 0 || src->color.a == 255)
338
- {
339
- *tp = *psrc;
340
- tp++;
341
- continue;
342
- }
343
- int a1 = src->color.a + 1;
344
- int a2 = 256 - src->color.a;
345
- src->color.r = (*psrc & src->fmt->Rmask) >> src->fmt->Rshift;
346
- src->color.g = (*psrc & src->fmt->Gmask) >> src->fmt->Gshift;
347
- src->color.b = (*psrc & src->fmt->Bmask) >> src->fmt->Bshift;
348
- *tp = ((src->color.r * a1 + dst->color.r * a2) >> 8) << dst->fmt->Rshift |
349
- ((src->color.g * a1 + dst->color.g * a2) >> 8) << dst->fmt->Gshift |
350
- ((src->color.b * a1 + dst->color.b * a2) >> 8) << dst->fmt->Bshift |
351
- 0xff;
352
- #endif
353
- tp++;
354
- }
355
- }
356
-
357
- SDL_UnlockSurface(src->surface);
358
- SDL_UnlockSurface(dst->surface);
359
- }
360
-
361
- /*
362
- 画像を変形(回転・拡大・縮小・鏡像)させて貼り付ける
363
- */
364
- static VALUE bitmap_miyako_transform(VALUE self, VALUE vsrc, VALUE vdst, VALUE radian, VALUE xscale, VALUE yscale)
365
- {
366
- MiyakoBitmap src, dst;
367
- SDL_Surface *scr = GetSurface(rb_iv_get(mScreen, "@@screen"))->surface;
368
-
369
- _miyako_setup_unit_2(vsrc, vdst, scr, &src, &dst, Qnil, Qnil, 1);
370
-
371
- if(src.surface == dst.surface){ return Qnil; }
372
-
373
- transform_inner(&src, &dst, radian, xscale, yscale);
374
- return vdst;
375
- }
376
-
377
- /*
378
- インスタンスの内容を画面に描画する(回転/拡大/縮小/鏡像付き)
379
- */
380
- static VALUE sprite_render_transform(VALUE self, VALUE radian, VALUE xscale, VALUE yscale)
381
- {
382
- VALUE visible = rb_iv_get(self, "@visible");
383
- if(visible == Qfalse) return self;
384
- MiyakoBitmap src, dst;
385
- SDL_Surface *scr = GetSurface(rb_iv_get(mScreen, "@@screen"))->surface;
386
-
387
- _miyako_setup_unit_2(self, mScreen, scr, &src, &dst, Qnil, Qnil, 1);
388
-
389
- if(src.surface == dst.surface){ return Qnil; }
390
-
391
- transform_inner(&src, &dst, radian, xscale, yscale);
392
- return self;
393
- }
394
-
395
- /*
396
- インスタンスの内容を画面に描画する(回転/拡大/縮小/鏡像付き)
397
- */
398
- static VALUE sprite_render_to_sprite_transform(VALUE self, VALUE vdst, VALUE radian, VALUE xscale, VALUE yscale)
399
- {
400
- VALUE visible = rb_iv_get(self, "@visible");
401
- if(visible == Qfalse) return self;
402
- MiyakoBitmap src, dst;
403
- SDL_Surface *scr = GetSurface(rb_iv_get(mScreen, "@@screen"))->surface;
404
-
405
- _miyako_setup_unit_2(self, vdst, scr, &src, &dst, Qnil, Qnil, 1);
406
-
407
- if(src.surface == dst.surface){ return Qnil; }
408
-
409
- transform_inner(&src, &dst, radian, xscale, yscale);
410
- return self;
411
- }
412
-
413
- void Init_miyako_transform()
414
- {
415
- mSDL = rb_define_module("SDL");
416
- mMiyako = rb_define_module("Miyako");
417
- mScreen = rb_define_module_under(mMiyako, "Screen");
418
- cSurface = rb_define_class_under(mSDL, "Surface", rb_cObject);
419
- cBitmap = rb_define_class_under(mMiyako, "Bitmap", rb_cObject);
420
- cSprite = rb_define_class_under(mMiyako, "Sprite", rb_cObject);
421
-
422
- rb_define_method(cSprite, "render_transform", sprite_render_transform, 3);
423
- rb_define_method(cSprite, "render_to_transform", sprite_render_to_sprite_transform, 4);
424
-
425
- id_update = rb_intern("update");
426
- id_kakko = rb_intern("[]");
427
- id_render = rb_intern("render");
428
- id_to_a = rb_intern("to_a");
429
-
430
- zero = 0;
431
- nZero = INT2NUM(zero);
432
- one = 1;
433
- nOne = INT2NUM(one);
434
-
435
- rb_define_singleton_method(cBitmap, "rotate", bitmap_miyako_rotate, 3);
436
- rb_define_singleton_method(cBitmap, "scale", bitmap_miyako_scale, 4);
437
- rb_define_singleton_method(cBitmap, "transform", bitmap_miyako_transform, 5);
438
- }
1
+ /*
2
+ --
3
+ Miyako v2.0 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 "defines.h"
30
+ #include "extern.h"
31
+
32
+ static VALUE mSDL = Qnil;
33
+ static VALUE mMiyako = Qnil;
34
+ static VALUE mScreen = Qnil;
35
+ static VALUE cSurface = Qnil;
36
+ static VALUE cBitmap = Qnil;
37
+ static VALUE cSprite = Qnil;
38
+ static VALUE nZero = Qnil;
39
+ static VALUE nOne = Qnil;
40
+ static volatile ID id_update = Qnil;
41
+ static volatile ID id_kakko = Qnil;
42
+ static volatile ID id_render = Qnil;
43
+ static volatile ID id_to_a = Qnil;
44
+ static volatile int zero = Qnil;
45
+ static volatile int one = Qnil;
46
+
47
+ // from rubysdl_video.c
48
+ static GLOBAL_DEFINE_GET_STRUCT(Surface, GetSurface, cSurface, "SDL::Surface");
49
+
50
+ /*
51
+ 画像を回転させて貼り付ける
52
+ */
53
+ static VALUE bitmap_miyako_rotate(VALUE self, VALUE vsrc, VALUE vdst, VALUE radian)
54
+ {
55
+ MiyakoBitmap src, dst;
56
+ MiyakoSize size;
57
+ SDL_Surface *scr = GetSurface(rb_iv_get(mScreen, "@@screen"))->surface;
58
+
59
+ _miyako_setup_unit_2(vsrc, vdst, scr, &src, &dst, Qnil, Qnil, 1);
60
+
61
+ size.w = dst.rect.w;
62
+ size.h = dst.rect.h;
63
+
64
+ if(src.surface == dst.surface){ return Qnil; }
65
+
66
+ if(dst.rect.w >= 32768 || dst.rect.h >= 32768){ return Qnil; }
67
+
68
+ double rad = NUM2DBL(radian) * -1.0;
69
+ long isin = (long)(sin(rad)*4096.0);
70
+ long icos = (long)(cos(rad)*4096.0);
71
+
72
+ int px = -(NUM2INT(*(RSTRUCT_PTR(src.unit)+7)));
73
+ int py = -(NUM2INT(*(RSTRUCT_PTR(src.unit)+8)));
74
+ int pr = src.rect.w + px;
75
+ int pb = src.rect.h + py;
76
+ int qx = -(NUM2INT(*(RSTRUCT_PTR(dst.unit)+7)));
77
+ int qy = -(NUM2INT(*(RSTRUCT_PTR(dst.unit)+8)));
78
+ int qr = dst.rect.w + qx;
79
+ int qb = dst.rect.h + qy;
80
+
81
+ SDL_LockSurface(src.surface);
82
+ SDL_LockSurface(dst.surface);
83
+
84
+ int x, y;
85
+ for(y = qy; y < qb; y++)
86
+ {
87
+ Uint32 *tp = dst.ptr + (dst.rect.y + y - qy) * dst.surface->w + dst.rect.x;
88
+ for(x = qx; x < qr; x++)
89
+ {
90
+ int nx = (x*icos-y*isin) >> 12;
91
+ if(nx < px || nx >= pr){ tp++; continue; }
92
+ int ny = (x*isin+y*icos) >> 12;
93
+ if(ny < py || ny >= pb){ tp++; continue; }
94
+ #if SDL_BYTEORDER == SDL_LIL_ENDIAN
95
+ dst.color.r = (*tp >> 16) & 0xff;
96
+ dst.color.g = (*tp >> 8) & 0xff;
97
+ dst.color.b = (*tp ) & 0xff;
98
+ dst.color.a = (*tp >> 24) & 0xff | dst.a255;
99
+ Uint32 *psrc = src.ptr + (src.rect.x + ny - py) * src.surface->w + src.rect.x + nx - px;
100
+ src.color.a = (*psrc >> 24) & 0xff | src.a255;
101
+ if(src.color.a == 0){ tp++; continue; }
102
+ if(dst.color.a == 0 || src.color.a == 255)
103
+ {
104
+ *tp = *psrc;
105
+ tp++;
106
+ continue;
107
+ }
108
+ int a1 = src.color.a + 1;
109
+ int a2 = 256 - src.color.a;
110
+ src.color.r = (*psrc >> 16) & 0xff;
111
+ src.color.g = (*psrc >> 8) & 0xff;
112
+ src.color.b = (*psrc ) & 0xff;
113
+ *tp = ((src.color.r * a1 + dst.color.r * a2) >> 8) << 16 |
114
+ ((src.color.g * a1 + dst.color.g * a2) >> 8) << 8 |
115
+ ((src.color.b * a1 + dst.color.b * a2) >> 8) |
116
+ 0xff << 24;
117
+ #else
118
+ dst.color.r = (*tp & dst.fmt->Rmask) >> dst.fmt->Rshift;
119
+ dst.color.g = (*tp & dst.fmt->Gmask) >> dst.fmt->Gshift;
120
+ dst.color.b = (*tp & dst.fmt->Bmask) >> dst.fmt->Bshift;
121
+ dst.color.a = (*tp & dst.fmt->Amask) | dst.a255;
122
+ Uint32 *psrc = src.ptr + (src.rect.x + ny - py) * src.surface->w + src.rect.x + nx - px;
123
+ src.color.a = (*psrc & src.fmt->Amask) | src.a255;
124
+ if(src.color.a == 0){ tp++; continue; }
125
+ if(dst.color.a == 0 || src.color.a == 255)
126
+ {
127
+ *tp = *psrc;
128
+ tp++;
129
+ continue;
130
+ }
131
+ int a1 = src.color.a + 1;
132
+ int a2 = 256 - src.color.a;
133
+ src.color.r = (*psrc & src.fmt->Rmask) >> src.fmt->Rshift;
134
+ src.color.g = (*psrc & src.fmt->Gmask) >> src.fmt->Gshift;
135
+ src.color.b = (*psrc & src.fmt->Bmask) >> src.fmt->Bshift;
136
+ *tp = (((src.color.r * a1 + dst.color.r * a2) >> 8)) << dst.fmt->Rshift |
137
+ (((src.color.g * a1 + dst.color.g * a2) >> 8)) << dst.fmt->Gshift |
138
+ (((src.color.b * a1 + dst.color.b * a2) >> 8)) << dst.fmt->Bshift |
139
+ 0xff;
140
+ #endif
141
+ tp++;
142
+ }
143
+ }
144
+
145
+ SDL_UnlockSurface(src.surface);
146
+ SDL_UnlockSurface(dst.surface);
147
+
148
+ return vdst;
149
+ }
150
+
151
+ /*
152
+ 画像を拡大・縮小・鏡像(ミラー反転)させて貼り付ける
153
+ */
154
+ static VALUE bitmap_miyako_scale(VALUE self, VALUE vsrc, VALUE vdst, VALUE xscale, VALUE yscale)
155
+ {
156
+ MiyakoBitmap src, dst;
157
+ MiyakoSize size;
158
+ SDL_Surface *scr = GetSurface(rb_iv_get(mScreen, "@@screen"))->surface;
159
+
160
+ _miyako_setup_unit_2(vsrc, vdst, scr, &src, &dst, Qnil, Qnil, 1);
161
+
162
+ if(_miyako_init_rect(&src, &dst, &size) == 0) return Qnil;
163
+
164
+ if(src.surface == dst.surface){ return Qnil; }
165
+
166
+ if(dst.rect.w >= 32768 || dst.rect.h >= 32768){ return Qnil; }
167
+
168
+ double tscx = NUM2DBL(xscale);
169
+ double tscy = NUM2DBL(yscale);
170
+
171
+ if(tscx == 0.0 || tscy == 0.0){ return Qnil; }
172
+
173
+ int scx = (int)(4096.0 / tscx);
174
+ int scy = (int)(4096.0 / tscy);
175
+
176
+ int off_x = scx < 0 ? 1 : 0;
177
+ int off_y = scy < 0 ? 1 : 0;
178
+
179
+ int px = -(NUM2INT(*(RSTRUCT_PTR(src.unit)+7)));
180
+ int py = -(NUM2INT(*(RSTRUCT_PTR(src.unit)+8)));
181
+ int pr = src.rect.w + px;
182
+ int pb = src.rect.h + py;
183
+ int qx = -(NUM2INT(*(RSTRUCT_PTR(dst.unit)+7)));
184
+ int qy = -(NUM2INT(*(RSTRUCT_PTR(dst.unit)+8)));
185
+ int qr = dst.rect.w + qx;
186
+ int qb = dst.rect.h + qy;
187
+
188
+ SDL_LockSurface(src.surface);
189
+ SDL_LockSurface(dst.surface);
190
+
191
+ int x, y;
192
+ for(y = qy; y < qb; y++)
193
+ {
194
+ Uint32 *tp = dst.ptr + (dst.rect.y + y - qy) * dst.surface->w + dst.rect.x;
195
+ for(x = qx; x < qr; x++)
196
+ {
197
+ int nx = (x*scx) >> 12 - off_x;
198
+ if(nx < px || nx >= pr){ tp++; continue; }
199
+ int ny = (y*scy) >> 12 - off_y;
200
+ if(ny < py || ny >= pb){ tp++; continue; }
201
+ #if SDL_BYTEORDER == SDL_LIL_ENDIAN
202
+ dst.color.r = (*tp >> 16) & 0xff;
203
+ dst.color.g = (*tp >> 8) & 0xff;
204
+ dst.color.b = (*tp ) & 0xff;
205
+ dst.color.a = (*tp >> 24) & 0xff | dst.a255;
206
+ Uint32 *psrc = src.ptr + (src.rect.x + ny - py) * src.surface->w + src.rect.x + nx - px;
207
+ src.color.a = (*psrc >> 24) & 0xff | src.a255;
208
+ if(src.color.a == 0){ tp++; continue; }
209
+ if(dst.color.a == 0 || src.color.a == 255)
210
+ {
211
+ *tp = *psrc;
212
+ tp++;
213
+ continue;
214
+ }
215
+ int a1 = src.color.a + 1;
216
+ int a2 = 256 - src.color.a;
217
+ src.color.r = (*psrc >> 16) & 0xff;
218
+ src.color.g = (*psrc >> 8) & 0xff;
219
+ src.color.b = (*psrc ) & 0xff;
220
+ *tp = ((src.color.r * a1 + dst.color.r * a2) >> 8) << 16 |
221
+ ((src.color.g * a1 + dst.color.g * a2) >> 8) << 8 |
222
+ ((src.color.b * a1 + dst.color.b * a2) >> 8) |
223
+ 0xff << 24;
224
+ #else
225
+ dst.color.r = (*tp & dst.fmt->Rmask) >> dst.fmt->Rshift;
226
+ dst.color.g = (*tp & dst.fmt->Gmask) >> dst.fmt->Gshift;
227
+ dst.color.b = (*tp & dst.fmt->Bmask) >> dst.fmt->Bshift;
228
+ dst.color.a = (*tp & dst.fmt->Amask) | dst.a255;
229
+ Uint32 *psrc = src.ptr + (src.rect.x + ny - py) * src.surface->w + src.rect.x + nx - px;
230
+ src.color.a = (*psrc & src.fmt->Amask) | src.a255;
231
+ if(src.color.a == 0){ tp++; continue; }
232
+ if(dst.color.a == 0 || src.color.a == 255)
233
+ {
234
+ *tp = *psrc;
235
+ tp++;
236
+ continue;
237
+ }
238
+ int a1 = src.color.a + 1;
239
+ int a2 = 256 - src.color.a;
240
+ src.color.r = (*psrc & src.fmt->Rmask) >> src.fmt->Rshift;
241
+ src.color.g = (*psrc & src.fmt->Gmask) >> src.fmt->Gshift;
242
+ src.color.b = (*psrc & src.fmt->Bmask) >> src.fmt->Bshift;
243
+ *tp = ((src.color.r * a1 + dst.color.r * a2) >> 8) << dst.fmt->Rshift |
244
+ ((src.color.g * a1 + dst.color.g * a2) >> 8) << dst.fmt->Gshift |
245
+ ((src.color.b * a1 + dst.color.b * a2) >> 8) << dst.fmt->Bshift |
246
+ 0xff;
247
+ #endif
248
+ tp++;
249
+ }
250
+ }
251
+
252
+ SDL_UnlockSurface(src.surface);
253
+ SDL_UnlockSurface(dst.surface);
254
+
255
+ return vdst;
256
+ }
257
+
258
+ /*
259
+ ===回転・拡大・縮小・鏡像用インナーメソッド
260
+ */
261
+ static void transform_inner(MiyakoBitmap *src, MiyakoBitmap *dst, VALUE radian, VALUE xscale, VALUE yscale)
262
+ {
263
+ if(dst->rect.w >= 32768 || dst->rect.h >= 32768) return;
264
+
265
+ MiyakoSize size;
266
+
267
+ if(_miyako_init_rect(src, dst, &size) == 0) return;
268
+
269
+ double rad = NUM2DBL(radian) * -1.0;
270
+ long isin = (long)(sin(rad)*4096.0);
271
+ long icos = (long)(cos(rad)*4096.0);
272
+
273
+ double tscx = NUM2DBL(xscale);
274
+ double tscy = NUM2DBL(yscale);
275
+
276
+ if(tscx == 0.0 || tscy == 0.0) return;
277
+
278
+ int scx = (int)(4096.0 / tscx);
279
+ int scy = (int)(4096.0 / tscy);
280
+
281
+ int off_x = scx < 0 ? 1 : 0;
282
+ int off_y = scy < 0 ? 1 : 0;
283
+
284
+ int px = -(NUM2INT(*(RSTRUCT_PTR(src->unit)+7)));
285
+ int py = -(NUM2INT(*(RSTRUCT_PTR(src->unit)+8)));
286
+ int pr = src->rect.w + px;
287
+ int pb = src->rect.h + py;
288
+ int qx = -(NUM2INT(*(RSTRUCT_PTR(dst->unit)+7)));
289
+ int qy = -(NUM2INT(*(RSTRUCT_PTR(dst->unit)+8)));
290
+ int qr = dst->rect.w + qx;
291
+ int qb = dst->rect.h + qy;
292
+
293
+ SDL_LockSurface(src->surface);
294
+ SDL_LockSurface(dst->surface);
295
+
296
+ int x, y;
297
+ for(y = qy; y < qb; y++)
298
+ {
299
+ Uint32 *tp = dst->ptr + (dst->rect.y + y - qy) * dst->surface->w + dst->rect.x;
300
+ for(x = qx; x < qr; x++)
301
+ {
302
+ int nx = (((x*icos-y*isin) >> 12) * scx) >> 12 - off_x;
303
+ if(nx < px || nx >= pr){ tp++; continue; }
304
+ int ny = (((x*isin+y*icos) >> 12) * scy) >> 12 - off_y;
305
+ if(ny < py || ny >= pb){ tp++; continue; }
306
+ #if SDL_BYTEORDER == SDL_LIL_ENDIAN
307
+ dst->color.r = (*tp >> 16) & 0xff;
308
+ dst->color.g = (*tp >> 8) & 0xff;
309
+ dst->color.b = (*tp ) & 0xff;
310
+ dst->color.a = (*tp >> 24) & 0xff | dst->a255;
311
+ Uint32 *psrc = src->ptr + (src->rect.x + ny - py) * src->surface->w + src->rect.x + nx - px;
312
+ src->color.a = (*psrc >> 24) & 0xff | src->a255;
313
+ if(src->color.a == 0){ tp++; continue; }
314
+ if(dst->color.a == 0 || src->color.a == 255)
315
+ {
316
+ *tp = *psrc;
317
+ tp++;
318
+ continue;
319
+ }
320
+ int a1 = src->color.a + 1;
321
+ int a2 = 256 - src->color.a;
322
+ src->color.r = (*psrc >> 16) & 0xff;
323
+ src->color.g = (*psrc >> 8) & 0xff;
324
+ src->color.b = (*psrc ) & 0xff;
325
+ *tp = ((src->color.r * a1 + dst->color.r * a2) >> 8) << 16 |
326
+ ((src->color.g * a1 + dst->color.g * a2) >> 8) << 8 |
327
+ ((src->color.b * a1 + dst->color.b * a2) >> 8) |
328
+ 0xff << 24;
329
+ #else
330
+ dst->color.r = (*tp & dst->fmt->Rmask) >> dst->fmt->Rshift;
331
+ dst->color.g = (*tp & dst->fmt->Gmask) >> dst->fmt->Gshift;
332
+ dst->color.b = (*tp & dst->fmt->Bmask) >> dst->fmt->Bshift;
333
+ dst->color.a = (*tp & dst->fmt->Amask) | dst->a255;
334
+ Uint32 *psrc = src->ptr + (src->rect.x + ny - py) * src->surface->w + src->rect.x + nx - px;
335
+ src->color.a = (*psrc & src->fmt->Amask) | src->a255;
336
+ if(src->color.a == 0){ tp++; continue; }
337
+ if(dst->color.a == 0 || src->color.a == 255)
338
+ {
339
+ *tp = *psrc;
340
+ tp++;
341
+ continue;
342
+ }
343
+ int a1 = src->color.a + 1;
344
+ int a2 = 256 - src->color.a;
345
+ src->color.r = (*psrc & src->fmt->Rmask) >> src->fmt->Rshift;
346
+ src->color.g = (*psrc & src->fmt->Gmask) >> src->fmt->Gshift;
347
+ src->color.b = (*psrc & src->fmt->Bmask) >> src->fmt->Bshift;
348
+ *tp = ((src->color.r * a1 + dst->color.r * a2) >> 8) << dst->fmt->Rshift |
349
+ ((src->color.g * a1 + dst->color.g * a2) >> 8) << dst->fmt->Gshift |
350
+ ((src->color.b * a1 + dst->color.b * a2) >> 8) << dst->fmt->Bshift |
351
+ 0xff;
352
+ #endif
353
+ tp++;
354
+ }
355
+ }
356
+
357
+ SDL_UnlockSurface(src->surface);
358
+ SDL_UnlockSurface(dst->surface);
359
+ }
360
+
361
+ /*
362
+ 画像を変形(回転・拡大・縮小・鏡像)させて貼り付ける
363
+ */
364
+ static VALUE bitmap_miyako_transform(VALUE self, VALUE vsrc, VALUE vdst, VALUE radian, VALUE xscale, VALUE yscale)
365
+ {
366
+ MiyakoBitmap src, dst;
367
+ SDL_Surface *scr = GetSurface(rb_iv_get(mScreen, "@@screen"))->surface;
368
+
369
+ _miyako_setup_unit_2(vsrc, vdst, scr, &src, &dst, Qnil, Qnil, 1);
370
+
371
+ if(src.surface == dst.surface){ return Qnil; }
372
+
373
+ transform_inner(&src, &dst, radian, xscale, yscale);
374
+ return vdst;
375
+ }
376
+
377
+ /*
378
+ インスタンスの内容を画面に描画する(回転/拡大/縮小/鏡像付き)
379
+ */
380
+ static VALUE sprite_render_transform(VALUE self, VALUE radian, VALUE xscale, VALUE yscale)
381
+ {
382
+ VALUE visible = rb_iv_get(self, "@visible");
383
+ if(visible == Qfalse) return self;
384
+ MiyakoBitmap src, dst;
385
+ SDL_Surface *scr = GetSurface(rb_iv_get(mScreen, "@@screen"))->surface;
386
+
387
+ _miyako_setup_unit_2(self, mScreen, scr, &src, &dst, Qnil, Qnil, 1);
388
+
389
+ if(src.surface == dst.surface){ return Qnil; }
390
+
391
+ transform_inner(&src, &dst, radian, xscale, yscale);
392
+ return self;
393
+ }
394
+
395
+ /*
396
+ インスタンスの内容を画面に描画する(回転/拡大/縮小/鏡像付き)
397
+ */
398
+ static VALUE sprite_render_to_sprite_transform(VALUE self, VALUE vdst, VALUE radian, VALUE xscale, VALUE yscale)
399
+ {
400
+ VALUE visible = rb_iv_get(self, "@visible");
401
+ if(visible == Qfalse) return self;
402
+ MiyakoBitmap src, dst;
403
+ SDL_Surface *scr = GetSurface(rb_iv_get(mScreen, "@@screen"))->surface;
404
+
405
+ _miyako_setup_unit_2(self, vdst, scr, &src, &dst, Qnil, Qnil, 1);
406
+
407
+ if(src.surface == dst.surface){ return Qnil; }
408
+
409
+ transform_inner(&src, &dst, radian, xscale, yscale);
410
+ return self;
411
+ }
412
+
413
+ void Init_miyako_transform()
414
+ {
415
+ mSDL = rb_define_module("SDL");
416
+ mMiyako = rb_define_module("Miyako");
417
+ mScreen = rb_define_module_under(mMiyako, "Screen");
418
+ cSurface = rb_define_class_under(mSDL, "Surface", rb_cObject);
419
+ cBitmap = rb_define_class_under(mMiyako, "Bitmap", rb_cObject);
420
+ cSprite = rb_define_class_under(mMiyako, "Sprite", rb_cObject);
421
+
422
+ rb_define_method(cSprite, "render_transform", sprite_render_transform, 3);
423
+ rb_define_method(cSprite, "render_to_transform", sprite_render_to_sprite_transform, 4);
424
+
425
+ id_update = rb_intern("update");
426
+ id_kakko = rb_intern("[]");
427
+ id_render = rb_intern("render");
428
+ id_to_a = rb_intern("to_a");
429
+
430
+ zero = 0;
431
+ nZero = INT2NUM(zero);
432
+ one = 1;
433
+ nOne = INT2NUM(one);
434
+
435
+ rb_define_singleton_method(cBitmap, "rotate", bitmap_miyako_rotate, 3);
436
+ rb_define_singleton_method(cBitmap, "scale", bitmap_miyako_scale, 4);
437
+ rb_define_singleton_method(cBitmap, "transform", bitmap_miyako_transform, 5);
438
+ }