Fix sine and sun pos offset

pull/3039/head
g-rden 2023-10-08 10:53:27 +00:00 committed by GitHub
parent a9cfd89466
commit 27ed85d677
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 5 additions and 5 deletions

View File

@ -182,11 +182,10 @@ function drawSinuses () {
g.setColor(1, 1, 1); g.setColor(1, 1, 1);
let y = ypos(x); let y = ypos(x);
// until drawn line touches right side of the screen while (x < w) {
while ((x - sinStep / 2) < w) {
y2 = ypos(x + sinStep); y2 = ypos(x + sinStep);
// both x are offset by -sinStep/2 // both x are offset by -sinStep/2
g.drawLine(x - sinStep / 2, y, x + sinStep / 2, y2); g.drawLine(x, y, x + sinStep, y2);
y = y2; y = y2;
x += sinStep; // no need to draw all steps x += sinStep; // no need to draw all steps
} }
@ -224,7 +223,7 @@ function drawGlow () {
pos = xfromTime(now.getHours() + now.getMinutes() / 60); pos = xfromTime(now.getHours() + now.getMinutes() / 60);
} }
const x = pos; const x = pos;
const y = ypos(x + sinStep / 2); const y = ypos(x);
g.setColor(0.2, 0.2, 0); g.setColor(0.2, 0.2, 0);
// wide glow // wide glow
@ -256,7 +255,8 @@ function drawBall () {
pos = xfromTime(now.getHours() + now.getMinutes() / 60); pos = xfromTime(now.getHours() + now.getMinutes() / 60);
} }
const x = pos; const x = pos;
const y = ypos(x + sinStep / 2); const y = ypos(x);
// glow // glow
if (x > sunRiseX && x < sunSetX) { if (x > sunRiseX && x < sunSetX) {
g.setColor(1, 1, 1); g.setColor(1, 1, 1);