Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
const getCircles = (
circleCount: number,
canvas: HTMLCanvasElement | any,
context: CanvasRenderingContext2D | any,
): Circle[] => {
const localCircles: any[] = [];
for (let i = 0; i < circleCount; i++) {
localCircles.push(
new Circle(
context,
getIntInRange(50, 350),
getFloatInRange(0.1, 1),
getFloatInRange(2, 10),
getIntInRange(0, canvas.width),
getIntInRange(0, canvas.height),
),
);
}
return localCircles;
};
const getCircles = (
circleCount: number,
canvas: HTMLCanvasElement | any,
context: CanvasRenderingContext2D | any,
): Circle[] => {
const localCircles: any[] = [];
for (let i = 0; i < circleCount; i++) {
localCircles.push(
new Circle(
context,
getIntInRange(50, 350),
getFloatInRange(0.1, 1),
getFloatInRange(2, 10),
getIntInRange(0, canvas.width),
getIntInRange(0, canvas.height),
),
);
}
return localCircles;
};
this.xPos + Math.cos(this.counter / 100) * this.radius,
this.yPos + Math.sin(this.counter / 100) * this.radius,
this.width,
0,
Math.PI * 2,
false,
);
this.context.closePath();
this.context.fillStyle = 'rgba(244, 59, 108,' + this.opacity + ')';
this.context.fill();
if (this.opacity <= 0) {
this.counter = 0;
this.opacity = getFloatInRange(0.05, 0.9);
this.width = getIntInRange(2, 10);
this.speed = getFloatInRange(0.1, 1);
}
}
}
import { getFloatInRange, getIntInRange } from '@vuesion/utils/dist/randomGenerator';
class Circle {
private opacity: number = getFloatInRange(0.05, 0.9);
private counter: number = 0;
private direction: number = 0;
constructor(
private context: CanvasRenderingContext2D | any,
private radius: number,
private speed: number,
private width: number,
private xPos: number,
private yPos: number,
) {
this.direction = getIntInRange(0, 1) === 1 ? -1 : 1;
}
public update(): void {
this.counter += this.direction * this.speed;
this.width,
0,
Math.PI * 2,
false,
);
this.context.closePath();
this.context.fillStyle = 'rgba(244, 59, 108,' + this.opacity + ')';
this.context.fill();
if (this.opacity <= 0) {
this.counter = 0;
this.opacity = getFloatInRange(0.05, 0.9);
this.width = getIntInRange(2, 10);
this.speed = getFloatInRange(0.1, 1);
}
}
}