Skip to content

Commit 319f31f

Browse files
committed
refac: Remove value interpolation
1 parent 4ec2849 commit 319f31f

3 files changed

Lines changed: 6 additions & 25 deletions

File tree

src/components/neonRails.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import { customElement, property } from "lit/decorators.js";
22
import Particle from "../Particle";
3-
import { getRandomFloat, interpolateLinear } from "../utils/number";
3+
import { getRandomFloat } from "../utils/number";
44
import { randomColor } from "../utils/color";
55
import { BeautifulBackground } from "../BeautifulBackground";
66
import { stringToArrayConverter } from "../utils/lit";
@@ -101,8 +101,8 @@ export class BbNeonRails extends BeautifulBackground {
101101
protected createParticle(): Particle {
102102
const size = getRandomFloat(this.particleSizeMin, this.particleSizeMax);
103103
const speed = getRandomFloat(
104-
interpolateLinear(this.particleSpeedMin, -10, 10, -10, 10),
105-
interpolateLinear(this.particleSpeedMax, -10, 10, -10, 10),
104+
this.particleSpeedMin,
105+
this.particleSpeedMax,
106106
);
107107

108108
const lifespan = getRandomFloat(

src/components/startTrail.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import { customElement, property } from "lit/decorators.js";
22
import Particle from "../Particle";
3-
import { getRandomFloat, interpolateLinear } from "../utils/number";
3+
import { getRandomFloat } from "../utils/number";
44
import { randomColor } from "../utils/color";
55
import { BeautifulBackground } from "../BeautifulBackground";
66
import { stringToArrayConverter } from "../utils/lit";
@@ -109,8 +109,8 @@ export class BbStarTrail extends BeautifulBackground {
109109
protected createParticle(): Particle {
110110
const size = getRandomFloat(this.particleSizeMin, this.particleSizeMax);
111111
const speed = getRandomFloat(
112-
interpolateLinear(this.particleSpeedMin, -10, 10, -1, 1),
113-
interpolateLinear(this.particleSpeedMax, -10, 10, -1, 1),
112+
this.particleSpeedMin,
113+
this.particleSpeedMax,
114114
);
115115

116116
const lifespan = getRandomFloat(

src/utils/number.ts

Lines changed: 0 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -8,22 +8,3 @@ export function getRandomInt(min: number, max: number): number {
88

99
return Math.floor(Math.random() * (max - min + 1) + min);
1010
}
11-
12-
export function interpolateLinear(
13-
value: number,
14-
domainStart: number,
15-
domainEnd: number,
16-
rangeStart: number,
17-
rangeEnd: number
18-
): number {
19-
// Ensure the value is within the domain
20-
if (value < domainStart) value = domainStart;
21-
if (value > domainEnd) value = domainEnd;
22-
23-
// Normalize the value within the domain
24-
const normalized = (value - domainStart) / (domainEnd - domainStart);
25-
26-
// Scale the normalized value to the range and return it
27-
// The output is always between rangeStart and rangeEnd,
28-
return normalized * (rangeEnd - rangeStart) + rangeStart;
29-
}

0 commit comments

Comments
 (0)