draw method

void draw(
  1. Canvas canvas,
  2. Size size
)

Implementation

void draw(Canvas canvas, Size size) {
  if (behaviour.shape == ShapeType.FilledCircle)
    canvas.drawCircle(pos, this.size / 2, getPaint());
  else if (behaviour.shape == ShapeType.TripleStrokeCircle) {
    canvas.drawCircle(pos, this.size / 2, getPaint());
    canvas.drawCircle(pos, this.size / 6, getPaint());
    canvas.drawCircle(pos, this.size / 3, getPaint());
  } else if (behaviour.shape == ShapeType.DoubleStrokeCircle) {
    canvas.drawCircle(pos, this.size / 2, getPaint());
    canvas.drawCircle(pos, this.size / 4, getPaint());
  } else if (behaviour.shape == ShapeType.FilledTriangle) {
    canvas.drawRect(
        Rect.fromPoints(
            Offset(pos.dx - this.size / 2, pos.dy - this.size / 2),
            Offset(pos.dx + this.size / 2, pos.dy + this.size / 2)),
        getPaint());
  } else if (behaviour.shape == ShapeType.StrokeTriangle) {
    canvas.drawRect(
        Rect.fromPoints(
            Offset(pos.dx - this.size / 2, pos.dy - this.size / 2),
            Offset(pos.dx + this.size / 2, pos.dy + this.size / 2)),
        getPaint());
  } else if (behaviour.shape == ShapeType.DoubleStrokeTriangle) {
    canvas.drawRect(
        Rect.fromPoints(
            Offset(pos.dx - this.size / 2, pos.dy - this.size / 2),
            Offset(pos.dx + this.size / 2, pos.dy + this.size / 2)),
        getPaint());
    canvas.drawRect(
        Rect.fromPoints(
            Offset(pos.dx - this.size / 4, pos.dy - this.size / 4),
            Offset(pos.dx + this.size / 4, pos.dy + this.size / 4)),
        getPaint());
  } else if (behaviour.shape == ShapeType.TripleStrokeTriangle) {
    canvas.drawRect(
        Rect.fromPoints(
            Offset(pos.dx - this.size / 2, pos.dy - this.size / 2),
            Offset(pos.dx + this.size / 2, pos.dy + this.size / 2)),
        getPaint());

    canvas.drawRect(
        Rect.fromPoints(
            Offset(pos.dx - this.size / 3, pos.dy - this.size / 3),
            Offset(pos.dx + this.size / 3, pos.dy + this.size / 3)),
        getPaint());

    canvas.drawRect(
        Rect.fromPoints(
            Offset(pos.dx - this.size / 6, pos.dy - this.size / 6),
            Offset(pos.dx + this.size / 6, pos.dy + this.size / 6)),
        getPaint());
  } else if (behaviour.shape == ShapeType.Icon && behaviour.icon != null) {
    TextPainter textPainter = TextPainter(textDirection: TextDirection.ltr);
    textPainter.text = TextSpan(
      text: String.fromCharCode(behaviour.icon!.codePoint),
      style: TextStyle(
        color: color,
        fontSize: this.size,
        fontFamily: behaviour.icon!.fontFamily,
        package: behaviour.icon!.fontPackage,
      ),
    );
    textPainter.layout();
    textPainter.paint(
        canvas, Offset(pos.dx - this.size / 2, pos.dy - this.size / 2));

//      var builder = ParagraphBuilder(ParagraphStyle(
//        fontFamily: behaviour.icon!.fontFamily,
//      ))
//        ..addText(String.fromCharCode(behaviour.icon!.codePoint));
//      var para = builder.build();
//      para.layout(ParagraphConstraints(width: this.size));
//      canvas.drawParagraph(para, Offset(pos.dx - this.size / 2, pos.dy - this.size / 2));
  }
}