getLinesShapes method

List<Shape> getLinesShapes(
  1. int lines
)

Implementation

List<Shape> getLinesShapes(int lines) {
  List<Shape> res = [];
  double size = maxHeight / (2 * lines);

  double speed = randomSpeed();
  double space = ((maxWidth % size) + size) / ((maxWidth / size) - 1);
  double x = 0;
  ItemBehaviour behaviour =
      behaviours[getDouble(0, behaviours.length - 1).toInt()];

  Color color = colors[getDouble(0, colors.length - 1).toInt()]
      .withOpacity(getDouble(minOpacity, maxOpacity));

  while (x < maxWidth) {
    res.add(
      Shape(
        pos: Offset(x, size / 2),
        dx: speed,
        dy: 0,
        size: size,
        color: color,
        behaviour: behaviour,
      ),
    );
    x += size + space;
  }
  return res;
}