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

  final translationX = (size.width - 20.107920827826867 * scale) / 2 - 1.9942016756583283 * scale;
  final translationY = (size.height - 20.107920438656592 * scale) / 2 - 1.877877885685086 * scale;

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

  path.moveTo(
    4.91 * scale + translationX,
    13.1 * scale + translationY,
  );

  path.cubicTo(
    5.093115453776088 * scale + translationX,
    13.392985450365881 * scale + translationY,
    5.414498530362069 * scale + translationX,
    13.57069138683107 * scale + translationY,
    5.76 * scale + translationX,
    13.570000000000002 * scale + translationY,
  );

  path.cubicTo(
    6.137203385953984 * scale + translationX,
    13.580807551472137 * scale + translationY,
    6.488368473880486 * scale + translationX,
    13.378357800505263 * scale + translationY,
    6.668029722043761 * scale + translationX,
    13.046512906838979 * scale + translationY,
  );

  path.cubicTo(
    6.8476909702070365 * scale + translationX,
    12.714668013172696 * scale + translationY,
    6.825248959831009 * scale + translationX,
    12.309946903252222 * scale + translationY,
    6.61 * scale + translationX,
    12.0 * scale + translationY,
  );

  path.cubicTo(
    5.30157355279344 * scale + translationX,
    9.921869463410431 * scale + translationY,
    4.45891201800817 * scale + translationX,
    7.584933628074767 * scale + translationY,
    4.140000015422702 * scale + translationX,
    5.150000019185245 * scale + translationY,
  );

  path.cubicTo(
    4.096424415472916 * scale + translationX,
    4.857803958849954 * scale + translationY,
    4.184279377695674 * scale + translationX,
    4.561293461348147 * scale + translationY,
    4.38 * scale + translationX,
    4.34 * scale + translationY,
  );

  path.cubicTo(
    4.569569842804111 * scale + translationX,
    4.124215745440111 * scale + translationY,
    4.842772846815071 * scale + translationX,
    4.000363716955143 * scale + translationY,
    5.13 * scale + translationX,
    4.0 * scale + translationY,
  );

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

  path.cubicTo(
    8.612760763749648 * scale + translationX,
    3.9902642946024733 * scale + translationY,
    9.033526374198882 * scale + translationX,
    4.32687678296186 * scale + translationY,
    9.129999999999999 * scale + translationX,
    4.8 * scale + translationY,
  );

  path.cubicTo(
    9.129999999999999 * scale + translationX,
    5.03 * scale + translationY,
    9.209999999999999 * scale + translationX,
    5.24 * scale + translationY,
    9.26 * scale + translationX,
    5.47 * scale + translationY,
  );

  path.lineTo(
    9.26 * scale + translationX,
    5.6 * scale + translationY,
  );

  path.cubicTo(
    9.376360968217437 * scale + translationX,
    6.1247799121721656 * scale + translationY,
    9.533504866444627 * scale + translationX,
    6.639676940405929 * scale + translationY,
    9.730000168818028 * scale + translationX,
    7.140000123880857 * scale + translationY,
  );

  path.lineTo(
    8.34 * scale + translationX,
    7.8 * scale + translationY,
  );

  path.cubicTo(
    8.097396451314637 * scale + translationX,
    7.91278955268894 * scale + translationY,
    7.910105414800355 * scale + translationX,
    8.118089342714208 * scale + translationY,
    7.82 * scale + translationX,
    8.37 * scale + translationY,
  );

  path.cubicTo(
    7.717222096814642 * scale + translationX,
    8.616377740644088 * scale + translationY,
    7.717222096814642 * scale + translationX,
    8.89362225935591 * scale + translationY,
    7.82 * scale + translationX,
    9.139999999999999 * scale + translationY,
  );

  path.cubicTo(
    7.92 * scale + translationX,
    9.35 * scale + translationY,
    8.02 * scale + translationX,
    9.559999999999999 * scale + translationY,
    8.14 * scale + translationX,
    9.78 * scale + translationY,
  );

  path.cubicTo(
    8.271951220025187 * scale + translationX,
    10.011439709081982 * scale + translationY,
    8.490798975687232 * scale + translationX,
    10.18065958979868 * scale + translationY,
    8.74799634209089 * scale + translationX,
    10.250121652258061 * scale + translationY,
  );

  path.cubicTo(
    9.005193708494547 * scale + translationX,
    10.319583714717442 * scale + translationY,
    9.279476263824046 * scale + translationX,
    10.283545012881673 * scale + translationY,
    9.510000000000002 * scale + translationX,
    10.149999999999999 * scale + translationY,
  );

  path.cubicTo(
    9.843482106768576 * scale + translationX,
    9.958810206003902 * scale + translationY,
    10.03785449584707 * scale + translationX,
    9.593390114536332 * scale + translationY,
    10.010000000000002 * scale + translationX,
    9.209999999999999 * scale + translationY,
  );

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

  path.cubicTo(
    11.517529960863982 * scale + translationX,
    8.568148129710277 * scale + translationY,
    11.972411028550844 * scale + translationX,
    7.493762369840354 * scale + translationY,
    11.63 * scale + translationX,
    6.52 * scale + translationY,
  );

  path.cubicTo(
    11.46851144759729 * scale + translationX,
    6.096744010833154 * scale + translationY,
    11.338164419017392 * scale + translationX,
    5.662253915566831 * scale + translationY,
    11.240000414760528 * scale + translationX,
    5.220000192620102 * scale + translationY,
  );

  path.lineTo(
    11.24 * scale + translationX,
    5.12 * scale + translationY,
  );

  path.cubicTo(
    11.24 * scale + translationX,
    4.92 * scale + translationY,
    11.16 * scale + translationX,
    4.72 * scale + translationY,
    11.13 * scale + translationX,
    4.54 * scale + translationY,
  );

  path.cubicTo(
    10.902866744299846 * scale + translationX,
    3.0761947480547183 * scale + translationY,
    9.641320116768036 * scale + translationX,
    1.9972962854517549 * scale + translationY,
    8.160000243186952 * scale + translationX,
    2.0000000596046443 * scale + translationY,
  );

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

  path.cubicTo(
    4.291031872914322 * scale + translationX,
    1.9873557872833818 * scale + translationY,
    3.4592816018027834 * scale + translationX,
    2.3521585377708987 * scale + translationY,
    2.8800000858306887 * scale + translationX,
    3.000000089406967 * scale + translationY,
  );

  path.cubicTo(
    2.3042335817002915 * scale + translationX,
    3.654262910511269 * scale + translationY,
    2.041446566677891 * scale + translationX,
    4.526569807599513 * scale + translationY,
    2.1600000643730164 * scale + translationX,
    5.390000160634516 * scale + translationY,
  );

  path.cubicTo(
    2.507150779761718 * scale + translationX,
    8.128908711256022 * scale + translationY,
    3.4454770200672646 * scale + translationX,
    10.759634279530845 * scale + translationY,
    4.909999785066688 * scale + translationX,
    13.099999426552671 * scale + translationY,
  );

  path.close();

  path.moveTo(
    19.52 * scale + translationX,
    12.889999999999999 * scale + translationY,
  );

  path.lineTo(
    18.919999999999998 * scale + translationX,
    12.78 * scale + translationY,
  );

  path.lineTo(
    18.84 * scale + translationX,
    12.78 * scale + translationY,
  );

  path.cubicTo(
    18.38759298327134 * scale + translationX,
    12.683226897745747 * scale + translationY,
    17.943028021724114 * scale + translationX,
    12.552865743607837 * scale + translationY,
    17.51000062221553 * scale + translationX,
    12.390000440277007 * scale + translationY,
  );

  path.cubicTo(
    16.552159353885788 * scale + translationX,
    12.046429427775173 * scale + translationY,
    15.489043181142295 * scale + translationX,
    12.476840833744198 * scale + translationY,
    15.039999999999997 * scale + translationX,
    13.389999999999999 * scale + translationY,
  );

  path.lineTo(
    14.829999999999997 * scale + translationX,
    13.85 * scale + translationY,
  );

  path.cubicTo(
    14.1478897085293 * scale + translationX,
    13.45542876938976 * scale + translationY,
    13.504977295649551 * scale + translationX,
    12.996683974782856 * scale + translationY,
    12.909999871025565 * scale + translationX,
    12.479999875321385 * scale + translationY,
  );

  path.lineTo(
    21.709999999999997 * scale + translationX,
    3.6900000000000013 * scale + translationY,
  );

  path.cubicTo(
    22.10212250348519 * scale + translationX,
    3.2978778731839413 * scale + translationY,
    22.102122503485194 * scale + translationX,
    2.6621222235406217 * scale + translationY,
    21.710000334557428 * scale + translationX,
    2.2700000546128543 * scale + translationY,
  );

  path.cubicTo(
    21.31787816562966 * scale + translationX,
    1.8778778856850864 * scale + translationY,
    20.682122515986343 * scale + translationX,
    1.877877885685086 * scale + translationY,
    20.290000347058577 * scale + translationX,
    2.2700000546128534 * scale + translationY,
  );

  path.lineTo(
    2.289999999999999 * scale + translationX,
    20.270000000000003 * scale + translationY,
  );

  path.cubicTo(
    2.1006873491769023 * scale + translationX,
    20.457766599905558 * scale + translationY,
    1.9942016756583283 * scale + translationX,
    20.713362463629444 * scale + translationY,
    1.9942016756583283 * scale + translationX,
    20.980000000000004 * scale + translationY,
  );

  path.cubicTo(
    1.9942016756583283 * scale + translationX,
    21.246637536370564 * scale + translationY,
    2.1006873491769023 * scale + translationX,
    21.502233400094447 * scale + translationY,
    2.289999999999999 * scale + translationX,
    21.690000000000005 * scale + translationY,
  );

  path.cubicTo(
    2.477766599905555 * scale + translationX,
    21.879312650823103 * scale + translationY,
    2.7333624636294402 * scale + translationX,
    21.985798324341676 * scale + translationY,
    2.999999999999999 * scale + translationX,
    21.985798324341676 * scale + translationY,
  );

  path.cubicTo(
    3.266637536370558 * scale + translationX,
    21.985798324341676 * scale + translationY,
    3.5222334000944437 * scale + translationX,
    21.879312650823103 * scale + translationY,
    3.71 * scale + translationX,
    21.690000000000005 * scale + translationY,
  );

  path.lineTo(
    8.299999999999999 * scale + translationX,
    17.090000000000003 * scale + translationY,
  );

  path.cubicTo(
    11.172597271350332 * scale + translationX,
    19.671208264310096 * scale + translationY,
    14.760519010995823 * scale + translationX,
    21.320466751047046 * scale + translationY,
    18.589999571020098 * scale + translationX,
    21.81999949648514 * scale + translationY,
  );

  path.cubicTo(
    18.723149645552574 * scale + translationX,
    21.82992826164424 * scale + translationY,
    18.856852531396814 * scale + translationX,
    21.82992826164424 * scale + translationY,
    18.990001100060375 * scale + translationX,
    21.820001263997767 * scale + translationY,
  );

  path.cubicTo(
    19.726103796612662 * scale + translationX,
    21.823838333161937 * scale + translationY,
    20.437925708993912 * scale + translationX,
    21.556905116018967 * scale + translationY,
    20.990000625550742 * scale + translationX,
    21.070000627934938 * scale + translationY,
  );

  path.cubicTo(
    21.62993342675201 * scale + translationX,
    20.49764394123688 * scale + translationY,
    21.99397952788732 * scale + translationX,
    19.678540213682442 * scale + translationY,
    21.990000655353064 * scale + translationX,
    18.820000560879713 * scale + translationY,
  );

  path.lineTo(
    21.989999999999995 * scale + translationX,
    15.820000000000004 * scale + translationY,
  );

  path.cubicTo(
    21.9790141507303 * scale + translationX,
    14.376205753515517 * scale + translationY,
    20.941134127695488 * scale + translationX,
    13.145036333478263 * scale + translationY,
    19.520000581741332 * scale + translationX,
    12.890000384151936 * scale + translationY,
  );

  path.close();

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

  path.cubicTo(
    19.999636283044858 * scale + translationX,
    19.17722715318493 * scale + translationY,
    19.87578425455989 * scale + translationX,
    19.45043015719589 * scale + translationY,
    19.66 * scale + translationX,
    19.64 * scale + translationY,
  );

  path.cubicTo(
    19.438706538651854 * scale + translationX,
    19.835720622304326 * scale + translationY,
    19.142196041150047 * scale + translationX,
    19.923575584527082 * scale + translationY,
    18.85 * scale + translationX,
    19.88 * scale + translationY,
  );

  path.cubicTo(
    15.452891191974004 * scale + translationX,
    19.435470304676294 * scale + translationY,
    12.268153360085618 * scale + translationX,
    17.978992827948346 * scale + translationY,
    9.710000073464217 * scale + translationX,
    15.70000011878354 * scale + translationY,
  );

  path.lineTo(
    11.48 * scale + translationX,
    13.93 * scale + translationY,
  );

  path.cubicTo(
    12.499553519435066 * scale + translationX,
    14.818755799466311 * scale + translationY,
    13.636965176501963 * scale + translationX,
    15.562448036779278 * scale + translationY,
    14.85999939506082 * scale + translationX,
    16.139999342953004 * scale + translationY,
  );

  path.cubicTo(
    15.106377740644088 * scale + translationX,
    16.24277790318536 * scale + translationY,
    15.38362225935591 * scale + translationX,
    16.24277790318536 * scale + translationY,
    15.629999999999999 * scale + translationX,
    16.14 * scale + translationY,
  );

  path.cubicTo(
    15.88191065728579 * scale + translationX,
    16.049894585199645 * scale + translationY,
    16.087210447311058 * scale + translationX,
    15.862603548685366 * scale + translationY,
    16.2 * scale + translationX,
    15.620000000000001 * scale + translationY,
  );

  path.lineTo(
    16.82 * scale + translationX,
    14.21 * scale + translationY,
  );

  path.cubicTo(
    17.341789651260978 * scale + translationX,
    14.403580227085003 * scale + translationY,
    17.87641357159986 * scale + translationX,
    14.560626003684549 * scale + translationY,
    18.42000054895878 * scale + translationX,
    14.680000437498094 * scale + translationY,
  );

  path.lineTo(
    18.53 * scale + translationX,
    14.680000000000001 * scale + translationY,
  );

  path.lineTo(
    19.220000000000002 * scale + translationX,
    14.810000000000002 * scale + translationY,
  );

  path.cubicTo(
    19.685152582958235 * scale + translationX,
    14.914754150329733 * scale + translationY,
    20.01164963751061 * scale + translationX,
    15.333340117704573 * scale + translationY,
    20.000000000000004 * scale + translationX,
    15.810000000000002 * scale + translationY,
  );

  path.close();

  canvas.drawPath(path, paint);
}