paint method
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:
-
Obtain an ImageStream, for example by calling ImageProvider.resolve on an AssetImage or NetworkImage object.
-
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.
-
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.14908036143851;
final scaleY = size.height / 20.154507295664633;
final scale = math.min(scaleX, scaleY);
final translationX = (size.width - 18.14908036143851 * scale) / 2 - 2.9254799605330244 * scale;
final translationY = (size.height - 20.154507295664633 * scale) / 2 - 1.9288945168679936 * scale;
final path = Path();
final paint = Paint()..color = color;
path.moveTo(
14.478 * scale + translationX,
14.8829 * scale + translationY,
);
path.cubicTo(
13.726066139973563 * scale + translationX,
14.956183611783548 * scale + translationY,
12.968596736204002 * scale + translationX,
14.818265134219837 * scale + translationY,
12.290750063691132 * scale + translationX,
14.484650075060005 * scale + translationY,
);
path.cubicTo(
11.980397765464664 * scale + translationX,
14.2363291163595 * scale + translationY,
11.786585916283585 * scale + translationX,
13.870693708354876 * scale + translationY,
11.75527974967505 * scale + translationX,
13.474459713065665 * scale + translationY,
);
path.cubicTo(
11.754647209722206 * scale + translationX,
13.415207279287719 * scale + translationY,
11.730335805230343 * scale + translationX,
13.358670551538921 * scale + translationY,
11.687764779924258 * scale + translationX,
13.31745206079379 * scale + translationY,
);
path.cubicTo(
11.645193754618173 * scale + translationX,
13.276233570048662 * scale + translationY,
11.587901814909122 * scale + translationX,
13.25375959360293 * scale + translationY,
11.528659791408298 * scale + translationX,
13.25503976017236 * scale + translationY,
);
path.cubicTo(
11.212069999999999 * scale + translationX,
13.25119 * scale + translationY,
10.895539999999999 * scale + translationX,
13.25204 * scale + translationY,
10.579009999999998 * scale + translationX,
13.25461 * scale + translationY,
);
path.cubicTo(
10.463886784226752 * scale + translationX,
13.242869004518937 * scale + translationY,
10.360735679579978 * scale + translationX,
13.325914158696484 * scale + translationY,
10.347630408756029 * scale + translationX,
13.440890530947168 * scale + translationY,
);
path.cubicTo(
10.311080361781185 * scale + translationX,
14.137260649684343 * scale + translationY,
10.587206696397052 * scale + translationX,
14.8136115815645 * scale + translationY,
11.100680127849873 * scale + translationX,
15.285430176046898 * scale + translationY,
);
path.cubicTo(
11.740876611687835 * scale + translationX,
15.784997387279224 * scale + translationY,
12.518220915528234 * scale + translationX,
16.07740808951864 * scale + translationY,
13.328950294679041 * scale + translationX,
16.123630356464375 * scale + translationY,
);
path.cubicTo(
14.173697160211626 * scale + translationX,
16.221611801798687 * scale + translationY,
15.02862787628258 * scale + translationX,
16.18531298829361 * scale + translationY,
15.862029760193924 * scale + translationX,
16.016079757864954 * scale + translationY,
);
path.cubicTo(
16.50196622349986 * scale + translationX,
15.89670753314965 * scale + translationY,
17.08866966500147 * scale + translationX,
15.580525408790724 * scale + translationY,
17.540259568731223 * scale + translationX,
15.111659628444098 * scale + translationY,
);
path.cubicTo(
18.047753281296462 * scale + translationX,
14.485946165012772 * scale + translationY,
18.197382690348935 * scale + translationX,
13.643045162911799 * scale + translationY,
17.936258997982907 * scale + translationX,
12.880889280403384 * scale + translationY,
);
path.cubicTo(
17.717626702845585 * scale + translationX,
12.345283274950916 * scale + translationY,
17.26328716597532 * scale + translationX,
11.941111626148915 * scale + translationY,
16.70586042750197 * scale + translationX,
11.786350301611998 * scale + translationY,
);
path.cubicTo(
15.42509 * scale + translationX,
11.336949999999998 * scale + translationY,
14.04155 * scale + translationX,
11.37094 * scale + translationY,
12.735860000000002 * scale + translationX,
11.029449999999999 * scale + translationY,
);
path.cubicTo(
12.509180000000002 * scale + translationX,
10.958099999999998 * scale + translationY,
12.232200000000002 * scale + translationX,
10.88065 * scale + translationY,
12.131190000000002 * scale + translationX,
10.640659999999999 * scale + translationY,
);
path.cubicTo(
12.011456694832578 * scale + translationX,
10.29438799177 * scale + translationY,
12.125770629469349 * scale + translationX,
9.910319237767272 * scale + translationY,
12.415370666319323 * scale + translationX,
9.68588051983058 * scale + translationY,
);
path.cubicTo(
12.825334824344068 * scale + translationX,
9.451584776272643 * scale + translationY,
13.292158067799713 * scale + translationX,
9.33535573947202 * scale + translationY,
13.764120607207843 * scale + translationX,
9.350070412480841 * scale + translationY,
);
path.cubicTo(
14.404652196727728 * scale + translationX,
9.289769514234713 * scale + translationY,
15.050356372042431 * scale + translationX,
9.382158371138102 * scale + translationY,
15.648279195725431 * scale + translationX,
9.619659505578381 * scale + translationY,
);
path.cubicTo(
16.011830619504185 * scale + translationX,
9.833456387437955 * scale + translationY,
16.26298057193754 * scale + translationX,
10.196297617114347 * scale + translationY,
16.335050099755385 * scale + translationX,
10.611850064804772 * scale + translationY,
);
path.cubicTo(
16.338600118496434 * scale + translationX,
10.737422032588489 * scale + translationY,
16.437276761515882 * scale + translationX,
10.839588776558317 * scale + translationY,
16.562649772332108 * scale + translationX,
10.847499850891767 * scale + translationY,
);
path.cubicTo(
16.876980000000003 * scale + translationX,
10.85391 * scale + translationY,
17.19143 * scale + translationX,
10.84921 * scale + translationY,
17.505760000000002 * scale + translationX,
10.84964 * scale + translationY,
);
path.cubicTo(
17.618462016792506 * scale + translationX,
10.863119320492476 * scale + translationY,
17.72390595771808 * scale + translationX,
10.791612536681878 * scale + translationY,
17.753079147851967 * scale + translationX,
10.681919487267724 * scale + translationY,
);
path.cubicTo(
17.758772283985362 * scale + translationX,
9.819212992185848 * scale + translationY,
17.30730196359911 * scale + translationX,
9.017968737575433 * scale + translationY,
16.56643084527074 * scale + translationX,
8.57592043757009 * scale + translationY,
);
path.cubicTo(
15.561438916685924 * scale + translationX,
8.112104310381657 * scale + translationY,
14.44592918359123 * scale + translationX,
7.941415584426831 * scale + translationY,
13.34822932844382 * scale + translationX,
8.083489593315543 * scale + translationY,
);
path.lineTo(
13.348230000000001 * scale + translationX,
8.08341 * scale + translationY,
);
path.cubicTo(
12.543971671102625 * scale + translationX,
8.116378715659641 * scale + translationY,
11.775560441244128 * scale + translationX,
8.425127382416838 * scale + translationY,
11.172079870367902 * scale + translationX,
8.957789896060795 * scale + translationY,
);
path.cubicTo(
10.606817394857014 * scale + translationX,
9.567032849155252 * scale + translationY,
10.4382320686794 * scale + translationX,
10.44517618545646 * scale + translationY,
10.7376995839392 * scale + translationX,
11.220429565234543 * scale + translationY,
);
path.cubicTo(
10.96891937330234 * scale + translationX,
11.735567877187577 * scale + translationY,
11.414167848110317 * scale + translationX,
12.123584319592139 * scale + translationY,
11.956080614872564 * scale + translationX,
12.282200631644134 * scale + translationY,
);
path.cubicTo(
13.232569999999999 * scale + translationX,
12.74326 * scale + translationY,
14.63162 * scale + translationX,
12.59531 * scale + translationY,
15.9205 * scale + translationX,
13.00302 * scale + translationY,
);
path.cubicTo(
16.17166 * scale + translationX,
13.08823 * scale + translationY,
16.46414 * scale + translationX,
13.218539999999999 * scale + translationY,
16.5411 * scale + translationX,
13.49808 * scale + translationY,
);
path.cubicTo(
16.625231597925445 * scale + translationX,
13.838966239634438 * scale + translationY,
16.522646998400088 * scale + translationX,
14.198919678117337 * scale + translationY,
16.271449345757187 * scale + translationX,
14.444239419225683 * scale + translationY,
);
path.cubicTo(
15.735401584158154 * scale + translationX,
14.777241905407596 * scale + translationY,
15.107234758339999 * scale + translationX,
14.930885251925977 * scale + translationY,
14.478000417571838 * scale + translationX,
14.88290042924989 * scale + translationY,
);
path.close();
path.moveTo(
20.29691 * scale + translationX,
6.437529999999999 * scale + translationY,
);
path.cubicTo(
17.80466333333333 * scale + translationX,
5.028196666666665 * scale + translationY,
15.311846666666668 * scale + translationX,
3.620136666666666 * scale + translationY,
12.81846 * scale + translationX,
2.2133499999999993 * scale + translationY,
);
path.cubicTo(
12.309747605215684 * scale + translationX,
1.9288945168679936 * scale + translationY,
11.6898426840727 * scale + translationX,
1.9288945168679936 * scale + translationY,
11.181130134776094 * scale + translationX,
2.213350026679474 * scale + translationY,
);
path.cubicTo(
8.697443333333332 * scale + translationX,
3.6158833333333327 * scale + translationY,
6.213626666666667 * scale + translationX,
5.01835 * scale + translationY,
3.72968 * scale + translationX,
6.42075 * scale + translationY,
);
path.cubicTo(
3.23757853586953 * scale + translationX,
6.688973367245176 * scale + translationY,
2.9296948765955038 * scale + translationX,
7.203022693462321 * scale + translationY,
2.9254799605330244 * scale + translationX,
7.763459895264952 * scale + translationY,
);
path.lineTo(
2.9254800000000003 * scale + translationX,
16.2377 * scale + translationY,
);
path.cubicTo(
2.9335829447959085 * scale + translationX,
16.808570556456612 * scale + translationY,
3.2543308044955563 * scale + translationX,
17.328940946654196 * scale + translationY,
3.7606800598294945 * scale + translationX,
17.592700279886177 * scale + translationY,
);
path.cubicTo(
4.47419 * scale + translationX,
17.981070000000003 * scale + translationY,
5.16742 * scale + translationX,
18.40899 * scale + translationY,
5.89386 * scale + translationX,
18.77154 * scale + translationY,
);
path.cubicTo(
6.743939409222684 * scale + translationX,
19.225982153683148 * scale + translationY,
7.758324421139175 * scale + translationX,
19.253858829825575 * scale + translationY,
8.632079623216661 * scale + translationX,
18.8467891773528 * scale + translationY,
);
path.cubicTo(
9.288836557574458 * scale + translationX,
18.43539408174479 * scale + translationY,
9.669943159293195 * scale + translationX,
17.69942261270925 * scale + translationY,
9.626900306260728 * scale + translationX,
16.92565053845598 * scale + translationY,
);
path.cubicTo(
9.63245 * scale + translationX,
14.128960000000001 * scale + translationY,
9.62775 * scale + translationX,
11.33214 * scale + translationY,
9.62903 * scale + translationX,
8.535390000000001 * scale + translationY,
);
path.cubicTo(
9.638875555082063 * scale + translationX,
8.473546001161505 * scale + translationY,
9.621875634714685 * scale + translationX,
8.410438661460601 * scale + translationY,
9.58229733878367 * scale + translationX,
8.36190860930222 * scale + translationY,
);
path.cubicTo(
9.542719042852651 * scale + translationX,
8.313378557143837 * scale + translationY,
9.484320306137828 * scale + translationX,
8.284033691038585 * scale + translationY,
9.421759916500255 * scale + translationX,
8.281239926608041 * scale + translationY,
);
path.cubicTo(
9.104370000000001 * scale + translationX,
8.276110000000003 * scale + translationY,
8.7865 * scale + translationX,
8.278240000000002 * scale + translationY,
8.46912 * scale + translationX,
8.280390000000002 * scale + translationY,
);
path.cubicTo(
8.409681328610636 * scale + translationX,
8.275055241853009 * scale + translationY,
8.350791423038089 * scale + translationX,
8.295341005387979 * scale + translationY,
8.307247889153938 * scale + translationX,
8.336149699775548 * scale + translationY,
);
path.cubicTo(
8.263704355269786 * scale + translationX,
8.376958394163118 * scale + translationY,
8.23964658675408 * scale + translationX,
8.434410608694716 * scale + translationY,
8.241119801181101 * scale + translationX,
8.494069795078627 * scale + translationY,
);
path.cubicTo(
8.23685 * scale + translationX,
11.272820000000003 * scale + translationY,
8.24198 * scale + translationX,
14.052360000000004 * scale + translationY,
8.23856 * scale + translationX,
16.83153 * scale + translationY,
);
path.cubicTo(
8.240049208992435 * scale + translationX,
17.22438567220297 * scale + translationY,
7.997203968201677 * scale + translationX,
17.576782428597088 * scale + translationY,
7.629559800400664 * scale + translationX,
17.715259536545474 * scale + translationY,
);
path.cubicTo(
7.211461648827402 * scale + translationX,
17.838845734570672 * scale + translationY,
6.76051518852548 * scale + translationX,
17.778491871782364 * scale + translationY,
6.389630211066582 * scale + translationX,
17.54931057970069 * scale + translationY,
);
path.cubicTo(
5.728616666666666 * scale + translationX,
17.17597666666667 * scale + translationY,
5.067616666666666 * scale + translationX,
16.802683333333334 * scale + translationY,
4.40663 * scale + translationX,
16.429430000000004 * scale + translationY,
);
path.cubicTo(
4.316926168528017 * scale + translationX,
16.386912833369685 * scale + translationY,
4.26319839054813 * scale + translationX,
16.293020907635228 * scale + translationY,
4.271990192458374 * scale + translationX,
16.19414072956582 * scale + translationY,
);
path.cubicTo(
4.27199 * scale + translationX,
13.398253333333338 * scale + translationY,
4.27199 * scale + translationX,
10.602500000000003 * scale + translationY,
4.27199 * scale + translationX,
7.806880000000005 * scale + translationY,
);
path.cubicTo(
4.262560926690972 * scale + translationX,
7.695323974453202 * scale + translationY,
4.32590309643378 * scale + translationX,
7.590345423070534 * scale + translationY,
4.42898978706198 * scale + translationX,
7.546679637168952 * scale + translationY,
);
path.cubicTo(
6.904529999999999 * scale + translationX,
6.152426666666668 * scale + translationY,
9.379596666666666 * scale + translationX,
4.75671 * scale + translationY,
11.854190000000001 * scale + translationX,
3.35953 * scale + translationY,
);
path.cubicTo(
11.94216476824285 * scale + translationX,
3.299449459489946 * scale + translationY,
12.058021156881283 * scale + translationX,
3.299620286384005 * scale + translationY,
12.145819174902135 * scale + translationX,
3.3599597717489775 * scale + translationY,
);
path.cubicTo(
14.621273333333335 * scale + translationX,
4.754653333333334 * scale + translationY,
17.09661333333333 * scale + translationX,
6.1498333333333335 * scale + translationY,
19.57184 * scale + translationX,
7.5455 * scale + translationY,
);
path.cubicTo(
19.674375451345828 * scale + translationX,
7.590349996290109 * scale + translationY,
19.737101865139447 * scale + translationX,
7.695377467589204 * scale + translationY,
19.72796971879446 * scale + translationX,
7.806919888718951 * scale + translationY,
);
path.cubicTo(
19.727543333333333 * scale + translationX,
10.602306666666665 * scale + translationY,
19.727259999999998 * scale + translationX,
13.39792 * scale + translationY,
19.72712 * scale + translationX,
16.19376 * scale + translationY,
);
path.cubicTo(
19.736075121629842 * scale + translationX,
16.292977745376014 * scale + translationY,
19.683313560122674 * scale + translationX,
16.38754691098401 * scale + translationY,
19.594179090308852 * scale + translationX,
16.43203923711626 * scale + translationY,
);
path.cubicTo(
17.15656 * scale + translationX,
17.810393333333334 * scale + translationY,
14.717636666666664 * scale + translationX,
19.186756666666668 * scale + translationY,
12.277409999999998 * scale + translationX,
20.56113 * scale + translationY,
);
path.cubicTo(
12.160829999999997 * scale + translationX,
20.62607 * scale + translationY,
12.022829999999997 * scale + translationX,
20.730559999999997 * scale + translationY,
11.886479999999997 * scale + translationX,
20.651889999999998 * scale + translationY,
);
path.cubicTo(
11.247379999999996 * scale + translationX,
20.290129999999998 * scale + translationY,
10.616089999999996 * scale + translationX,
19.91434 * scale + translationY,
9.979129999999998 * scale + translationX,
19.549159999999997 * scale + translationY,
);
path.cubicTo(
9.9125219816607 * scale + translationX,
19.49822151454151 * scale + translationY,
9.821675258946401 * scale + translationX,
19.492767072246885 * scale + translationY,
9.749450445597303 * scale + translationX,
19.53537089286146 * scale + translationY,
);
path.cubicTo(
9.4688902577138 * scale + translationX,
19.699759681468148 * scale + translationY,
9.173579179697862 * scale + translationX,
19.837565714858457 * scale + translationY,
8.86736996428542 * scale + translationX,
19.946989919660695 * scale + translationY,
);
path.cubicTo(
8.729309999999998 * scale + translationX,
20.002899999999997 * scale + translationY,
8.559449999999998 * scale + translationX,
20.018829999999998 * scale + translationY,
8.464419999999997 * scale + translationX,
20.146879999999996 * scale + translationY,
);
path.cubicTo(
8.585549411958038 * scale + translationX,
20.278677358398227 * scale + translationY,
8.73229988975544 * scale + translationX,
20.384370232719768 * scale + translationY,
8.89569003329502 * scale + translationX,
20.45749007656883 * scale + translationY,
);
path.cubicTo(
9.640629999999996 * scale + translationX,
20.888823333333328 * scale + translationY,
10.38596333333333 * scale + translationX,
21.31977333333333 * scale + translationY,
11.131689999999997 * scale + translationX,
21.750339999999998 * scale + translationY,
);
path.cubicTo(
11.63399899930526 * scale + translationX,
22.065783365171363 * scale + translationY,
12.268029468378405 * scale + translationX,
22.083401812532628 * scale + translationY,
12.787080452792548 * scale + translationX,
21.796340771811888 * scale + translationY,
);
path.cubicTo(
15.271146666666663 * scale + translationX,
20.395673333333328 * scale + translationY,
17.755096666666663 * scale + translationX,
18.994366666666664 * scale + translationY,
20.238929999999996 * scale + translationX,
17.592419999999997 * scale + translationY,
);
path.cubicTo(
20.74480660994559 * scale + translationX,
17.32822076698286 * scale + translationY,
21.065491394312374 * scale + translationX,
16.80832020719797 * scale + translationY,
21.074560321971536 * scale + translationX,
16.237680248074962 * scale + translationY,
);
path.lineTo(
21.074559999999998 * scale + translationX,
7.76346 * scale + translationY,
);
path.cubicTo(
21.070319975706735 * scale + translationX,
7.214444722730161 * scale + translationY,
20.774028133561465 * scale + translationX,
6.709233639867476 * scale + translationY,
20.296940130275683 * scale + translationX,
6.437530041319215 * scale + translationY,
);
path.close();
canvas.drawPath(path, paint);
}