<commit_before>var Potion = require('potion');

var app = Potion.init(document.querySelector('.game'), {
  configure: function() {
    app.setSize(document.body.clientWidth, document.body.clientHeight);
    app.config.allowHiDPI = true;
  },

  init: function() {
    this.particles = [];

    window.addEventListener('resize', function() {
      this.setSize(document.body.clientWidth, document.body.clientHeight);
    }.bind(this));
  },

  mousemove: function(value) {
    this.particles.push(new Particle(value.x, value.y, app.input.mouse.dx * 20, app.input.mouse.dy * 20));
  },

  update: function(time) {
    for (var i=0, len=this.particles.length; i<len; i++) {
      var particle = this.particles[i];
      if (particle) { particle.update(time); }
    }
  },

  render: function() {
    for (var i=0, len=this.particles.length; i<len; i++) {
      var particle = this.particles[i];
      if (particle) { particle.render(); }
    }
  }
});

var Particle = function(x, y, dx, dy) {
  this.x = x;
  this.y = y;
  this.r = Math.random() * 20 + 5;
  this.dx = dx;
  this.dy = dy;

  var colors = ['#04819e', '#38b2ce', '#60b9ce', '#015367', '#ff9900'];
  this.color = colors[Math.floor(colors.length * Math.random())];
};

Particle.prototype.update = function(time) {
  this.dx = this.dx + (0 - this.dx) * time;
  this.dy = this.dy + (0 - this.dy) * time;

  this.r = this.r + (0 - this.r) * time;

  if (this.r <= 0.5) {
    app.main.particles.splice(app.main.particles.indexOf(this), 1);
  }

  this.x += this.dx * time;
  this.y += this.dy * time;
};

Particle.prototype.render = function() {
  app.video.ctx.beginPath();
  app.video.ctx.arc(this.x, this.y, this.r, 0, Math.PI*2, false);
  app.video.ctx.strokeStyle = this.color;
  app.video.ctx.stroke();
  app.video.ctx.closePath();
};
<commit_msg>fix error in particle demo<commit_after>var Potion = require('potion');

var app = Potion.init(document.querySelector('.game'), {
  configure: function() {
    app.setSize(document.body.clientWidth, document.body.clientHeight);
    app.config.allowHiDPI = true;
  },

  init: function() {
    this.particles = [];

    window.addEventListener('resize', function() {
      app.setSize(document.body.clientWidth, document.body.clientHeight);
    });
  },

  mousemove: function(value) {
    this.particles.push(new Particle(value.x, value.y, app.input.mouse.dx * 20, app.input.mouse.dy * 20));
  },

  update: function(time) {
    for (var i=0, len=this.particles.length; i<len; i++) {
      var particle = this.particles[i];
      if (particle) { particle.update(time); }
    }
  },

  render: function() {
    for (var i=0, len=this.particles.length; i<len; i++) {
      var particle = this.particles[i];
      if (particle) { particle.render(); }
    }
  }
});

var Particle = function(x, y, dx, dy) {
  this.x = x;
  this.y = y;
  this.r = Math.random() * 20 + 5;
  this.dx = dx;
  this.dy = dy;

  var colors = ['#04819e', '#38b2ce', '#60b9ce', '#015367', '#ff9900'];
  this.color = colors[Math.floor(colors.length * Math.random())];
};

Particle.prototype.update = function(time) {
  this.dx = this.dx + (0 - this.dx) * time;
  this.dy = this.dy + (0 - this.dy) * time;

  this.r = this.r + (0 - this.r) * time;

  if (this.r <= 0.5) {
    app.main.particles.splice(app.main.particles.indexOf(this), 1);
  }

  this.x += this.dx * time;
  this.y += this.dy * time;
};

Particle.prototype.render = function() {
  app.video.ctx.beginPath();
  app.video.ctx.arc(this.x, this.y, this.r, 0, Math.PI*2, false);
  app.video.ctx.strokeStyle = this.color;
  app.video.ctx.stroke();
  app.video.ctx.closePath();
};

{'fraction_non_alphanumeric': 0.19270113353607962, 'fraction_numerical': 0.021011888305225324, 'mean_word_length': 3.1490825688073394, 'pattern_counts': {'":': 0, '<': 9, '<?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': '4601143', 'n_tokens_mistral': 1412, 'n_tokens_neox': 1348, 'n_words': 255}