mirror of
https://github.com/edubart/otclient.git
synced 2025-10-19 05:53:26 +02:00
bunch of optimizations
This commit is contained in:
44
src/framework/math/color.cpp
Normal file
44
src/framework/math/color.cpp
Normal file
@@ -0,0 +1,44 @@
|
||||
/*
|
||||
* Copyright (c) 2010-2012 OTClient <https://github.com/edubart/otclient>
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
* of this software and associated documentation files (the "Software"), to deal
|
||||
* in the Software without restriction, including without limitation the rights
|
||||
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
* copies of the Software, and to permit persons to whom the Software is
|
||||
* furnished to do so, subject to the following conditions:
|
||||
*
|
||||
* The above copyright notice and this permission notice shall be included in
|
||||
* all copies or substantial portions of the Software.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
||||
* THE SOFTWARE.
|
||||
*/
|
||||
|
||||
#include "color.h"
|
||||
|
||||
// NOTE: AABBGGRR order
|
||||
const Color Color::alpha = 0x00000000;
|
||||
const Color Color::white = 0xffffffff;
|
||||
const Color Color::black = 0xff000000;
|
||||
const Color Color::red = 0xff0000ff;
|
||||
const Color Color::darkRed = 0xff000080;
|
||||
const Color Color::green = 0xff00ff00;
|
||||
const Color Color::darkGreen = 0xff008000;
|
||||
const Color Color::blue = 0xffff0000;
|
||||
const Color Color::darkBlue = 0xff800000;
|
||||
const Color Color::pink = 0xffff00ff;
|
||||
const Color Color::darkPink = 0xff800080;
|
||||
const Color Color::yellow = 0xff00ffff;
|
||||
const Color Color::darkYellow = 0xff008080;
|
||||
const Color Color::teal = 0xffffff00;
|
||||
const Color Color::darkTeal = 0xff808000;
|
||||
const Color Color::gray = 0xffa0a0a0;
|
||||
const Color Color::darkGray = 0xff808080;
|
||||
const Color Color::lightGray = 0xffc0c0c0;
|
||||
const Color Color::orange = 0xffff8c00;
|
@@ -76,6 +76,26 @@ public:
|
||||
return Color(r, g, b);
|
||||
}
|
||||
|
||||
static const Color alpha;
|
||||
static const Color white;
|
||||
static const Color black;
|
||||
static const Color red;
|
||||
static const Color darkRed;
|
||||
static const Color green;
|
||||
static const Color darkGreen;
|
||||
static const Color blue;
|
||||
static const Color darkBlue;
|
||||
static const Color pink;
|
||||
static const Color darkPink;
|
||||
static const Color yellow;
|
||||
static const Color darkYellow;
|
||||
static const Color teal;
|
||||
static const Color darkTeal;
|
||||
static const Color gray;
|
||||
static const Color darkGray;
|
||||
static const Color lightGray;
|
||||
static const Color orange;
|
||||
|
||||
private:
|
||||
float m_r;
|
||||
float m_g;
|
||||
@@ -118,43 +138,43 @@ inline std::istream& operator>>(std::istream& in, Color& color)
|
||||
in >> tmp;
|
||||
|
||||
if(tmp == "alpha") {
|
||||
color = Fw::alpha;
|
||||
color = Color::alpha;
|
||||
} else if(tmp == "black") {
|
||||
color = Fw::black;
|
||||
color = Color::black;
|
||||
} else if(tmp == "white") {
|
||||
color = Fw::white;
|
||||
color = Color::white;
|
||||
} else if(tmp == "red") {
|
||||
color = Fw::red;
|
||||
color = Color::red;
|
||||
} else if(tmp == "darkRed") {
|
||||
color = Fw::darkRed;
|
||||
color = Color::darkRed;
|
||||
} else if(tmp == "green") {
|
||||
color = Fw::green;
|
||||
color = Color::green;
|
||||
} else if(tmp == "darkGreen") {
|
||||
color = Fw::darkGreen;
|
||||
color = Color::darkGreen;
|
||||
} else if(tmp == "blue") {
|
||||
color = Fw::blue;
|
||||
color = Color::blue;
|
||||
} else if(tmp == "darkBlue") {
|
||||
color = Fw::darkBlue;
|
||||
color = Color::darkBlue;
|
||||
} else if(tmp == "pink") {
|
||||
color = Fw::pink;
|
||||
color = Color::pink;
|
||||
} else if(tmp == "darkPink") {
|
||||
color = Fw::darkPink;
|
||||
color = Color::darkPink;
|
||||
} else if(tmp == "yellow") {
|
||||
color = Fw::yellow;
|
||||
color = Color::yellow;
|
||||
} else if(tmp == "darkYellow") {
|
||||
color = Fw::darkYellow;
|
||||
color = Color::darkYellow;
|
||||
} else if(tmp == "teal") {
|
||||
color = Fw::teal;
|
||||
color = Color::teal;
|
||||
} else if(tmp == "darkTeal") {
|
||||
color = Fw::darkTeal;
|
||||
color = Color::darkTeal;
|
||||
} else if(tmp == "gray") {
|
||||
color = Fw::gray;
|
||||
color = Color::gray;
|
||||
} else if(tmp == "darkGray") {
|
||||
color = Fw::darkGray;
|
||||
color = Color::darkGray;
|
||||
} else if(tmp == "lightGray") {
|
||||
color = Fw::lightGray;
|
||||
color = Color::lightGray;
|
||||
} else if(tmp == "orange") {
|
||||
color = Fw::orange;
|
||||
color = Color::orange;
|
||||
} else {
|
||||
in.seekg(-tmp.length(), ios_base::cur);
|
||||
}
|
||||
|
Reference in New Issue
Block a user