-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmath testing.html
More file actions
90 lines (90 loc) · 1.42 KB
/
Copy pathmath testing.html
File metadata and controls
90 lines (90 loc) · 1.42 KB
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
<!DOCTYPE html>
<html>
<head>
<title></title>
<meta name="viewport"content="width=device-width,initial-scale=1">
<style>
</style>
</head>
<body>
<sub id=fps>fps</sub>
<div id=disp></div>
<script>
(function(){
let elapsed=Date.now(),
frame=0;
const update=()=>{
let r=4;
if(Date.now()-elapsed<=1e3/r){
frame+=r
}else{
fps.textContent=frame+" fps";
elapsed=Date.now()
frame=0
}
requestAnimationFrame(update)
}
requestAnimationFrame(update)
})();
const rate=5e4;
function display(a){
switch(typeof a){
case"object":
a=JSON.stringify(a);
break;
case"function":
let r=a();
a=typeof r=="object"?JSON.stringify(r):r;
}
disp.innerText=a;
}
const harmonic=(()=>{
let r=1,
d=2;
setInterval(()=>{
for(let i=0;i<rate;i++){
r+=1/d++;
}
})
return()=>{return{r:r,d:d}};
})();
const piOverFour=(()=>{
let r=0,
d=0;
setInterval(()=>{
for(let i=0;i<rate;i++){
r+=((-1)**(++d+1))/(2*d-1)
}
})
return()=>r*4;
})();
const odseries=(()=>{
let r=4,
d=1,
s=-1;
setInterval(()=>{
for(let i=0;i<rate;i++){
d+=2
r+=(4/d)*s;
s*=-1;
}
})
return()=>r;
})();
const piOverTwo=(()=>{
let r=1,
d=2;
setInterval(()=>{
for(let i=0;i<rate;i++){
r*=(d*d)/((d-1)*(d+1))
d+=2;
}
})
return()=>r*2;
})();
setInterval(()=>{
display(piOverFour);
},1e3/30);
</script>
</body>
</html>