Cockatrice 2026-09-01-Development-3.1.0-beta.10
A virtual tabletop for multiplayer card games
Loading...
Searching...
No Matches
PlaymatUtils Namespace Reference

Functions

qreal playmatVisibleWidth (const QSize &fullCardSize, const PlaymatParams &params)
 Width of the outer viewing window: full card width trimmed by the horizontal margins. Guarded against margins summing to >= 1.
qreal playmatClampedZoom (const QSize &fullCardSize, const PlaymatParams &params)
 Zoom clamped to the range where every step renders differently.
qreal playmatWindowSide (const QSize &fullCardSize, const PlaymatParams &params)
 Side of the square sampling window actually rendered for these parameters. Never exceeds either card dimension, so the source rect always lies within the image (vertical travel remains for panning whenever the art is taller than it is wide).
QRectF computeArtSourceRect (const QSize &fullCardSize, const PlaymatParams &params)
 Computes the source region of the full resolution card image to use as a playmat.
QRectF coverFitRect (const QRectF &dstArea, const QSizeF &srcSize)
 Returns the destination rectangle that fits a source of the given aspect ratio into dstArea using "cover" semantics (no distortion, overflows cropped).
QRectF aspectFitRect (const QRectF &dstArea, qreal aspect)
 Fits a rectangle of the given aspect ratio into dstArea, centered, touching the constraining dimension ("aspect fit" of the FRAME itself, not of a source image).

Variables

constexpr qreal MAX_ZOOM = 4.0
 Upper bound for zooming into the playmat art.

Function Documentation

◆ aspectFitRect()

QRectF PlaymatUtils::aspectFitRect ( const QRectF & dstArea,
qreal aspect )
inline

Fits a rectangle of the given aspect ratio into dstArea, centered, touching the constraining dimension ("aspect fit" of the FRAME itself, not of a source image).

Here is the caller graph for this function:

◆ computeArtSourceRect()

QRectF PlaymatUtils::computeArtSourceRect ( const QSize & fullCardSize,
const PlaymatParams & params )
inline

Computes the source region of the full resolution card image to use as a playmat.

Parameters are relative to the full card image. horizontal margins trim the card borders (shifting them pans the window), verticalOffset places the top edge of the sampling window within its available travel, and zoom scales into the trimmed span. The result always lies within the card image bounds.

Parameters
fullCardSizeSize of the full card image.
paramsPositioning parameters.
Returns
Source rectangle in full card image pixel coordinates.
Here is the call graph for this function:
Here is the caller graph for this function:

◆ coverFitRect()

QRectF PlaymatUtils::coverFitRect ( const QRectF & dstArea,
const QSizeF & srcSize )
inline

Returns the destination rectangle that fits a source of the given aspect ratio into dstArea using "cover" semantics (no distortion, overflows cropped).

Parameters
dstAreaArea to fill.
srcSizeSize of the source, only its aspect ratio matters.
Returns
Destination rectangle centered in dstArea.
Here is the caller graph for this function:

◆ playmatClampedZoom()

qreal PlaymatUtils::playmatClampedZoom ( const QSize & fullCardSize,
const PlaymatParams & params )
inline

Zoom clamped to the range where every step renders differently.

The square sampling window is visibleWidth / zoom, zooming out past visibleWidth / min(card width, height) would sample beyond the card itself, which both looks broken and makes whole ranges of the parameter dead. The floor is therefore derived from the actual image instead of a static value, and is shared verbatim by the render path and the editor's gesture math so the two can never disagree.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ playmatVisibleWidth()

qreal PlaymatUtils::playmatVisibleWidth ( const QSize & fullCardSize,
const PlaymatParams & params )
inline

Width of the outer viewing window: full card width trimmed by the horizontal margins. Guarded against margins summing to >= 1.

Here is the caller graph for this function:

◆ playmatWindowSide()

qreal PlaymatUtils::playmatWindowSide ( const QSize & fullCardSize,
const PlaymatParams & params )
inline

Side of the square sampling window actually rendered for these parameters. Never exceeds either card dimension, so the source rect always lies within the image (vertical travel remains for panning whenever the art is taller than it is wide).

Here is the call graph for this function:
Here is the caller graph for this function:

Variable Documentation

◆ MAX_ZOOM

qreal PlaymatUtils::MAX_ZOOM = 4.0
constexpr

Upper bound for zooming into the playmat art.