mirror of
https://github.com/Cockatrice/Cockatrice.git
synced 2026-06-11 16:44:48 -07:00
set p/t, set annotation, multiple counters per card
This commit is contained in:
parent
7553251baf
commit
df7bcf179d
25 changed files with 891 additions and 385 deletions
|
|
@ -1,33 +1,45 @@
|
|||
#include "abstractgraphicsitem.h"
|
||||
#include <QPainter>
|
||||
|
||||
void AbstractGraphicsItem::paintNumberEllipse(int number, QPainter *painter)
|
||||
void AbstractGraphicsItem::paintNumberEllipse(int number, int fontSize, const QColor &color, int position, QPainter *painter)
|
||||
{
|
||||
painter->save();
|
||||
|
||||
QString numStr = QString::number(number);
|
||||
QFont font("Serif");
|
||||
font.setPixelSize(32);
|
||||
font.setPixelSize(fontSize);
|
||||
font.setWeight(QFont::Bold);
|
||||
|
||||
QFontMetrics fm(font);
|
||||
double w = fm.width(numStr) * 1.5;
|
||||
double h = fm.height() * 1.5;
|
||||
double w = fm.width(numStr) * 1.3;
|
||||
double h = fm.height() * 1.3;
|
||||
if (w < h)
|
||||
w = h;
|
||||
|
||||
painter->setPen(QColor(255, 255, 255, 0));
|
||||
QRadialGradient grad(QPointF(0.5, 0.5), 0.5);
|
||||
grad.setCoordinateMode(QGradient::ObjectBoundingMode);
|
||||
grad.setColorAt(0, QColor(255, 255, 255, 200));
|
||||
grad.setColorAt(0.7, QColor(255, 255, 255, 200));
|
||||
grad.setColorAt(1, QColor(255, 255, 255, 0));
|
||||
QColor color1(color), color2(color);
|
||||
color1.setAlpha(255);
|
||||
color2.setAlpha(0);
|
||||
grad.setColorAt(0, color1);
|
||||
grad.setColorAt(0.8, color1);
|
||||
grad.setColorAt(1, color2);
|
||||
painter->setBrush(QBrush(grad));
|
||||
painter->drawEllipse(QRectF((boundingRect().width() - w) / 2.0, (boundingRect().height() - h) / 2.0, w, h));
|
||||
|
||||
QRectF textRect;
|
||||
if (position == -1)
|
||||
textRect = QRectF((boundingRect().width() - w) / 2.0, (boundingRect().height() - h) / 2.0, w, h);
|
||||
else {
|
||||
qreal offset = boundingRect().width() / 20.0;
|
||||
textRect = QRectF(offset, offset * (position + 1) + h * position, w, h);
|
||||
}
|
||||
|
||||
painter->drawEllipse(textRect);
|
||||
|
||||
painter->setPen(Qt::black);
|
||||
painter->setFont(font);
|
||||
painter->drawText(boundingRect(), Qt::AlignCenter, numStr);
|
||||
painter->drawText(textRect, Qt::AlignCenter, numStr);
|
||||
|
||||
painter->restore();
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue