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

  final translationX = (size.width - 19.102354327344333 * scale) / 2 - 2.919645672655664 * scale;
  final translationY = (size.height - 20.095650264739202 * scale) / 2 - 2.000002387707036 * scale;

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

  path.moveTo(
    14.022 * scale + translationX,
    7.0 * scale + translationY,
  );

  path.lineTo(
    15.022 * scale + translationX,
    7.0 * scale + translationY,
  );

  path.cubicTo(
    15.573987530110124 * scale + translationX,
    7.000716054498824 * scale + translationY,
    16.021283511735334 * scale + translationX,
    7.448012036124036 * scale + translationY,
    16.021999698123693 * scale + translationX,
    7.999999849269102 * scale + translationY,
  );

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

  path.cubicTo(
    16.022 * scale + translationX,
    9.552284749830793 * scale + translationY,
    16.469715250169205 * scale + translationX,
    10.0 * scale + translationY,
    17.022 * scale + translationX,
    10.0 * scale + translationY,
  );

  path.cubicTo(
    17.57428474983079 * scale + translationX,
    10.0 * scale + translationY,
    18.022 * scale + translationX,
    9.552284749830793 * scale + translationY,
    18.022 * scale + translationX,
    9.0 * scale + translationY,
  );

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

  path.cubicTo(
    18.020191313848304 * scale + translationX,
    6.3438947975992255 * scale + translationY,
    16.678104013284745 * scale + translationX,
    5.001807497035664 * scale + translationY,
    15.021999224094301 * scale + translationX,
    4.999999741743544 * scale + translationY,
  );

  path.lineTo(
    14.021999999999998 * scale + translationX,
    5.0 * scale + translationY,
  );

  path.cubicTo(
    13.469715250169205 * scale + translationX,
    5.0 * scale + translationY,
    13.021999999999998 * scale + translationX,
    5.447715250169207 * scale + translationY,
    13.021999999999998 * scale + translationX,
    6.0 * scale + translationY,
  );

  path.cubicTo(
    13.021999999999998 * scale + translationX,
    6.552284749830793 * scale + translationY,
    13.469715250169205 * scale + translationX,
    7.0 * scale + translationY,
    14.021999999999998 * scale + translationX,
    7.0 * scale + translationY,
  );

  path.close();

  path.moveTo(
    10.022 * scale + translationX,
    16.0 * scale + translationY,
  );

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

  path.cubicTo(
    8.470012016868163 * scale + translationX,
    15.999283512149844 * scale + translationY,
    8.02271603524295 * scale + translationX,
    15.551987530524634 * scale + translationY,
    8.021999848854593 * scale + translationX,
    14.999999717379566 * scale + translationY,
  );

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

  path.cubicTo(
    8.022 * scale + translationX,
    13.447715250169207 * scale + translationY,
    7.5742847498307935 * scale + translationX,
    13.0 * scale + translationY,
    7.022 * scale + translationX,
    13.0 * scale + translationY,
  );

  path.cubicTo(
    6.469715250169207 * scale + translationX,
    13.0 * scale + translationY,
    6.022 * scale + translationX,
    13.447715250169207 * scale + translationY,
    6.022 * scale + translationX,
    14.0 * scale + translationY,
  );

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

  path.cubicTo(
    6.023807444248044 * scale + translationX,
    16.656104014421075 * scale + translationY,
    7.365894744811606 * scale + translationX,
    17.998191314984638 * scale + translationY,
    9.02199953400205 * scale + translationX,
    17.999999070276758 * scale + translationY,
  );

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

  path.cubicTo(
    10.574284749830793 * scale + translationX,
    18.0 * scale + translationY,
    11.022 * scale + translationX,
    17.552284749830793 * scale + translationY,
    11.022 * scale + translationX,
    17.0 * scale + translationY,
  );

  path.cubicTo(
    11.022 * scale + translationX,
    16.447715250169207 * scale + translationY,
    10.574284749830793 * scale + translationX,
    16.0 * scale + translationY,
    10.022 * scale + translationX,
    16.0 * scale + translationY,
  );

  path.close();

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

  path.cubicTo(
    21.57428474983079 * scale + translationX,
    15.0 * scale + translationY,
    22.022 * scale + translationX,
    14.552284749830793 * scale + translationY,
    22.022 * scale + translationX,
    14.0 * scale + translationY,
  );

  path.cubicTo(
    22.022 * scale + translationX,
    13.447715250169207 * scale + translationY,
    21.57428474983079 * scale + translationX,
    13.0 * scale + translationY,
    21.022 * scale + translationX,
    13.0 * scale + translationY,
  );

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

  path.lineTo(
    18.022 * scale + translationX,
    12.5 * scale + translationY,
  );

  path.cubicTo(
    18.022 * scale + translationX,
    11.947715250169207 * scale + translationY,
    17.57428474983079 * scale + translationX,
    11.5 * scale + translationY,
    17.022 * scale + translationX,
    11.5 * scale + translationY,
  );

  path.cubicTo(
    16.469715250169205 * scale + translationX,
    11.5 * scale + translationY,
    16.022 * scale + translationX,
    11.947715250169207 * scale + translationY,
    16.022 * scale + translationX,
    12.5 * scale + translationY,
  );

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

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

  path.cubicTo(
    12.469715250169205 * scale + translationX,
    13.0 * scale + translationY,
    12.021999999999998 * scale + translationX,
    13.447715250169207 * scale + translationY,
    12.021999999999998 * scale + translationX,
    14.0 * scale + translationY,
  );

  path.cubicTo(
    12.021999999999998 * scale + translationX,
    14.552284749830793 * scale + translationY,
    12.469715250169205 * scale + translationX,
    15.0 * scale + translationY,
    13.021999999999998 * scale + translationX,
    15.0 * scale + translationY,
  );

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

  path.cubicTo(
    17.98004471025082 * scale + translationX,
    15.919055256226446 * scale + translationY,
    17.56243828389272 * scale + translationX,
    16.78003265317815 * scale + translationY,
    16.980740148083765 * scale + translationX,
    17.526670152844652 * scale + translationY,
  );

  path.cubicTo(
    16.74271070738856 * scale + translationX,
    17.21811016723505 * scale + translationY,
    16.532188249782113 * scale + translationX,
    16.889278204207145 * scale + translationY,
    16.351590082095182 * scale + translationX,
    16.54395008306095 * scale + translationY,
  );

  path.cubicTo(
    16.099721204773196 * scale + translationX,
    16.052613383705722 * scale + translationY,
    15.497233038100925 * scale + translationX,
    15.858486292033195 * scale + translationY,
    15.00589567746816 * scale + translationX,
    16.110355749307242 * scale + translationY,
  );

  path.cubicTo(
    14.514558316835398 * scale + translationX,
    16.362225206581293 * scale + translationY,
    14.320431225162867 * scale + translationX,
    16.964713373253563 * scale + translationY,
    14.572300682436916 * scale + translationX,
    17.456050733886325 * scale + translationY,
  );

  path.cubicTo(
    14.841613274553731 * scale + translationX,
    17.9765114624417 * scale + translationY,
    15.162953398550346 * scale + translationX,
    18.468355172197757 * scale + translationY,
    15.531399744377326 * scale + translationX,
    18.92404968853959 * scale + translationY,
  );

  path.cubicTo(
    14.80586930700753 * scale + translationX,
    19.450846524141447 * scale + translationY,
    13.980862447346562 * scale + translationX,
    19.824726929273275 * scale + translationY,
    13.106449980860555 * scale + translationX,
    20.022999970760264 * scale + translationY,
  );

  path.cubicTo(
    12.567887630806561 * scale + translationX,
    20.141799554769715 * scale + translationY,
    12.227154057029058 * scale + translationX,
    20.674167123161855 * scale + translationY,
    12.344823237127803 * scale + translationX,
    21.21297753870013 * scale + translationY,
  );

  path.cubicTo(
    12.46249241722655 * scale + translationX,
    21.751787954238406 * scale + translationY,
    12.994143740717867 * scale + translationX,
    22.093638018454982 * scale + translationY,
    13.533199913410398 * scale + translationX,
    21.977099859383713 * scale + translationY,
  );

  path.cubicTo(
    14.787889455444471 * scale + translationX,
    21.699616978238698 * scale + translationY,
    15.964831663994731 * scale + translationX,
    21.14560346210707 * scale + translationY,
    16.97820027005326 * scale + translationX,
    20.355460323771563 * scale + translationY,
  );

  path.cubicTo(
    18.000076746036452 * scale + translationX,
    21.14602406393328 * scale + translationY,
    19.18479641935891 * scale + translationX,
    21.69974167620771 * scale + translationY,
    20.446768472093147 * scale + translationX,
    21.976608357774214 * scale + translationY,
  );

  path.cubicTo(
    20.98615935407258 * scale + translationX,
    22.095652652446237 * scale + translationY,
    21.519907130588578 * scale + translationX,
    21.754833264070136 * scale + translationY,
    21.638846682540898 * scale + translationX,
    21.21542115774702 * scale + translationY,
  );

  path.cubicTo(
    21.757786234493214 * scale + translationX,
    20.676009051423904 * scale + translationY,
    21.41686482511694 * scale + translationX,
    20.142326433140603 * scale + translationY,
    20.877429993054875 * scale + translationX,
    20.023489993338945 * scale + translationY,
  );

  path.cubicTo(
    19.997227673482925 * scale + translationX,
    19.827796065775292 * scale + translationY,
    19.16536907043512 * scale + translationX,
    19.45708319851869 * scale + translationY,
    18.43133104727379 * scale + translationX,
    18.933401075801562 * scale + translationY,
  );

  path.cubicTo(
    19.356014746039605 * scale + translationX,
    17.795162403473146 * scale + translationY,
    19.9792920588228 * scale + translationX,
    16.442466510723595 * scale + translationY,
    20.24370989118085 * scale + translationX,
    14.999999919368179 * scale + translationY,
  );

  path.close();

  path.moveTo(
    9.05176 * scale + translationX,
    11.24268 * scale + translationY,
  );

  path.cubicTo(
    9.187126699572085 * scale + translationX,
    11.776957027329619 * scale + translationY,
    9.729233001269012 * scale + translationX,
    12.10101075199342 * scale + translationY,
    10.263918652810545 * scale + translationX,
    11.96726976271156 * scale + translationY,
  );

  path.cubicTo(
    10.798604304352075 * scale + translationX,
    11.8335287734297 * scale + translationY,
    11.124304994496239 * scale + translationX,
    11.292410376729295 * scale + translationY,
    10.992190522179191 * scale + translationX,
    10.757320511021794 * scale + translationY,
  );

  path.lineTo(
    9.23486 * scale + translationX,
    3.7275400000000003 * scale + translationY,
  );

  path.cubicTo(
    8.98088922472199 * scale + translationX,
    2.7122251258413197 * scale + translationY,
    8.06856723418108 * scale + translationX,
    2.000002387707036 * scale + translationY,
    7.021970083928109 * scale + translationX,
    2.000002387707036 * scale + translationY,
  );

  path.cubicTo(
    5.975372933675139 * scale + translationX,
    2.000002387707036 * scale + translationY,
    5.063050943134229 * scale + translationX,
    2.7122251258413184 * scale + translationY,
    4.809080057479168 * scale + translationX,
    3.727540044552367 * scale + translationY,
  );

  path.lineTo(
    3.05176 * scale + translationX,
    10.75732 * scale + translationY,
  );

  path.cubicTo(
    2.919645672655664 * scale + translationX,
    11.292410376729224 * scale + translationY,
    3.2453463627998245 * scale + translationX,
    11.833528773429446 * scale + translationY,
    3.7800320143412454 * scale + translationX,
    11.967269762711277 * scale + translationY,
  );

  path.cubicTo(
    4.314717665882667 * scale + translationX,
    12.10101075199311 * scale + translationY,
    4.856823967579506 * scale + translationX,
    11.77695702732947 * scale + translationY,
    4.992190237151808 * scale + translationX,
    11.24268053407861 * scale + translationY,
  );

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

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

  path.close();

  path.moveTo(
    6.0528 * scale + translationX,
    7.0 * scale + translationY,
  );

  path.lineTo(
    6.749510000000001 * scale + translationX,
    4.21289 * scale + translationY,
  );

  path.cubicTo(
    6.792362274919734 * scale + translationX,
    4.099600682637519 * scale + translationY,
    6.9008469836976465 * scale + translationX,
    4.024649395107731 * scale + translationY,
    7.021970009624772 * scale + translationX,
    4.024649395107731 * scale + translationY,
  );

  path.cubicTo(
    7.143093035551898 * scale + translationX,
    4.024649395107731 * scale + translationY,
    7.2515777443298095 * scale + translationX,
    4.099600682637519 * scale + translationY,
    7.294430009998223 * scale + translationX,
    4.2128900057744625 * scale + translationY,
  );

  path.lineTo(
    7.99115 * scale + translationX,
    7.0 * scale + translationY,
  );

  path.close();

  canvas.drawPath(path, paint);
}