From 5a546819540d1a1a9ca9ddc0ba239e13370ddc84 Mon Sep 17 00:00:00 2001 From: g-rden <94605617+g-rden@users.noreply.github.com> Date: Sat, 7 Oct 2023 22:30:37 +0000 Subject: [PATCH] sine line fix & simplification Corrected first sine line section. Removed radius offset from sine line x values. & Simplified --- apps/sunrise/app.js | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) diff --git a/apps/sunrise/app.js b/apps/sunrise/app.js index e1f4c76b5..13f77fe00 100644 --- a/apps/sunrise/app.js +++ b/apps/sunrise/app.js @@ -183,7 +183,7 @@ function drawSinuses () { g.setColor(1, 1, 1); let y = ypos(x); while (x < w) { - y2 = ypos(x); + y2 = ypos(x + sinStep); g.drawLine(x, y, x + sinStep, y2); y = y2; x += sinStep; // no need to draw all steps @@ -225,7 +225,7 @@ function drawGlow () { } const rh = r / 2; const x = pos; - const y = ypos(x - r); + const y = ypos(x); const r2 = 0; if (x > sunRiseX && x < sunSetX) { g.setColor(0.2, 0.2, 0); @@ -246,8 +246,7 @@ function seaLevel (hour) { } function ypos (x) { - const pc = (x * 100 / w); - return oy + (32 * Math.sin(1.7 + (pc / 16))); + return oy + (32 * Math.sin(1.7 + (x * 100 / (16 * w)))); } function xfromTime (t) { @@ -260,7 +259,7 @@ function drawBall () { if (frames < 1 && realTime) { x = xfromTime(now.getHours()); } - const y = ypos(x - r); + const y = ypos(x); // glow if (x < sunRiseX || x > sunSetX) {