-
Notifications
You must be signed in to change notification settings - Fork 0
/
index1.html
54 lines (53 loc) · 1.28 KB
/
index1.html
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
<!DOCTYPE html>
<html lang="">
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>p5.js example</title>
<script src="p5/addons/p5.dom.min.js"></script>
<script src="p5/addons/p5.sound.min.js"></script>
<script src="p5/p5.js"></script>
</head>
<body>
<script>
// 函数setup() : 准备阶段
function setup() {
// 创建画布,宽度640像素,高度480像素
// 画布的坐标系统为,左上角坐标为(0,0),
// x方向水平向右,y方向垂直向下,单位像素
createCanvas(640,480);
}
// 函数draw():作画阶段
function draw() {
fill(255);// 填充白色
// 1 画脸
strokeWeight(2);
ellipse(320,240,200,200);// 圆圈
// 2 左眼
fill(0);
ellipse(280,220,50,50);// 另一个圆圈
// 3 右眼
ellipse(360,220,50,50);
// 4 嘴巴
//ellipse(320,300,80,40);
fill(255);// 填充黑色
// 5 左眼珠
ellipse(280,220,10,20);
// 6 右眼珠
ellipse(360,220,10,20);
fill(0);
ellipse(280,220,8,8);
ellipse(360,220,8,8);
//鼻子
ellipse(320,250,10,10);
line(320,250,320,280);
noFill();
arc(320,280,30,15,TWO_PI, PI);
//耳朵
fill(0);
ellipse(240,140,60,60);
ellipse(400,140,60,60);
}
</script>
</body>
</html>