<commit_before>
;(function(window) {
  function Painter(el) {
    if (!(this instanceof Painter)) return new Painter(el);
    if (!el) throw new Error('A HTML Canvas element is required to operate on');
    this.el = el;
    this.ctx = el.getContext('2d');
    this.inProgress = false;
    this.eventManager = EventManager(this.el, this);
    this.attachEvents();
  }

  Painter.prototype.attachEvents = function() {
    this.eventManager.bind('mousedown', this.start);
    this.eventManager.bind('mousemove', this.paint);
    this.eventManager.bind('mouseup', this.stop);
    return this;
  };

  Painter.prototype.start = function(e) {
    this.inProgress = true;
    this.ctx.beginPath();
    this.ctx.moveTo(e.x, e.y);
    return this;
  };

  Painter.prototype.paint = function(e) {
    if (this.inProgress) {
      this.ctx.lineTo(e.x, e.y);
      this.ctx.stroke();
    }

    return this;
  };

  Painter.prototype.stop = function() {
    this.ctx.closePath();
    this.inProgress = false;
    return this;
  };

  Painter.prototype.save = function() {
    this.ctx.save();
    return this;
  };

  Painter.prototype.restore = function() {
    this.ctx.restore();
    return this;
  };

  window.Painter = Painter;
})(window);<commit_msg>add finish method for the painter<commit_after>
;(function(window) {
  function Painter(el) {
    if (!(this instanceof Painter)) return new Painter(el);
    if (!el) throw new Error('A HTML Canvas element is required to operate on');
    this.el = el;
    this.ctx = el.getContext('2d');
    this.inProgress = false;
    this.eventManager = EventManager(this.el, this);
    this.attachEvents();
  }

  Painter.prototype.attachEvents = function() {
    this.eventManager.bind('mousedown', this.start);
    this.eventManager.bind('mousemove', this.paint);
    this.eventManager.bind('mouseup', this.stop);
    return this;
  };

  Painter.prototype.start = function(e) {
    this.inProgress = true;
    this.ctx.beginPath();
    this.ctx.moveTo(e.x, e.y);
    return this;
  };

  Painter.prototype.paint = function(e) {
    if (this.inProgress) {
      this.ctx.lineTo(e.x, e.y);
      this.ctx.stroke();
    }

    return this;
  };

  Painter.prototype.stop = function() {
    this.ctx.closePath();
    this.inProgress = false;
    return this;
  };

  Painter.prototype.save = function() {
    this.ctx.save();
    return this;
  };

  Painter.prototype.restore = function() {
    this.ctx.restore();
    return this;
  };

  // TODO make this work
  Painter.prototype.finish = function() {
    this.eventManager.unbind('mousedown', this.start);
    this.eventManager.unbind('mousemove', this.paint);
    this.eventManager.unbind('mouseup', this.stop);
    return this;
  };

  window.Painter = Painter;
})(window);
{'fraction_non_alphanumeric': 0.15412445730824892, 'fraction_numerical': 0.000723589001447178, 'mean_word_length': 3.0542521994134897, 'pattern_counts': {'":': 0, '<': 3, '<?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': '3452859', 'n_tokens_mistral': 940, 'n_tokens_neox': 917, 'n_words': 182}