<commit_before>define(function(require){

  var fabric = require("fabric"),
      getRandomInt = fabric.util.getRandomInt;

  var RectBrushClass = fabric.util.createClass(fabric.BaseBrush, {

    width: 10,

    initialize: function(canvas){
      this.canvas = canvas;
      this.points = [];
    },

    onMouseDown: function(){
      this.points.length = 0;
      this.canvas.clearContext(this.canvas.contextTop);
    },

    onMouseMove: function(pointer){
      var point = this.addPoint(pointer),
          ctx = this.canvas.contextTop;

      ctx.fillStyle = point.fill;
      ctx.fillRect(point.x - point.width/2, point.y - point.height/2, point.width, point.height);
    },

    onMouseUp: function(){
      var originalRenderOnAddition = this.canvas.renderOnAddition;
      this.canvas.renderOnAddition = false;

      for (var i = 0, len = this.points.length; i < len; i++) {
        var point = this.points[i];
        this.canvas.add(new fabric.Rect({
          width: point.width,
          height: point.height,
          top: point.y,
          left: point.x,
          fill: point.fill
        }));
      }

      this.canvas.clearContext(this.canvas.contextTop);
      this.canvas.renderOnAddition = originalRenderOnAddition;
      this.canvas.renderAll();
    },

    addPoint: function(pointer) {
      var pointerPoint = new fabric.Point(pointer.x, pointer.y);

      var width = getRandomInt(0, this.width);

      var color = new fabric.Color(this.color)
                          .setAlpha(fabric.util.getRandomInt(0, 100) / 100)
                          .toRgba();<commit_msg>update rectbrush based on the updated fabric.CircleBrush implementation<commit_after>define(function(require){

  var fabric = require("fabric"),
      getRandomInt = fabric.util.getRandomInt;

  var RectBrushClass = fabric.util.createClass(fabric.BaseBrush, {

    width: 10,

    initialize: function(canvas){
      this.canvas = canvas;
      this.points = [];
    },

    drawRect: function( pointer ) {
      var point = this.addPoint(pointer),
          ctx = this.canvas.contextTop;

      ctx.fillStyle = point.fill;
      ctx.fillRect(point.x - point.width/2, point.y - point.height/2, point.width, point.height);
    },

    onMouseDown: function( pointer ){
      this.points.length = 0;
      this.canvas.clearContext(this.canvas.contextTop);
      this.drawRect(pointer);
    },

    onMouseMove: function( pointer ){
      this.drawRect(pointer);
    },

    onMouseUp: function(){
      var originalRenderOnAddition = this.canvas.renderOnAddition;
      this.canvas.renderOnAddition = false;

      var rects = [];

      for (var i = 0, len = this.points.length; i < len; i++) {
        var point = this.points[i];
        rects.push(new fabric.Rect({
          width: point.width,
          height: point.height,
          top: point.y,
          left: point.x,
          fill: point.fill
        }));
      }

      var group = new fabric.Group(rects);

      this.canvas.add(group);
      this.canvas.fire('path:created', { path: group });

      this.canvas.clearContext(this.canvas.contextTop);
      this.canvas.renderOnAddition = originalRenderOnAddition;
      this.canvas.renderAll();
    },

    addPoint: function(pointer) {
      var pointerPoint = new fabric.Point(pointer.x, pointer.y);

      var width = getRandomInt(0, this.width);

      var color = new fabric.Color(this.color)
                          .setAlpha(fabric.util.getRandomInt(0, 100) / 100)
                          .toRgba();
{'fraction_non_alphanumeric': 0.125886022115112, 'fraction_numerical': 0.00793875815140346, 'mean_word_length': 2.328301886792453, 'pattern_counts': {'":': 0, '<': 5, '<?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': '3615983', 'n_tokens_mistral': 1102, 'n_tokens_neox': 1031, 'n_words': 203}