paint method

  1. @override
void paint(
  1. Canvas canvas,
  2. Size size
)
override

Called whenever the object needs to paint. The given Canvas has its coordinate space configured such that the origin is at the top left of the box. The area of the box is the size of the size argument.

Paint operations should remain inside the given area. Graphical operations outside the bounds may be silently ignored, clipped, or not clipped. It may sometimes be difficult to guarantee that a certain operation is inside the bounds (e.g., drawing a rectangle whose size is determined by user inputs). In that case, consider calling Canvas.clipRect at the beginning of paint so everything that follows will be guaranteed to only draw within the clipped area.

Implementations should be wary of correctly pairing any calls to Canvas.save/Canvas.saveLayer and Canvas.restore, otherwise all subsequent painting on this canvas may be affected, with potentially hilarious but confusing results.

To paint text on a Canvas, use a TextPainter.

To paint an image on a Canvas:

  1. Obtain an ImageStream, for example by calling ImageProvider.resolve on an AssetImage or NetworkImage object.

  2. Whenever the ImageStream's underlying ImageInfo object changes (see ImageStream.addListener), create a new instance of your custom paint delegate, giving it the new ImageInfo object.

  3. In your delegate's paint method, call the Canvas.drawImage, Canvas.drawImageRect, or Canvas.drawImageNine methods to paint the ImageInfo.image object, applying the ImageInfo.scale value to obtain the correct rendering size.

Implementation

