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

  final translationX = (size.width - 20.164467196019523 * scale) / 2 - 1.9041181001651482 * scale;
  final translationY = (size.height - 19.04516486015651 * scale) / 2 - 2.454835691186455 * scale;

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

  path.moveTo(
    21.7 * scale + translationX,
    7.57 * scale + translationY,
  );

  path.cubicTo(
    21.45515877672906 * scale + translationX,
    7.329480843168106 * scale + translationY,
    21.104077181295253 * scale + translationX,
    7.231328999283385 * scale + translationY,
    20.77 * scale + translationX,
    7.3100000000000005 * scale + translationY,
  );

  path.cubicTo(
    20.553374678232146 * scale + translationX,
    7.359509992566382 * scale + translationY,
    20.332181215162787 * scale + translationX,
    7.3863213214232735 * scale + translationY,
    20.11000029966235 * scale + translationX,
    7.390000110119582 * scale + translationY,
  );

  path.cubicTo(
    18.45314628000114 * scale + translationX,
    7.390000269617271 * scale + translationY,
    17.110000460539627 * scale + translationX,
    6.046854450155761 * scale + translationY,
    17.110000509917732 * scale + translationX,
    4.390000130832195 * scale + translationY,
  );

  path.cubicTo(
    17.112867079900305 * scale + translationX,
    4.1710632579112765 * scale + translationY,
    17.139693552604953 * scale + translationX,
    3.9530981671859884 * scale + translationY,
    17.190000512301918 * scale + translationX,
    3.7400001114606853 * scale + translationY,
  );

  path.cubicTo(
    17.270768184516236 * scale + translationX,
    3.404417176560724 * scale + translationY,
    17.172764246650196 * scale + translationX,
    3.0509061404060778 * scale + translationY,
    16.930737581400543 * scale + translationX,
    2.804811800110211 * scale + translationY,
  );

  path.cubicTo(
    16.68871091615089 * scale + translationX,
    2.5587174598143445 * scale + translationY,
    16.33688226088369 * scale + translationX,
    2.454835691186455 * scale + translationY,
    16.0 * scale + translationX,
    2.5300000000000007 * scale + translationY,
  );

  path.cubicTo(
    13.960401698806981 * scale + translationX,
    2.980303431433082 * scale + translationY,
    12.425927895567417 * scale + translationX,
    4.667022677291715 * scale + translationY,
    12.169999899041501 * scale + translationX,
    6.739999944087079 * scale + translationY,
  );

  path.cubicTo(
    11.626765203750244 * scale + translationX,
    6.584766705500926 * scale + translationY,
    11.064964687031193 * scale + translationX,
    6.504028906691002 * scale + translationY,
    10.499999965337594 * scale + translationX,
    6.499999978542322 * scale + translationY,
  );

  path.cubicTo(
    7.521040365357404 * scale + translationX,
    6.498307110317448 * scale + translationY,
    4.991948841023213 * scale + translationX,
    8.682522517696976 * scale + translationY,
    4.56000013589859 * scale + translationX,
    11.630000346601008 * scale + translationY,
  );

  path.cubicTo(
    3.133030839563905 * scale + translationX,
    12.027358384940023 * scale + translationY,
    2.110720291763677 * scale + translationX,
    13.279976977516554 * scale + translationY,
    2.0074191959644123 * scale + translationX,
    14.75763178264516 * scale + translationY,
  );

  path.cubicTo(
    1.9041181001651482 * scale + translationX,
    16.235286587773764 * scale + translationY,
    2.7421983055949983 * scale + translationX,
    17.617962892582188 * scale + translationY,
    4.10000018328428 * scale + translationX,
    18.21000081405044 * scale + translationY,
  );

  path.cubicTo(
    4.2274390025696755 * scale + translationX,
    18.260498457968268 * scale + translationY,
    4.362941176147005 * scale + translationX,
    18.287598892683732 * scale + translationY,
    4.499999900617098 * scale + translationX,
    18.289999596063716 * scale + translationY,
  );

  path.cubicTo(
    4.976725322554911 * scale + translationX,
    18.293890112927784 * scale + translationY,
    5.389906825369611 * scale + translationX,
    17.96070784013424 * scale + translationY,
    5.487140220014982 * scale + translationX,
    17.493987545836454 * scale + translationY,
  );

  path.cubicTo(
    5.584373614660355 * scale + translationX,
    17.027267251538667 * scale + translationY,
    5.338617770100539 * scale + translationX,
    16.556806364708766 * scale + translationY,
    4.9 * scale + translationX,
    16.369999999999997 * scale + translationY,
  );

  path.cubicTo(
    4.351410513368174 * scale + translationX,
    16.136332277392793 * scale + translationY,
    3.9966266168074482 * scale + translationX,
    15.596272345961468 * scale + translationY,
    4.000000137380653 * scale + translationX,
    15.000000515177447 * scale + translationY,
  );

  path.cubicTo(
    4.000000094520236 * scale + translationX,
    14.171573287373054 * scale + translationY,
    4.67157300425099 * scale + translationX,
    13.500000377642298 * scale + translationY,
    5.500000163912772 * scale + translationX,
    13.500000402331352 * scale + translationY,
  );

  path.cubicTo(
    6.052284749830793 * scale + translationX,
    13.5 * scale + translationY,
    6.5 * scale + translationX,
    13.052284749830793 * scale + translationY,
    6.5 * scale + translationX,
    12.5 * scale + translationY,
  );

  path.cubicTo(
    6.5 * scale + translationX,
    10.290861000676827 * scale + translationY,
    8.290861000676827 * scale + translationX,
    8.5 * scale + translationY,
    10.5 * scale + translationX,
    8.5 * scale + translationY,
  );

  path.cubicTo(
    11.275974177892124 * scale + translationX,
    8.49938254529606 * scale + translationY,
    12.03467478839577 * scale + translationX,
    8.729080895265056 * scale + translationY,
    12.680000125861651 * scale + translationX,
    9.16000009092214 * scale + translationY,
  );

  path.lineTo(
    12.68 * scale + translationX,
    9.16 * scale + translationY,
  );

  path.cubicTo(
    13.406928645836178 * scale + translationX,
    9.638166390137215 * scale + translationY,
    13.958119728713731 * scale + translationX,
    10.340320635841104 * scale + translationY,
    14.25 * scale + translationX,
    11.16 * scale + translationY,
  );

  path.cubicTo(
    14.366470548279553 * scale + translationX,
    11.510138715443741 * scale + translationY,
    14.666298082065273 * scale + translationX,
    11.767682879080192 * scale + translationY,
    15.03 * scale + translationX,
    11.83 * scale + translationY,
  );

  path.cubicTo(
    16.015179686178666 * scale + translationX,
    11.936671692764314 * scale + translationY,
    16.823848767058035 * scale + translationX,
    12.657298526132612 * scale + translationY,
    17.0428760595082 * scale + translationX,
    13.623728228902404 * scale + translationY,
  );

  path.cubicTo(
    17.26190335195836 * scale + translationX,
    14.590157931672195 * scale + translationY,
    16.842929753221256 * scale + translationX,
    15.589012194766656 * scale + translationY,
    15.999999272576702 * scale + translationX,
    16.109999267575667 * scale + translationY,
  );

  path.cubicTo(
    15.536197800473225 * scale + translationX,
    16.413802139382145 * scale + translationY,
    15.406439309019863 * scale + translationX,
    17.036038400452814 * scale + translationY,
    15.71015582759889 * scale + translationX,
    17.49989635610078 * scale + translationY,
  );

  path.cubicTo(
    16.013872346177916 * scale + translationX,
    17.963754311748744 * scale + translationY,
    16.63608438182333 * scale + translationX,
    18.0936289181714 * scale + translationY,
    17.099999006773597 * scale + translationX,
    17.78999896669604 * scale + translationY,
  );

  path.cubicTo(
    18.300365000541927 * scale + translationX,
    16.978347917056134 * scale + translationY,
    19.013859746413527 * scale + translationX,
    15.618952664395511 * scale + translationY,
    19.000000437895448 * scale + translationX,
    14.170000326577814 * scale + translationY,
  );

  path.cubicTo(
    19.003903449216427 * scale + translationX,
    13.473149261001707 * scale + translationY,
    18.835583101940436 * scale + translationX,
    12.786127435385424 * scale + translationY,
    18.510000469612102 * scale + translationX,
    12.170000308761715 * scale + translationY,
  );

  path.cubicTo(
    20.259624467904086 * scale + translationX,
    11.681398811842833 * scale + translationY,
    21.599930316814717 * scale + translationX,
    10.271965440638812 * scale + translationY,
    21.999999795872185 * scale + translationX,
    8.499999921132435 * scale + translationY,
  );

  path.cubicTo(
    22.068585296184672 * scale + translationX,
    8.158920169920325 * scale + translationY,
    21.95496836443393 * scale + translationX,
    7.806707681493028 * scale + translationY,
    21.7 * scale + translationX,
    7.5699999999999985 * scale + translationY,
  );

  path.close();

  path.moveTo(
    17.11 * scale + translationX,
    10.39 * scale + translationY,
  );

  path.cubicTo(
    16.97022635319695 * scale + translationX,
    10.401282065971829 * scale + translationY,
    16.82977172417555 * scale + translationX,
    10.401282065971829 * scale + translationY,
    16.689999050631567 * scale + translationX,
    10.389999408991134 * scale + translationY,
  );

  path.cubicTo(
    16.471647985084566 * scale + translationX,
    10.240389896982341 * scale + translationY,
    16.240791282647358 * scale + translationX,
    10.109905673865658 * scale + translationY,
    15.999999143766331 * scale + translationX,
    9.999999464853957 * scale + translationY,
  );

  path.cubicTo(
    15.590150710916143 * scale + translationX,
    9.101841211992918 * scale + translationY,
    14.96500597181154 * scale + translationX,
    8.318692857510227 * scale + translationY,
    14.180000422596933 * scale + translationX,
    7.720000230073928 * scale + translationY,
  );

  path.cubicTo(
    14.18 * scale + translationX,
    7.6 * scale + translationY,
    14.18 * scale + translationX,
    7.47 * scale + translationY,
    14.18 * scale + translationX,
    7.35 * scale + translationY,
  );

  path.cubicTo(
    14.179942716561074 * scale + translationX,
    6.473064735639785 * scale + translationY,
    14.56358717123033 * scale + translationX,
    5.640008205500834 * scale + translationY,
    15.230000453889367 * scale + translationX,
    5.070000151097776 * scale + translationY,
  );

  path.cubicTo(
    15.547993527080672 * scale + translationX,
    7.26100020885145 * scale + translationY,
    17.269000156674032 * scale + translationX,
    8.98200683844481 * scale + translationY,
    19.4600002899766 * scale + translationX,
    9.300000138580799 * scale + translationY,
  );

  path.cubicTo(
    18.881981710204535 * scale + translationX,
    10.000240570515164 * scale + translationY,
    18.01792171098603 * scale + translationX,
    10.401017336110131 * scale + translationY,
    17.110000509917736 * scale + translationX,
    10.390000309646132 * scale + translationY,
  );

  path.close();

  path.moveTo(
    11.11 * scale + translationX,
    14.33 * scale + translationY,
  );

  path.cubicTo(
    10.771684268837335 * scale + translationX,
    14.101323476117757 * scale + translationY,
    10.328315731162663 * scale + translationX,
    14.101323476117757 * scale + translationY,
    9.989999999999998 * scale + translationX,
    14.33 * scale + translationY,
  );

  path.cubicTo(
    9.84 * scale + translationX,
    14.41 * scale + translationY,
    7.5 * scale + translationX,
    16.0 * scale + translationY,
    7.5 * scale + translationX,
    18.5 * scale + translationY,
  );

  path.cubicTo(
    7.500000312924385 * scale + translationX,
    20.156854800835344 * scale + translationY,
    8.843146063432005 * scale + translationX,
    21.500000551342964 * scale + translationY,
    10.500000312924385 * scale + translationX,
    21.500000551342964 * scale + translationY,
  );

  path.cubicTo(
    12.156854562416765 * scale + translationX,
    21.500000551342964 * scale + translationY,
    13.500000312924385 * scale + translationX,
    20.156854800835344 * scale + translationY,
    13.500000312924385 * scale + translationX,
    18.500000551342964 * scale + translationY,
  );

  path.cubicTo(
    13.5 * scale + translationX,
    16.0 * scale + translationY,
    11.15 * scale + translationX,
    14.4 * scale + translationY,
    11.06 * scale + translationX,
    14.33 * scale + translationY,
  );

  path.close();

  path.moveTo(
    10.5 * scale + translationX,
    19.5 * scale + translationY,
  );

  path.cubicTo(
    9.947715250169207 * scale + translationX,
    19.5 * scale + translationY,
    9.5 * scale + translationX,
    19.052284749830793 * scale + translationY,
    9.5 * scale + translationX,
    18.5 * scale + translationY,
  );

  path.cubicTo(
    9.563142894987774 * scale + translationX,
    17.729376443041872 * scale + translationY,
    9.921386593402936 * scale + translationX,
    17.01288904621154 * scale + translationY,
    10.500000312924385 * scale + translationX,
    16.50000049173832 * scale + translationY,
  );

  path.cubicTo(
    11.078614032445834 * scale + translationX,
    17.01288904621154 * scale + translationY,
    11.436857730860998 * scale + translationX,
    17.729376443041872 * scale + translationY,
    11.500000342726707 * scale + translationX,
    18.500000551342964 * scale + translationY,
  );

  path.cubicTo(
    11.5 * scale + translationX,
    19.052284749830793 * scale + translationY,
    11.052284749830793 * scale + translationX,
    19.5 * scale + translationY,
    10.5 * scale + translationX,
    19.5 * scale + translationY,
  );

  path.close();

  canvas.drawPath(path, paint);
}