Bubble.random constructor

Bubble.random(
  1. double maxWidth,
  2. double maxHeight,
  3. BubbleConfig config,
  4. List<Color> colors,
)

Implementation

factory Bubble.random(double maxWidth, double maxHeight, BubbleConfig config,
    List<Color> colors) {
  final random = Random();
  return Bubble(
    x: random.nextDouble() * maxWidth,
    y: maxHeight + (random.nextDouble() * 40 + config.maxRadius),
    radius: random.nextDouble() * (config.maxRadius - config.minRadius) +
        config.minRadius,
    speed: random.nextDouble() * (config.maxSpeed - config.minSpeed) +
        config.minSpeed,
    opacity: random.nextDouble() * (config.maxOpacity - config.minOpacity) +
        config.minOpacity,
    wobbleSpeed: random.nextDouble() * 2 * pi,
    color: colors[random.nextInt(colors.length)],
  );
}