From 5a9a800ef94472fd3a05d01b11e2f0278737d661 Mon Sep 17 00:00:00 2001 From: Sam <34695753+SamEyeBam@users.noreply.github.com> Date: Sat, 12 Apr 2025 01:04:08 +1200 Subject: [PATCH] fade disable --- docs/js/helper.js | 3 ++- docs/js/objects.js | 23 +++++++++++++++-------- 2 files changed, 17 insertions(+), 9 deletions(-) diff --git a/docs/js/helper.js b/docs/js/helper.js index f3460e9..6ddcfb1 100644 --- a/docs/js/helper.js +++ b/docs/js/helper.js @@ -108,8 +108,9 @@ async function fetchConfig(className) { { type: "range", min: 1, max: 200, defaultValue: 100, property: "speedVert" }, { type: "range", min: 1, max: 200, defaultValue: 100, property: "speedHorr" }, { type: "range", min: 10, max: 2000, defaultValue: 800, property: "boxSize" }, - { type: "range", min: 1, max: 200, defaultValue: 20, property: "trailLength" }, + { type: "range", min: 1, max: 60, defaultValue: 20, property: "trailLength" }, { type: "range", min: 1, max: 500, defaultValue: 5, property: "lineWidth" }, + { type: "checkbox", defaultValue: false, property: "fade" }, { type: "color", defaultValue: "#43dbad", property: "colourFree" }, { type: "color", defaultValue: "#f05c79", property: "colourContained" }, { type: "header", text: "--CollisionBox---" }, diff --git a/docs/js/objects.js b/docs/js/objects.js index 3241347..ecfc804 100644 --- a/docs/js/objects.js +++ b/docs/js/objects.js @@ -677,7 +677,7 @@ class NewWave extends BaseShape { } class RaysInShape extends BaseShape { - constructor(rays, speed, doesWave,speedVertRate, speedHorrRate,speedVert, speedHorr, boxSize, trailLength = 50, lineWidth, colourFree, colourContained, boxVisible,) { + constructor(rays, speed, doesWave, speedVertRate, speedHorrRate, speedVert, speedHorr, boxSize, trailLength = 50, lineWidth, fade, colourFree, colourContained, boxVisible,) { super(); this.rays = rays; this.speed = speed; @@ -694,6 +694,7 @@ class RaysInShape extends BaseShape { this.colourContained = colourContained; this.speedHorrRate = speedHorrRate; this.speedVertRate = speedVertRate; + this.fade = fade; } initialise(config) { //is overide @@ -813,7 +814,11 @@ class RaysInShape extends BaseShape { const curr = ray.positions[j]; // Fade alpha (newer = brighter) - const alpha = (j / ray.positions.length) * 0.8 + 0.2; + let alpha = 1; + if (this.fade) { + alpha = (j / ray.positions.length) * 0.8 + 0.2; + + } ctx.beginPath(); ctx.moveTo(prev.x, prev.y); @@ -831,10 +836,10 @@ class RaysInShape extends BaseShape { deltaTime *= this.speedMultiplier / 100; if (this.doesWave) { - const vertRate = this.speedVertRate /100; - const horrRate = this.speedHorrRate /100; - this.speedVert = Math.sin(elapsed / 10 * vertRate) * 100 + 100; - this.speedHorr = Math.sin(elapsed / 10 * horrRate) * 100 + 100; + const vertRate = this.speedVertRate / 100; + const horrRate = this.speedHorrRate / 100; + this.speedVert = Math.sin(elapsed / 10 * vertRate) * 90 + 100; + this.speedHorr = Math.sin(elapsed / 10 * horrRate) * 90 + 100; updateControlInput(this.speedVert, "speedVert"); updateControlInput(this.speedHorr, "speedHorr"); console.log(this.controls) @@ -974,8 +979,10 @@ class RaysInShape extends BaseShape { const curr = ray.positions[i]; // Fade color based on position in trail (newer = brighter) - const alpha = (i / ray.positions.length) * 0.8 + 0.2; - + let alpha = 1; + if (this.fade) { + alpha = (i / ray.positions.length) * 0.8 + 0.2; + } ctx.beginPath(); ctx.moveTo(prev.x, prev.y); ctx.lineTo(curr.x, curr.y);