1#ifndef COCKATRICE_PLAYMAT_UTILS_H
2#define COCKATRICE_PLAYMAT_UTILS_H
21 const qreal srcW = fullCardSize.width();
22 const qreal marginL = params.
marginPctL * srcW;
23 const qreal marginR = params.
marginPctR * srcW;
24 return qMax(0.0, srcW - marginL - marginR);
39 const qreal minDim = qMin<qreal>(fullCardSize.width(), fullCardSize.height());
41 const qreal zoomOutFloor = (minDim > 0.0 && visibleW > 0.0) ? visibleW / minDim : 1.0;
58 if (visibleW <= 0.0) {
78 const qreal srcW = fullCardSize.width();
79 const qreal srcH = fullCardSize.height();
90 const qreal y = offset * qMax(0.0, srcH - side);
96 const qreal x = qBound(0.0, params.
marginPctL * srcW + (outerW - side) / 2.0, qMax(0.0, srcW - side));
98 return QRectF(x, y, side, side);
109inline QRectF
coverFitRect(
const QRectF &dstArea,
const QSizeF &srcSize)
111 const qreal srcAspect = srcSize.width() / srcSize.height();
112 const qreal dstAspect = dstArea.width() / dstArea.height();
114 if (srcAspect > dstAspect) {
115 const qreal dstW = dstArea.height() * srcAspect;
116 return QRectF(dstArea.left() + (dstArea.width() - dstW) / 2.0, dstArea.top(), dstW, dstArea.height());
119 const qreal dstH = dstArea.width() / srcAspect;
120 return QRectF(dstArea.left(), dstArea.top() + (dstArea.height() - dstH) / 2.0, dstArea.width(), dstH);
133 qreal w = qMin(dstArea.width(), dstArea.height() * aspect);
134 qreal h = w / aspect;
135 return QRectF(dstArea.left() + (dstArea.width() - w) / 2.0, dstArea.top() + (dstArea.height() - h) / 2.0, w, h);
Defines the DeckList class, which manages a full deck structure including cards, zones,...
Definition playmat_utils.h:10
qreal playmatWindowSide(const QSize &fullCardSize, const PlaymatParams ¶ms)
Side of the square sampling window actually rendered for these parameters. Never exceeds either card ...
Definition playmat_utils.h:55
QRectF computeArtSourceRect(const QSize &fullCardSize, const PlaymatParams ¶ms)
Computes the source region of the full resolution card image to use as a playmat.
Definition playmat_utils.h:76
qreal playmatClampedZoom(const QSize &fullCardSize, const PlaymatParams ¶ms)
Zoom clamped to the range where every step renders differently.
Definition playmat_utils.h:37
constexpr qreal MAX_ZOOM
Upper bound for zooming into the playmat art.
Definition playmat_utils.h:13
QRectF coverFitRect(const QRectF &dstArea, const QSizeF &srcSize)
Returns the destination rectangle that fits a source of the given aspect ratio into dstArea using "co...
Definition playmat_utils.h:109
QRectF aspectFitRect(const QRectF &dstArea, qreal aspect)
Fits a rectangle of the given aspect ratio into dstArea, centered, touching the constraining dimensio...
Definition playmat_utils.h:128
qreal playmatVisibleWidth(const QSize &fullCardSize, const PlaymatParams ¶ms)
Width of the outer viewing window: full card width trimmed by the horizontal margins....
Definition playmat_utils.h:19
Positioning parameters for a playmat card image.
Definition playmat_params.h:18
double marginPctL
Left margin as fraction of card width (0.0–0.95).
Definition playmat_params.h:19
double marginPctR
Right margin as fraction of card width (0.0–0.95).
Definition playmat_params.h:20
double verticalOffset
Vertical position within card (0.0=top, 1.0=bottom).
Definition playmat_params.h:21
double zoom
Scale factor (0.1–4.0).
Definition playmat_params.h:22