<commit_before>import { removeDeadParticles } from '../utils';
import { particle } from '../particle';

const switcher = { on: false };
let frameId;

export const fireWorks = {
  tearDown() {
    switcher.on = false;
    cancelAnimationFrame(frameId);
  },
  setUp() {
    switcher.on = true;
    const canvas = document.getElementById('canvas');
    const context = canvas.getContext('2d');
    const width = canvas.width = window.innerWidth;
    const height = canvas.height = window.innerHeight;
    const particles = [];

    for (let i = 0; i < 100; i++) {
      const p = particle.create(
        width / 2,
        height / 3,
        Math.random() * 5 + 2,
        Math.random() * Math.PI * 2,
        0.1
      );
      p.radius = 50;
      particles.push(p);
    }

    function update() {
      context.clearRect(0, 0, width, height);

      for (let i = 0; i < particles.length; i++) {
        const p = particles[i];
        p.update();
        context.beginPath();
        context.arc(p.position.getX(), p.position.getY(), p.radius, 0, Math.PI * 2, false);
        context.fill();
      }

      removeDeadParticles(particles, width, height);
      context.font = '24px serif';
      context.fillText(`particles on page: ${particles.length}`, 200, 50);
      if (switcher.on && particles.length) {
        frameId = requestAnimationFrame(update);
      }
    }

    update();
  },
};<commit_msg>Better sizes on fireworks<commit_after>import { removeDeadParticles, getRandomInt } from '../utils';
import { particle } from '../particle';

const switcher = { on: false };
let frameId;

export const fireWorks = {
  tearDown() {
    switcher.on = false;
    cancelAnimationFrame(frameId);
  },
  setUp() {
    switcher.on = true;
    const canvas = document.getElementById('canvas');
    const context = canvas.getContext('2d');
    const width = canvas.width = window.innerWidth;
    const height = canvas.height = window.innerHeight;
    const particles = [];

    for (let i = 0; i < 100; i++) {
      const p = particle.create(
        width / 2,
        height / 3,
        Math.random() * 5 + 2,
        Math.random() * Math.PI * 2,
        0.1
      );
      p.radius = getRandomInt(2, 15);
      particles.push(p);
    }

    function update() {
      context.clearRect(0, 0, width, height);

      for (let i = 0; i < particles.length; i++) {
        const p = particles[i];
        p.update();
        context.beginPath();
        context.arc(p.position.getX(), p.position.getY(), p.radius, 0, Math.PI * 2, false);
        context.fill();
      }

      removeDeadParticles(particles, width, height);
      context.font = '24px serif';
      context.fillText(`particles on page: ${particles.length}`, 200, 50);
      if (switcher.on && particles.length) {
        frameId = requestAnimationFrame(update);
      }
    }

    update();
  },
};
{'fraction_non_alphanumeric': 0.1495980426424327, 'fraction_numerical': 0.018524991261796575, 'mean_word_length': 2.351288056206089, 'pattern_counts': {'":': 0, '<': 7, '<?xml version=': 0, '>': 3, 'https://': 0, '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': '4118690', 'n_tokens_mistral': 936, 'n_tokens_neox': 889, 'n_words': 221}