This repository has been archived by the owner on Sep 30, 2021. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 21
/
main.dart
138 lines (124 loc) 路 4.95 KB
/
main.dart
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
import 'package:flutter/material.dart';
void main() {
runApp(
MaterialApp(
home: MyWidget(),
),
);
}
class MyWidget extends StatelessWidget {
@override
Widget build(BuildContext context) {
return Scaffold(
body: CustomPaint(
painter:DashBird(),
child: Container(),
),
);
}
}
class DashBird extends CustomPainter{
@override
void paint(Canvas canvas,Size size){
final width=size.width;
final height=size.height;
Paint paint=Paint();
Path bigOval=Path();
paint.color=Color.fromRGBO(89, 170, 255,1);
bigOval.addOval(Rect.fromPoints(Offset(width*0.05,height*0.15),Offset(width*0.95,height*0.95)));
canvas.drawPath(bigOval,paint);
//white curve
Path whiteCurve=Path();
whiteCurve.moveTo(width*0.18,height*0.68);
whiteCurve.quadraticBezierTo(width*0.2,height*0.94,width*0.5,height*0.94);
whiteCurve.moveTo(width*0.5,height*0.94);
whiteCurve.quadraticBezierTo(width*0.8,height*0.94,width*0.82,height*0.68);
whiteCurve.lineTo(width*0.18,height*0.68);
whiteCurve.close();
paint.color=Color.fromRGBO(242, 242, 242,1);
canvas.drawPath(whiteCurve,paint);
//blue curve just above white curve
Path smallBlueCurve=Path();
smallBlueCurve.moveTo(width*0.18,height*0.6799);
smallBlueCurve.quadraticBezierTo(width*0.5,height*0.8,width*0.82,height*0.6799);
paint.color=Color.fromRGBO(89, 170, 255,1);
canvas.drawPath(smallBlueCurve,paint);
//big blue circles for eyes
paint.color=Color.fromRGBO(61, 145, 255,1);
canvas.drawCircle(Offset(width*0.37,height*0.5),width*0.2,paint);
canvas.drawCircle(Offset(width*0.63,height*0.5),width*0.2,paint);
//black circles
paint.color=Color.fromRGBO(0,0,0,1);
canvas.drawCircle(Offset(width*0.35,height*0.47),width*0.07,paint);
canvas.drawCircle(Offset(width*0.65,height*0.47),width*0.07,paint);
//eye border
Paint paintBorder=Paint()..color=Color.fromRGBO(32, 170, 140,1)
..style=PaintingStyle.stroke
..strokeWidth=6.0;
canvas.drawCircle(Offset(width*0.35,height*0.47),width*0.07,paintBorder);
canvas.drawCircle(Offset(width*0.65,height*0.47),width*0.07,paintBorder);
//big white circles
paint.color=Colors.white;
canvas.drawCircle(Offset(width*0.35,height*0.47),width*0.02,paint);
canvas.drawCircle(Offset(width*0.65,height*0.47),width*0.02,paint);
//tiny white circle
canvas.drawCircle(Offset(width*0.40,height*0.47),width*0.005,paint);
canvas.drawCircle(Offset(width*0.69,height*0.45),width*0.005,paint);
//legs
Path oval=Path();
paint.color=Color.fromRGBO(139, 94, 60,1);
//left side legs
oval.addOval(Rect.fromPoints(Offset(width*0.28,height*0.885),Offset(width*0.32,height*0.98)));
canvas.drawPath(oval,paint);
oval.addOval(Rect.fromPoints(Offset(width*0.31,height*0.885),Offset(width*0.35,height*0.98)));
canvas.drawPath(oval,paint);
oval.addOval(Rect.fromPoints(Offset(width*0.34,height*0.885),Offset(width*0.38,height*0.98)));
canvas.drawPath(oval,paint);
//right side legs
oval.addOval(Rect.fromPoints(Offset(width*0.64,height*0.885),Offset(width*0.6,height*0.98)));
canvas.drawPath(oval,paint);
oval.addOval(Rect.fromPoints(Offset(width*0.67,height*0.885),Offset(width*0.63,height*0.98)));
canvas.drawPath(oval,paint);
oval.addOval(Rect.fromPoints(Offset(width*0.7,height*0.885),Offset(width*0.66,height*0.98)));
canvas.drawPath(oval,paint);
//head fur
Path head=Path();
paint.color=Color.fromRGBO(89, 170, 255,1);
head.addOval(Rect.fromPoints(Offset(width*0.435,height*0.085),Offset(width*0.475,height*0.175)));
canvas.drawPath(head,paint);
head.addOval(Rect.fromPoints(Offset(width*0.465,height*0.085),Offset(width*0.505,height*0.175)));
canvas.drawPath(head,paint);
head.addOval(Rect.fromPoints(Offset(width*0.495,height*0.085),Offset(width*0.535,height*0.175)));
canvas.drawPath(head,paint);
//nose
Path nose=Path();
nose.moveTo(width*0.465,height*0.5);
nose.quadraticBezierTo(width*0.5,height*0.45,width*0.54,height*0.5);
nose.lineTo(width*0.5,height*0.65);
nose.close();
paint.color=Color.fromRGBO(139, 94, 60,1);
canvas.drawPath(nose,paint);
//wings
//left wing
Path wing1=Path();
paint.color=Color.fromRGBO(61, 145, 255,1);
wing1.addOval(Rect.fromPoints(Offset(width*0.035,height*0.45),Offset(width*0.165,height*0.78)));
canvas.translate(width*0.1,height*0.6);
canvas.rotate(-38);
canvas.translate(-width*0.1,-height*0.6);
canvas.drawPath(wing1,paint);
//right wing
Path wing2=Path();
paint.color=Color.fromRGBO(61, 145, 255,1);
wing2.addOval(Rect.fromPoints(Offset(width*0.805,height*0.53),Offset(width*0.935,height*0.87)));
canvas.translate(width*0.6,height*0.75);
canvas.rotate(32);
canvas.translate(-width*0.6,-height*0.75);
canvas.drawPath(wing2,paint);
}
@override
bool shouldRepaint(old)
{
return old!=this;
}
}