added additional functions
This commit is contained in:
1 parent
5d5a502976
commit
e5f109327c
2 files changed
+52
No files matched your search
@@ -389,6 +389,23 @@ void rframe(Dpi::Canvas &canvas, int x0, int y0, int x1, int y1, QColor cl0, QCo
|
||||
canvas.lineTo(x1, y1);
|
||||
}
|
||||
|
||||
void cframe(Dpi::Canvas &canvas, int x0, int y0, int x1, int y1, int corner, QColor cl)
|
||||
{
|
||||
canvas.pen().setColor(cl);
|
||||
canvas.moveTo(x0, y0 + corner - 1);
|
||||
canvas.lineTo(x0, y0);
|
||||
canvas.lineTo(x0 + corner, y0);
|
||||
canvas.moveTo(x1, y0 + corner - 1);
|
||||
canvas.lineTo(x1, y0);
|
||||
canvas.lineTo(x1 - corner, y0);
|
||||
canvas.moveTo(x1, y1 - corner + 1);
|
||||
canvas.lineTo(x1, y1);
|
||||
canvas.lineTo(x1 - corner, y1);
|
||||
canvas.moveTo(x0, y1 - corner + 1);
|
||||
canvas.lineTo(x0, y1);
|
||||
canvas.lineTo(x0 + corner, y1);
|
||||
}
|
||||
|
||||
void btnFrame(Dpi::Canvas &canvas, const QRect &rect, const Texture &texture)
|
||||
{
|
||||
rframe(canvas, rect.left() - 1, rect.top() - 1, rect.right(), rect.bottom(),
|
||||
@@ -449,6 +466,37 @@ void fill(Dpi::Canvas &canvas, const QRect &rect, const QPoint &offset)
|
||||
fill(canvas, rect.left(), rect.top(), rect.width(), rect.height(), offset.x(), offset.y());
|
||||
}
|
||||
|
||||
void fillLarge(Dpi::Canvas &canvas, int x0, int y0, int x1, int y1, int xm)
|
||||
{
|
||||
if (!MainTexture || MainTexture->width() <= 0 || y1 <= y0)
|
||||
return;
|
||||
const int textureWidth = MainTexture->width();
|
||||
const int textureHeight = MainTexture->height();
|
||||
const int bandHeight = y1 - y0;
|
||||
const auto band = [&](int i) {
|
||||
const int n = ((textureHeight / 2) / bandHeight) * 2;
|
||||
if (n <= 0)
|
||||
return 0;
|
||||
while (textureHeight / 2 + (i + 1) * bandHeight > textureHeight)
|
||||
i -= n;
|
||||
while (textureHeight / 2 + i * bandHeight < 0)
|
||||
i += n;
|
||||
return i;
|
||||
};
|
||||
const auto blit = [&](int xDst, int width, int xSrc, int yBand) {
|
||||
canvas.copyRect(QRect(xDst, y0, width, bandHeight), MainTexture->canvas(),
|
||||
QRect(xSrc, textureHeight / 2 + band(yBand) * bandHeight, width, bandHeight));
|
||||
};
|
||||
const int rightCount = (x1 - xm) / textureWidth;
|
||||
for (int i = 0; i < rightCount; ++i)
|
||||
blit(xm + i * textureWidth, textureWidth, 0, i);
|
||||
blit(xm + rightCount * textureWidth, x1 - (xm + rightCount * textureWidth), 0, rightCount);
|
||||
const int leftCount = (xm - x0) / textureWidth;
|
||||
for (int i = 0; i < leftCount; ++i)
|
||||
blit(xm - (i + 1) * textureWidth, textureWidth, 0, -i - 1);
|
||||
blit(x0, xm - leftCount * textureWidth - x0, (leftCount + 1) * textureWidth - (xm - x0), -leftCount - 1);
|
||||
}
|
||||
|
||||
void fillSeamless(Dpi::Canvas &canvas, int left, int top, int width, int height, int xOffset, int yOffset,
|
||||
Dpi::Bitmap &texture)
|
||||
{
|
||||
|
||||
Reference in new issue
Block a user