📄 wg_color.cpp
字号:
// wg_color.cpp//// CRGBColor class////// Copyright (c) 2002 Rob Wiskow// rob-dev@boxedchaos.com//// This library is free software; you can redistribute it and/or// modify it under the terms of the GNU Lesser General Public// License as published by the Free Software Foundation; either// version 2.1 of the License, or (at your option) any later version.//// This library is distributed in the hope that it will be useful,// but WITHOUT ANY WARRANTY; without even the implied warranty of// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU// Lesser General Public License for more details.//// You should have received a copy of the GNU Lesser General Public// License along with this library; if not, write to the Free Software// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA//#include "wgui_include_config.h"#include "wg_color.h"namespace wGui{CRGBColor::CRGBColor(const Uint32* pColorValue, const SDL_PixelFormat* pFormat){ red = static_cast<unsigned char>((pFormat->Rmask & *pColorValue) >> pFormat->Rshift); green = static_cast<unsigned char>((pFormat->Gmask & *pColorValue) >> pFormat->Gshift); blue = static_cast<unsigned char>((pFormat->Bmask & *pColorValue) >> pFormat->Bshift); alpha = static_cast<unsigned char>((pFormat->Amask & *pColorValue) >> pFormat->Ashift);}CRGBColor& CRGBColor::operator=(const CRGBColor& c){ red = c.red; green = c.green; blue = c.blue; alpha = c.alpha; return *this;}CRGBColor CRGBColor::operator+(const CRGBColor& c) const{ double fg_ratio = static_cast<double>(c.alpha) / 0xFF; double bg_ratio = static_cast<double>(0xFF - c.alpha) / 0xFF; unsigned char new_red = static_cast<unsigned char>(red * bg_ratio + c.red * fg_ratio); unsigned char new_green = static_cast<unsigned char>(green * bg_ratio + c.green * fg_ratio); unsigned char new_blue = static_cast<unsigned char>(blue * bg_ratio + c.blue * fg_ratio); return CRGBColor(new_red, new_green, new_blue, alpha);}CRGBColor CRGBColor::operator|(const CRGBColor& c) const{ return CRGBColor(red | c.red, green | c.green, blue | c.blue, alpha | c.alpha);}CRGBColor CRGBColor::operator&(const CRGBColor& c) const{ return CRGBColor(red & c.red, green & c.green, blue & c.blue, alpha & c.alpha);}CRGBColor CRGBColor::operator^(const CRGBColor& c) const{ return CRGBColor(red ^ c.red, green ^ c.green, blue ^ c.blue, alpha ^ c.alpha);}CRGBColor DEFAULT_BG_COLOR = CRGBColor(0x60, 0x60, 0x60);CRGBColor DEFAULT_FG_COLOR = CRGBColor(0xA0, 0xA0, 0xA0);CRGBColor DEFAULT_LINE_COLOR = CRGBColor(0x00, 0x00, 0x00);CRGBColor DEFAULT_DISABLED_LINE_COLOR = CRGBColor(0x40, 0x40, 0x40);CRGBColor COLOR_TRANSPARENT = CRGBColor(0x00, 0x00, 0x00, 0x00);CRGBColor COLOR_WHITE = CRGBColor(0xFF, 0xFF, 0xFF);CRGBColor COLOR_LIGHTGRAY = CRGBColor(0xC0, 0xC0, 0xC0);CRGBColor COLOR_GRAY = CRGBColor(0x80, 0x80, 0x80);CRGBColor COLOR_DARKGRAY = CRGBColor(0x40, 0x40, 0x40);CRGBColor COLOR_BLACK = CRGBColor(0x00, 0x00, 0x00);CRGBColor COLOR_BLUE = CRGBColor(0x00, 0x00, 0xFF);CRGBColor COLOR_RED = CRGBColor(0xFF, 0x00, 0x00);CRGBColor COLOR_GREEN = CRGBColor(0x00, 0xFF, 0x00);CRGBColor COLOR_YELLOW = CRGBColor(0xFF, 0xFF, 0x00);}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -