added missing tools

This commit is contained in:
Geoffray Levasseur committed 2026-11-03 13:42:11 +01:00
1 parent cae16313f8
commit 2978f6edf7
2 files changed
+52

No files matched your search

+49
View File
@@ -232,6 +232,55 @@ void bitmapReplaceColor(Dpi::Bitmap &dst, int x, int y, int width, int height, Q
}
}
void glowFrame(Dpi::Bitmap &dst, int x0, int y0, int width, int height, QColor cl)
{
constexpr int glowRange = 8;
const int red = cl.red();
const int green = cl.green();
const int blue = cl.blue();
for (int y = -glowRange + 1; y <= height - 1 + glowRange - 1; ++y) {
for (int x = -glowRange + 1; x <= width - 1 + glowRange - 1; ++x) {
int r;
if (x < 0) {
if (y < 0)
r = static_cast<int>(std::lround(std::sqrt(static_cast<double>(x * x + y * y))));
else if (y >= height)
r = static_cast<int>(
std::lround(std::sqrt(static_cast<double>(x * x + (y - (height - 1)) * (y - (height - 1))))));
else
r = -x;
} else if (x >= width) {
if (y < 0)
r = static_cast<int>(
std::lround(std::sqrt(static_cast<double>((x - (width - 1)) * (x - (width - 1)) + y * y))));
else if (y >= height)
r = static_cast<int>(std::lround(std::sqrt(static_cast<double>(
(x - (width - 1)) * (x - (width - 1)) + (y - (height - 1)) * (y - (height - 1))))));
else
r = x - (width - 1);
} else if (y < 0) {
r = -y;
} else if (y >= height) {
r = y - (height - 1);
} else {
continue;
}
if (r == 0)
r = 1;
if (r < glowRange) {
const int px = x0 + x;
const int py = y0 + y;
if (px < 0 || py < 0 || px >= dst.width() || py >= dst.height())
continue;
const QRgb old = dst.image().pixel(px, py);
auto mix = [&](int oldC, int clC) { return (oldC * (r - 1) + clC * (glowRange - r)) / (glowRange - 1); };
dst.image().setPixel(px, py, qRgb(mix(qRed(old), red), mix(qGreen(old), green), mix(qBlue(old), blue)));
}
}
}
}
void sprite(Dpi::Canvas &canvas, GraphicSet &graphicSet, int xDst, int yDst,
int width, int height, int xGr, int yGr)
{