@override
void paint(Canvas canvas, Size size) {
  final scaleX = size.width / 20.26267363401378;
  final scaleY = size.height / 19.996231528900196;
  final scale = math.min(scaleX, scaleY);

  final translationX = (size.width - 20.26267363401378 * scale) / 2 - 1.9000000000000004 * scale;
  final translationY = (size.height - 19.996231528900196 * scale) / 2 - 2.003769176129005 * scale;

  final path = Path();
  final paint = Paint()..color = color;

  path.moveTo(
    8.9 * scale + translationX,
    17.0 * scale + translationY,
  );

  path.cubicTo(
    8.347715250169207 * scale + translationX,
    17.0 * scale + translationY,
    7.9 * scale + translationX,
    17.447715250169207 * scale + translationY,
    7.9 * scale + translationX,
    18.0 * scale + translationY,
  );

  path.cubicTo(
    7.9 * scale + translationX,
    18.552284749830793 * scale + translationY,
    8.347715250169207 * scale + translationX,
    19.0 * scale + translationY,
    8.9 * scale + translationX,
    19.0 * scale + translationY,
  );

  path.cubicTo(
    9.452284749830794 * scale + translationX,
    19.0 * scale + translationY,
    9.9 * scale + translationX,
    18.552284749830793 * scale + translationY,
    9.9 * scale + translationX,
    18.0 * scale + translationY,
  );

  path.cubicTo(
    9.9 * scale + translationX,
    17.447715250169207 * scale + translationY,
    9.452284749830794 * scale + translationX,
    17.0 * scale + translationY,
    8.9 * scale + translationX,
    17.0 * scale + translationY,
  );

  path.close();

  path.moveTo(
    5.9 * scale + translationX,
    17.0 * scale + translationY,
  );

  path.cubicTo(
    5.347715250169207 * scale + translationX,
    17.0 * scale + translationY,
    4.9 * scale + translationX,
    17.447715250169207 * scale + translationY,
    4.9 * scale + translationX,
    18.0 * scale + translationY,
  );

  path.cubicTo(
    4.9 * scale + translationX,
    18.552284749830793 * scale + translationY,
    5.347715250169207 * scale + translationX,
    19.0 * scale + translationY,
    5.9 * scale + translationX,
    19.0 * scale + translationY,
  );

  path.cubicTo(
    6.452284749830794 * scale + translationX,
    19.0 * scale + translationY,
    6.9 * scale + translationX,
    18.552284749830793 * scale + translationY,
    6.9 * scale + translationX,
    18.0 * scale + translationY,
  );

  path.cubicTo(
    6.9 * scale + translationX,
    17.447715250169207 * scale + translationY,
    6.452284749830794 * scale + translationX,
    17.0 * scale + translationY,
    5.9 * scale + translationX,
    17.0 * scale + translationY,
  );

  path.close();

  path.moveTo(
    11.9 * scale + translationX,
    17.0 * scale + translationY,
  );

  path.cubicTo(
    11.347715250169207 * scale + translationX,
    17.0 * scale + translationY,
    10.9 * scale + translationX,
    17.447715250169207 * scale + translationY,
    10.9 * scale + translationX,
    18.0 * scale + translationY,
  );

  path.cubicTo(
    10.9 * scale + translationX,
    18.552284749830793 * scale + translationY,
    11.347715250169207 * scale + translationX,
    19.0 * scale + translationY,
    11.9 * scale + translationX,
    19.0 * scale + translationY,
  );

  path.cubicTo(
    12.452284749830794 * scale + translationX,
    19.0 * scale + translationY,
    12.9 * scale + translationX,
    18.552284749830793 * scale + translationY,
    12.9 * scale + translationX,
    18.0 * scale + translationY,
  );

  path.cubicTo(
    12.9 * scale + translationX,
    17.447715250169207 * scale + translationY,
    12.452284749830794 * scale + translationX,
    17.0 * scale + translationY,
    11.9 * scale + translationX,
    17.0 * scale + translationY,
  );

  path.close();

  path.moveTo(
    15.0 * scale + translationX,
    8.5 * scale + translationY,
  );

  path.cubicTo(
    15.178898880714998 * scale + translationX,
    8.191597827624118 * scale + translationY,
    15.508465696675282 * scale + translationX,
    8.001771860510331 * scale + translationY,
    15.865 * scale + translationX,
    8.001771860510331 * scale + translationY,
  );

  path.cubicTo(
    16.22153430332472 * scale + translationX,
    8.001771860510331 * scale + translationY,
    16.551101119285 * scale + translationX,
    8.191597827624118 * scale + translationY,
    16.73 * scale + translationX,
    8.5 * scale + translationY,
  );

  path.cubicTo(
    17.004608480643558 * scale + translationX,
    8.97613641647177 * scale + translationY,
    17.61202082339018 * scale + translationX,
    9.141388303836658 * scale + translationY,
    18.09 * scale + translationX,
    8.869999999999997 * scale + translationY,
  );

  path.cubicTo(
    18.328286824023607 * scale + translationX,
    8.744925797220734 * scale + translationY,
    18.50610383673912 * scale + translationX,
    8.529087476388188 * scale + translationY,
    18.583261480030757 * scale + translationX,
    8.271268034169788 * scale + translationY,
  );

  path.cubicTo(
    18.660419123322395 * scale + translationX,
    8.01344859195139 * scale + translationY,
    18.63040399290431 * scale + translationX,
    7.735412330473022 * scale + translationY,
    18.5 * scale + translationX,
    7.5 * scale + translationY,
  );

  path.cubicTo(
    17.96460780130395 * scale + translationX,
    6.569916858786682 * scale + translationY,
    16.97317355502473 * scale + translationX,
    5.996663043618391 * scale + translationY,
    15.900000473856927 * scale + translationX,
    5.996663043618391 * scale + translationY,
  );

  path.cubicTo(
    14.826827392689125 * scale + translationX,
    5.996663043618391 * scale + translationY,
    13.835393146409906 * scale + translationX,
    6.569916858786682 * scale + translationY,
    13.300000396370889 * scale + translationX,
    7.500000223517418 * scale + translationY,
  );

  path.cubicTo(
    13.125648998433732 * scale + translationX,
    7.956101905683067 * scale + translationY,
    13.306185706822493 * scale + translationX,
    8.471425688426804 * scale + translationY,
    13.727059649485073 * scale + translationX,
    8.71899859587538 * scale + translationY,
  );

  path.cubicTo(
    14.147933592147652 * scale + translationX,
    8.966571503323955 * scale + translationY,
    14.686060903248798 * scale + translationX,
    8.873991261456634 * scale + translationY,
    15.0 * scale + translationX,
    8.5 * scale + translationY,
  );

  path.close();

  path.moveTo(
    22.0 * scale + translationX,
    5.5 * scale + translationY,
  );

  path.cubicTo(
    20.749003261592424 * scale + translationX,
    3.336316885347072 * scale + translationY,
    18.439304812670123 * scale + translationX,
    2.003769176129005 * scale + translationY,
    15.940000712573527 * scale + translationX,
    2.003769176129005 * scale + translationY,
  );

  path.cubicTo(
    13.440696612476932 * scale + translationX,
    2.003769176129005 * scale + translationY,
    11.13099816355463 * scale + translationX,
    3.3363168853470704 * scale + translationY,
    9.880000441670417 * scale + translationX,
    5.500000245869159 * scale + translationY,
  );

  path.cubicTo(
    9.746454987118328 * scale + translationX,
    5.730523736175956 * scale + translationY,
    9.710416285282559 * scale + translationX,
    6.004806291505455 * scale + translationY,
    9.77987834774194 * scale + translationX,
    6.262003657909111 * scale + translationY,
  );

  path.cubicTo(
    9.849340410201322 * scale + translationX,
    6.519201024312768 * scale + translationY,
    10.01856029091802 * scale + translationX,
    6.738048779974813 * scale + translationY,
    10.25 * scale + translationX,
    6.87 * scale + translationY,
  );

  path.cubicTo(
    10.38759288729417 * scale + translationX,
    6.948347767055126 * scale + translationY,
    10.541823479365323 * scale + translationX,
    6.992903271431238 * scale + translationY,
    10.7 * scale + translationX,
    7.0 * scale + translationY,
  );

  path.cubicTo(
    11.058684758437725 * scale + translationX,
    7.001424006341473 * scale + translationY,
    11.390659034129504 * scale + translationX,
    6.810634192725508 * scale + translationY,
    11.57 * scale + translationX,
    6.5 * scale + translationY,
  );

  path.cubicTo(
    12.463197343948046 * scale + translationX,
    4.953118623134955 * scale + translationY,
    14.113762995967424 * scale + translationX,
    4.000219975436075 * scale + translationY,
    15.900000236928465 * scale + translationX,
    4.000219975436075 * scale + translationY,
  );

  path.cubicTo(
    17.686237477889506 * scale + translationX,
    4.000219975436075 * scale + translationY,
    19.33680312990888 * scale + translationX,
    4.953118623134956 * scale + translationY,
    20.23000030145049 * scale + translationX,
    6.500000096857548 * scale + translationY,
  );

  path.cubicTo(
    20.361951220025187 * scale + translationX,
    6.731439709081982 * scale + translationY,
    20.580798975687234 * scale + translationX,
    6.900659589798681 * scale + translationY,
    20.83799634209089 * scale + translationX,
    6.9701216522580625 * scale + translationY,
  );

  path.cubicTo(
    21.095193708494545 * scale + translationX,
    7.039583714717444 * scale + translationY,
    21.369476263824044 * scale + translationX,
    7.003545012881673 * scale + translationY,
    21.6 * scale + translationX,
    6.87 * scale + translationY,
  );

  path.cubicTo(
    21.83656562685139 * scale + translationX,
    6.743180386228184 * scale + translationY,
    22.01221690784198 * scale + translationX,
    6.526582770117484 * scale + translationY,
    22.08744527092788 * scale + translationX,
    6.268925626548286 * scale + translationY,
  );

  path.cubicTo(
    22.162673634013778 * scale + translationX,
    6.011268482979087 * scale + translationY,
    22.13116266289324 * scale + translationX,
    5.734185537784844 * scale + translationY,
    22.0 * scale + translationX,
    5.5 * scale + translationY,
  );

  path.close();

  path.moveTo(
    17.9 * scale + translationX,
    14.0 * scale + translationY,
  );

  path.lineTo(
    16.9 * scale + translationX,
    14.0 * scale + translationY,
  );

  path.lineTo(
    16.9 * scale + translationX,
    11.0 * scale + translationY,
  );

  path.cubicTo(
    16.9 * scale + translationX,
    10.447715250169207 * scale + translationY,
    16.452284749830792 * scale + translationX,
    10.0 * scale + translationY,
    15.899999999999999 * scale + translationX,
    10.0 * scale + translationY,
  );

  path.cubicTo(
    15.347715250169205 * scale + translationX,
    10.0 * scale + translationY,
    14.899999999999999 * scale + translationX,
    10.447715250169207 * scale + translationY,
    14.899999999999999 * scale + translationX,
    11.0 * scale + translationY,
  );

  path.lineTo(
    14.899999999999999 * scale + translationX,
    14.0 * scale + translationY,
  );

  path.lineTo(
    4.9 * scale + translationX,
    14.0 * scale + translationY,
  );

  path.cubicTo(
    3.2431458267078157 * scale + translationX,
    14.000000367854406 * scale + translationY,
    1.9000000072463075 * scale + translationX,
    15.343146187315913 * scale + translationY,
    1.900000056624413 * scale + translationX,
    17.000000506639477 * scale + translationY,
  );

  path.lineTo(
    1.9000000000000004 * scale + translationX,
    19.0 * scale + translationY,
  );

  path.cubicTo(
    1.9000000072463061 * scale + translationX,
    20.65685488556769 * scale + translationY,
    3.243145826707813 * scale + translationX,
    22.0000007050292 * scale + translationY,
    4.9000001460313785 * scale + translationX,
    22.000000655651093 * scale + translationY,
  );

  path.lineTo(
    17.9 * scale + translationX,
    22.0 * scale + translationY,
  );

  path.cubicTo(
    19.556854852785136 * scale + translationX,
    22.000000705029198 * scale + translationY,
    20.90000067224664 * scale + translationX,
    20.65685488556769 * scale + translationY,
    20.900000622868536 * scale + translationX,
    19.000000566244125 * scale + translationY,
  );

  path.lineTo(
    20.9 * scale + translationX,
    17.0 * scale + translationY,
  );

  path.cubicTo(
    20.90000067224664 * scale + translationX,
    15.343146187315915 * scale + translationY,
    19.556854852785136 * scale + translationX,
    14.000000367854406 * scale + translationY,
    17.90000053346157 * scale + translationX,
    14.000000417232513 * scale + translationY,
  );

  path.close();

  path.moveTo(
    18.9 * scale + translationX,
    19.0 * scale + translationY,
  );

  path.cubicTo(
    18.9 * scale + translationX,
    19.552284749830793 * scale + translationY,
    18.452284749830792 * scale + translationX,
    20.0 * scale + translationY,
    17.9 * scale + translationX,
    20.0 * scale + translationY,
  );

  path.lineTo(
    4.9 * scale + translationX,
    20.0 * scale + translationY,
  );

  path.cubicTo(
    4.347715250169207 * scale + translationX,
    20.0 * scale + translationY,
    3.9000000000000004 * scale + translationX,
    19.552284749830793 * scale + translationY,
    3.9000000000000004 * scale + translationX,
    19.0 * scale + translationY,
  );

  path.lineTo(
    3.9000000000000004 * scale + translationX,
    17.0 * scale + translationY,
  );

  path.cubicTo(
    3.9000000000000004 * scale + translationX,
    16.447715250169207 * scale + translationY,
    4.347715250169207 * scale + translationX,
    16.0 * scale + translationY,
    4.9 * scale + translationX,
    16.0 * scale + translationY,
  );

  path.lineTo(
    17.9 * scale + translationX,
    16.0 * scale + translationY,
  );

  path.cubicTo(
    18.452284749830792 * scale + translationX,
    16.0 * scale + translationY,
    18.9 * scale + translationX,
    16.447715250169207 * scale + translationY,
    18.9 * scale + translationX,
    17.0 * scale + translationY,
  );

  path.close();

  canvas.drawPath(path, paint);
}