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
|
function coss(height, width, theta) {
let amplitude = height/2;
let period = width;
let dx = Math.PI/width;
let yVal = [];
let x = theta;
for(let i=0;i<width;i++){
yVal.push((Math.cos(x)*amplitude)+(height/2));
x += dx;
}
return yVal;
}
function lamby(height, width, thick) {
let out = "";
let yvals = coss(height, width, Math.PI);
let halfWidth = width/2;
for(let y=0;y<height;y++){
for(let x=0;x<width;x++){
let posy = yvals[x];
let negy = height-posy;
if (Math.abs(posy-y) < thick) {
out += "<span style=\"color: hsl("+ (Math.abs(posy-y)/thick*260) +",100%, 50%)\">λ</span>";
} else if ((x < halfWidth) && (Math.abs(negy-y) < thick)) {
out += "<span style=\"color: hsl("+ (Math.abs(negy-y)/thick*260) +",100%, 50%)\">λ</span>";
} else {
out += " ";
}
}
out += "\n";
}
return out;
}
function putlam(el, height, width, min, max, period) {
let amp = max-min;
const f = function() {
let percent = (Math.sin(((new Date).getTime()/period)) + 1) / 2;
let thick = (amp * percent) + min;
el.innerHTML = lamby(height, width, thick);
};
window.setInterval(f, 100);
}
let lamEl = document.querySelector('.lambda');
putlam(lamEl, 45, 45, 0.3, 4.5, 450);
`
00
0
0
0 0
0 0
0 00
0
0
0 0
_
\
\
/\
/ \
/ \
/ \_
`;
|