-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathjava.js
98 lines (82 loc) · 1.99 KB
/
java.js
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
let canvas = document.querySelector("canvas");
console.log(canvas);
canvas.width = window.innerWidth;
canvas.height = window.innerHeight;
let c = canvas.getContext("2d");
// c.fillRect(100, 100, 100, 100);
//TRianlge co ordinates//
c.beginPath();
c.arc(100, 100, 4, 0, 2 * Math.PI);
c.stroke();
c.fillStyle = "red";
c.fill();
c.beginPath();
c.arc(600, 100, 4, 0, 4 * Math.PI);
c.stroke();
c.fillStyle = "red";
c.fill();
c.beginPath();
c.arc(100, 500, 4, 0, 2 * Math.PI);
c.stroke();
c.fillStyle = "red";
c.fill();
// let x = Math.floor(Math.random() * 500 + 100);
// let y = Math.floor(Math.random() * 400 + 100);
// c.beginPath();
// c.arc(x, y, 4, 0, 2 * Math.PI);
// c.stroke();
// c.fillStyle = "black";
// c.fill();
// c.beginPath();
// c.arc(300 + 20i,200+30i, 4, 0, 2 * Math.PI);
// c.stroke();
// c.fillStyle = "black";
// c.fill();
c.beginPath();
c.moveTo(100, 100);
c.lineTo(100, 500);
c.strokeStyle = "red";
c.stroke();
c.lineTo(600, 100);
c.lineTo(100, 100);
c.strokeStyle = "rgba(45,67,89,0.8)";
c.stroke();
let x = Math.floor(Math.random() * 500 + 100);
let y = Math.floor(Math.random() * 400 + 100);
c.beginPath();
c.arc(x, y, 0.05, 0, 2 * Math.PI);
c.stroke();
c.fillStyle = "green";
c.fill();
const vertex = function () {
let rand = Math.floor(Math.random() * 3 + 1);
return rand;
};
for (let i = 1; i <= 50000; i++) {
let rand = vertex();
if (rand == 1) {
x = (x + 100) / 2;
y = (y + 100) / 2;
c.beginPath();
c.arc(x, y, 0.05, 0, 2 * Math.PI);
c.stroke();
c.fillStyle = "pink";
c.fill();
} else if (rand == 2) {
x = (x + 600) / 2;
y = (y + 100) / 2;
c.beginPath();
c.arc(x, y, 0.05, 0, 2 * Math.PI);
c.stroke();
c.fillStyle = "yellow";
c.fill();
} else {
x = (x + 100) / 2;
y = (y + 500) / 2;
c.beginPath();
c.arc(x, y, 0.05, 0, 2 * Math.PI);
c.stroke();
c.fillStyle = "white";
c.fill();
}
}