fillSurface.cpp

00001 /*
00002   塗りつぶしサーフェス
00003   Satofumi KAMIMURA
00004   $Id$
00005 */
00006 
00007 #include "fillSurface.h"
00008 #include "sdlVideo.h"
00009 
00010 
00011 FillSurface::  FillSurface(const VXV::Rect& size, unsigned long color)
00012   : draw_size(size), draw_color(color), draw_surface(NULL) {
00013   w = size.w;
00014   h = size.h;
00015 }
00016 
00017 
00018 FillSurface:: FillSurface(const VXV::Rect& size, SurfaceInterface* surface)
00019   : draw_size(size), draw_surface(surface) {
00020   w = size.w;
00021   h = size.h;
00022 }
00023 
00024 
00025 FillSurface::~FillSurface(void) {
00026 }
00027 
00028 
00029 bool FillSurface::draw(const VXV::Rect& size, const VXV::Grid& pos,
00030                        unsigned long ticks) {
00031   draw_size.x = pos.x;
00032   draw_size.y = pos.y;
00033   if (!draw_surface) {
00034     SDL_Video::fillRect(draw_size, draw_color);
00035 
00036   } else {
00037     VXV::Rect surface_pos, surface_size;
00038     for (int y_offset = 0; y_offset < size.h; y_offset += draw_surface->h) {
00039       for (int x_offset = 0; x_offset < size.w; x_offset += draw_surface->w) {
00040         surface_pos.x = pos.x + x_offset;
00041         surface_pos.y = pos.y + y_offset;
00042         surface_size.w = (x_offset + draw_surface->w > size.w) ?
00043           size.w - x_offset : draw_surface->w;
00044         surface_size.h = (y_offset + draw_surface->h > size.h) ?
00045           size.h - y_offset : draw_surface->h;
00046         draw_surface->draw(surface_size, surface_pos, ticks);
00047       }
00048     }
00049   }
00050   return true;
00051 }
00052 

Generated on Mon Apr 13 22:52:02 2009 by  doxygen 1.5.7.1