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 / 22.17194441901624;
  final scaleY = size.height / 22.17194441901624;
  final scale = math.min(scaleX, scaleY);

  final translationX = (size.width - 22.17194441901624 * scale) / 2 - 0.9140277904918974 * scale;
  final translationY = (size.height - 22.17194441901624 * scale) / 2 - 0.9140277904918981 * scale;

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

  path.moveTo(
    8.7 * scale + translationX,
    4.0 * scale + translationY,
  );

  path.lineTo(
    18.323 * scale + translationX,
    4.0 * scale + translationY,
  );

  path.lineTo(
    19.984 * scale + translationX,
    8.154 * scale + translationY,
  );

  path.cubicTo(
    19.900953739314904 * scale + translationX,
    9.222367816979636 * scale + translationY,
    18.988732378179947 * scale + translationX,
    10.034293707909317 * scale + translationY,
    17.917941381654085 * scale + translationX,
    9.992902690473327 * scale + translationY,
  );

  path.cubicTo(
    16.84715038512822 * scale + translationX,
    9.951511673037338 * scale + translationY,
    16.000326724142475 * scale + translationX,
    9.071590567899175 * scale + translationY,
    15.999999885654688 * scale + translationX,
    7.999999942827344 * scale + translationY,
  );

  path.cubicTo(
    16.0 * scale + translationX,
    7.447715250169207 * scale + translationY,
    15.552284749830793 * scale + translationX,
    7.0 * scale + translationY,
    15.0 * scale + translationX,
    7.0 * scale + translationY,
  );

  path.cubicTo(
    14.447715250169207 * scale + translationX,
    7.0 * scale + translationY,
    14.0 * scale + translationX,
    7.447715250169207 * scale + translationY,
    14.0 * scale + translationX,
    8.0 * scale + translationY,
  );

  path.cubicTo(
    14.002937316537059 * scale + translationX,
    8.242894002904713 * scale + translationY,
    13.957381384478348 * scale + translationX,
    8.483932479245203 * scale + translationY,
    13.866000461323177 * scale + translationX,
    8.70900028974928 * scale + translationY,
  );

  path.cubicTo(
    13.655897013262207 * scale + translationX,
    9.219310557940611 * scale + translationY,
    13.898913069851925 * scale + translationX,
    9.80335467184408 * scale + translationY,
    14.408999999999999 * scale + translationX,
    10.014 * scale + translationY,
  );

  path.cubicTo(
    14.465777501371562 * scale + translationX,
    10.031088807285132 * scale + translationY,
    14.52403329102599 * scale + translationX,
    10.042806925893784 * scale + translationY,
    14.583001087450732 * scale + translationX,
    10.049000749351467 * scale + translationY,
  );

  path.cubicTo(
    15.299561092203426 * scale + translationX,
    11.255074194971794 * scale + translationY,
    16.597126098423242 * scale + translationX,
    11.99594318154916 * scale + translationY,
    18.00000058680382 * scale + translationX,
    12.000000391202546 * scale + translationY,
  );

  path.lineTo(
    18.0 * scale + translationX,
    13.3 * scale + translationY,
  );

  path.cubicTo(
    18.0 * scale + translationX,
    13.852284749830794 * scale + translationY,
    18.447715250169207 * scale + translationX,
    14.3 * scale + translationY,
    19.0 * scale + translationX,
    14.3 * scale + translationY,
  );

  path.cubicTo(
    19.552284749830793 * scale + translationX,
    14.3 * scale + translationY,
    20.0 * scale + translationX,
    13.852284749830794 * scale + translationY,
    20.0 * scale + translationX,
    13.3 * scale + translationY,
  );

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

  path.cubicTo(
    21.22015694072602 * scale + translationX,
    10.74132854325576 * scale + translationY,
    21.978935030209616 * scale + translationX,
    9.44692002888119 * scale + translationY,
    21.99600023382006 * scale + translationX,
    8.039000085455514 * scale + translationY,
  );

  path.cubicTo(
    21.996 * scale + translationX,
    8.029000000000002 * scale + translationY,
    21.999 * scale + translationX,
    8.021 * scale + translationY,
    21.999 * scale + translationX,
    8.011000000000001 * scale + translationY,
  );

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

  path.cubicTo(
    21.993610294340073 * scale + translationX,
    7.94204555764181 * scale + translationY,
    21.98189408513138 * scale + translationX,
    7.884803506936489 * scale + translationY,
    21.9649991894118 * scale + translationX,
    7.828999711081492 * scale + translationY,
  );

  path.cubicTo(
    21.960170534837655 * scale + translationX,
    7.761240004511619 * scale + translationY,
    21.948101794586663 * scale + translationX,
    7.694191447561644 * scale + translationY,
    21.929000442514674 * scale + translationX,
    7.629000153948854 * scale + translationY,
  );

  path.lineTo(
    19.929 * scale + translationX,
    2.6289999999999996 * scale + translationY,
  );

  path.cubicTo(
    19.77718981553806 * scale + translationX,
    2.2490108992132254 * scale + translationY,
    19.409191918612642 * scale + translationX,
    1.9998497827804083 * scale + translationY,
    19.0 * scale + translationX,
    2.0 * scale + translationY,
  );

  path.lineTo(
    8.7 * scale + translationX,
    2.0 * scale + translationY,
  );

  path.cubicTo(
    8.147715250169206 * scale + translationX,
    2.0 * scale + translationY,
    7.699999999999999 * scale + translationX,
    2.4477152501692068 * scale + translationY,
    7.699999999999999 * scale + translationX,
    3.0 * scale + translationY,
  );

  path.cubicTo(
    7.699999999999999 * scale + translationX,
    3.5522847498307932 * scale + translationY,
    8.147715250169206 * scale + translationX,
    4.0 * scale + translationY,
    8.7 * scale + translationX,
    4.0 * scale + translationY,
  );

  path.close();

  path.moveTo(
    22.707 * scale + translationX,
    21.293 * scale + translationY,
  );

  path.lineTo(
    19.774 * scale + translationX,
    18.36 * scale + translationY,
  );

  path.cubicTo(
    19.728787790584914 * scale + translationX,
    18.302892319471606 * scale + translationY,
    19.677109891926513 * scale + translationX,
    18.251214420813206 * scale + translationY,
    19.620001142381017 * scale + translationX,
    18.206001060050397 * scale + translationY,
  );

  path.lineTo(
    9.670000000000002 * scale + translationX,
    8.256 * scale + translationY,
  );

  path.cubicTo(
    9.612059960018195 * scale + translationX,
    8.177383906635677 * scale + translationY,
    9.542615076606348 * scale + translationX,
    8.10793902322383 * scale + translationY,
    9.463999456964025 * scale + translationX,
    8.049999538098097 * scale + translationY,
  );

  path.lineTo(
    5.182 * scale + translationX,
    3.7680000000000002 * scale + translationY,
  );

  path.cubicTo(
    5.1434471469134415 * scale + translationX,
    3.7214090728553484 * scale + translationY,
    5.100591192002442 * scale + translationX,
    3.67855311794435 * scale + translationY,
    5.0540001517333115 * scale + translationX,
    3.640000109281609 * scale + translationY,
  );

  path.lineTo(
    2.707 * scale + translationX,
    1.2930000000000001 * scale + translationY,
  );

  path.cubicTo(
    2.31462111303569 * scale + translationX,
    0.9140277904918981 * scale + translationY,
    1.6909152229788837 * scale + translationX,
    0.9194476261028997 * scale + translationY,
    1.3051814245408915 * scale + translationX,
    1.305181424540892 * scale + translationY,
  );

  path.cubicTo(
    0.9194476261028992 * scale + translationX,
    1.690915222978884 * scale + translationY,
    0.9140277904918974 * scale + translationX,
    2.31462111303569 * scale + translationY,
    1.2929999999999993 * scale + translationX,
    2.707 * scale + translationY,
  );

  path.lineTo(
    3.2569999999999997 * scale + translationX,
    4.671 * scale + translationY,
  );

  path.lineTo(
    2.0789999999999997 * scale + translationX,
    7.611000000000001 * scale + translationY,
  );

  path.lineTo(
    2.0719999999999996 * scale + translationX,
    7.628000000000001 * scale + translationY,
  );

  path.cubicTo(
    2.05399362652628 * scale + translationX,
    7.689659619063467 * scale + translationY,
    2.042267330912756 * scale + translationX,
    7.752981615376495 * scale + translationY,
    2.037000043890954 * scale + translationX,
    7.817000168431808 * scale + translationY,
  );

  path.cubicTo(
    2.0186754010111745 * scale + translationX,
    7.8766344130816455 * scale + translationY,
    2.006281978699052 * scale + translationX,
    7.937931609922681 * scale + translationY,
    2.0000001159579455 * scale + translationX,
    8.000000463831782 * scale + translationY,
  );

  path.lineTo(
    2.001 * scale + translationX,
    8.012 * scale + translationY,
  );

  path.lineTo(
    2.004 * scale + translationX,
    8.036 * scale + translationY,
  );

  path.cubicTo(
    2.0202111447426763 * scale + translationX,
    9.444939500269752 * scale + translationY,
    2.779076302123396 * scale + translationX,
    10.740637123693343 * scale + translationY,
    3.999999942755494 * scale + translationX,
    11.443999836223467 * scale + translationY,
  );

  path.lineTo(
    4.0 * scale + translationX,
    21.0 * scale + translationY,
  );

  path.cubicTo(
    4.0 * scale + translationX,
    21.552284749830793 * scale + translationY,
    4.447715250169207 * scale + translationX,
    22.0 * scale + translationY,
    5.0 * scale + translationX,
    22.0 * scale + translationY,
  );

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

  path.cubicTo(
    19.41698664636338 * scale + translationX,
    21.998289979625387 * scale + translationY,
    19.788485818573868 * scale + translationX,
    21.73624325170057 * scale + translationY,
    19.92999895529505 * scale + translationX,
    21.34399888117499 * scale + translationY,
  );

  path.lineTo(
    21.293 * scale + translationX,
    22.707 * scale + translationY,
  );

  path.cubicTo(
    21.685378886964305 * scale + translationX,
    23.085972209508135 * scale + translationY,
    22.309084777021134 * scale + translationX,
    23.08055237389715 * scale + translationY,
    22.69481857545914 * scale + translationX,
    22.69481857545914 * scale + translationY,
  );

  path.cubicTo(
    23.08055237389715 * scale + translationX,
    22.309084777021138 * scale + translationY,
    23.085972209508135 * scale + translationX,
    21.685378886964305 * scale + translationY,
    22.707 * scale + translationX,
    21.293 * scale + translationY,
  );

  path.close();

  path.moveTo(
    4.016 * scale + translationX,
    8.153 * scale + translationY,
  );

  path.lineTo(
    4.7940000000000005 * scale + translationX,
    6.208 * scale + translationY,
  );

  path.lineTo(
    7.67 * scale + translationX,
    9.084 * scale + translationY,
  );

  path.cubicTo(
    7.3074715268339405 * scale + translationX,
    9.65575096242516 * scale + translationY,
    6.67699600549715 * scale + translationX,
    10.001568673529652 * scale + translationY,
    5.9999999915388 * scale + translationX,
    9.999999985898 * scale + translationY,
  );

  path.cubicTo(
    4.958273018704985 * scale + translationX,
    9.996682943106144 * scale + translationY,
    4.094281393185732 * scale + translationX,
    9.192787509281274 * scale + translationY,
    4.016000181172658 * scale + translationX,
    8.154000367849065 * scale + translationY,
  );

  path.close();

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

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

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

  path.lineTo(
    6.0 * scale + translationX,
    12.0 * scale + translationY,
  );

  path.cubicTo(
    7.2058993776944975 * scale + translationX,
    12.0029194519524 * scale + translationY,
    8.347553448162065 * scale + translationX,
    11.456750966918918 * scale + translationY,
    9.101999840222772 * scale + translationX,
    10.515999815401305 * scale + translationY,
  );

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

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

  path.cubicTo(
    9.447715250169207 * scale + translationX,
    14.0 * scale + translationY,
    9.0 * scale + translationX,
    14.447715250169207 * scale + translationY,
    9.0 * scale + translationX,
    15.0 * scale + translationY,
  );

  path.close();

  path.moveTo(
    13.0 * scale + translationX,
    20.0 * scale + translationY,
  );

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

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

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

  path.close();

  path.moveTo(
    18.0 * scale + translationX,
    20.0 * scale + translationY,
  );

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

  path.lineTo(
    15.0 * scale + translationX,
    16.414 * scale + translationY,
  );

  path.lineTo(
    18.0 * scale + translationX,
    19.414 * scale + translationY,
  );

  path.close();

  canvas.drawPath(path, paint);
}