<commit_before>import { IParams, Particle, hexToRgb, ParticlesLibrary } from ".";
import { ImageManager } from "./ImageManager";
import { PolygonInlineArrangementType } from "./IParams";

export default class Vendors {
	params: IParams;
	library: ParticlesLibrary;
	lastDraw: number;
	private initialized: boolean = false;

	constructor(
		private imageManager: ImageManager,
		params: IParams,
		library: ParticlesLibrary
	) {
		this.params = params;
		this.library = library;
		if (typeof performance !== "undefined") {
			this.lastDraw = performance.now();
		}
		this.draw = this.draw.bind(this);
	}

	densityAutoParticles(): void {
		let { canvas, modes } = this.library;
		let { particles } = this.params;

		const density = particles.number.density;
		let densityValueArea = density.value_area;

		if (density.enable) {
			let area = (canvas.element.width * canvas.element.height) / 1000;
			if (this.library.retina) {
				area = area / canvas.pxratio;
			}
			const nb_particles = area * particles.number.value / densityValueArea;
			const missing_particles = particles.array.length - nb_particles;
			if (missing_particles < 0) {
				modes.pushParticles(Math.abs(missing_particles));
			} else {
				modes.removeParticles(missing_particles);
			}
		}
	}

	checkOverlap(p1: Particle, position?: { x: number; y: number }): void {
		let { canvas, vendors } = this.library;

		// Hot fix: maximum call stack due to not rendered canvas.
		// https://github.com/Wufe/react-particles-js/issues/49
		if (!canvas.width || !canvas.height) return;

		let { particles } = this.params;

		particles.array.forEach((particle: Particle) => {
			let p2: Particle = particle;
<commit_msg>Reverting density area calculation which could cause a breaking change<commit_after>import { IParams, Particle, hexToRgb, ParticlesLibrary } from ".";
import { ImageManager } from "./ImageManager";
import { PolygonInlineArrangementType } from "./IParams";

export default class Vendors {
	params: IParams;
	library: ParticlesLibrary;
	lastDraw: number;
	private initialized: boolean = false;

	constructor(
		private imageManager: ImageManager,
		params: IParams,
		library: ParticlesLibrary
	) {
		this.params = params;
		this.library = library;
		if (typeof performance !== "undefined") {
			this.lastDraw = performance.now();
		}
		this.draw = this.draw.bind(this);
	}

	densityAutoParticles(): void {
		let { canvas, modes } = this.library;
		let { particles } = this.params;

		const density = particles.number.density;
		let densityValueArea = density.value_area;

		if (density.enable) {
			let area = (canvas.element.width * canvas.element.height) / 1000;
			if (this.library.retina) {
				area = area / canvas.pxratio * 2;
			}
			const nb_particles = area * particles.number.value / densityValueArea;
			const missing_particles = particles.array.length - nb_particles;
			if (missing_particles < 0) {
				modes.pushParticles(Math.abs(missing_particles));
			} else {
				modes.removeParticles(missing_particles);
			}
		}
	}

	checkOverlap(p1: Particle, position?: { x: number; y: number }): void {
		let { canvas, vendors } = this.library;

		// Hot fix: maximum call stack due to not rendered canvas.
		// https://github.com/Wufe/react-particles-js/issues/49
		if (!canvas.width || !canvas.height) return;

		let { particles } = this.params;

		particles.array.forEach((particle: Particle) => {
			let p2: Particle = particle;

{'fraction_non_alphanumeric': 0.1237928007023705, 'fraction_numerical': 0.00556043312847527, 'mean_word_length': 3.8551136363636362, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 5, 'https://': 2, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '5857075', 'n_tokens_mistral': 1197, 'n_tokens_neox': 1065, 'n_words': 262}