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 / 22.50291891028868;
final scaleY = size.height / 22.04230252393722;
final scale = math.min(scaleX, scaleY);
final translationX = (size.width - 22.50291891028868 * scale) / 2 - 0.5008319672859519 * scale;
final translationY = (size.height - 22.04230252393722 * scale) / 2 - 0.9576974760627794 * scale;
final path = Path();
final paint = Paint()..color = color;
path.moveTo(
14.41016 * scale + translationX,
16.86719 * scale + translationY,
);
path.cubicTo(
13.727979293084076 * scale + translationX,
17.36746745997754 * scale + translationY,
12.882797751171227 * scale + translationX,
17.59331340431317 * scale + translationY,
12.04200008971989 * scale + translationX,
17.500000130385157 * scale + translationY,
);
path.cubicTo(
11.202247928755096 * scale + translationX,
17.593503276787093 * scale + translationY,
10.358024384282539 * scale + translationX,
17.36798009116052 * scale + translationY,
9.676770258541726 * scale + translationX,
16.868160450679632 * scale + translationY,
);
path.cubicTo(
9.285803588015979 * scale + translationX,
16.47995558425233 * scale + translationY,
8.654569861896658 * scale + translationX,
16.480859283885522 * scale + translationY,
8.264717068529167 * scale + translationX,
16.870180710098214 * scale + translationY,
);
path.cubicTo(
7.874864275161675 * scale + translationX,
17.259502136310903 * scale + translationY,
7.873099622028821 * scale + translationX,
17.890734042715223 * scale + translationY,
8.260769588103575 * scale + translationX,
18.28222908841608 * scale + translationY,
);
path.cubicTo(
9.305387363425563 * scale + translationX,
19.181453508847202 * scale + translationY,
10.668941713292963 * scale + translationX,
19.62059515869078 * scale + translationY,
12.041999402353104 * scale + translationX,
19.499999032211058 * scale + translationY,
);
path.cubicTo(
13.415134916760111 * scale + translationX,
19.62004857538856 * scale + translationY,
14.778673408039992 * scale + translationX,
19.181377834532142 * scale + translationY,
15.824229646300896 * scale + translationX,
18.283199591338636 * scale + translationY,
);
path.cubicTo(
16.078106002493936 * scale + translationX,
18.03078961892755 * scale + translationY,
16.177784070744508 * scale + translationX,
17.66197457167927 * scale + translationY,
16.085618960400097 * scale + translationX,
17.316041670722438 * scale + translationY,
);
path.cubicTo(
15.993453850055685 * scale + translationX,
16.970108769765613 * scale + translationY,
15.723490754816927 * scale + translationX,
16.69977530240349 * scale + translationY,
15.377684536880363 * scale + translationX,
16.607136006391404 * scale + translationY,
);
path.cubicTo(
15.031878318943798 * scale + translationX,
16.51449671037932 * scale + translationY,
14.662926960177563 * scale + translationX,
16.6136690413566 * scale + translationY,
14.41016945025715 * scale + translationX,
16.867199356522335 * scale + translationY,
);
path.close();
path.moveTo(
9.2005 * scale + translationX,
15.00165 * scale + translationY,
);
path.cubicTo(
9.752784713254796 * scale + translationX,
15.00148428973321 * scale + translationY,
10.200365603707253 * scale + translationX,
14.553634743286768 * scale + translationY,
10.200199910009005 * scale + translationX,
14.001350030027 * scale + translationY,
);
path.cubicTo(
10.200034216310756 * scale + translationX,
13.449065316767232 * scale + translationY,
9.752184683291741 * scale + translationX,
13.001484412879288 * scale + translationY,
9.199899970027003 * scale + translationX,
13.001650090008996 * scale + translationY,
);
path.cubicTo(
8.647615256762265 * scale + translationX,
13.001815767138703 * scale + translationY,
8.200034339438835 * scale + translationX,
13.44966528673029 * scale + translationY,
8.2002 * scale + translationX,
14.001949999999999 * scale + translationY,
);
path.cubicTo(
8.200801041721933 * scale + translationX,
14.554053670409214 * scale + translationY,
8.648395428224545 * scale + translationX,
15.00137958082275 * scale + translationY,
9.200499746226148 * scale + translationX,
15.001649586215258 * scale + translationY,
);
path.close();
path.moveTo(
15.2005 * scale + translationX,
13.00165 * scale + translationY,
);
path.cubicTo(
14.648215286730291 * scale + translationX,
13.001484339438832 * scale + translationY,
14.200365767138702 * scale + translationX,
13.449065256762262 * scale + translationY,
14.200200090008995 * scale + translationX,
14.001349970027 * scale + translationY,
);
path.cubicTo(
14.200034412879287 * scale + translationX,
14.553634683291738 * scale + translationY,
14.647615316767231 * scale + translationX,
15.001484216310754 * scale + translationY,
15.199900030026999 * scale + translationX,
15.001649910009004 * scale + translationY,
);
path.cubicTo(
15.752184743286767 * scale + translationX,
15.001815603707254 * scale + translationY,
16.20003428973321 * scale + translationX,
14.554234713254797 * scale + translationY,
16.2002 * scale + translationX,
14.001949999999999 * scale + translationY,
);
path.cubicTo(
16.19960458357691 * scale + translationX,
13.449979459339914 * scale + translationY,
15.752468507228542 * scale + translationX,
13.00257502083709 * scale + translationY,
15.200499178954434 * scale + translationX,
13.001649297723953 * scale + translationY,
);
path.close();
path.moveTo(
23.0 * scale + translationX,
11.78027 * scale + translationY,
);
path.cubicTo(
23.00375087757463 * scale + translationX,
10.1536823511339 * scale + translationY,
21.96425367176476 * scale + translationX,
8.707937165401475 * scale + translationY,
20.421135907293944 * scale + translationX,
8.193554734966575 * scale + translationY,
);
path.cubicTo(
18.878018142823127 * scale + translationX,
7.679172304531675 * scale + translationY,
17.178967148809654 * scale + translationX,
8.212050623378333 * scale + translationY,
16.2060001152193 * scale + translationX,
9.515560067652485 * scale + translationY,
);
path.cubicTo(
15.206500750216474 * scale + translationX,
9.261107424380706 * scale + translationY,
14.185350962065993 * scale + translationX,
9.10090336702824 * scale + translationY,
13.155949744753842 * scale + translationX,
9.037049824666996 * scale + translationY,
);
path.lineTo(
14.011729999999998 * scale + translationX,
3.3320500000000006 * scale + translationY,
);
path.lineTo(
16.099249999999998 * scale + translationX,
4.04189 * scale + translationY,
);
path.cubicTo(
16.11906466128921 * scale + translationX,
5.695473048505574 * scale + translationY,
17.474532887466548 * scale + translationX,
7.0204958902414 * scale + translationY,
19.128139480375438 * scale + translationX,
7.002747332693206 * scale + translationY,
);
path.cubicTo(
20.78174607328433 * scale + translationX,
6.984998775145011 * scale + translationY,
22.10846172716468 * scale + translationX,
5.631187408282238 * scale + translationY,
22.092779595695067 * scale + translationX,
3.977559927209382 * scale + translationY,
);
path.lineTo(
22.092779999999998 * scale + translationX,
3.95508 * scale + translationY,
);
path.cubicTo(
22.05306607034791 * scale + translationX,
2.3223195636383367 * scale + translationY,
20.725954419226767 * scale + translationX,
1.0150791976399802 * scale + translationY,
19.092780551759443 * scale + translationX,
1.000000028898853 * scale + translationY,
);
path.cubicTo(
18.17938737807653 * scale + translationX,
1.0068256465137475 * scale + translationY,
17.319687780394474 * scale + translationX,
1.432603826310742 * scale + translationY,
16.760690690155457 * scale + translationX,
2.155000088736503 * scale + translationY,
);
path.lineTo(
13.52246 * scale + translationX,
1.05371 * scale + translationY,
);
path.cubicTo(
13.241886798694125 * scale + translationX,
0.9576974760627794 * scale + translationY,
12.933159142507856 * scale + translationX,
0.9912982198115259 * scale + translationY,
12.679809540731082 * scale + translationX,
1.145420901720761 * scale + translationY,
);
path.cubicTo(
12.426459938954308 * scale + translationX,
1.2995435836299964 * scale + translationY,
12.254677062809511 * scale + translationX,
1.5582565889817888 * scale + translationY,
12.21094015009009 * scale + translationX,
1.8515600227583464 * scale + translationY,
);
path.lineTo(
11.13446 * scale + translationX,
9.027 * scale + translationY,
);
path.cubicTo(
10.007305904616063 * scale + translationX,
9.076352696322367 * scale + translationY,
8.888077197860962 * scale + translationX,
9.240045833486793 * scale + translationY,
7.794000200678756 * scale + translationX,
9.515560245005231 * scale + translationY,
);
path.cubicTo(
6.590202370113375 * scale + translationX,
7.891805148011636 * scale + translationY,
4.31953955126054 * scale + translationX,
7.50733986512389 * scale + translationY,
2.648302101644025 * scale + translationX,
8.644297984787675 * scale + translationY,
);
path.cubicTo(
0.9770646520275097 * scale + translationX,
9.78125610445146 * scale + translationY,
0.5008319672859519 * scale + translationX,
12.03445951751707 * scale + translationY,
1.569079994496438 * scale + translationX,
13.750429951770244 * scale + translationY,
);
path.cubicTo(
1.2006085385417942 * scale + translationX,
14.443367901572929 * scale + translationY,
1.005354903989053 * scale + translationX,
15.215204407302894 * scale + translationY,
1.0000000315335593 * scale + translationX,
16.000000504536956 * scale + translationY,
);
path.cubicTo(
1.0 * scale + translationX,
19.9248 * scale + translationY,
5.832 * scale + translationX,
23.0 * scale + translationY,
12.0 * scale + translationX,
23.0 * scale + translationY,
);
path.cubicTo(
18.168 * scale + translationX,
23.0 * scale + translationY,
23.0 * scale + translationX,
19.9248 * scale + translationY,
23.0 * scale + translationX,
16.0 * scale + translationY,
);
path.cubicTo(
22.994662372437105 * scale + translationX,
15.215466569684873 * scale + translationY,
22.799556815628087 * scale + translationX,
14.443875659988757 * scale + translationY,
22.43134020060453 * scale + translationX,
13.751100122976737 * scale + translationY,
);
path.cubicTo(
22.798759892635175 * scale + translationX,
13.159055479514775 * scale + translationY,
22.99554612903941 * scale + translationX,
12.477044755545167 * scale + translationY,
23.000001156695774 * scale + translationX,
11.78027059244298 * scale + translationY,
);
path.close();
path.moveTo(
19.09277 * scale + translationX,
3.0 * scale + translationY,
);
path.cubicTo(
19.645054749830795 * scale + translationX,
3.0 * scale + translationY,
20.09277 * scale + translationX,
3.4477152501692068 * scale + translationY,
20.09277 * scale + translationX,
4.0 * scale + translationY,
);
path.cubicTo(
20.09277 * scale + translationX,
4.552284749830793 * scale + translationY,
19.645054749830795 * scale + translationX,
5.0 * scale + translationY,
19.09277 * scale + translationX,
5.0 * scale + translationY,
);
path.cubicTo(
18.54048525016921 * scale + translationX,
5.0 * scale + translationY,
18.09277 * scale + translationX,
4.552284749830793 * scale + translationY,
18.09277 * scale + translationX,
4.0 * scale + translationY,
);
path.cubicTo(
18.1017198669569 * scale + translationX,
3.451464946373251 * scale + translationY,
18.544235758677328 * scale + translationX,
3.0089490546528204 * scale + translationY,
19.092771027587045 * scale + translationX,
3.000000161462225 * scale + translationY,
);
path.close();
path.moveTo(
4.78027 * scale + translationX,
10.0 * scale + translationY,
);
path.cubicTo(
5.091053651659883 * scale + translationX,
10.003846237049121 * scale + translationY,
5.395274574462098 * scale + translationX,
10.089934975478986 * scale + translationY,
5.66198997878647 * scale + translationX,
10.24950996159861 * scale + translationY,
);
path.cubicTo(
4.6967394625023475 * scale + translationX,
10.66459097964372 * scale + translationY,
3.803100729333186 * scale + translationX,
11.229513593145233 * scale + translationY,
3.0141001040074102 * scale + translationX,
11.92340041144021 * scale + translationY,
);
path.cubicTo(
3.0101 * scale + translationX,
11.87555 * scale + translationY,
3.0 * scale + translationX,
11.8284 * scale + translationY,
3.0 * scale + translationX,
11.780270000000002 * scale + translationY,
);
path.cubicTo(
3.0012561182160433 * scale + translationX,
10.797574799793638 * scale + translationY,
3.7975747998672995 * scale + translationX,
10.001256118142383 * scale + translationY,
4.780269999949697 * scale + translationX,
9.999999999894769 * scale + translationY,
);
path.close();
path.moveTo(
12.0 * scale + translationX,
21.0 * scale + translationY,
);
path.cubicTo(
7.12109 * scale + translationX,
21.0 * scale + translationY,
3.0 * scale + translationX,
18.71 * scale + translationY,
3.0 * scale + translationX,
16.0 * scale + translationY,
);
path.cubicTo(
3.0 * scale + translationX,
13.29 * scale + translationY,
7.12109 * scale + translationX,
11.0 * scale + translationY,
12.0 * scale + translationX,
11.0 * scale + translationY,
);
path.cubicTo(
16.87891 * scale + translationX,
11.0 * scale + translationY,
21.0 * scale + translationX,
13.29 * scale + translationY,
21.0 * scale + translationX,
16.0 * scale + translationY,
);
path.cubicTo(
21.0 * scale + translationX,
18.71 * scale + translationY,
16.87891 * scale + translationX,
21.0 * scale + translationY,
12.0 * scale + translationX,
21.0 * scale + translationY,
);
path.close();
path.moveTo(
20.9859 * scale + translationX,
11.92346 * scale + translationY,
);
path.cubicTo(
20.196908863790448 * scale + translationX,
11.22953970975628 * scale + translationY,
19.30326462758761 * scale + translationX,
10.66459550144337 * scale + translationY,
18.33799988095645 * scale + translationX,
10.249509933463957 * scale + translationY,
);
path.cubicTo(
18.604721251246307 * scale + translationX,
10.089940643742507 * scale + translationY,
18.908943780796957 * scale + translationX,
10.003852427000213 * scale + translationY,
19.219729675934875 * scale + translationX,
9.999999831389346 * scale + translationY,
);
path.cubicTo(
20.202425199880143 * scale + translationX,
10.001256118142383 * scale + translationY,
20.9987438815314 * scale + translationX,
10.797574799793637 * scale + translationY,
20.999999999779014 * scale + translationX,
11.780269999876035 * scale + translationY,
);
path.cubicTo(
21.0 * scale + translationX,
11.82837 * scale + translationY,
20.98993 * scale + translationX,
11.87561 * scale + translationY,
20.9859 * scale + translationX,
11.92346 * scale + translationY,
);
path.close();
canvas.drawPath(path, paint);
}