import 'package:flutter/material.dart'; Color lighten(Color c, double amount) => Color.lerp(c, Colors.white, amount)!; Color darken(Color c, double amount) => Color.lerp(c, Colors.black, amount)!; /// Candy-gloss tile: diagonal gradient body, glass top highlight, optional /// colored glow (used for gems and clear flashes). Shared by the board, /// tray, and drag overlay so every tile in the game matches. void paintGlossyTile( Canvas canvas, Rect rect, Color color, { double radiusFactor = 0.18, double glow = 0, }) { final radius = Radius.circular(rect.width * radiusFactor); final rrect = RRect.fromRectAndRadius(rect, radius); if (glow > 0) { final glowPaint = Paint() ..color = color.withValues(alpha: 0.55 * glow) ..maskFilter = MaskFilter.blur(BlurStyle.normal, rect.width * 0.28 * glow); canvas.drawRRect(rrect.inflate(rect.width * 0.05), glowPaint); } final body = Paint() ..shader = LinearGradient( begin: Alignment.topLeft, end: Alignment.bottomRight, colors: [lighten(color, 0.28), color, darken(color, 0.22)], stops: const [0.0, 0.45, 1.0], ).createShader(rect); canvas.drawRRect(rrect, body); final highlight = Paint()..color = Colors.white.withValues(alpha: 0.30); final hl = Rect.fromLTWH( rect.left + rect.width * 0.10, rect.top + rect.height * 0.07, rect.width * 0.80, rect.height * 0.30, ); canvas.drawRRect( RRect.fromRectAndRadius(hl, Radius.circular(rect.width * 0.12)), highlight, ); }