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 / 23.107103202595294;
final scaleY = size.height / 23.107103202595294;
final scale = math.min(scaleX, scaleY);
final translationX = (size.width - 23.107103202595294 * scale) / 2 - 0.446448259124278 * scale;
final translationY = (size.height - 23.107103202595294 * scale) / 2 - 0.44644825912427744 * scale;
final path = Path();
final paint = Paint()..color = color;
path.moveTo(
15.13916 * scale + translationX,
11.8125 * scale + translationY,
);
path.cubicTo(
14.73874245366424 * scale + translationX,
11.555367213608529 * scale + translationY,
14.304153532465204 * scale + translationX,
11.355823236211817 * scale + translationY,
13.848159995643764 * scale + translationX,
11.21972999647059 * scale + translationY,
);
path.cubicTo(
13.56838 * scale + translationX,
11.13513 * scale + translationY,
13.25863 * scale + translationX,
11.05237 * scale + translationY,
12.93776 * scale + translationX,
10.9726 * scale + translationY,
);
path.cubicTo(
12.658650000000002 * scale + translationX,
10.894779999999999 * scale + translationY,
12.326440000000002 * scale + translationX,
10.81494 * scale + translationY,
11.915550000000001 * scale + translationX,
10.7246 * scale + translationY,
);
path.cubicTo(
11.426286158044567 * scale + translationX,
10.622083978010867 * scale + translationY,
10.946068620478107 * scale + translationX,
10.480349577630092 * scale + translationY,
10.479549925683672 * scale + translationX,
10.300769926951496 * scale + translationY,
);
path.cubicTo(
10.239184171814241 * scale + translationX,
10.207256548624365 * scale + translationY,
10.027080198026988 * scale + translationX,
10.05318388033994 * scale + translationY,
9.863829852389504 * scale + translationX,
9.853509852543938 * scale + translationY,
);
path.cubicTo(
9.744684316217175 * scale + translationX,
9.69021919116634 * scale + translationY,
9.688190993076532 * scale + translationX,
9.48954687238626 * scale + translationY,
9.704650234605314 * scale + translationX,
9.288080224534927 * scale + translationY,
);
path.cubicTo(
9.704106042755171 * scale + translationX,
9.071969475232695 * scale + translationY,
9.775961191370856 * scale + translationX,
8.861903183826495 * scale + translationY,
9.90875033789307 * scale + translationX,
8.691400296380857 * scale + translationY,
);
path.cubicTo(
10.095032789941357 * scale + translationX,
8.472896741805958 * scale + translationY,
10.336737877522914 * scale + translationX,
8.30861079105077 * scale + translationY,
10.608460136032827 * scale + translationX,
8.215810105351755 * scale + translationY,
);
path.cubicTo(
11.0661521859491 * scale + translationX,
8.058600145300684 * scale + translationY,
11.54850922332528 * scale + translationX,
7.985486178693609 * scale + translationY,
12.032230401931873 * scale + translationX,
8.00000026723683 * scale + translationY,
);
path.cubicTo(
12.405929325598747 * scale + translationX,
7.994012643824287 * scale + translationY,
12.778456541821924 * scale + translationX,
8.043374260722413 * scale + translationY,
13.137700248541641 * scale + translationX,
8.146480154116741 * scale + translationY,
);
path.cubicTo(
13.376236908778644 * scale + translationX,
8.213264411155516 * scale + translationY,
13.600946822792407 * scale + translationX,
8.32206536399166 * scale + translationY,
13.801270717483897 * scale + translationX,
8.467770440212284 * scale + translationY,
);
path.cubicTo(
13.9307183953626 * scale + translationX,
8.560035013939782 * scale + translationY,
14.041135713744382 * scale + translationX,
8.676424965644653 * scale + translationY,
14.126459944680782 * scale + translationX,
8.810549965497886 * scale + translationY,
);
path.cubicTo(
14.29503560324492 * scale + translationX,
9.126272164286355 * scale + translationY,
14.619533797172537 * scale + translationX,
9.327786560083368 * scale + translationY,
14.9772695988688 * scale + translationX,
9.338905427204299 * scale + translationY,
);
path.cubicTo(
15.335005400565063 * scale + translationX,
9.350024294325227 * scale + translationY,
15.671391780608195 * scale + translationX,
9.169051000999394 * scale + translationY,
15.859249563377933 * scale + translationX,
8.864406968603946 * scale + translationY,
);
path.cubicTo(
16.04710734614767 * scale + translationX,
8.5597629362085 * scale + translationY,
16.057771247748644 * scale + translationX,
8.177933902767661 * scale + translationY,
15.887209516912167 * scale + translationX,
7.863279760898552 * scale + translationY,
);
path.cubicTo(
15.676224260251029 * scale + translationX,
7.490253727238639 * scale + translationY,
15.391262656287624 * scale + translationX,
7.164256645048384 * scale + translationY,
15.04980117652227 * scale + translationX,
6.90528053982217 * scale + translationY,
);
path.cubicTo(
14.655521390002686 * scale + translationX,
6.602389739482199 * scale + translationY,
14.208303503865608 * scale + translationX,
6.375542298678893 * scale + translationY,
13.731000251861124 * scale + translationX,
6.2363301143899985 * scale + translationY,
);
path.cubicTo(
13.179687079247143 * scale + translationX,
6.073329772586276 * scale + translationY,
12.60710107505663 * scale + translationX,
5.993672579222639 * scale + translationY,
12.032230691821457 * scale + translationX,
6.000000344984159 * scale + translationY,
);
path.cubicTo(
11.301790451227856 * scale + translationX,
5.984477146709261 * scale + translationY,
10.57471644009639 * scale + translationX,
6.103313919465708 * scale + translationY,
9.887230060244473 * scale + translationX,
6.35059003869516 * scale + translationY,
);
path.cubicTo(
9.265203243271394 * scale + translationX,
6.576373284792095 * scale + translationY,
8.718614164043629 * scale + translationX,
6.971424728285281 * scale + translationY,
8.309079589425112 * scale + translationX,
7.491209629838357 * scale + translationY,
);
path.cubicTo(
7.917160260056989 * scale + translationX,
8.008295665832135 * scale + translationY,
7.704896548382085 * scale + translationX,
8.639261303368576 * scale + translationY,
7.7045899401496944 * scale + translationX,
9.288089927848851 * scale + translationY,
);
path.cubicTo(
7.68839074796616 * scale + translationX,
9.934030798497265 * scale + translationY,
7.8930187444971525 * scale + translationX,
10.566173554295668 * scale + translationY,
8.284670310899003 * scale + translationX,
11.080090415802793 * scale + translationY,
);
path.cubicTo(
8.662744444697127 * scale + translationX,
11.556332543884428 * scale + translationY,
9.158347319231437 * scale + translationX,
11.925884100385234 * scale + translationY,
9.722670103552636 * scale + translationX,
12.152350129430276 * scale + translationY,
);
path.cubicTo(
10.149094087602363 * scale + translationX,
12.316390167363627 * scale + translationY,
10.585694428779378 * scale + translationX,
12.452641968479186 * scale + translationY,
11.029729822845614 * scale + translationX,
12.560249798263117 * scale + translationY,
);
path.cubicTo(
11.0381 * scale + translationX,
12.563 * scale + translationY,
11.04373 * scale + translationX,
12.56971 * scale + translationY,
11.05226 * scale + translationX,
12.57225 * scale + translationY,
);
path.cubicTo(
11.24366 * scale + translationX,
12.62986 * scale + translationY,
11.54981 * scale + translationX,
12.70701 * scale + translationY,
11.9922 * scale + translationX,
12.802710000000001 * scale + translationY,
);
path.cubicTo(
12.16456 * scale + translationX,
12.839710000000002 * scale + translationY,
12.32698 * scale + translationX,
12.880600000000001 * scale + translationY,
12.48933 * scale + translationX,
12.921180000000001 * scale + translationY,
);
path.cubicTo(
12.505080000000001 * scale + translationX,
12.925880000000001 * scale + translationY,
12.527840000000001 * scale + translationX,
12.930830000000002 * scale + translationY,
12.54298 * scale + translationX,
12.935530000000002 * scale + translationY,
);
path.lineTo(
12.56105 * scale + translationX,
12.938270000000001 * scale + translationY,
);
path.cubicTo(
12.8094 * scale + translationX,
13.001570000000001 * scale + translationY,
13.04811 * scale + translationX,
13.067 * scale + translationY,
13.26661 * scale + translationX,
13.133770000000002 * scale + translationY,
);
path.cubicTo(
13.535880522133338 * scale + translationX,
13.212371559415123 * scale + translationY,
13.792902366842274 * scale + translationX,
13.328064540832095 * scale + translationY,
14.030279819664019 * scale + translationX,
13.477519826768836 * scale + translationY,
);
path.cubicTo(
14.177935343469253 * scale + translationX,
13.570522483048885 * scale + translationY,
14.301965510879754 * scale + translationX,
13.696555290406808 * scale + translationY,
14.392590629171835 * scale + translationX,
13.845680605263675 * scale + translationY,
);
path.cubicTo(
14.480725486370384 * scale + translationX,
14.027593529105046 * scale + translationY,
14.521535102606654 * scale + translationX,
14.228804026350879 * scale + translationY,
14.511240551733502 * scale + translationX,
14.430680548670523 * scale + translationY,
);
path.cubicTo(
14.525230702331697 * scale + translationX,
14.692030714660063 * scale + translationY,
14.449800090854607 * scale + translationX,
14.95035419511157 * scale + translationY,
14.297369958276008 * scale + translationX,
15.163109955749523 * scale + translationY,
);
path.cubicTo(
14.091377578502088 * scale + translationX,
15.43100109135499 * scale + translationY,
13.812744764871429 * scale + translationX,
15.634058403245582 * scale + translationY,
13.494639479728141 * scale + translationX,
15.748109392847946 * scale + translationY,
);
path.cubicTo(
13.02107759871582 * scale + translationX,
15.93082481990399 * scale + translationY,
12.515619467768952 * scale + translationX,
16.01648479582081 * scale + translationY,
12.008299231938787 * scale + translationX,
15.99999897662622 * scale + translationY,
);
path.cubicTo(
11.421155566356072 * scale + translationX,
16.022745054989045 * scale + translationY,
10.837073477016844 * scale + translationX,
15.90489048838615 * scale + translationY,
10.304689466206362 * scale + translationX,
15.656249188989996 * scale + translationY,
);
path.cubicTo(
10.059005259921294 * scale + translationX,
15.525337143200213 * scale + translationY,
9.847960380459721 * scale + translationX,
15.337894411432798 * scale + translationY,
9.688960399534915 * scale + translationX,
15.109380623051889 * scale + translationY,
);
path.cubicTo(
9.577468595598438 * scale + translationX,
14.963072669074615 * scale + translationY,
9.507771746683991 * scale + translationX,
14.78925219786296 * scale + translationY,
9.487299666772426 * scale + translationX,
14.60644948696975 * scale + translationY,
);
path.cubicTo(
9.487300000000001 * scale + translationX,
14.054165250169207 * scale + translationY,
9.039584749830794 * scale + translationX,
13.60645 * scale + translationY,
8.487300000000001 * scale + translationX,
13.60645 * scale + translationY,
);
path.cubicTo(
7.935015250169208 * scale + translationX,
13.60645 * scale + translationY,
7.487300000000001 * scale + translationX,
14.054165250169207 * scale + translationY,
7.487300000000001 * scale + translationX,
14.60645 * scale + translationY,
);
path.cubicTo(
7.504069157898561 * scale + translationX,
15.196103846783359 * scale + translationY,
7.697854457416172 * scale + translationX,
15.767072914606505 * scale + translationY,
8.043460136969413 * scale + translationX,
16.24512027663276 * scale + translationY,
);
path.cubicTo(
8.388900535787506 * scale + translationX,
16.74293551939457 * scale + translationY,
8.849136387536394 * scale + translationX,
17.15024968476457 * scale + translationY,
9.385249696781596 * scale + translationX,
17.43261943678738 * scale + translationY,
);
path.cubicTo(
10.200964019743854 * scale + translationX,
17.83076066118964 * scale + translationY,
11.100964058016027 * scale + translationX,
18.02543557082341 * scale + translationY,
12.00829996839399 * scale + translationX,
17.999999952623757 * scale + translationY,
);
path.cubicTo(
12.779266098487724 * scale + translationX,
18.01854844140684 * scale + translationY,
13.545996246623723 * scale + translationX,
17.880684583872565 * scale + translationY,
14.262210292058263 * scale + translationX,
17.594730360300844 * scale + translationY,
);
path.cubicTo(
14.927951786870933 * scale + translationX,
17.33938035086408 * scale + translationY,
15.506012462957761 * scale + translationX,
16.897603120898044 * scale + translationY,
15.92721001677649 * scale + translationX,
16.32227001719262 * scale + translationY,
);
path.cubicTo(
16.327471781162313 * scale + translationX,
15.76125102030072 * scale + translationY,
16.53246614691926 * scale + translationX,
15.084332916878465 * scale + translationY,
16.51069935949823 * scale + translationX,
14.395509441553077 * scale + translationY,
);
path.cubicTo(
16.520056956317827 * scale + translationX,
13.861579879509218 * scale + translationY,
16.390855389162144 * scale + translationX,
13.334341015010565 * scale + translationY,
16.135700223924726 * scale + translationX,
12.865230178538464 * scale + translationY,
);
path.cubicTo(
15.889424739386884 * scale + translationX,
12.441956538115456 * scale + translationY,
15.548300200487832 * scale + translationX,
12.081597660563927 * scale + translationY,
15.139158923317805 * scale + translationX,
11.812499159906599 * scale + translationY,
);
path.close();
path.moveTo(
22.361330000000002 * scale + translationX,
13.69141 * scale + translationY,
);
path.cubicTo(
22.908965944513856 * scale + translationX,
10.356712564005393 * scale + translationY,
21.81675281613122 * scale + translationX,
6.9623907775490546 * scale + translationY,
19.42718066410299 * scale + translationX,
4.572818625520823 * scale + translationY,
);
path.cubicTo(
17.03760851207476 * scale + translationX,
2.1832464734925927 * scale + translationY,
13.643286725618422 * scale + translationX,
1.0910333451099619 * scale + translationY,
10.308589694875964 * scale + translationX,
1.6386699514969951 * scale + translationY,
);
path.cubicTo(
7.821872779745221 * scale + translationX,
0.44644825912427744 * scale + translationY,
4.853489970788853 * scale + translationX,
0.9534503373636685 * scale + translationY,
2.903470154076261 * scale + translationX,
2.9034701540762593 * scale + translationY,
);
path.cubicTo(
0.953450337363671 * scale + translationX,
4.85348997078885 * scale + translationY,
0.446448259124278 * scale + translationX,
7.8218727797452186 * scale + translationY,
1.638669980939801 * scale + translationX,
10.308589880095568 * scale + translationY,
);
path.cubicTo(
1.0910333451099636 * scale + translationX,
13.64328672561842 * scale + translationY,
2.183246473492594 * scale + translationX,
17.03760851207476 * scale + translationY,
4.572818625520823 * scale + translationX,
19.427180664102988 * scale + translationY,
);
path.cubicTo(
6.9623907775490546 * scale + translationX,
21.816752816131217 * scale + translationY,
10.356712564005392 * scale + translationX,
22.908965944513852 * scale + translationY,
13.691409594747848 * scale + translationX,
22.36132933812682 * scale + translationY,
);
path.cubicTo(
16.178126941098625 * scale + translationX,
23.55355146171957 * scale + translationY,
19.146509750054996 * scale + translationX,
23.04654938348018 * scale + translationY,
21.096529566767586 * scale + translationX,
21.096529566767586 * scale + translationY,
);
path.cubicTo(
23.04654938348018 * scale + translationX,
19.146509750054996 * scale + translationY,
23.55355146171957 * scale + translationX,
16.178126941098625 * scale + translationY,
22.361329739904047 * scale + translationX,
13.691409840748276 * scale + translationY,
);
path.close();
path.moveTo(
16.5 * scale + translationX,
21.0 * scale + translationY,
);
path.cubicTo(
15.741447441260934 * scale + translationX,
20.99970696184734 * scale + translationY,
14.995245937931719 * scale + translationX,
20.807906865837587 * scale + translationY,
14.330570466494342 * scale + translationX,
20.442380665448386 * scale + translationY,
);
path.cubicTo(
14.124307288290266 * scale + translationX,
20.32852138109697 * scale + translationY,
13.884566387842971 * scale + translationX,
20.290842501150706 * scale + translationY,
13.653320530767202 * scale + translationX,
20.33594079055131 * scale + translationY,
);
path.cubicTo(
11.157679637891125 * scale + translationX,
20.833746616993682 * scale + translationY,
8.570332420740595 * scale + translationX,
20.18611923576434 * scale + translationY,
6.603487767463596 * scale + translationX,
18.571327323460007 * scale + translationY,
);
path.cubicTo(
4.636643114186599 * scale + translationX,
16.95653541115567 * scale + translationY,
3.4976371193227895 * scale + translationX,
14.544803214024556 * scale + translationY,
3.499999895166762 * scale + translationX,
11.99999964057176 * scale + translationY,
);
path.cubicTo(
3.501028370022418 * scale + translationX,
11.444557324783961 * scale + translationY,
3.5559727008024686 * scale + translationX,
10.890525833808475 * scale + translationY,
3.66406006625397 * scale + translationX,
10.345700187072179 * scale + translationY,
);
path.cubicTo(
3.7092116738252696 * scale + translationX,
10.114688679505866 * scale + translationY,
3.671708416934893 * scale + translationX,
9.875156315770917 * scale + translationY,
3.5581100473497984 * scale + translationX,
9.669000128670897 * scale + translationY,
);
path.cubicTo(
2.5925734653143016 * scale + translationX,
7.9148413826850765 * scale + translationY,
2.902415486427602 * scale + translationX,
5.733703706300299 * scale + translationY,
4.318271377729916 * scale + translationX,
4.3178339143425655 * scale + translationY,
);
path.cubicTo(
5.734127269032229 * scale + translationX,
2.9019641223848316 * scale + translationY,
7.9152619033455025 * scale + translationX,
2.592100687317279 * scale + translationY,
9.669430454684786 * scale + translationX,
3.5576201672896635 * scale + translationY,
);
path.cubicTo(
9.875575718603862 * scale + translationX,
3.671821657872682 * scale + translationY,
10.115440825945488 * scale + translationX,
3.709520058796185 * scale + translationY,
10.346679891956796 * scale + translationX,
3.6640599617387624 * scale + translationY,
);
path.cubicTo(
12.842319643252393 * scale + translationX,
3.166252664149834 * scale + translationY,
15.429666860402927 * scale + translationX,
3.813880045379177 * scale + translationY,
17.396511513679922 * scale + translationX,
5.4286719576835125 * scale + translationY,
);
path.cubicTo(
19.363356166956915 * scale + translationX,
7.043463869987847 * scale + translationY,
20.502362161820724 * scale + translationX,
9.455196067118964 * scale + translationY,
20.499999385976754 * scale + translationX,
11.999999640571758 * scale + translationY,
);
path.cubicTo(
20.498972063948436 * scale + translationX,
12.555443109186893 * scale + translationY,
20.444027733168387 * scale + translationX,
13.10947460016238 * scale + translationY,
20.335940367716884 * scale + translationX,
13.654300246898675 * scale + translationY,
);
path.cubicTo(
20.290791692709714 * scale + translationX,
13.88533351933361 * scale + translationY,
20.32831303645696 * scale + translationX,
14.124886060663314 * scale + translationY,
20.441940272032554 * scale + translationX,
14.331050190711453 * scale + translationY,
);
path.cubicTo(
21.20959838012846 * scale + translationX,
15.72489990736874 * scale + translationY,
21.1838005032837 * scale + translationX,
17.420590599563763 * scale + translationY,
20.374097019097793 * scale + translationX,
18.790442005435388 * scale + translationY,
);
path.cubicTo(
19.56439353491189 * scale + translationX,
20.16029341130701 * scale + translationY,
18.091262258379857 * scale + translationX,
21.000481899772318 * scale + translationY,
16.500001005324464 * scale + translationX,
21.000001279503863 * scale + translationY,
);
path.close();
canvas.drawPath(path, paint);
}