00001
00002
00003
00004
00005
00006
00007
00008
00009 #include "EffectMirror.h"
00010
00011 #include "SurfaceLock.h"
00012 #include "PixelTool.h"
00013
00014
00015
00016
00017
00018
00019
00020 void
00021 EffectMirror::blit(SDL_Surface *screen, SDL_Surface *surface, int x, int y)
00022 {
00023 SurfaceLock lock1(screen);
00024 SurfaceLock lock2(surface);
00025
00026 SDL_Color mask = PixelTool::getColor(surface,
00027 surface->w / 2, surface->h / 2);
00028
00029 for (int py = 0; py < surface->h; ++py) {
00030 for (int px = 0; px < surface->w; ++px) {
00031 SDL_Color pixel = PixelTool::getColor(surface, px, py);
00032 if (px > MIRROR_BORDER && PixelTool::colorEquals(pixel, mask)) {
00033 SDL_Color sample = PixelTool::getColor(screen,
00034 x - px + MIRROR_BORDER, y + py);
00035 PixelTool::putColor(screen, x + px, y + py, sample);
00036 }
00037 else {
00038 if (pixel.unused == 255) {
00039 PixelTool::putColor(screen, x + px, y + py, pixel);
00040 }
00041 }
00042 }
00043 }
00044 }
00045