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

  final translationX = (size.width - 18.633875952352916 * scale) / 2 - 3.4403440476470823 * scale;
  final translationY = (size.height - 20.103162071891052 * scale) / 2 - 1.9499933843918593 * scale;

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

  path.moveTo(
    20.47168 * scale + translationX,
    11.99707 * scale + translationY,
  );

  path.cubicTo(
    19.587265327578674 * scale + translationX,
    10.643316107091565 * scale + translationY,
    18.08805532657901 * scale + translationX,
    9.817427528391692 * scale + translationY,
    16.47118975179625 * scale + translationX,
    9.793269852425576 * scale + translationY,
  );

  path.cubicTo(
    16.459414686865397 * scale + translationX,
    9.44855719519781 * scale + translationY,
    16.415772035004117 * scale + translationX,
    9.105672643368763 * scale + translationY,
    16.34082073885 * scale + translationX,
    8.76900039649024 * scale + translationY,
  );

  path.cubicTo(
    16.213264745484782 * scale + translationX,
    8.23181775565714 * scale + translationY,
    15.6743879659248 * scale + translationX,
    7.899749600129217 * scale + translationY,
    15.13720545381512 * scale + translationX,
    8.027305283281878 * scale + translationY,
  );

  path.cubicTo(
    14.600022941705438 * scale + translationX,
    8.154860966434539 * scale + translationY,
    14.267954786177517 * scale + translationX,
    8.69373774599452 * scale + translationY,
    14.39551046933018 * scale + translationX,
    9.230920258104202 * scale + translationY,
  );

  path.cubicTo(
    14.4401775641312 * scale + translationX,
    9.428634974036031 * scale + translationY,
    14.467845143485821 * scale + translationX,
    9.629808720318008 * scale + translationY,
    14.47821086237272 * scale + translationX,
    9.832240585642529 * scale + translationY,
  );

  path.cubicTo(
    13.362707831170448 * scale + translationX,
    9.970329157845885 * scale + translationY,
    12.2686703560252 * scale + translationX,
    10.246404828845924 * scale + translationY,
    11.22120982524707 * scale + translationX,
    10.654129834078457 * scale + translationY,
  );

  path.cubicTo(
    11.243730000000003 * scale + translationX,
    9.45028 * scale + translationY,
    11.297990000000002 * scale + translationX,
    8.246849999999998 * scale + translationY,
    11.417930000000004 * scale + translationX,
    7.046839999999999 * scale + translationY,
  );

  path.lineTo(
    11.456200000000004 * scale + translationX,
    6.664629999999999 * scale + translationY,
  );

  path.cubicTo(
    12.627874246732496 * scale + translationX,
    6.50497021684434 * scale + translationY,
    13.790254219666123 * scale + translationX,
    6.283265357207133 * scale + translationY,
    14.938439106930499 * scale + translationX,
    6.000449641273188 * scale + translationY,
  );

  path.lineTo(
    15.058550000000004 * scale + translationX,
    5.970659999999999 * scale + translationY,
  );

  path.cubicTo(
    15.407046702892599 * scale + translationX,
    5.88638900164923 * scale + translationY,
    15.683757576902591 * scale + translationX,
    5.621993985368905 * scale + translationY,
    15.783797035189039 * scale + translationX,
    5.277692286453842 * scale + translationY,
  );

  path.cubicTo(
    15.883836493475489 * scale + translationX,
    4.933390587538779 * scale + translationY,
    15.791892740124778 * scale + translationX,
    4.561880185734157 * scale + translationY,
    15.542816499963141 * scale + translationX,
    4.303979856775492 * scale + translationY,
  );

  path.cubicTo(
    15.293740259801504 * scale + translationX,
    4.046079527816827 * scale + translationY,
    14.925654535708116 * scale + translationX,
    3.9412628681300594 * scale + translationY,
    14.578080000000003 * scale + translationX,
    4.029259999999999 * scale + translationY,
  );

  path.lineTo(
    14.456010000000003 * scale + translationX,
    4.059529999999999 * scale + translationY,
  );

  path.cubicTo(
    13.534380000000002 * scale + translationX,
    4.289999999999999 * scale + translationY,
    12.600360000000002 * scale + translationX,
    4.464009999999999 * scale + translationY,
    11.662070000000003 * scale + translationX,
    4.610129999999999 * scale + translationY,
  );

  path.lineTo(
    11.813440000000003 * scale + translationX,
    3.099569999999999 * scale + translationY,
  );

  path.cubicTo(
    11.86835823232547 * scale + translationX,
    2.550034095131268 * scale + translationY,
    11.467440895543712 * scale + translationX,
    2.060007025467304 * scale + translationY,
    10.917913867599747 * scale + translationX,
    2.0050002049295816 * scale + translationY,
  );

  path.cubicTo(
    10.368386839655782 * scale + translationX,
    1.9499933843918593 * scale + translationY,
    9.8782952202559 * scale + translationX,
    2.350831811354186 * scale + translationY,
    9.823199915069758 * scale + translationX,
    2.9003499749239094 * scale + translationY,
  );

  path.lineTo(
    9.627 * scale + translationX,
    4.8596200000000005 * scale + translationY,
  );

  path.cubicTo(
    8.69312 * scale + translationX,
    4.94336 * scale + translationY,
    7.7566500000000005 * scale + translationX,
    5.0 * scale + translationY,
    6.81836 * scale + translationX,
    5.0 * scale + translationY,
  );

  path.cubicTo(
    6.266075250169207 * scale + translationX,
    5.0 * scale + translationY,
    5.81836 * scale + translationX,
    5.447715250169207 * scale + translationY,
    5.81836 * scale + translationX,
    6.0 * scale + translationY,
  );

  path.cubicTo(
    5.81836 * scale + translationX,
    6.552284749830793 * scale + translationY,
    6.266075250169207 * scale + translationX,
    7.0 * scale + translationY,
    6.81836 * scale + translationX,
    7.0 * scale + translationY,
  );

  path.cubicTo(
    7.6889 * scale + translationX,
    7.0 * scale + translationY,
    8.55786 * scale + translationX,
    6.95361 * scale + translationY,
    9.425170000000001 * scale + translationX,
    6.8858 * scale + translationY,
  );

  path.cubicTo(
    9.27852651146006 * scale + translationX,
    8.447409296492843 * scale + translationY,
    9.210717091816722 * scale + translationX,
    10.01541993807177 * scale + translationY,
    9.22199939546437 * scale + translationX,
    11.583859240635839 * scale + translationY,
  );

  path.cubicTo(
    9.08779 * scale + translationX,
    11.6571 * scale + translationY,
    8.95235 * scale + translationX,
    11.72595 * scale + translationY,
    8.81936 * scale + translationX,
    11.80322 * scale + translationY,
  );

  path.cubicTo(
    8.139145088891475 * scale + translationX,
    12.192941792260998 * scale + translationY,
    7.487736362153218 * scale + translationX,
    12.630913753777307 * scale + translationY,
    6.870139898423746 * scale + translationX,
    13.113769806110561 * scale + translationY,
  );

  path.lineTo(
    6.8476799999999995 * scale + translationX,
    13.131839999999999 * scale + translationY,
  );

  path.cubicTo(
    5.844577732384332 * scale + translationX,
    13.905658974348476 * scale + translationY,
    4.953320333170626 * scale + translationX,
    14.8144962645678 * scale + translationY,
    4.199240063280397 * scale + translationX,
    15.832520238587978 * scale + translationY,
  );

  path.cubicTo(
    3.4847397863373017 * scale + translationX,
    16.82242555735166 * scale + translationY,
    3.4403440476470823 * scale + translationX,
    18.14627655659195 * scale + translationY,
    4.0869199591492 * scale + translationX,
    19.181826377689198 * scale + translationY,
  );

  path.cubicTo(
    4.733495870651317 * scale + translationX,
    20.217376198786447 * scale + translationY,
    5.942445782548313 * scale + translationX,
    20.75866407074332 * scale + translationY,
    7.145529922888332 * scale + translationX,
    20.551269778219012 * scale + translationY,
  );

  path.cubicTo(
    8.138285590337475 * scale + translationX,
    20.362724887348357 * scale + translationY,
    9.095655572884935 * scale + translationX,
    20.0208448700057 * scale + translationY,
    9.983280095459495 * scale + translationX,
    19.537900186820167 * scale + translationY,
  );

  path.cubicTo(
    10.237806375813827 * scale + translationX,
    19.937979155171814 * scale + translationY,
    10.739169581164903 * scale + translationX,
    20.103042703418005 * scale + translationY,
    11.181589896147607 * scale + translationX,
    19.932417665529996 * scale + translationY,
  );

  path.cubicTo(
    11.62401021113031 * scale + translationX,
    19.761792627641988 * scale + translationY,
    11.884709713744908 * scale + translationX,
    19.302829875366783 * scale + translationY,
    11.804689069849148 * scale + translationX,
    18.835448515860236 * scale + translationY,
  );

  path.cubicTo(
    11.780460000000001 * scale + translationX,
    18.690250000000002 * scale + translationY,
    11.769350000000001 * scale + translationX,
    18.54352 * scale + translationY,
    11.746580000000002 * scale + translationX,
    18.398130000000002 * scale + translationY,
  );

  path.cubicTo(
    12.208517514783976 * scale + translationX,
    18.041086941785583 * scale + translationY,
    12.647394709617416 * scale + translationX,
    17.655165591123254 * scale + translationY,
    13.060580991629012 * scale + translationX,
    17.242681309156385 * scale + translationY,
  );

  path.cubicTo(
    13.877615842418061 * scale + translationX,
    16.428966688431927 * scale + translationY,
    14.584220529851653 * scale + translationX,
    15.511451085673057 * scale + translationY,
    15.162259872405055 * scale + translationX,
    14.513679877863048 * scale + translationY,
  );

  path.cubicTo(
    15.185150000000002 * scale + translationX,
    14.47419 * scale + translationY,
    15.204380000000002 * scale + translationX,
    14.43458 * scale + translationY,
    15.226710000000002 * scale + translationX,
    14.39503 * scale + translationY,
  );

  path.cubicTo(
    15.344710000000003 * scale + translationX,
    14.18446 * scale + translationY,
    15.456150000000003 * scale + translationX,
    13.97303 * scale + translationY,
    15.558500000000002 * scale + translationX,
    13.76008 * scale + translationY,
  );

  path.cubicTo(
    15.612330000000002 * scale + translationX,
    13.649000000000001 * scale + translationY,
    15.660800000000002 * scale + translationX,
    13.53834 * scale + translationY,
    15.710050000000003 * scale + translationX,
    13.42726 * scale + translationY,
  );

  path.cubicTo(
    15.769990000000002 * scale + translationX,
    13.291030000000001 * scale + translationY,
    15.827240000000003 * scale + translationX,
    13.15504 * scale + translationY,
    15.880520000000002 * scale + translationX,
    13.01844 * scale + translationY,
  );

  path.cubicTo(
    15.936980000000002 * scale + translationX,
    12.87483 * scale + translationY,
    15.990330000000002 * scale + translationX,
    12.73182 * scale + translationY,
    16.038970000000003 * scale + translationX,
    12.58876 * scale + translationY,
  );

  path.cubicTo(
    16.071320000000004 * scale + translationX,
    12.492930000000001 * scale + translationY,
    16.099520000000002 * scale + translationX,
    12.39753 * scale + translationY,
    16.128450000000004 * scale + translationX,
    12.30183 * scale + translationY,
  );

  path.cubicTo(
    16.179780000000004 * scale + translationX,
    12.13301 * scale + translationY,
    16.230190000000004 * scale + translationX,
    11.964730000000001 * scale + translationY,
    16.270450000000004 * scale + translationX,
    11.79756 * scale + translationY,
  );

  path.lineTo(
    16.275450000000003 * scale + translationX,
    11.7798 * scale + translationY,
  );

  path.cubicTo(
    17.245801940337614 * scale + translationX,
    11.765781474910469 * scale + translationY,
    18.16356635116028 * scale + translationX,
    12.219754436103349 * scale + translationY,
    18.741270913379037 * scale + translationX,
    12.999520633547727 * scale + translationY,
  );

  path.cubicTo(
    19.759830000000004 * scale + translationX,
    14.76661 * scale + translationY,
    17.778380000000002 * scale + translationX,
    17.97652 * scale + translationY,
    14.324270000000004 * scale + translationX,
    20.154310000000002 * scale + translationY,
  );

  path.cubicTo(
    14.020935838141607 * scale + translationX,
    20.344268913807728 * scale + translationY,
    13.842285340306043 * scale + translationX,
    20.681886824579138 * scale + translationY,
    13.855853520135277 * scale + translationX,
    21.03953456918806 * scale + translationY,
  );

  path.cubicTo(
    13.869421699964509 * scale + translationX,
    21.397182313796986 * scale + translationY,
    14.07313848594567 * scale + translationX,
    21.720294252852252 * scale + translationY,
    14.389993120660709 * scale + translationX,
    21.886724854567582 * scale + translationY,
  );

  path.cubicTo(
    14.706847755375748 * scale + translationX,
    22.053155456282912 * scale + translationY,
    15.088498326991317 * scale + translationX,
    22.037512718796854 * scale + translationY,
    15.390670030426481 * scale + translationX,
    21.84571004318773 * scale + translationY,
  );

  path.cubicTo(
    19.88965 * scale + translationX,
    19.00977 * scale + translationY,
    22.07422 * scale + translationX,
    14.77734 * scale + translationY,
    20.47168 * scale + translationX,
    11.99707 * scale + translationY,
  );

  path.close();

  path.moveTo(
    6.7959 * scale + translationX,
    18.58252 * scale + translationY,
  );

  path.cubicTo(
    6.396055634299606 * scale + translationX,
    18.647227269132657 * scale + translationY,
    5.996460604162541 * scale + translationX,
    18.465502645746135 * scale + translationY,
    5.782429631128088 * scale + translationX,
    18.121622704967248 * scale + translationY,
  );

  path.cubicTo(
    5.568398658093634 * scale + translationX,
    17.77774276418836 * scale + translationY,
    5.5817966597151045 * scale + translationX,
    17.33897116026695 * scale + translationY,
    5.816410237333518 * scale + translationX,
    17.008790694028782 * scale + translationY,
  );

  path.cubicTo(
    6.469754265664124 * scale + translationX,
    16.132977211023167 * scale + translationY,
    7.240672146414184 * scale + translationX,
    15.351375505430763 * scale + translationY,
    8.10740972785409 * scale + translationX,
    14.686039507025587 * scale + translationY,
  );

  path.lineTo(
    8.13378 * scale + translationX,
    14.664549999999998 * scale + translationY,
  );

  path.cubicTo(
    8.48766 * scale + translationX,
    14.387629999999998 * scale + translationY,
    8.87578 * scale + translationX,
    14.125549999999999 * scale + translationY,
    9.27778 * scale + translationX,
    13.87155 * scale + translationY,
  );

  path.cubicTo(
    9.33888 * scale + translationX,
    15.06692 * scale + translationY,
    9.45063 * scale + translationX,
    16.25839 * scale + translationY,
    9.60371 * scale + translationX,
    17.44644 * scale + translationY,
  );

  path.cubicTo(
    8.746606175167404 * scale + translationX,
    17.996524123272682 * scale + translationY,
    7.79436714588451 * scale + translationX,
    18.38181362519329 * scale + translationY,
    6.795900364034911 * scale + translationX,
    18.582520995406938 * scale + translationY,
  );

  path.close();

  path.moveTo(
    14.12567 * scale + translationX,
    11.999519999999999 * scale + translationY,
  );

  path.cubicTo(
    14.033804487230766 * scale + translationX,
    12.265245676158921 * scale + translationY,
    13.92827728857816 * scale + translationX,
    12.526049658987823 * scale + translationY,
    13.809510273921827 * scale + translationX,
    12.780890253518391 * scale + translationY,
  );

  path.cubicTo(
    13.75391 * scale + translationX,
    12.89979 * scale + translationY,
    13.69151 * scale + translationX,
    13.01863 * scale + translationY,
    13.62933 * scale + translationX,
    13.13783 * scale + translationY,
  );

  path.cubicTo(
    13.533203333333333 * scale + translationX,
    13.323503333333331 * scale + translationY,
    13.429669999999998 * scale + translationX,
    13.508276666666667 * scale + translationY,
    13.318729999999999 * scale + translationX,
    13.69215 * scale + translationY,
  );

  path.cubicTo(
    13.23407 * scale + translationX,
    13.83168 * scale + translationY,
    13.146849999999999 * scale + translationX,
    13.97102 * scale + translationY,
    13.053589999999998 * scale + translationX,
    14.10957 * scale + translationY,
  );

  path.cubicTo(
    12.64122172582944 * scale + translationX,
    14.726706589290249 * scale + translationY,
    12.169979657756459 * scale + translationX,
    15.302400824294946 * scale + translationY,
    11.64647923518003 * scale + translationX,
    15.828568960543752 * scale + translationY,
  );

  path.cubicTo(
    11.576659999999999 * scale + translationX,
    15.898399999999999 * scale + translationY,
    11.503049999999998 * scale + translationX,
    15.96187 * scale + translationY,
    11.431879999999998 * scale + translationX,
    16.02957 * scale + translationY,
  );

  path.cubicTo(
    11.323119999999998 * scale + translationX,
    14.964569999999998 * scale + translationY,
    11.252706666666663 * scale + translationX,
    13.896983333333333 * scale + translationY,
    11.220639999999998 * scale + translationX,
    12.82681 * scale + translationY,
  );

  path.cubicTo(
    12.158440276823372 * scale + translationX,
    12.395966309267937 * scale + translationY,
    13.145940312597999 * scale + translationX,
    12.082797803024675 * scale + translationY,
    14.16064063154442 * scale + translationX,
    11.894440530475123 * scale + translationY,
  );

  path.cubicTo(
    14.149000000000001 * scale + translationX,
    11.9295 * scale + translationY,
    14.13794 * scale + translationX,
    11.96436 * scale + translationY,
    14.12567 * scale + translationX,
    11.99951 * scale + translationY,
  );

  path.close();

  canvas.drawPath(path, paint);
}