mirror of
https://github.com/Cockatrice/Cockatrice.git
synced 2026-06-11 08:34:52 -07:00
made counters look nicer
This commit is contained in:
parent
5d40996c0b
commit
ae82996c0e
9 changed files with 59 additions and 51 deletions
33
cockatrice/src/abstractgraphicsitem.cpp
Normal file
33
cockatrice/src/abstractgraphicsitem.cpp
Normal file
|
|
@ -0,0 +1,33 @@
|
|||
#include "abstractgraphicsitem.h"
|
||||
#include <QPainter>
|
||||
|
||||
void AbstractGraphicsItem::paintNumberEllipse(int number, QPainter *painter)
|
||||
{
|
||||
painter->save();
|
||||
|
||||
QString numStr = QString::number(number);
|
||||
QFont font("Times");
|
||||
font.setPixelSize(32);
|
||||
font.setWeight(QFont::Bold);
|
||||
|
||||
QFontMetrics fm(font);
|
||||
double w = fm.width(numStr) * 1.5;
|
||||
double h = fm.height() * 1.5;
|
||||
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));
|
||||
painter->setBrush(QBrush(grad));
|
||||
painter->drawEllipse(QRectF((boundingRect().width() - w) / 2.0, (boundingRect().height() - h) / 2.0, w, h));
|
||||
|
||||
painter->setPen(Qt::black);
|
||||
painter->setFont(font);
|
||||
painter->drawText(boundingRect(), Qt::AlignCenter, numStr);
|
||||
|
||||
painter->restore();
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue