#include "engine/pixel.h" #include #include "engine/math.h" uint32_t ShadeColor(uint32_t c, float k) { const float r = Clampf(float(c & 0xFF) * k, 0.0f, 255.0f); const float g = Clampf(float((c >> 8) & 0xFF) * k, 0.0f, 255.0f); const float b = Clampf(float((c >> 16) & 0xFF) * k, 0.0f, 255.0f); return RGBA(uint8_t(r), uint8_t(g), uint8_t(b), AlphaOf(c)); } void DiamondRowN(int y, int dw, int dh, int& x0, int& x1) { const int half = std::max(1, dh / 2); const int k = (y < half) ? y : (dh - 1 - y); const int width = std::max(1, (dw / half) * (k + 1)); x0 = (dw - width) / 2; x1 = x0 + width; } void OutlineSilhouette(Sprite& s, uint32_t outline) { Sprite copy = s; for (int y = 0; y < s.h; ++y) { for (int x = 0; x < s.w; ++x) { if (AlphaOf(copy.Get(x, y)) == 0) continue; const bool border = x == 0 || y == 0 || x == s.w - 1 || y == s.h - 1 || AlphaOf(copy.Get(x - 1, y)) == 0 || AlphaOf(copy.Get(x + 1, y)) == 0 || AlphaOf(copy.Get(x, y - 1)) == 0 || AlphaOf(copy.Get(x, y + 1)) == 0; if (border) s.Set(x, y, outline); } } }