Definition at line 11 of file LayeredPicture.h.
Public Member Functions | |
LayeredPicture (const Path &bg_file, const V2 &loc, const Path &lowerLayer, const Path &colorMask) | |
Create picture with two layers and color mask to select active areas. | |
~LayeredPicture () | |
void | setNoActive () |
void | setActiveMask (Uint32 color) |
Uint32 | getMaskAtWorld (const V2 &worldLoc) |
Return pixel at worldLoc. | |
Uint32 | getMaskAt (const V2 &loc) |
Return pixel at position from left top image corner. | |
Uint32 | getNoMask () const |
virtual void | drawOn (SDL_Surface *screen) |
Blit entire surface to [x,y]. |
|
Create picture with two layers and color mask to select active areas.
Definition at line 25 of file LayeredPicture.cpp. 00027 : Picture(bg_file, loc) 00028 { 00029 m_lowerLayer = ResImagePack::loadImage(lowerLayer); 00030 m_colorMask = ResImagePack::loadImage(colorMask); 00031 if (m_lowerLayer->w != m_colorMask->w 00032 || m_lowerLayer->h != m_colorMask->h) { 00033 SDL_FreeSurface(m_lowerLayer); 00034 SDL_FreeSurface(m_colorMask); 00035 SDL_FreeSurface(m_surface); 00036 00037 throw ResourceException(ExInfo( 00038 "lowerLayer and colorMask have different proportions") 00039 .addInfo("lowerLayer", lowerLayer.getNative()) 00040 .addInfo("colorMask", colorMask.getNative())); 00041 } 00042 00043 setNoActive(); 00044 }
|
|
Definition at line 46 of file LayeredPicture.cpp. 00047 { 00048 SDL_FreeSurface(m_lowerLayer); 00049 SDL_FreeSurface(m_colorMask); 00050 }
|
|
Blit entire surface to [x,y].
Reimplemented from Picture. Definition at line 82 of file LayeredPicture.cpp. 00083 { 00084 Picture::drawOn(screen); 00085 if (m_activeColor == MASK_NO) { 00086 return; 00087 } 00088 00089 SurfaceLock lock1(screen); 00090 SurfaceLock lock2(m_lowerLayer); 00091 SurfaceLock lock3(m_colorMask); 00092 00093 //TODO: support alpha channels 00094 for (int py = 0; py < m_colorMask->h; ++py) { 00095 int world_y = m_loc.getY() + py; 00096 for (int px = 0; px < m_colorMask->w; ++px) { 00097 Uint32 sample = PixelTool::getPixel(m_colorMask, px, py); 00098 00099 if (sample == m_activeColor) { 00100 SDL_Color lower = PixelTool::getColor(m_lowerLayer, px, py); 00101 if (lower.unused == 255) { 00102 PixelTool::putColor(screen, 00103 m_loc.getX() + px, world_y, lower); 00104 } 00105 } 00106 } 00107 } 00108 }
|
|
Return pixel at position from left top image corner.
Definition at line 67 of file LayeredPicture.cpp. 00068 { 00069 Uint32 result = MASK_NO; 00070 00071 if ((0 <= loc.getX() && loc.getX() < m_colorMask->w) 00072 && (0 <= loc.getY() && loc.getY() < m_colorMask->h)) 00073 { 00074 SurfaceLock lock1(m_colorMask); 00075 result = PixelTool::getPixel(m_colorMask, 00076 loc.getX(), loc.getY()); 00077 } 00078 return result; 00079 }
|
|
Return pixel at worldLoc. Translates world coordinates to local coordinates. Definition at line 57 of file LayeredPicture.cpp.
|
|
Definition at line 27 of file LayeredPicture.h. 00027 { return MASK_NO; }
|
|
Definition at line 23 of file LayeredPicture.h. 00023 { m_activeColor = color; }
|
|
Definition at line 22 of file LayeredPicture.h. 00022 { m_activeColor = MASK_NO; }
|