ruby-miyako 2.1.4 → 2.1.5
Sign up to get free protection for your applications and to get access to all the features.
- data/README +42 -5
- data/lib/Miyako/API/choices.rb +0 -2
- data/lib/Miyako/API/collision.rb +0 -4
- data/lib/Miyako/API/fixedmap.rb +0 -3
- data/lib/Miyako/API/i_yuki.rb +28 -46
- data/lib/Miyako/API/layout.rb +0 -1
- data/lib/Miyako/API/map.rb +0 -2
- data/lib/Miyako/API/map_event.rb +0 -3
- data/lib/Miyako/API/map_struct.rb +0 -2
- data/lib/Miyako/API/parts.rb +0 -11
- data/lib/Miyako/API/screen.rb +3 -4
- data/lib/Miyako/API/shape.rb +27 -27
- data/lib/Miyako/API/sprite.rb +0 -2
- data/lib/Miyako/API/story.rb +0 -2
- data/lib/Miyako/API/textbox.rb +9 -11
- data/lib/Miyako/API/utility.rb +2 -2
- data/lib/Miyako/API/yuki.rb +19 -8
- data/lib/Miyako/miyako.rb +3 -0
- data/miyako_basicdata.c +52 -5
- data/miyako_bitmap.c +351 -342
- data/miyako_collision.c +77 -67
- data/miyako_diagram.c +22 -21
- data/miyako_drawing.c +9 -6
- data/miyako_font.c +63 -53
- data/miyako_hsv.c +428 -436
- data/miyako_input_audio.c +17 -14
- data/miyako_layout.c +23 -18
- data/miyako_no_katana.c +284 -248
- data/miyako_sprite2.c +30 -18
- data/miyako_transform.c +95 -93
- data/miyako_utility.c +9 -18
- data/miyako_yuki.c +10 -6
- data/sample/Diagram_sample/diagram_sample_yuki2.rb +2 -2
- data/sample/Room3/room3.rb +8 -10
- data/sample/ball_action_sample.rb +8 -8
- data/sample/map_test/main_scene.rb +1 -1
- data/sample/map_test/map_test.rb +8 -8
- data/sample/takahashi.rb +14 -14
- data/win/miyako_no_katana.so +0 -0
- metadata +6 -4
data/miyako_bitmap.c
CHANGED
@@ -20,8 +20,8 @@ Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
|
20
20
|
*/
|
21
21
|
|
22
22
|
/*
|
23
|
-
|
24
|
-
Authors::
|
23
|
+
=miyako_no_katana
|
24
|
+
Authors:: Cyross Makoto
|
25
25
|
Version:: 2.0
|
26
26
|
Copyright:: 2007-2008 Cyross Makoto
|
27
27
|
License:: LGPL2.1
|
@@ -48,28 +48,28 @@ static volatile int one = Qnil;
|
|
48
48
|
static GLOBAL_DEFINE_GET_STRUCT(Surface, GetSurface, cSurface, "SDL::Surface");
|
49
49
|
|
50
50
|
/*
|
51
|
-
|
51
|
+
:nodoc:
|
52
52
|
*/
|
53
53
|
static VALUE bitmap_miyako_blit_aa(VALUE self, VALUE vsrc, VALUE vdst, VALUE vx, VALUE vy)
|
54
54
|
{
|
55
55
|
MiyakoBitmap src, dst;
|
56
56
|
MiyakoSize size;
|
57
|
-
|
57
|
+
SDL_Surface *scr = GetSurface(rb_iv_get(mScreen, "@@screen"))->surface;
|
58
|
+
int x, y, a1, a2;
|
58
59
|
|
59
60
|
_miyako_setup_unit_2(vsrc, vdst, scr, &src, &dst, vx, vy, 1);
|
60
61
|
|
61
62
|
if(_miyako_init_rect(&src, &dst, &size) == 0) return Qnil;
|
62
|
-
|
63
|
-
|
64
|
-
|
65
|
-
|
66
|
-
|
67
|
-
|
68
|
-
{
|
63
|
+
|
64
|
+
SDL_LockSurface(src.surface);
|
65
|
+
SDL_LockSurface(dst.surface);
|
66
|
+
|
67
|
+
for(y = 0; y < size.h; y++)
|
68
|
+
{
|
69
69
|
Uint32 *ppsrc = src.ptr + (src.rect.y + y) * src.surface->w + src.rect.x;
|
70
70
|
Uint32 *ppdst = dst.ptr + (dst.rect.y + src.y + y) * dst.surface->w + dst.rect.x + src.x;
|
71
|
-
|
72
|
-
|
71
|
+
for(x = 0; x < size.w; x++)
|
72
|
+
{
|
73
73
|
#if SDL_BYTEORDER == SDL_LIL_ENDIAN
|
74
74
|
dst.color.a = (*ppdst >> 24) & 0xff | dst.a255;
|
75
75
|
src.color.a = (*ppsrc >> 24) & 0xff | src.a255;
|
@@ -86,8 +86,8 @@ static VALUE bitmap_miyako_blit_aa(VALUE self, VALUE vsrc, VALUE vdst, VALUE vx,
|
|
86
86
|
src.color.r = (*ppsrc >> 16) & 0xff;
|
87
87
|
src.color.g = (*ppsrc >> 8) & 0xff;
|
88
88
|
src.color.b = (*ppsrc ) & 0xff;
|
89
|
-
|
90
|
-
|
89
|
+
a1 = src.color.a + 1;
|
90
|
+
a2 = 256 - src.color.a;
|
91
91
|
*ppdst = ((src.color.r * a1 + dst.color.r * a2) >> 8) << 16 |
|
92
92
|
((src.color.g * a1 + dst.color.g * a2) >> 8) << 8 |
|
93
93
|
((src.color.b * a1 + dst.color.b * a2) >> 8) |
|
@@ -120,35 +120,36 @@ static VALUE bitmap_miyako_blit_aa(VALUE self, VALUE vsrc, VALUE vdst, VALUE vx,
|
|
120
120
|
}
|
121
121
|
}
|
122
122
|
|
123
|
-
|
124
|
-
|
123
|
+
SDL_UnlockSurface(src.surface);
|
124
|
+
SDL_UnlockSurface(dst.surface);
|
125
125
|
|
126
126
|
return vdst;
|
127
127
|
}
|
128
128
|
|
129
129
|
/*
|
130
|
-
|
130
|
+
:nodoc:
|
131
131
|
*/
|
132
132
|
static VALUE bitmap_miyako_blit_and(VALUE self, VALUE vsrc, VALUE vdst)
|
133
133
|
{
|
134
134
|
MiyakoBitmap src, dst;
|
135
135
|
MiyakoSize size;
|
136
|
-
|
136
|
+
SDL_Surface *scr = GetSurface(rb_iv_get(mScreen, "@@screen"))->surface;
|
137
|
+
int x, y;
|
138
|
+
Uint32 *ppsrc, *ppdst;
|
137
139
|
|
138
140
|
_miyako_setup_unit_2(vsrc, vdst, scr, &src, &dst, Qnil, Qnil, 1);
|
139
141
|
|
140
142
|
if(_miyako_init_rect(&src, &dst, &size) == 0) return Qnil;
|
141
|
-
|
142
|
-
|
143
|
-
|
144
|
-
|
145
|
-
|
146
|
-
|
147
|
-
|
148
|
-
|
149
|
-
|
150
|
-
|
151
|
-
{
|
143
|
+
|
144
|
+
SDL_LockSurface(src.surface);
|
145
|
+
SDL_LockSurface(dst.surface);
|
146
|
+
|
147
|
+
for(y = 0; y < size.h; y++)
|
148
|
+
{
|
149
|
+
ppsrc = src.ptr + (src.rect.y + y) * src.surface->w + src.rect.x;
|
150
|
+
ppdst = dst.ptr + (dst.rect.y + src.y + y) * dst.surface->w + dst.rect.x + src.x;
|
151
|
+
for(x = 0; x < size.w; x++)
|
152
|
+
{
|
152
153
|
#if SDL_BYTEORDER == SDL_LIL_ENDIAN
|
153
154
|
src.color.a = (*ppsrc >> 24) & 0xff | src.a255;
|
154
155
|
dst.color.a = (*ppdst >> 24) & 0xff | dst.a255;
|
@@ -167,36 +168,37 @@ static VALUE bitmap_miyako_blit_and(VALUE self, VALUE vsrc, VALUE vdst)
|
|
167
168
|
}
|
168
169
|
}
|
169
170
|
|
170
|
-
|
171
|
-
|
171
|
+
SDL_UnlockSurface(src.surface);
|
172
|
+
SDL_UnlockSurface(dst.surface);
|
172
173
|
|
173
174
|
return vdst;
|
174
175
|
}
|
175
176
|
|
176
177
|
|
177
178
|
/*
|
178
|
-
|
179
|
+
:nodoc:
|
179
180
|
*/
|
180
181
|
static VALUE bitmap_miyako_blit_or(VALUE self, VALUE vsrc, VALUE vdst)
|
181
182
|
{
|
182
183
|
MiyakoBitmap src, dst;
|
183
184
|
MiyakoSize size;
|
184
|
-
|
185
|
+
SDL_Surface *scr = GetSurface(rb_iv_get(mScreen, "@@screen"))->surface;
|
186
|
+
int x, y;
|
187
|
+
Uint32 *ppsrc, *ppdst;
|
185
188
|
|
186
189
|
_miyako_setup_unit_2(vsrc, vdst, scr, &src, &dst, Qnil, Qnil, 1);
|
187
190
|
|
188
191
|
if(_miyako_init_rect(&src, &dst, &size) == 0) return Qnil;
|
189
|
-
|
190
|
-
|
191
|
-
|
192
|
-
|
193
|
-
|
194
|
-
|
195
|
-
|
196
|
-
|
197
|
-
|
198
|
-
|
199
|
-
{
|
192
|
+
|
193
|
+
SDL_LockSurface(src.surface);
|
194
|
+
SDL_LockSurface(dst.surface);
|
195
|
+
|
196
|
+
for(y = 0; y < size.h; y++)
|
197
|
+
{
|
198
|
+
ppsrc = src.ptr + (src.rect.y + y) * src.surface->w + src.rect.x;
|
199
|
+
ppdst = dst.ptr + (dst.rect.y + src.y + y) * dst.surface->w + dst.rect.x + src.x;
|
200
|
+
for(x = 0; x < size.w; x++)
|
201
|
+
{
|
200
202
|
#if SDL_BYTEORDER == SDL_LIL_ENDIAN
|
201
203
|
src.color.a = (*ppsrc >> 24) & 0xff | src.a255;
|
202
204
|
dst.color.a = (*ppdst >> 24) & 0xff | dst.a255;
|
@@ -215,36 +217,37 @@ static VALUE bitmap_miyako_blit_or(VALUE self, VALUE vsrc, VALUE vdst)
|
|
215
217
|
}
|
216
218
|
}
|
217
219
|
|
218
|
-
|
219
|
-
|
220
|
+
SDL_UnlockSurface(src.surface);
|
221
|
+
SDL_UnlockSurface(dst.surface);
|
220
222
|
|
221
223
|
return vdst;
|
222
224
|
}
|
223
225
|
|
224
226
|
|
225
227
|
/*
|
226
|
-
|
228
|
+
:nodoc:
|
227
229
|
*/
|
228
230
|
static VALUE bitmap_miyako_blit_xor(VALUE self, VALUE vsrc, VALUE vdst)
|
229
231
|
{
|
230
232
|
MiyakoBitmap src, dst;
|
231
233
|
MiyakoSize size;
|
232
|
-
|
234
|
+
SDL_Surface *scr = GetSurface(rb_iv_get(mScreen, "@@screen"))->surface;
|
235
|
+
int x, y;
|
236
|
+
Uint32 *ppsrc, *ppdst;
|
233
237
|
|
234
238
|
_miyako_setup_unit_2(vsrc, vdst, scr, &src, &dst, Qnil, Qnil, 1);
|
235
239
|
|
236
240
|
if(_miyako_init_rect(&src, &dst, &size) == 0) return Qnil;
|
237
|
-
|
238
|
-
|
239
|
-
|
240
|
-
|
241
|
-
|
242
|
-
|
243
|
-
|
244
|
-
|
245
|
-
|
246
|
-
|
247
|
-
{
|
241
|
+
|
242
|
+
SDL_LockSurface(src.surface);
|
243
|
+
SDL_LockSurface(dst.surface);
|
244
|
+
|
245
|
+
for(y = 0; y < size.h; y++)
|
246
|
+
{
|
247
|
+
ppsrc = src.ptr + (src.rect.y + y) * src.surface->w + src.rect.x;
|
248
|
+
ppdst = dst.ptr + (dst.rect.y + src.y + y) * dst.surface->w + dst.rect.x + src.x;
|
249
|
+
for(x = 0; x < size.w; x++)
|
250
|
+
{
|
248
251
|
#if SDL_BYTEORDER == SDL_LIL_ENDIAN
|
249
252
|
src.color.a = (*ppsrc >> 24) & 0xff | src.a255;
|
250
253
|
dst.color.a = (*ppdst >> 24) & 0xff | dst.a255;
|
@@ -263,40 +266,41 @@ static VALUE bitmap_miyako_blit_xor(VALUE self, VALUE vsrc, VALUE vdst)
|
|
263
266
|
}
|
264
267
|
}
|
265
268
|
|
266
|
-
|
267
|
-
|
269
|
+
SDL_UnlockSurface(src.surface);
|
270
|
+
SDL_UnlockSurface(dst.surface);
|
268
271
|
|
269
272
|
return vdst;
|
270
273
|
}
|
271
274
|
|
272
275
|
/*
|
273
|
-
|
276
|
+
:nodoc:
|
274
277
|
*/
|
275
278
|
static VALUE bitmap_miyako_colorkey_to_alphachannel(VALUE self, VALUE vsrc, VALUE vdst, VALUE vcolor_key)
|
276
279
|
{
|
277
280
|
MiyakoBitmap src, dst;
|
278
281
|
MiyakoSize size;
|
279
|
-
|
280
|
-
|
282
|
+
SDL_Surface *scr = GetSurface(rb_iv_get(mScreen, "@@screen"))->surface;
|
283
|
+
MiyakoColor color_key;
|
284
|
+
int x, y;
|
285
|
+
Uint32 *ppsrc, *ppdst;
|
281
286
|
|
282
287
|
_miyako_setup_unit_2(vsrc, vdst, scr, &src, &dst, Qnil, Qnil, 1);
|
283
|
-
|
288
|
+
|
284
289
|
if(_miyako_init_rect(&src, &dst, &size) == 0) return Qnil;
|
285
290
|
|
286
|
-
|
287
|
-
|
288
|
-
|
291
|
+
color_key.r = NUM2INT(*(RARRAY_PTR(vcolor_key) + 0));
|
292
|
+
color_key.g = NUM2INT(*(RARRAY_PTR(vcolor_key) + 1));
|
293
|
+
color_key.b = NUM2INT(*(RARRAY_PTR(vcolor_key) + 2));
|
289
294
|
|
290
|
-
|
291
|
-
|
292
|
-
|
293
|
-
|
294
|
-
|
295
|
-
|
296
|
-
|
297
|
-
|
298
|
-
|
299
|
-
{
|
295
|
+
SDL_LockSurface(src.surface);
|
296
|
+
SDL_LockSurface(dst.surface);
|
297
|
+
|
298
|
+
for(y = 0; y < size.h; y++)
|
299
|
+
{
|
300
|
+
ppsrc = src.ptr + (src.rect.y + y) * src.surface->w + src.rect.x;
|
301
|
+
ppdst = dst.ptr + (dst.rect.y + src.y + y) * dst.surface->w + dst.rect.x + src.x;
|
302
|
+
for(x = 0; x < size.w; x++)
|
303
|
+
{
|
300
304
|
#if SDL_BYTEORDER == SDL_LIL_ENDIAN
|
301
305
|
src.color.r = (*ppsrc >> 16) & 0xff;
|
302
306
|
src.color.g = (*ppsrc >> 8) & 0xff;
|
@@ -315,35 +319,35 @@ static VALUE bitmap_miyako_colorkey_to_alphachannel(VALUE self, VALUE vsrc, VALU
|
|
315
319
|
}
|
316
320
|
}
|
317
321
|
|
318
|
-
|
319
|
-
|
322
|
+
SDL_UnlockSurface(src.surface);
|
323
|
+
SDL_UnlockSurface(dst.surface);
|
320
324
|
|
321
325
|
return vdst;
|
322
326
|
}
|
323
327
|
|
324
328
|
/*
|
325
|
-
画像のαチャネルを255に拡張する
|
326
329
|
*/
|
327
330
|
static VALUE bitmap_miyako_reset_alphachannel(VALUE self, VALUE vsrc, VALUE vdst)
|
328
331
|
{
|
329
332
|
MiyakoBitmap src, dst;
|
330
333
|
MiyakoSize size;
|
331
|
-
|
334
|
+
SDL_Surface *scr = GetSurface(rb_iv_get(mScreen, "@@screen"))->surface;
|
335
|
+
int x, y;
|
336
|
+
Uint32 *ppsrc, *ppdst;
|
332
337
|
|
333
338
|
_miyako_setup_unit_2(vsrc, vdst, scr, &src, &dst, Qnil, Qnil, 1);
|
334
339
|
|
335
340
|
if(_miyako_init_rect(&src, &dst, &size) == 0) return Qnil;
|
336
|
-
|
337
|
-
|
338
|
-
|
339
|
-
|
340
|
-
|
341
|
-
|
342
|
-
|
343
|
-
|
344
|
-
|
345
|
-
|
346
|
-
{
|
341
|
+
|
342
|
+
SDL_LockSurface(src.surface);
|
343
|
+
SDL_LockSurface(dst.surface);
|
344
|
+
|
345
|
+
for(y = 0; y < size.h; y++)
|
346
|
+
{
|
347
|
+
ppsrc = src.ptr + (src.rect.y + y) * src.surface->w + src.rect.x;
|
348
|
+
ppdst = dst.ptr + (dst.rect.y + src.y + y) * dst.surface->w + dst.rect.x + src.x;
|
349
|
+
for(x = 0; x < size.w; x++)
|
350
|
+
{
|
347
351
|
#if SDL_BYTEORDER == SDL_LIL_ENDIAN
|
348
352
|
*ppdst = *ppsrc | (0xff << 24);
|
349
353
|
#else
|
@@ -354,35 +358,35 @@ static VALUE bitmap_miyako_reset_alphachannel(VALUE self, VALUE vsrc, VALUE vdst
|
|
354
358
|
}
|
355
359
|
}
|
356
360
|
|
357
|
-
|
358
|
-
|
361
|
+
SDL_UnlockSurface(src.surface);
|
362
|
+
SDL_UnlockSurface(dst.surface);
|
359
363
|
|
360
364
|
return vdst;
|
361
365
|
}
|
362
366
|
|
363
367
|
/*
|
364
|
-
画像をαチャネル付き画像へ転送する
|
365
368
|
*/
|
366
369
|
static VALUE bitmap_miyako_colorkey_to_alphachannel_self(VALUE self, VALUE vdst, VALUE vcolor_key)
|
367
370
|
{
|
368
371
|
MiyakoBitmap dst;
|
369
|
-
|
370
|
-
|
372
|
+
SDL_Surface *scr = GetSurface(rb_iv_get(mScreen, "@@screen"))->surface;
|
373
|
+
MiyakoColor color_key;
|
374
|
+
int x, y;
|
375
|
+
Uint32 *ppdst;
|
371
376
|
|
372
377
|
_miyako_setup_unit(vdst, scr, &dst, Qnil, Qnil, 1);
|
373
|
-
|
374
|
-
|
375
|
-
|
376
|
-
|
377
|
-
|
378
|
-
|
379
|
-
|
380
|
-
|
381
|
-
|
382
|
-
|
383
|
-
|
384
|
-
|
385
|
-
{
|
378
|
+
|
379
|
+
color_key.r = NUM2INT(*(RARRAY_PTR(vcolor_key) + 0));
|
380
|
+
color_key.g = NUM2INT(*(RARRAY_PTR(vcolor_key) + 1));
|
381
|
+
color_key.b = NUM2INT(*(RARRAY_PTR(vcolor_key) + 2));
|
382
|
+
|
383
|
+
SDL_LockSurface(dst.surface);
|
384
|
+
|
385
|
+
for(y = 0; y < dst.rect.h; y++)
|
386
|
+
{
|
387
|
+
ppdst = dst.ptr + (dst.rect.y + y) * dst.surface->w + dst.rect.x;
|
388
|
+
for(x = 0; x < dst.rect.w; x++)
|
389
|
+
{
|
386
390
|
#if SDL_BYTEORDER == SDL_LIL_ENDIAN
|
387
391
|
dst.color.r = (*ppdst >> 16) & 0xff;
|
388
392
|
dst.color.g = (*ppdst >> 8) & 0xff;
|
@@ -400,29 +404,29 @@ static VALUE bitmap_miyako_colorkey_to_alphachannel_self(VALUE self, VALUE vdst,
|
|
400
404
|
}
|
401
405
|
}
|
402
406
|
|
403
|
-
|
407
|
+
SDL_UnlockSurface(dst.surface);
|
404
408
|
|
405
409
|
return vdst;
|
406
410
|
}
|
407
411
|
|
408
412
|
/*
|
409
|
-
画像のαチャネルを255に拡張する
|
410
413
|
*/
|
411
414
|
static VALUE bitmap_miyako_reset_alphachannel_self(VALUE self, VALUE vdst)
|
412
415
|
{
|
413
416
|
MiyakoBitmap dst;
|
414
|
-
|
417
|
+
SDL_Surface *scr = GetSurface(rb_iv_get(mScreen, "@@screen"))->surface;
|
418
|
+
int x, y;
|
419
|
+
Uint32 *ppdst;
|
415
420
|
|
416
421
|
_miyako_setup_unit(vdst, scr, &dst, Qnil, Qnil, 1);
|
417
422
|
|
418
|
-
|
419
|
-
|
420
|
-
|
421
|
-
|
422
|
-
|
423
|
-
|
424
|
-
|
425
|
-
{
|
423
|
+
SDL_LockSurface(dst.surface);
|
424
|
+
|
425
|
+
for(y = 0; y < dst.rect.h; y++)
|
426
|
+
{
|
427
|
+
ppdst = dst.ptr + (dst.rect.y + y) * dst.surface->w + dst.rect.x;
|
428
|
+
for(x = 0; x < dst.rect.w; x++)
|
429
|
+
{
|
426
430
|
#if SDL_BYTEORDER == SDL_LIL_ENDIAN
|
427
431
|
*ppdst = *ppdst | 0xff << 24;
|
428
432
|
#else
|
@@ -432,43 +436,44 @@ static VALUE bitmap_miyako_reset_alphachannel_self(VALUE self, VALUE vdst)
|
|
432
436
|
}
|
433
437
|
}
|
434
438
|
|
435
|
-
|
439
|
+
SDL_UnlockSurface(dst.surface);
|
436
440
|
|
437
441
|
return vdst;
|
438
442
|
}
|
439
443
|
|
440
444
|
/*
|
441
|
-
画像のαチャネルの値を一定の割合で変化させて転送する
|
442
445
|
*/
|
443
446
|
static VALUE bitmap_miyako_dec_alpha(VALUE self, VALUE vsrc, VALUE vdst, VALUE degree)
|
444
447
|
{
|
445
448
|
MiyakoBitmap src, dst;
|
446
449
|
MiyakoSize size;
|
447
|
-
|
450
|
+
SDL_Surface *scr = GetSurface(rb_iv_get(mScreen, "@@screen"))->surface;
|
451
|
+
int x, y, a1, a2;
|
452
|
+
double deg;
|
453
|
+
Uint32 da, *ppsrc, *ppdst;
|
448
454
|
|
449
455
|
_miyako_setup_unit_2(vsrc, vdst, scr, &src, &dst, Qnil, Qnil, 1);
|
450
456
|
|
451
457
|
if(_miyako_init_rect(&src, &dst, &size) == 0) return Qnil;
|
452
|
-
|
453
|
-
|
458
|
+
|
459
|
+
deg = NUM2DBL(degree);
|
454
460
|
if(deg < -1.0 || deg > 1.0){
|
455
461
|
char buf[256];
|
456
462
|
sprintf(buf, "Illegal degree! : %.15g", deg);
|
457
463
|
rb_raise(eMiyakoError, buf);
|
458
464
|
}
|
459
465
|
deg = 1.0 - deg;
|
460
|
-
|
461
|
-
|
462
|
-
|
463
|
-
|
464
|
-
|
465
|
-
|
466
|
-
|
467
|
-
|
468
|
-
|
469
|
-
|
470
|
-
|
471
|
-
{
|
466
|
+
da = (Uint32)(255.0 * deg);
|
467
|
+
|
468
|
+
SDL_LockSurface(src.surface);
|
469
|
+
SDL_LockSurface(dst.surface);
|
470
|
+
|
471
|
+
for(y = 0; y < size.h; y++)
|
472
|
+
{
|
473
|
+
ppsrc = src.ptr + (src.rect.y + y) * src.surface->w + src.rect.x;
|
474
|
+
ppdst = dst.ptr + (dst.rect.y + src.y + y) * dst.surface->w + dst.rect.x + src.x;
|
475
|
+
for(x = 0; x < size.w; x++)
|
476
|
+
{
|
472
477
|
#if SDL_BYTEORDER == SDL_LIL_ENDIAN
|
473
478
|
src.color.r = (*ppsrc >> 16) & 0xff;
|
474
479
|
src.color.g = (*ppsrc >> 8) & 0xff;
|
@@ -490,8 +495,8 @@ static VALUE bitmap_miyako_dec_alpha(VALUE self, VALUE vsrc, VALUE vdst, VALUE d
|
|
490
495
|
dst.color.r = (*ppdst >> 16) & 0xff;
|
491
496
|
dst.color.g = (*ppdst >> 8) & 0xff;
|
492
497
|
dst.color.b = (*ppdst ) & 0xff;
|
493
|
-
|
494
|
-
|
498
|
+
a1 = src.color.a + 1;
|
499
|
+
a2 = 256 - src.color.a;
|
495
500
|
*ppdst = ((src.color.r * a1 + dst.color.r * a2) >> 8) << 16 |
|
496
501
|
((src.color.g * a1 + dst.color.g * a2) >> 8) << 8 |
|
497
502
|
((src.color.b * a1 + dst.color.b * a2) >> 8) |
|
@@ -505,18 +510,18 @@ static VALUE bitmap_miyako_dec_alpha(VALUE self, VALUE vsrc, VALUE vdst, VALUE d
|
|
505
510
|
if(src.color.a > 0x80000000){ src.color.a = 0; }
|
506
511
|
if(src.color.a > 255){ src.color.a = 255; }
|
507
512
|
dst.color.a = (*pdst & dst.fmt->Amask) | dst.a255;
|
508
|
-
|
509
|
-
|
513
|
+
if(dst.color.a == 0 || src.color.a == 255){
|
514
|
+
*ppdst = src.color.r << dst.fmt->Rshift |
|
510
515
|
src.color.g << dst.fmt->Gshift |
|
511
516
|
src.color.b << dst.fmt->Bshift |
|
512
517
|
src.color.a;
|
513
|
-
|
514
|
-
|
515
|
-
|
516
|
-
|
517
|
-
|
518
|
-
|
519
|
-
|
518
|
+
ppsrc++;
|
519
|
+
ppdst++;
|
520
|
+
continue;
|
521
|
+
}
|
522
|
+
a1 = src.color.a + 1;
|
523
|
+
a2 = 256 - src.color.a;
|
524
|
+
*ppdst = ((src.color.r * a1 + dst.color.r * a2) >> 8) << dst.fmt->Rshift |
|
520
525
|
((src.color.g * a1 + dst.color.g * a2) >> 8) << dst.fmt->Gshift |
|
521
526
|
((src.color.b * a1 + dst.color.b * a2) >> 8) << dst.fmt->Bshift |
|
522
527
|
0xff;
|
@@ -526,44 +531,45 @@ static VALUE bitmap_miyako_dec_alpha(VALUE self, VALUE vsrc, VALUE vdst, VALUE d
|
|
526
531
|
}
|
527
532
|
}
|
528
533
|
|
529
|
-
|
530
|
-
|
534
|
+
SDL_UnlockSurface(src.surface);
|
535
|
+
SDL_UnlockSurface(dst.surface);
|
531
536
|
|
532
537
|
return vdst;
|
533
538
|
}
|
534
539
|
|
535
540
|
/*
|
536
|
-
画像の色を一定の割合で黒に近づける(ブラックアウト)
|
537
541
|
*/
|
538
542
|
static VALUE bitmap_miyako_black_out(VALUE self, VALUE vsrc, VALUE vdst, VALUE degree)
|
539
543
|
{
|
540
544
|
MiyakoBitmap src, dst;
|
541
545
|
MiyakoSize size;
|
542
|
-
|
546
|
+
SDL_Surface *scr = GetSurface(rb_iv_get(mScreen, "@@screen"))->surface;
|
547
|
+
int x, y, a1, a2;
|
548
|
+
double deg;
|
549
|
+
Uint32 d, *ppsrc, *ppdst;
|
543
550
|
|
544
551
|
_miyako_setup_unit_2(vsrc, vdst, scr, &src, &dst, Qnil, Qnil, 1);
|
545
552
|
|
546
553
|
if(_miyako_init_rect(&src, &dst, &size) == 0) return Qnil;
|
547
|
-
|
548
|
-
|
554
|
+
|
555
|
+
deg = NUM2DBL(degree);
|
549
556
|
if(deg < -1.0 || deg > 1.0){
|
550
557
|
char buf[256];
|
551
558
|
sprintf(buf, "Illegal degree! : %.15g", deg);
|
552
559
|
rb_raise(eMiyakoError, buf);
|
553
560
|
}
|
554
561
|
deg = 1.0 - deg;
|
555
|
-
|
556
|
-
|
557
|
-
|
558
|
-
|
559
|
-
|
560
|
-
|
561
|
-
|
562
|
-
|
563
|
-
|
564
|
-
|
565
|
-
|
566
|
-
{
|
562
|
+
d = (Uint32)(255.0 * deg);
|
563
|
+
|
564
|
+
SDL_LockSurface(src.surface);
|
565
|
+
SDL_LockSurface(dst.surface);
|
566
|
+
|
567
|
+
for(y = 0; y < size.h; y++)
|
568
|
+
{
|
569
|
+
ppsrc = src.ptr + (src.rect.y + y) * src.surface->w + src.rect.x;
|
570
|
+
ppdst = dst.ptr + (dst.rect.y + src.y + y) * dst.surface->w + dst.rect.x + src.x;
|
571
|
+
for(x = 0; x < size.w; x++)
|
572
|
+
{
|
567
573
|
#if SDL_BYTEORDER == SDL_LIL_ENDIAN
|
568
574
|
src.color.r = (*ppsrc >> 16) & 0xff;
|
569
575
|
src.color.g = (*ppsrc >> 8) & 0xff;
|
@@ -584,17 +590,17 @@ static VALUE bitmap_miyako_black_out(VALUE self, VALUE vsrc, VALUE vdst, VALUE d
|
|
584
590
|
dst.color.g = (*ppdst >> 8) & 0xff;
|
585
591
|
dst.color.b = (*ppdst ) & 0xff;
|
586
592
|
dst.color.a = (*ppdst >> 24) & 0xff | dst.a255;
|
587
|
-
|
588
|
-
|
593
|
+
if(dst.color.a == 0 || src.color.a == 255){
|
594
|
+
*ppdst = src.color.r << 16 |
|
589
595
|
src.color.g << 8 |
|
590
596
|
src.color.b |
|
591
597
|
src.color.a << 24;
|
592
|
-
|
593
|
-
|
594
|
-
|
595
|
-
|
596
|
-
|
597
|
-
|
598
|
+
ppsrc++;
|
599
|
+
ppdst++;
|
600
|
+
continue;
|
601
|
+
}
|
602
|
+
a1 = src.color.a + 1;
|
603
|
+
a2 = 256 - src.color.a;
|
598
604
|
*ppdst = ((src.color.r * a1 + dst.color.r * a2) >> 8) << 16 |
|
599
605
|
((src.color.g * a1 + dst.color.g * a2) >> 8) << 8 |
|
600
606
|
((src.color.b * a1 + dst.color.b * a2) >> 8) |
|
@@ -616,18 +622,18 @@ static VALUE bitmap_miyako_black_out(VALUE self, VALUE vsrc, VALUE vdst, VALUE d
|
|
616
622
|
if(src.color.a > 0x80000000){ src.color.a = 0; }
|
617
623
|
}
|
618
624
|
dst.color.a = (*pdst & dst.fmt->Amask) | dst.a255;
|
619
|
-
|
620
|
-
|
625
|
+
if(dst.color.a == 0 || src.color.a == 255){
|
626
|
+
*ppdst = src.color.r << dst.fmt->Rshift |
|
621
627
|
src.color.g << dst.fmt->Gshift |
|
622
628
|
src.color.b << dst.fmt->Bshift |
|
623
629
|
src.color.a;
|
624
|
-
|
625
|
-
|
626
|
-
|
627
|
-
|
628
|
-
|
629
|
-
|
630
|
-
|
630
|
+
ppsrc++;
|
631
|
+
ppdst++;
|
632
|
+
continue;
|
633
|
+
}
|
634
|
+
a1 = src.color.a + 1;
|
635
|
+
a2 = 256 - src.color.a;
|
636
|
+
*ppdst = ((src.color.r * a1 + dst.color.r * a2) >> 8) << dst.fmt->Rshift |
|
631
637
|
((src.color.g * a1 + dst.color.g * a2) >> 8) << dst.fmt->Gshift |
|
632
638
|
((src.color.b * a1 + dst.color.b * a2) >> 8) << dst.fmt->Bshift |
|
633
639
|
0xff;
|
@@ -637,44 +643,45 @@ static VALUE bitmap_miyako_black_out(VALUE self, VALUE vsrc, VALUE vdst, VALUE d
|
|
637
643
|
}
|
638
644
|
}
|
639
645
|
|
640
|
-
|
641
|
-
|
646
|
+
SDL_UnlockSurface(src.surface);
|
647
|
+
SDL_UnlockSurface(dst.surface);
|
642
648
|
|
643
|
-
|
649
|
+
return vdst;
|
644
650
|
}
|
645
651
|
|
646
652
|
/*
|
647
|
-
画像の色を一定の割合で白に近づける(ホワイトアウト)
|
648
653
|
*/
|
649
654
|
static VALUE bitmap_miyako_white_out(VALUE self, VALUE vsrc, VALUE vdst, VALUE degree)
|
650
655
|
{
|
651
656
|
MiyakoBitmap src, dst;
|
652
657
|
MiyakoSize size;
|
653
|
-
|
658
|
+
SDL_Surface *scr = GetSurface(rb_iv_get(mScreen, "@@screen"))->surface;
|
659
|
+
int x, y, a1, a2;
|
660
|
+
double deg;
|
661
|
+
Uint32 d, *ppsrc, *ppdst;
|
654
662
|
|
655
663
|
_miyako_setup_unit_2(vsrc, vdst, scr, &src, &dst, Qnil, Qnil, 1);
|
656
664
|
|
657
665
|
if(_miyako_init_rect(&src, &dst, &size) == 0) return Qnil;
|
658
|
-
|
659
|
-
|
666
|
+
|
667
|
+
deg = NUM2DBL(degree);
|
660
668
|
if(deg < -1.0 || deg > 1.0){
|
661
669
|
char buf[256];
|
662
670
|
sprintf(buf, "Illegal degree! : %.15g", deg);
|
663
671
|
rb_raise(eMiyakoError, buf);
|
664
672
|
}
|
665
673
|
deg = 1.0 - deg;
|
666
|
-
|
667
|
-
|
668
|
-
|
669
|
-
|
670
|
-
|
671
|
-
|
672
|
-
|
673
|
-
|
674
|
-
|
675
|
-
|
676
|
-
|
677
|
-
{
|
674
|
+
d = (Uint32)(255.0 * deg);
|
675
|
+
|
676
|
+
SDL_LockSurface(src.surface);
|
677
|
+
SDL_LockSurface(dst.surface);
|
678
|
+
|
679
|
+
for(y = 0; y < size.h; y++)
|
680
|
+
{
|
681
|
+
ppsrc = src.ptr + (src.rect.y + y) * src.surface->w + src.rect.x;
|
682
|
+
ppdst = dst.ptr + (dst.rect.y + src.y + y) * dst.surface->w + dst.rect.x + src.x;
|
683
|
+
for(x = 0; x < size.w; x++)
|
684
|
+
{
|
678
685
|
#if SDL_BYTEORDER == SDL_LIL_ENDIAN
|
679
686
|
src.color.r = (*ppsrc >> 16) & 0xff;
|
680
687
|
src.color.g = (*ppsrc >> 8) & 0xff;
|
@@ -695,17 +702,17 @@ static VALUE bitmap_miyako_white_out(VALUE self, VALUE vsrc, VALUE vdst, VALUE d
|
|
695
702
|
dst.color.g = (*ppdst >> 8) & 0xff;
|
696
703
|
dst.color.b = (*ppdst ) & 0xff;
|
697
704
|
dst.color.a = (*ppdst >> 24) & 0xff | dst.a255;
|
698
|
-
|
699
|
-
|
705
|
+
if(dst.color.a == 0 || src.color.a == 255){
|
706
|
+
*ppdst = src.color.r << 16 |
|
700
707
|
src.color.g << 8 |
|
701
708
|
src.color.b |
|
702
709
|
src.color.a << 24;
|
703
|
-
|
704
|
-
|
705
|
-
|
706
|
-
|
707
|
-
|
708
|
-
|
710
|
+
ppsrc++;
|
711
|
+
ppdst++;
|
712
|
+
continue;
|
713
|
+
}
|
714
|
+
a1 = src.color.a + 1;
|
715
|
+
a2 = 256 - src.color.a;
|
709
716
|
*ppdst = ((src.color.r * a1 + dst.color.r * a2) >> 8) << 16 |
|
710
717
|
((src.color.g * a1 + dst.color.g * a2) >> 8) << 8 |
|
711
718
|
((src.color.b * a1 + dst.color.b * a2) >> 8) |
|
@@ -727,18 +734,18 @@ static VALUE bitmap_miyako_white_out(VALUE self, VALUE vsrc, VALUE vdst, VALUE d
|
|
727
734
|
if(src.color.a > 255){ src.color.a = 255; }
|
728
735
|
}
|
729
736
|
dst.color.a = (*pdst & dst.fmt->Amask) | dst.a255;
|
730
|
-
|
731
|
-
|
737
|
+
if(dst.color.a == 0 || src.color.a == 255){
|
738
|
+
*ppdst = src.color.r << dst.fmt->Rshift |
|
732
739
|
src.color.g << dst.fmt->Gshift |
|
733
740
|
src.color.b << dst.fmt->Bshift |
|
734
741
|
src.color.a;
|
735
|
-
|
736
|
-
|
737
|
-
|
738
|
-
|
739
|
-
|
740
|
-
|
741
|
-
|
742
|
+
ppsrc++;
|
743
|
+
ppdst++;
|
744
|
+
continue;
|
745
|
+
}
|
746
|
+
a1 = src.color.a + 1;
|
747
|
+
a2 = 256 - src.color.a;
|
748
|
+
*ppdst = ((src.color.r * a1 + dst.color.r * a2) >> 8) << dst.fmt->Rshift |
|
742
749
|
((src.color.g * a1 + dst.color.g * a2) >> 8) << dst.fmt->Gshift |
|
743
750
|
((src.color.b * a1 + dst.color.b * a2) >> 8) << dst.fmt->Bshift |
|
744
751
|
0xff;
|
@@ -748,56 +755,56 @@ static VALUE bitmap_miyako_white_out(VALUE self, VALUE vsrc, VALUE vdst, VALUE d
|
|
748
755
|
}
|
749
756
|
}
|
750
757
|
|
751
|
-
|
752
|
-
|
758
|
+
SDL_UnlockSurface(src.surface);
|
759
|
+
SDL_UnlockSurface(dst.surface);
|
753
760
|
|
754
|
-
|
761
|
+
return vdst;
|
755
762
|
}
|
756
763
|
|
757
764
|
/*
|
758
|
-
画像のRGB値を反転させる
|
759
765
|
*/
|
760
766
|
static VALUE bitmap_miyako_inverse(VALUE self, VALUE vsrc, VALUE vdst)
|
761
767
|
{
|
762
768
|
MiyakoBitmap src, dst;
|
763
769
|
MiyakoSize size;
|
764
|
-
|
770
|
+
SDL_Surface *scr = GetSurface(rb_iv_get(mScreen, "@@screen"))->surface;
|
771
|
+
int x, y, a1, a2;
|
772
|
+
Uint32 *ppsrc, *ppdst;
|
765
773
|
|
766
774
|
_miyako_setup_unit_2(vsrc, vdst, scr, &src, &dst, Qnil, Qnil, 1);
|
767
775
|
|
768
776
|
if(_miyako_init_rect(&src, &dst, &size) == 0) return Qnil;
|
769
|
-
|
770
|
-
|
771
|
-
|
772
|
-
|
773
|
-
|
774
|
-
|
775
|
-
|
776
|
-
|
777
|
-
|
778
|
-
|
779
|
-
{
|
777
|
+
|
778
|
+
SDL_LockSurface(src.surface);
|
779
|
+
SDL_LockSurface(dst.surface);
|
780
|
+
|
781
|
+
for(y = 0; y < size.h; y++)
|
782
|
+
{
|
783
|
+
ppsrc = src.ptr + (src.rect.y + y) * src.surface->w + src.rect.x;
|
784
|
+
ppdst = dst.ptr + (dst.rect.y + src.y + y) * dst.surface->w + dst.rect.x + src.x;
|
785
|
+
for(x = 0; x < size.w; x++)
|
786
|
+
{
|
780
787
|
#if SDL_BYTEORDER == SDL_LIL_ENDIAN
|
781
788
|
src.color.a = (*ppsrc >> 24) & 0xff | src.a255;
|
782
|
-
|
789
|
+
if(src.color.a == 0){ ppsrc++; ppdst++; continue; }
|
783
790
|
src.color.r = (*ppsrc >> 16) & 0xff;
|
784
791
|
src.color.g = (*ppsrc >> 8) & 0xff;
|
785
792
|
src.color.b = (*ppsrc ) & 0xff;
|
786
793
|
dst.color.a = (*ppdst >> 24) & 0xff | dst.a255;
|
787
|
-
|
788
|
-
|
794
|
+
if(dst.color.a == 0 || src.color.a == 255){
|
795
|
+
*ppdst = (src.color.r ^ 0xff) << 16 |
|
789
796
|
(src.color.g ^ 0xff) << 8 |
|
790
797
|
(src.color.b ^ 0xff) |
|
791
798
|
(src.color.a ) << 24;
|
792
|
-
|
793
|
-
|
794
|
-
|
795
|
-
|
799
|
+
ppsrc++;
|
800
|
+
ppdst++;
|
801
|
+
continue;
|
802
|
+
}
|
796
803
|
dst.color.r = (*ppdst >> 16) & 0xff;
|
797
804
|
dst.color.g = (*ppdst >> 8) & 0xff;
|
798
805
|
dst.color.b = (*ppdst ) & 0xff;
|
799
|
-
|
800
|
-
|
806
|
+
a1 = src.color.a + 1;
|
807
|
+
a2 = 256 - src.color.a;
|
801
808
|
*ppdst = (((src.color.r ^ 0xff) * a1 + dst.color.r * a2) >> 8) << 16 |
|
802
809
|
(((src.color.g ^ 0xff) * a1 + dst.color.g * a2) >> 8) << 8 |
|
803
810
|
(((src.color.b ^ 0xff) * a1 + dst.color.b * a2) >> 8) |
|
@@ -808,18 +815,18 @@ static VALUE bitmap_miyako_inverse(VALUE self, VALUE vsrc, VALUE vdst)
|
|
808
815
|
src.color.b = (*ppsrc & src.fmt->Bmask) >> src.fmt->Bshift;
|
809
816
|
src.color.a = (*ppsrc & src.fmt->Amask) | src.a255;
|
810
817
|
dst.color.a = (*ppdst & dst.fmt->Amask) | dst.a255;
|
811
|
-
|
812
|
-
|
818
|
+
if(dst.color.a == 0 || src.color.a == 255){
|
819
|
+
*ppdst = (src.color.r ^ 0xff) << dst.fmt->Rshift |
|
813
820
|
(src.color.g ^ 0xff) << dst.fmt->Gshift |
|
814
821
|
(src.color.b ^ 0xff) << dst.fmt->Bshift |
|
815
822
|
src.color.a;
|
816
|
-
|
817
|
-
|
818
|
-
|
819
|
-
|
820
|
-
|
821
|
-
|
822
|
-
|
823
|
+
ppsrc++;
|
824
|
+
ppdst++;
|
825
|
+
continue;
|
826
|
+
}
|
827
|
+
int a1 = src.color.a + 1;
|
828
|
+
int a2 = 256 - src.color.a;
|
829
|
+
*ppdst = (((src.color.r ^ 0xff) * a1 + dst.color.r * a2) >> 8) << dst.fmt->Rshift |
|
823
830
|
(((src.color.g ^ 0xff) * a1 + dst.color.g * a2) >> 8) << dst.fmt->Gshift |
|
824
831
|
(((src.color.b ^ 0xff) * a1 + dst.color.b * a2) >> 8) << dst.fmt->Bshift |
|
825
832
|
0xff;
|
@@ -829,39 +836,40 @@ static VALUE bitmap_miyako_inverse(VALUE self, VALUE vsrc, VALUE vdst)
|
|
829
836
|
}
|
830
837
|
}
|
831
838
|
|
832
|
-
|
833
|
-
|
839
|
+
SDL_UnlockSurface(src.surface);
|
840
|
+
SDL_UnlockSurface(dst.surface);
|
834
841
|
|
835
|
-
|
842
|
+
return vdst;
|
836
843
|
}
|
837
844
|
|
838
845
|
/*
|
839
|
-
画像のαチャネルの値を一定の割合で変化させて転送する
|
840
846
|
*/
|
841
847
|
static VALUE bitmap_miyako_dec_alpha_self(VALUE self, VALUE vdst, VALUE degree)
|
842
848
|
{
|
843
849
|
MiyakoBitmap dst;
|
844
|
-
|
850
|
+
SDL_Surface *scr = GetSurface(rb_iv_get(mScreen, "@@screen"))->surface;
|
851
|
+
int x, y;
|
852
|
+
double deg;
|
853
|
+
Uint32 da, *ppdst;
|
845
854
|
|
846
855
|
_miyako_setup_unit(vdst, scr, &dst, Qnil, Qnil, 1);
|
847
856
|
|
848
|
-
|
857
|
+
deg = NUM2DBL(degree);
|
849
858
|
if(deg < -1.0 || deg > 1.0){
|
850
859
|
char buf[256];
|
851
860
|
sprintf(buf, "Illegal degree! : %.15g", deg);
|
852
861
|
rb_raise(eMiyakoError, buf);
|
853
862
|
}
|
854
863
|
deg = 1.0 - deg;
|
855
|
-
|
856
|
-
|
857
|
-
|
858
|
-
|
859
|
-
|
860
|
-
|
861
|
-
|
862
|
-
|
863
|
-
|
864
|
-
{
|
864
|
+
da = (Uint32)(255.0 * deg);
|
865
|
+
|
866
|
+
SDL_LockSurface(dst.surface);
|
867
|
+
|
868
|
+
for(y = 0; y < dst.rect.h; y++)
|
869
|
+
{
|
870
|
+
ppdst = dst.ptr + (dst.rect.y + y) * dst.surface->w + dst.rect.x;
|
871
|
+
for(x = 0; x < dst.rect.w; x++)
|
872
|
+
{
|
865
873
|
#if SDL_BYTEORDER == SDL_LIL_ENDIAN
|
866
874
|
dst.color.r = (*ppdst >> 16) & 0xff;
|
867
875
|
dst.color.g = (*ppdst >> 8) & 0xff;
|
@@ -891,38 +899,39 @@ static VALUE bitmap_miyako_dec_alpha_self(VALUE self, VALUE vdst, VALUE degree)
|
|
891
899
|
}
|
892
900
|
}
|
893
901
|
|
894
|
-
|
902
|
+
SDL_UnlockSurface(dst.surface);
|
895
903
|
|
896
904
|
return vdst;
|
897
905
|
}
|
898
906
|
|
899
907
|
/*
|
900
|
-
画像の色を一定の割合で黒に近づける(ブラックアウト)
|
901
908
|
*/
|
902
909
|
static VALUE bitmap_miyako_black_out_self(VALUE self, VALUE vdst, VALUE degree)
|
903
910
|
{
|
904
911
|
MiyakoBitmap dst;
|
905
|
-
|
912
|
+
SDL_Surface *scr = GetSurface(rb_iv_get(mScreen, "@@screen"))->surface;
|
913
|
+
int x, y;
|
914
|
+
double deg;
|
915
|
+
Uint32 d, *ppdst;
|
906
916
|
|
907
917
|
_miyako_setup_unit(vdst, scr, &dst, Qnil, Qnil, 1);
|
908
918
|
|
909
|
-
|
919
|
+
deg = NUM2DBL(degree);
|
910
920
|
if(deg < -1.0 || deg > 1.0){
|
911
921
|
char buf[256];
|
912
922
|
sprintf(buf, "Illegal degree! : %.15g", deg);
|
913
923
|
rb_raise(eMiyakoError, buf);
|
914
924
|
}
|
915
925
|
deg = 1.0 - deg;
|
916
|
-
|
917
|
-
|
918
|
-
|
919
|
-
|
920
|
-
|
921
|
-
|
922
|
-
|
923
|
-
|
924
|
-
|
925
|
-
{
|
926
|
+
d = (Uint32)(255.0 * deg);
|
927
|
+
|
928
|
+
SDL_LockSurface(dst.surface);
|
929
|
+
|
930
|
+
for(y = 0; y < dst.rect.h; y++)
|
931
|
+
{
|
932
|
+
ppdst = dst.ptr + (dst.rect.y + y) * dst.surface->w + dst.rect.x;
|
933
|
+
for(x = 0; x < dst.rect.w; x++)
|
934
|
+
{
|
926
935
|
#if SDL_BYTEORDER == SDL_LIL_ENDIAN
|
927
936
|
dst.color.r = (*ppdst >> 16) & 0xff;
|
928
937
|
dst.color.g = (*ppdst >> 8) & 0xff;
|
@@ -968,38 +977,39 @@ static VALUE bitmap_miyako_black_out_self(VALUE self, VALUE vdst, VALUE degree)
|
|
968
977
|
}
|
969
978
|
}
|
970
979
|
|
971
|
-
|
980
|
+
SDL_UnlockSurface(dst.surface);
|
972
981
|
|
973
982
|
return vdst;
|
974
983
|
}
|
975
984
|
|
976
985
|
/*
|
977
|
-
画像の色を一定の割合で白に近づける(ホワイトアウト)
|
978
986
|
*/
|
979
987
|
static VALUE bitmap_miyako_white_out_self(VALUE self, VALUE vdst, VALUE degree)
|
980
988
|
{
|
981
989
|
MiyakoBitmap dst;
|
982
|
-
|
990
|
+
SDL_Surface *scr = GetSurface(rb_iv_get(mScreen, "@@screen"))->surface;
|
991
|
+
int x, y;
|
992
|
+
double deg;
|
993
|
+
Uint32 d, *ppdst;
|
983
994
|
|
984
995
|
_miyako_setup_unit(vdst, scr, &dst, Qnil, Qnil, 1);
|
985
996
|
|
986
|
-
|
997
|
+
deg = NUM2DBL(degree);
|
987
998
|
if(deg < -1.0 || deg > 1.0){
|
988
999
|
char buf[256];
|
989
1000
|
sprintf(buf, "Illegal degree! : %.15g", deg);
|
990
1001
|
rb_raise(eMiyakoError, buf);
|
991
1002
|
}
|
992
1003
|
deg = 1.0 - deg;
|
993
|
-
|
994
|
-
|
995
|
-
|
996
|
-
|
997
|
-
|
998
|
-
|
999
|
-
|
1000
|
-
|
1001
|
-
|
1002
|
-
{
|
1004
|
+
d = (Uint32)(255.0 * deg);
|
1005
|
+
|
1006
|
+
SDL_LockSurface(dst.surface);
|
1007
|
+
|
1008
|
+
for(y = 0; y < dst.rect.h; y++)
|
1009
|
+
{
|
1010
|
+
ppdst = dst.ptr + (dst.rect.y + y) * dst.surface->w + dst.rect.x;
|
1011
|
+
for(x = 0; x < dst.rect.w; x++)
|
1012
|
+
{
|
1003
1013
|
#if SDL_BYTEORDER == SDL_LIL_ENDIAN
|
1004
1014
|
dst.color.r = (*ppdst >> 16) & 0xff;
|
1005
1015
|
dst.color.g = (*ppdst >> 8) & 0xff;
|
@@ -1045,29 +1055,29 @@ static VALUE bitmap_miyako_white_out_self(VALUE self, VALUE vdst, VALUE degree)
|
|
1045
1055
|
}
|
1046
1056
|
}
|
1047
1057
|
|
1048
|
-
|
1058
|
+
SDL_UnlockSurface(dst.surface);
|
1049
1059
|
|
1050
1060
|
return vdst;
|
1051
1061
|
}
|
1052
1062
|
|
1053
1063
|
/*
|
1054
|
-
画像のRGB値を反転させる
|
1055
1064
|
*/
|
1056
1065
|
static VALUE bitmap_miyako_inverse_self(VALUE self, VALUE vdst)
|
1057
1066
|
{
|
1058
1067
|
MiyakoBitmap dst;
|
1059
1068
|
SDL_Surface *scr = GetSurface(rb_iv_get(mScreen, "@@screen"))->surface;
|
1069
|
+
int x, y;
|
1070
|
+
Uint32 *ppdst;
|
1060
1071
|
|
1061
1072
|
_miyako_setup_unit(vdst, scr, &dst, Qnil, Qnil, 1);
|
1062
1073
|
|
1063
|
-
|
1064
|
-
|
1065
|
-
|
1066
|
-
|
1067
|
-
|
1068
|
-
|
1069
|
-
|
1070
|
-
{
|
1074
|
+
SDL_LockSurface(dst.surface);
|
1075
|
+
|
1076
|
+
for(y = 0; y < dst.rect.h; y++)
|
1077
|
+
{
|
1078
|
+
ppdst = dst.ptr + (dst.rect.y + y) * dst.surface->w + dst.rect.x;
|
1079
|
+
for(x = 0; x < dst.rect.w; x++)
|
1080
|
+
{
|
1071
1081
|
#if SDL_BYTEORDER == SDL_LIL_ENDIAN
|
1072
1082
|
dst.color.r = (*ppdst >> 16) & 0xff;
|
1073
1083
|
dst.color.g = (*ppdst >> 8) & 0xff;
|
@@ -1091,34 +1101,34 @@ static VALUE bitmap_miyako_inverse_self(VALUE self, VALUE vdst)
|
|
1091
1101
|
}
|
1092
1102
|
}
|
1093
1103
|
|
1094
|
-
|
1104
|
+
SDL_UnlockSurface(dst.surface);
|
1095
1105
|
|
1096
|
-
|
1106
|
+
return vdst;
|
1097
1107
|
}
|
1098
1108
|
|
1099
1109
|
/*
|
1100
|
-
2枚の画像の加算合成を行う
|
1101
1110
|
*/
|
1102
1111
|
static VALUE bitmap_miyako_additive_synthesis(VALUE self, VALUE vsrc, VALUE vdst)
|
1103
1112
|
{
|
1104
1113
|
MiyakoBitmap src, dst;
|
1105
1114
|
MiyakoSize size;
|
1106
|
-
|
1115
|
+
SDL_Surface *scr = GetSurface(rb_iv_get(mScreen, "@@screen"))->surface;
|
1116
|
+
int x, y;
|
1117
|
+
Uint32 *ppsrc, *ppdst;
|
1107
1118
|
|
1108
1119
|
_miyako_setup_unit_2(vsrc, vdst, scr, &src, &dst, Qnil, Qnil, 1);
|
1109
1120
|
|
1110
1121
|
if(_miyako_init_rect(&src, &dst, &size) == 0) return Qnil;
|
1111
|
-
|
1112
|
-
|
1113
|
-
|
1114
|
-
|
1115
|
-
|
1116
|
-
|
1117
|
-
|
1118
|
-
|
1119
|
-
|
1120
|
-
|
1121
|
-
{
|
1122
|
+
|
1123
|
+
SDL_LockSurface(src.surface);
|
1124
|
+
SDL_LockSurface(dst.surface);
|
1125
|
+
|
1126
|
+
for(y = 0; y < size.h; y++)
|
1127
|
+
{
|
1128
|
+
ppsrc = src.ptr + (src.rect.y + y) * src.surface->w + src.rect.x;
|
1129
|
+
ppdst = dst.ptr + (dst.rect.y + src.y + y) * dst.surface->w + dst.rect.x + src.x;
|
1130
|
+
for(x = 0; x < size.w; x++)
|
1131
|
+
{
|
1122
1132
|
#if SDL_BYTEORDER == SDL_LIL_ENDIAN
|
1123
1133
|
src.color.r = (*ppsrc >> 16) & 0xff;
|
1124
1134
|
src.color.g = (*ppsrc >> 8) & 0xff;
|
@@ -1129,12 +1139,12 @@ static VALUE bitmap_miyako_additive_synthesis(VALUE self, VALUE vsrc, VALUE vdst
|
|
1129
1139
|
dst.color.b = (*ppdst ) & 0xff;
|
1130
1140
|
dst.color.a = (*ppdst >> 24) & 0xff | dst.a255;
|
1131
1141
|
dst.color.r += src.color.r;
|
1132
|
-
|
1133
|
-
|
1134
|
-
|
1135
|
-
|
1136
|
-
|
1137
|
-
|
1142
|
+
if(dst.color.r > 255){ dst.color.r = 255; }
|
1143
|
+
dst.color.g += src.color.g;
|
1144
|
+
if(dst.color.g > 255){ dst.color.g = 255; }
|
1145
|
+
dst.color.b += src.color.b;
|
1146
|
+
if(dst.color.b > 255){ dst.color.b = 255; }
|
1147
|
+
dst.color.a = (dst.color.a > src.color.a ? dst.color.a : src.color.a);
|
1138
1148
|
*ppdst = dst.color.r << 16 |
|
1139
1149
|
dst.color.g << 8 |
|
1140
1150
|
dst.color.b |
|
@@ -1149,12 +1159,12 @@ static VALUE bitmap_miyako_additive_synthesis(VALUE self, VALUE vsrc, VALUE vdst
|
|
1149
1159
|
dst.color.b = (*ppdst & dst.fmt->Bmask) >> dst.fmt->Bshift;
|
1150
1160
|
dst.color.a = (*ppdst & dst.fmt->Amask) | dst.a255;
|
1151
1161
|
dst.color.r += src.color.r;
|
1152
|
-
|
1153
|
-
|
1154
|
-
|
1155
|
-
|
1156
|
-
|
1157
|
-
|
1162
|
+
if(dst.color.r > 255){ dst.color.r = 255; }
|
1163
|
+
dst.color.g += src.color.g;
|
1164
|
+
if(dst.color.g > 255){ dst.color.g = 255; }
|
1165
|
+
dst.color.b += src.color.b;
|
1166
|
+
if(dst.color.b > 255){ dst.color.b = 255; }
|
1167
|
+
dst.color.a = (dst.color.a > src.color.a ? dst.color.a : src.color.a);
|
1158
1168
|
*ppdst = dst.color.r << dst.fmt->Rshift |
|
1159
1169
|
dst.color.g << dst.fmt->Gshift |
|
1160
1170
|
dst.color.b << dst.fmt->Bshift |
|
@@ -1165,14 +1175,13 @@ static VALUE bitmap_miyako_additive_synthesis(VALUE self, VALUE vsrc, VALUE vdst
|
|
1165
1175
|
}
|
1166
1176
|
}
|
1167
1177
|
|
1168
|
-
|
1169
|
-
|
1178
|
+
SDL_UnlockSurface(src.surface);
|
1179
|
+
SDL_UnlockSurface(dst.surface);
|
1170
1180
|
|
1171
|
-
|
1181
|
+
return vdst;
|
1172
1182
|
}
|
1173
1183
|
|
1174
1184
|
/*
|
1175
|
-
2枚の画像の減算合成を行う
|
1176
1185
|
*/
|
1177
1186
|
static VALUE bitmap_miyako_subtraction_synthesis(VALUE self, VALUE src, VALUE dst)
|
1178
1187
|
{
|
@@ -1200,7 +1209,7 @@ void Init_miyako_bitmap()
|
|
1200
1209
|
nZero = INT2NUM(zero);
|
1201
1210
|
one = 1;
|
1202
1211
|
nOne = INT2NUM(one);
|
1203
|
-
|
1212
|
+
|
1204
1213
|
rb_define_singleton_method(cBitmap, "blit_aa", bitmap_miyako_blit_aa, 4);
|
1205
1214
|
rb_define_singleton_method(cBitmap, "blit_and", bitmap_miyako_blit_and, 2);
|
1206
1215
|
rb_define_singleton_method(cBitmap, "blit_or", bitmap_miyako_blit_or, 2);
|