drawArcOfPoints method

void drawArcOfPoints(
  1. Canvas canvas,
  2. Size canvasSize, {
  3. Color color = const Color.fromRGBO(128, 128, 128, 1),
  4. int? elementAttributeRow,
  5. List<ElementAttributes>? allElementAttributes,
  6. Offset centerOffset = const Offset(0, 0),
  7. double rectSize = 20,
  8. int nbElements = 10,
  9. double angleArcDegres = 90,
  10. double angleOffset = 0,
  11. double rayonArc = 100,
  12. double rectRadius = 0,
  13. bool? hiliteFronde = false,
})

Implementation

void drawArcOfPoints(Canvas canvas, Size canvasSize,
    {Color color = const Color.fromRGBO(128, 128, 128, 1),
    int? elementAttributeRow,
    List<ElementAttributes>? allElementAttributes,
    Offset centerOffset = const Offset(0, 0),
    double rectSize = 20,
    int nbElements = 10,
    double angleArcDegres = 90,
    double angleOffset = 0,
    double rayonArc = 100,
    double rectRadius = 0,
    bool? hiliteFronde = false}) {
  if (nbElements == 1) {
    double angle = 0 + angleOffset;
    if (elementAttributeRow != null && allElementAttributes != null) {
      for (ElementAttributes element in allElementAttributes) {
        if (element.row == elementAttributeRow && element.position == 0) {
          color = returnTheDotColor(element);
        }
      }
    }
    rectPainting(
        canvas,
        canvasSize,
        color,
        rectSize,
        (centerOffset.dx + rayonArc * math.sin(angle.degreesToRadians))
            .toDouble(),
        (centerOffset.dy + rayonArc * -math.cos(angle.degreesToRadians))
            .toDouble(),
        radius: rectRadius);
  } else {
    double angleDebut = (-angleArcDegres / 2) + angleOffset;
    double angleFin = (angleArcDegres / 2) + angleOffset;

    if (elementAttributeRow != null && allElementAttributes != null) {
      for (ElementAttributes element in allElementAttributes) {
        if (element.row == elementAttributeRow && element.position == 0) {
          color = returnTheDotColor(element);
        }
      }
    }
    rectPainting(
        canvas,
        canvasSize,
        color,
        rectSize,
        (centerOffset.dx + rayonArc * math.sin(angleDebut.degreesToRadians))
            .toDouble(),
        (centerOffset.dy + rayonArc * -math.cos(angleDebut.degreesToRadians))
            .toDouble(),
        radius: rectRadius);
    int maxLoop = 0;
    for (var i = 1; i < nbElements - 1; i++) {
      double angle = ((angleArcDegres / (nbElements - 1) * i) + angleDebut);
      if (elementAttributeRow != null && allElementAttributes != null) {
        for (ElementAttributes element in allElementAttributes) {
          if (element.row == elementAttributeRow && element.position == i) {
            color = returnTheDotColor(element);
          }
        }
      }
      rectPainting(
          canvas,
          canvasSize,
          color,
          rectSize,
          (centerOffset.dx + rayonArc * math.sin(angle.degreesToRadians))
              .toDouble(),
          (centerOffset.dy + rayonArc * -math.cos(angle.degreesToRadians))
              .toDouble(),
          radius: rectRadius);
      maxLoop = i;
    }
    if (elementAttributeRow != null && allElementAttributes != null) {
      for (ElementAttributes element in allElementAttributes) {
        if (element.row == elementAttributeRow &&
            element.position == maxLoop + 1) {
          color = returnTheDotColor(element);
        }
      }
    }
    rectPainting(
        canvas,
        canvasSize,
        color,
        rectSize,
        (centerOffset.dx + rayonArc * math.sin(angleFin.degreesToRadians))
            .toDouble(),
        (centerOffset.dy + rayonArc * -math.cos(angleFin.degreesToRadians))
            .toDouble(),
        radius: rectRadius);
  }
}