style: ui perfection

This commit is contained in:
2026-06-24 09:09:00 +03:30
parent 108a972761
commit 08937a66cb
4 changed files with 536 additions and 172 deletions
@@ -7,49 +7,72 @@ import 'package:flutter/material.dart';
const _gold = Color(0xFFE9B949);
const _goldDark = Color(0xFFB8860B);
/// نمدِ سبزِ بیضی‌شکلِ میز با عمق: لبه‌ی برجسته، گرادیانِ شعاعی و وینیت.
/// میز: زمینِ سبزِ نمدی در کلِ صفحه + یک «میزِ» مرکزیِ سرمهای با قابِ طلاییِ
/// دولایه (مطابقِ تصویرِ مرجع). کارت‌های زمین داخلِ ناحیه‌ی سرمه‌ای انداخته می‌شوند
/// و پشت‌کارتِ حریفان روی نمدِ سبزِ دورِ آن می‌نشیند.
class Felt extends PositionComponent with HasGameReference {
@override
void render(Canvas canvas) {
final w = game.size.x, h = game.size.y;
final center = Offset(w / 2, h / 2);
final rect = Rect.fromCenter(center: center, width: w * 0.86, height: h * 0.62);
final radius = Radius.circular(h * 0.3);
final felt = RRect.fromRectAndRadius(rect, radius);
// ۱) لبه‌ی چوبیِ بیرونی (ریل) با گرادیان — حسِ برجستگی بدون drawShadowِ هر-فریمی.
final rail = RRect.fromRectAndRadius(
rect.inflate(w * 0.03), Radius.circular(h * 0.33));
// ۱) زمینِ سبزِ نمدی (کلِ صفحه) با وینیتِ شعاعی برای عمق.
canvas.drawRect(
Rect.fromLTWH(0, 0, w, h),
Paint()
..shader = RadialGradient(
center: Alignment.center,
radius: 1.0,
colors: const [Color(0xFF1C7A3E), Color(0xFF0C3A1B)],
stops: const [0.5, 1.0],
).createShader(Rect.fromLTWH(0, 0, w, h)),
);
// ۲) میزِ مرکزیِ سرمه‌ای با قابِ طلایی.
final rect = Rect.fromCenter(
center: center, width: w * 0.72, height: h * 0.46);
final radius = Radius.circular(h * 0.05);
final table = RRect.fromRectAndRadius(rect, radius);
// سایه‌ی نرمِ زیرِ میز (یک‌بار، نه هر-فریمی سنگین).
canvas.drawRRect(
rail,
table.shift(const Offset(0, 6)),
Paint()
..color = const Color(0x66000000)
..maskFilter = const MaskFilter.blur(BlurStyle.normal, 12),
);
// قابِ طلاییِ بیرونی.
canvas.drawRRect(
RRect.fromRectAndRadius(rect.inflate(w * 0.012), radius),
Paint()
..shader = const LinearGradient(
begin: Alignment.topCenter,
end: Alignment.bottomCenter,
colors: [Color(0xFF5A2E12), Color(0xFF2E1608)],
).createShader(rail.outerRect),
colors: [_gold, _goldDark],
).createShader(rect),
);
// ۲) حلقه‌ی طلایی بین ریل و نمد.
// سطحِ سرمه‌ایِ میز با گرادیانِ شعاعی (مرکز روشن‌تر).
canvas.drawRRect(
RRect.fromRectAndRadius(rect.inflate(w * 0.008), radius),
Paint()
..style = PaintingStyle.stroke
..strokeWidth = w * 0.012
..color = _gold,
);
// ۳) نمدِ سبز با گرادیانِ شعاعی (مرکز روشن، لبه‌ها تیره) — خودش حسِ وینیت/عمق می‌دهد.
canvas.drawRRect(
felt,
table,
Paint()
..shader = RadialGradient(
center: Alignment.center,
radius: 0.95,
colors: const [Color(0xFF34A03F), Color(0xFF0E3614)],
stops: const [0.45, 1.0],
radius: 0.9,
colors: const [Color(0xFF153A63), Color(0xFF07172E)],
stops: const [0.4, 1.0],
).createShader(rect),
);
// خطِ طلاییِ نازکِ داخلی (قابِ دولایه).
canvas.drawRRect(
RRect.fromRectAndRadius(rect.deflate(w * 0.018), Radius.circular(h * 0.04)),
Paint()
..style = PaintingStyle.stroke
..strokeWidth = w * 0.004
..color = _gold.withValues(alpha: 0.65),
);
}
}