<commit_before>define([
  "paper",
  "underscore",
  "config/Defaults",
  "tools/BaseCreateTool",
  "objects/Geometry"
], function(paper, _, Defaults, BaseCreateTool, Geometry) {
  
  var StarTool = _.extend({}, BaseCreateTool, {
    _currentPath: null,
    
    _params: {
      numPoints: 5,
      inRadius: null,
      outRadius: null
    },

    _startPoint: null,

    onMouseDown: function(event) {
      if (this._params.inRadius) {
        this._outerMouseDown(event);
      } else {
        this._innerMouseDown(event);
      }
    },

    _innerMouseDown: function(event) {
      console.log("Starting star creation...");
      this._startPoint = event.point;
      this._currentPath = new Geometry.Path.Circle(event.point, 1);
      this._currentPath.style = Defaults.tentativeStyle;
    },

    _outerMouseDown: function(event) {
      this._currentPath.remove();
      this._currentPath = new Geometry.Path.Star(
        this._startPoint, 
        this._params.numPoints, 
        this._params.inRadius, 
        this._params.inRadius + 1
      );
      this._currentPath.style = Defaults.tentativeStyle;
    },

    onMouseUp: function(event) {
      if (this._params.inRadius) {
        this._outerMouseUp(event);
      } else {
        this._innerMouseUp(event);
      }
    
    },

    _innerMouseUp: function(event) {
      this._params.inRadius = this._currentPath.bounds.width / 2;
      console.log("Star inner radius defined!");
    },

    _outerMouseUp: function(event) {
      this._currentPath.style = Defaults.committedStyle;
      this._startPoint = null;
      this._params.inRadius = null;
      console.log("Created star! ^^");
    },

    onMouseDrag: function(event) {
      if (this._params.inRadius) {
        this._outerMouseDrag(event);
      } else {
        this._innerMouseDrag(event);
      }
    },

    _innerMouseDrag: function(event) {
      var scaleDelta = this._currentPath.position.getDistance(event.point);
      var currRadius = this._currentPath.firstSegment.point.getDistance(this._currentPath.position);
      var scaleFactor = scaleDelta / currRadius;
      this._currentPath.scale(scaleFactor);
    },

    _outerMouseDrag: function(event) {
      var outerRadius = this._currentPath.position.getDistance(event.point);
      var angle = event.point.subtract(this._currentPath.position).angle;

      this._currentPath.remove();
      this._currentPath = new paper.Path.Star(
        this._startPoint,
        this._params.numPoints,
        this._params.inRadius,
        outerRadius
      );
      this._currentPath.style = Defaults.tentativeStyle;
      this._currentPath.rotate(angle);
    },

    onMouseMove: BaseCreateTool.onMouseMove 
  });
  return StarTool; 
});<commit_msg>added styling to Star tool, made it compatible with other creation tools<commit_after>define([
  "paper",
  "underscore",
  "config/Defaults",
  "tools/BaseCreateTool",
  "objects/Geometry",
  "objects/Index/Index"
], function(paper, _, Defaults, BaseCreateTool, Geometry, Index) {
  
  var StarTool = _.extend({}, BaseCreateTool, {
    _currentPath: null,
    
    _params: {
      numPoints: 5,
      inRadius: null,
      outRadius: null,
      style: {}
    },

    _sidebarComponents: ["Styler"],

    _startPoint: null,

    setup: function() {
      this.loadSidebarComponents(this._sidebarComponents);
    },

    cleanup: function() {
      this.clearSidebarComponents();
    },

    onMouseDown: function(event) {
      if (this._params.inRadius) {
        this._outerMouseDown(event);
      } else {
        this._innerMouseDown(event);
      }
    },

    _innerMouseDown: function(event) {
      console.log("Starting star creation...");
      this._startPoint = event.point;
      this._currentPath = new Geometry.Path.Circle(event.point, 1);
      this._currentPath.style = Defaults.committedStyle;
      this._currentPath.style = this._params.style;
      this._currentPath.opacity = this._currentPath.opacity / 2;
    },

    _outerMouseDown: function(event) {
      this._currentPath.remove();
      this._currentPath = new Geometry.Path.Star(
        this._startPoint, 
        this._params.numPoints, 
        this._params.inRadius, 
        this._params.inRadius + 1
      );
      this._currentPath.style = Defaults.committedStyle;
      this._currentPath.style = this._params.style;
      this._currentPath.opacity = this._currentPath.opacity / 2;
    },

    onMouseUp: function(event) {
      if (this._params.inRadius) {
        this._outerMouseUp(event);
      } else {
        this._innerMouseUp(event);
      }
    
    },

    _innerMouseUp: function(event) {
      this._params.inRadius = this._currentPath.bounds.width / 2;
      console.log("Star inner radius defined!");
    },

    _outerMouseUp: function(event) {
      this._currentPath.style = Defaults.committedStyle;
      this._currentPath.style = this._params.style;
      this._currentPath.opacity = 2 * this._currentPath.opacity;
      Index.insert(this._currentPath);
      this._currentPath = null;
      this._startPoint = null;
      this._params.inRadius = null;
      console.log("Created star! ^^");
    },

    onMouseDrag: function(event) {
      if (this._params.inRadius) {
        this._outerMouseDrag(event);
      } else {
        this._innerMouseDrag(event);
      }
    },
    

    _innerMouseDrag: function(event) {
      var scaleDelta = this._currentPath.position.getDistance(event.point);
      var currRadius = this._currentPath.firstSegment.point.getDistance(this._currentPath.position);
      var scaleFactor = scaleDelta / currRadius;
      this._currentPath.scale(scaleFactor);
    },

    _outerMouseDrag: function(event) {
      var outerRadius = this._currentPath.position.getDistance(event.point);
      var angle = event.point.subtract(this._currentPath.position).angle;

      // TODO: somehow get around creating a new object every single time!! bad!!
      this._currentPath.remove();
      this._currentPath = new Geometry.Path.Star(
        this._startPoint,
        this._params.numPoints,
        this._params.inRadius,
        outerRadius
      );
      this._currentPath.style = Defaults.committedStyle;
      this._currentPath.style = this._params.style;
      this._currentPath.opacity = this._currentPath.opacity / 2;
      this._currentPath.rotate(angle);
    },

    onMouseMove: BaseCreateTool.onMouseMove 
  });
  return StarTool; 
});
{'fraction_non_alphanumeric': 0.11829800498753117, 'fraction_numerical': 0.0018703241895261845, 'mean_word_length': 2.6752577319587627, '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': '3796626', 'n_tokens_mistral': 1944, 'n_tokens_neox': 1885, 'n_words': 311}