fade disable

This commit is contained in:
Sam
2025-04-12 01:04:08 +12:00
parent fc6e2026b7
commit 5a9a800ef9
2 changed files with 17 additions and 9 deletions

View File

@@ -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: "speedVert" },
{ type: "range", min: 1, max: 200, defaultValue: 100, property: "speedHorr" }, { type: "range", min: 1, max: 200, defaultValue: 100, property: "speedHorr" },
{ type: "range", min: 10, max: 2000, defaultValue: 800, property: "boxSize" }, { 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: "range", min: 1, max: 500, defaultValue: 5, property: "lineWidth" },
{ type: "checkbox", defaultValue: false, property: "fade" },
{ type: "color", defaultValue: "#43dbad", property: "colourFree" }, { type: "color", defaultValue: "#43dbad", property: "colourFree" },
{ type: "color", defaultValue: "#f05c79", property: "colourContained" }, { type: "color", defaultValue: "#f05c79", property: "colourContained" },
{ type: "header", text: "--CollisionBox---" }, { type: "header", text: "--CollisionBox---" },

View File

@@ -677,7 +677,7 @@ class NewWave extends BaseShape {
} }
class RaysInShape 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(); super();
this.rays = rays; this.rays = rays;
this.speed = speed; this.speed = speed;
@@ -694,6 +694,7 @@ class RaysInShape extends BaseShape {
this.colourContained = colourContained; this.colourContained = colourContained;
this.speedHorrRate = speedHorrRate; this.speedHorrRate = speedHorrRate;
this.speedVertRate = speedVertRate; this.speedVertRate = speedVertRate;
this.fade = fade;
} }
initialise(config) { //is overide initialise(config) { //is overide
@@ -813,7 +814,11 @@ class RaysInShape extends BaseShape {
const curr = ray.positions[j]; const curr = ray.positions[j];
// Fade alpha (newer = brighter) // 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.beginPath();
ctx.moveTo(prev.x, prev.y); ctx.moveTo(prev.x, prev.y);
@@ -833,8 +838,8 @@ class RaysInShape extends BaseShape {
if (this.doesWave) { if (this.doesWave) {
const vertRate = this.speedVertRate / 100; const vertRate = this.speedVertRate / 100;
const horrRate = this.speedHorrRate / 100; const horrRate = this.speedHorrRate / 100;
this.speedVert = Math.sin(elapsed / 10 * vertRate) * 100 + 100; this.speedVert = Math.sin(elapsed / 10 * vertRate) * 90 + 100;
this.speedHorr = Math.sin(elapsed / 10 * horrRate) * 100 + 100; this.speedHorr = Math.sin(elapsed / 10 * horrRate) * 90 + 100;
updateControlInput(this.speedVert, "speedVert"); updateControlInput(this.speedVert, "speedVert");
updateControlInput(this.speedHorr, "speedHorr"); updateControlInput(this.speedHorr, "speedHorr");
console.log(this.controls) console.log(this.controls)
@@ -974,8 +979,10 @@ class RaysInShape extends BaseShape {
const curr = ray.positions[i]; const curr = ray.positions[i];
// Fade color based on position in trail (newer = brighter) // 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.beginPath();
ctx.moveTo(prev.x, prev.y); ctx.moveTo(prev.x, prev.y);
ctx.lineTo(curr.x, curr.y); ctx.lineTo(curr.x, curr.y);