drawSparkles static method
void
drawSparkles({})
Sparkle util (set foreground=true untuk bintang terang di depan).
Implementation
static void drawSparkles({
required Canvas canvas,
required Offset center,
required double progress,
required Color baseColor,
required math.Random random,
required double maxDistance,
required int sparkleCount,
required bool foreground,
}) {
for (int i = 0; i < sparkleCount; i++) {
final d = random.nextDouble() * maxDistance * (foreground ? 1.5 : 1.2);
final a = random.nextDouble() * math.pi * 2;
final pos =
Offset(center.dx + math.cos(a) * d, center.dy + math.sin(a) * d);
final size =
random.nextDouble() * (foreground ? 4 : 3) + (foreground ? 2 : 1);
final col = HSLColor.fromColor(baseColor)
.withLightness(0.7 + random.nextDouble() * .3)
.withSaturation(0.7 + random.nextDouble() * .3)
.toColor()
.withOpacity(foreground
? (.5 + random.nextDouble() * .5)
: (.3 + random.nextDouble() * .4));
foreground
? drawStar(canvas, pos, size, col)
: canvas.drawCircle(pos, size, Paint()..color = col);
}
}