feat: add depth to game

This commit is contained in:
2026-06-15 19:40:25 +03:30
parent fbf068c2e6
commit 73b7c136f1
4 changed files with 117 additions and 16 deletions
+35 -11
View File
@@ -7,24 +7,48 @@ 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 rect = Rect.fromCenter(
center: Offset(w / 2, h / 2),
width: w * 0.86,
height: h * 0.62,
);
final rrect = RRect.fromRectAndRadius(rect, Radius.circular(h * 0.3));
canvas.drawRRect(rrect, Paint()..color = const Color(0xFF1B5E20));
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.drawRRect(
rrect,
rail,
Paint()
..shader = const LinearGradient(
begin: Alignment.topCenter,
end: Alignment.bottomCenter,
colors: [Color(0xFF5A2E12), Color(0xFF2E1608)],
).createShader(rail.outerRect),
);
// ۲) حلقه‌ی طلایی بین ریل و نمد.
canvas.drawRRect(
RRect.fromRectAndRadius(rect.inflate(w * 0.008), radius),
Paint()
..style = PaintingStyle.stroke
..strokeWidth = 6
..color = _goldDark,
..strokeWidth = w * 0.012
..color = _gold,
);
// ۳) نمدِ سبز با گرادیانِ شعاعی (مرکز روشن، لبه‌ها تیره) — خودش حسِ وینیت/عمق می‌دهد.
canvas.drawRRect(
felt,
Paint()
..shader = RadialGradient(
center: Alignment.center,
radius: 0.95,
colors: const [Color(0xFF34A03F), Color(0xFF0E3614)],
stops: const [0.45, 1.0],
).createShader(rect),
);
}
}