Add color class
Add Palladium Unique and Shared defs Make stb_image an internal dependency Start some work on font loader
This commit is contained in:
50
source/color.cpp
Normal file
50
source/color.cpp
Normal file
@@ -0,0 +1,50 @@
|
||||
#include <amethyst/color.hpp>
|
||||
|
||||
namespace Amy {
|
||||
// The Solution of the biggest performance issue
|
||||
// A Simple Lookup table
|
||||
static const std::map<char, int> HEX_DEC = {
|
||||
{'0', 0}, {'1', 1}, {'2', 2}, {'3', 3}, {'4', 4}, {'5', 5},
|
||||
{'6', 6}, {'7', 7}, {'8', 8}, {'9', 9}, {'a', 10}, {'b', 11},
|
||||
{'c', 12}, {'d', 13}, {'e', 14}, {'f', 15}, {'A', 10}, {'B', 11},
|
||||
{'C', 12}, {'D', 13}, {'E', 14}, {'F', 15}};
|
||||
|
||||
Color& Color::Hex(const std::string& hex) {
|
||||
// zu dumm nen safetey check zu schreiben wadafuk
|
||||
/**#ifndef AMY_GOD_DEV
|
||||
/// Safetey check (not required if you just program well xd)
|
||||
if (hex.length() != 7 || hex.length() != 9 || hex.length() != 6 ||
|
||||
hex.length() != 8 || std::find_if(hex.begin(), hex.end(), [](char c) {
|
||||
return !std::isxdigit(c);
|
||||
}) != hex.end()) {
|
||||
return *this;
|
||||
}
|
||||
#endif*/
|
||||
int offset = ((hex.length() == 7 || hex.length() == 9) ? 1 : 0);
|
||||
r = HEX_DEC.at(hex[offset]) * 16 + HEX_DEC.at(hex[offset + 1]);
|
||||
offset += 2;
|
||||
g = HEX_DEC.at(hex[offset]) * 16 + HEX_DEC.at(hex[offset + 1]);
|
||||
offset += 2;
|
||||
b = HEX_DEC.at(hex[offset]) * 16 + HEX_DEC.at(hex[offset + 1]);
|
||||
offset += 2;
|
||||
if (hex.length() == 9) {
|
||||
a = HEX_DEC.at(hex[offset]) * 16 + HEX_DEC.at(hex[offset + 1]);
|
||||
} else {
|
||||
a = 255;
|
||||
}
|
||||
return *this;
|
||||
}
|
||||
|
||||
std::string Color::Hex(bool rgba) const {
|
||||
/** Need to int cast (so it is used as num and not char...) */
|
||||
std::stringstream s;
|
||||
s << "#";
|
||||
s << std::hex << std::setw(2) << std::setfill('0') << (int)r;
|
||||
s << std::hex << std::setw(2) << std::setfill('0') << (int)g;
|
||||
s << std::hex << std::setw(2) << std::setfill('0') << (int)b;
|
||||
if (rgba) {
|
||||
s << std::hex << std::setw(2) << std::setfill('0') << (int)a;
|
||||
}
|
||||
return s.str();
|
||||
}
|
||||
} // namespace Amy
|
||||
7988
source/internal/stb_image.h
Normal file
7988
source/internal/stb_image.h
Normal file
File diff suppressed because it is too large
Load Diff
@@ -33,8 +33,8 @@ void Iron::Drawlist::Clear() {
|
||||
pLayer = 0;
|
||||
}
|
||||
|
||||
Iron::Command::ref Iron::Drawlist::NewCommand() {
|
||||
auto ret = std::make_unique<Command>();
|
||||
Iron::Command::Ref Iron::Drawlist::NewCommand() {
|
||||
auto ret = Command::New();
|
||||
ret->Layer = pLayer;
|
||||
ret->Index = pData.size();
|
||||
ret->Tex = pTex;
|
||||
@@ -48,7 +48,7 @@ void Iron::Drawlist::clipCmd(Command* ptr) {
|
||||
}
|
||||
}
|
||||
|
||||
void Iron::Drawlist::Push(Command::ref cmd) { pData.push_back(std::move(cmd)); }
|
||||
void Iron::Drawlist::Push(Command::Ref cmd) { pData.push_back(std::move(cmd)); }
|
||||
|
||||
void Iron::Drawlist::DrawSolid() { pTex = Iron::WhiteTex(); }
|
||||
|
||||
|
||||
24
source/iron/font.cpp
Normal file
24
source/iron/font.cpp
Normal file
@@ -0,0 +1,24 @@
|
||||
#include <amethyst/iron.hpp>
|
||||
|
||||
namespace Amy {
|
||||
void Iron::Font::LoadBMF(ksr path) {}
|
||||
|
||||
void Iron::Font::LoadTTF(ksr path, int size) {}
|
||||
|
||||
void Iron::Font::pMakeAtlas(bool final, vec<uc>& font_tex, int texszs,
|
||||
Texture* tex) {
|
||||
tex->Load(font_tex, texszs, texszs);
|
||||
Textures.push_back(tex);
|
||||
}
|
||||
|
||||
Iron::Font::Codepoint& Iron::Font::GetCodepoint(ui cp) {
|
||||
// Check if codepoijt exist or return a static invalid one
|
||||
auto res = pCodeMap.find(cp);
|
||||
if (res == pCodeMap.end()) {
|
||||
static Codepoint invalid;
|
||||
invalid.Valid = false;
|
||||
return invalid;
|
||||
}
|
||||
return res->second;
|
||||
}
|
||||
} // namespace Amy
|
||||
@@ -83,7 +83,7 @@ void Iron::DrawOn(C3D::Screen* screen) {
|
||||
m_shader->SetMat4(uLocProj, m_mtx);
|
||||
}
|
||||
|
||||
void Iron::Draw(const std::vector<Iron::Command::ref>& data) {
|
||||
void Iron::Draw(const std::vector<Iron::Command::Ref>& data) {
|
||||
// disable depthtest cause we have no z buffer
|
||||
C3D::DepthTest(false);
|
||||
pFragConfig();
|
||||
|
||||
Reference in New Issue
Block a user