setInitial method

void setInitial()

Implementation

void setInitial() {
  //map = [[]];
  textCenter = [];
  textPoints = [];
  textlist = [];
  isdrawed = [];

  centerX = mapX / 2;
  centerY = mapY / 2;

  map = setMap(shape);

  // for (var i = 0; i < mapX; i++) {
  //   for (var j = 0; j < mapY; j++) {
  //     if (pow(i - (mapX / 2), 2) + pow(j - (mapY / 2), 2) > pow(250, 2)) {
  //       map[i].add(1);
  //     } else {
  //       map[i].add(0);
  //     }
  //   }
  //   map.add([]);
  // }

  for (var i = 0; i < data.length; i++) {
    double getTextSize =
        (minTextSize * (data[0]['value'] - data[i]['value']) +
            maxTextSize *
                (data[i]['value'] - data[data.length - 1]['value'])) /
            (data[0]['value'] - data[data.length - 1]['value']);

    final textSpan = TextSpan(
      text: data[i]['word'],
      style: TextStyle(
        color: colorList?[Random().nextInt(colorList!.length)],
        fontSize: getTextSize,
        fontWeight: fontWeight,
        fontFamily: fontFamily,
        fontStyle: fontStyle,
      ),
    );

    final textPainter = TextPainter()
      ..text = textSpan
      ..textDirection = TextDirection.ltr
      ..textAlign = TextAlign.center
      ..layout();

    textlist.add(textPainter);

    double centerCorrectionX = centerX - textlist[i].width / 2;
    double centerCorrectionY = centerY - textlist[i].height / 2;
    textCenter.add([centerCorrectionX, centerCorrectionY]);
    textPoints.add([]);
    isdrawed.add(false);
  }
}