1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-07-25 05:07:34 +00:00

Chess+GamesSettings: Give chess pieces some breathing room

Draw pieces around 80% of the size of a square, instead of 100%, so that
there is a nice gap around them. This feels more comfy, and makes it
actually possible to read the coordinates while a piece is on their
square.
This commit is contained in:
Sam Atkins 2023-02-02 17:41:13 +00:00 committed by Andreas Kling
parent 7e4186de63
commit 0f2936d8cd
2 changed files with 4 additions and 2 deletions

View file

@ -163,6 +163,7 @@ private:
// With the same preview size as we use for card games, a nice fit is 2 ranks of 6.
// There are definitely better ways of doing this, but it'll do. ;^)
auto square_size = 61;
auto square_margin = square_size / 10;
auto rect_for_square = [&](Chess::Square const& square) {
return Gfx::IntRect {
@ -196,7 +197,7 @@ private:
auto draw_piece = [&](Chess::Piece const& piece, Chess::Square const& square) {
auto& bitmap = *m_piece_images.get(piece).value();
painter.draw_scaled_bitmap(
rect_for_square(square),
rect_for_square(square).shrunken(square_margin, square_margin, square_margin, square_margin),
bitmap,
bitmap.rect(),
1.0f,