<commit_before>(function( window )
{

  CrayonProgram = function( canvas )
  {
    this.initialize( canvas );

    Ticker.setFPS( 30 );
    Ticker.addListener( this );
  }

  var p = CrayonProgram.prototype; 

  p.canvas = null;

  p._listeners = {};

  p.initialize = function( canvas )
  {
    this.canvas = canvas;
  }

  p.clear = function()
  {
    var ctx = this.canvas.getContext('2d');
    ctx.clearRect( 0, 0, this.canvas.width, this.canvas.height );
  }

  p.draw = function( params )
  {
    this._setupParams( "shape", params )

    var ctx = this.canvas.getContext('2d');

    if( !isNaN(params.color) )
    {
      var r = (params.color & 0xFF0000) >> 16;
      var g = (params.color & 0x00FF00) >> 8;
      var b = (params.color & 0x0000FF);
      params.color = "rgb(" + r + "," + g + "," + b + ")";
    }

    ctx.fillStyle = params.color;

    switch( params.shape )
    {
      case "circle":
        ctx.beginPath();
        ctx.arc( params.center[0] || 0, params.center[1] || 0, params.radius || 0, 0, Math.PI*2, true );
        ctx.closePath();
        ctx.fill();
        break;

      case "rectangle":
        ctx.fillRect( params.corner[0] || 0, params.corner[1] || 0, params.width || 0, params.height || 0 );
        break;
    }
  }

  p.print = function( params )
  {
    this._setupParams( "output", params )
    console.log( params.output );
  }

  p.addEventListener = function( eventName, listenerObj, listenerFunction )
  {
    this.removeEventListener( eventName, listenerObj, listenerFunction );
    if( this._listeners[eventName] == null )
      this._listeners[eventName] = [];

    this._listeners[eventName].push( {listenerObj:listenerObj, listenerFunction:listenerFunction} );
  }

  p.removeEventListener = function( eventName, listenerObj, listenerFunction )
  {
    if( this._listeners == null || this._listeners[eventName] == null )
      return;

    var list = this._listeners[eventName];
    for( var i = 0; i < list.length; i++ )
    {
      if( list[i].listenerObj == listenerObj && list[i].listenerFunction == listenerFunction )
      {
        this._listeners[eventName].splice( i, 1 );
      }
    }
  }

  p.dispatchEvent = function( eventName, eventObj )
  {
    if( this._listeners == null || this._listeners[eventName] == null ) 
      return;

    var list = this._listeners[eventName];
    for( var i = 0; i < list.length; i++ )
    {
      list[i].listenerObj[list[i].listenerFunction](eventObj);
    }
  }

  p.random = function( params )
  {
    this._setupParams( "max", params );
    return Math.round( Math.random()*(params.max - params.min) + params.min );
  }

  p.tick = function()
  {
    this.dispatchEvent( "frame", {} );
  }

  p._setupParams = function( defaultParamName, params )
  {
    if( params.__default )
    {
      params[defaultParamName] = params.__default;
    }

    return params;
  }
  
  window.CrayonProgram = CrayonProgram;

}( window ));
<commit_msg>Add sin/cos to base JS class<commit_after>(function( window )
{

  CrayonProgram = function( canvas )
  {
    this.initialize( canvas );

    Ticker.setFPS( 30 );
    Ticker.addListener( this );
  }

  var p = CrayonProgram.prototype; 

  p.canvas = null;

  p._listeners = {};

  p.initialize = function( canvas )
  {
    this.canvas = canvas;
  }

  p.clear = function()
  {
    var ctx = this.canvas.getContext('2d');
    ctx.clearRect( 0, 0, this.canvas.width, this.canvas.height );
  }

  p.draw = function( params )
  {
    this._setupParams( "shape", params )

    var ctx = this.canvas.getContext('2d');

    if( !isNaN(params.color) )
    {
      var r = (params.color & 0xFF0000) >> 16;
      var g = (params.color & 0x00FF00) >> 8;
      var b = (params.color & 0x0000FF);
      params.color = "rgb(" + r + "," + g + "," + b + ")";
    }

    ctx.fillStyle = params.color;

    switch( params.shape )
    {
      case "circle":
        ctx.beginPath();
        ctx.arc( params.center[0] || 0, params.center[1] || 0, params.radius || 0, 0, Math.PI*2, true );
        ctx.closePath();
        ctx.fill();
        break;

      case "rectangle":
        ctx.fillRect( params.corner[0] || 0, params.corner[1] || 0, params.width || 0, params.height || 0 );
        break;
    }
  }

  p.print = function( params )
  {
    this._setupParams( "output", params )
    console.log( params.output );
  }

  p.addEventListener = function( eventName, listenerObj, listenerFunction )
  {
    this.removeEventListener( eventName, listenerObj, listenerFunction );
    if( this._listeners[eventName] == null )
      this._listeners[eventName] = [];

    this._listeners[eventName].push( {listenerObj:listenerObj, listenerFunction:listenerFunction} );
  }

  p.removeEventListener = function( eventName, listenerObj, listenerFunction )
  {
    if( this._listeners == null || this._listeners[eventName] == null )
      return;

    var list = this._listeners[eventName];
    for( var i = 0; i < list.length; i++ )
    {
      if( list[i].listenerObj == listenerObj && list[i].listenerFunction == listenerFunction )
      {
        this._listeners[eventName].splice( i, 1 );
      }
    }
  }

  p.dispatchEvent = function( eventName, eventObj )
  {
    if( this._listeners == null || this._listeners[eventName] == null ) 
      return;

    var list = this._listeners[eventName];
    for( var i = 0; i < list.length; i++ )
    {
      list[i].listenerObj[list[i].listenerFunction](eventObj);
    }
  }

  p.random = function( params )
  {
    this._setupParams( "max", params );
    return Math.round( Math.random()*(params.max - params.min) + params.min );
  }

  p.cos = function( params )
  {
    this._setupParams( "value", params );
    return Math.cos( params.value );
  }

  p.sin = function( params )
  {
    this._setupParams( "value", params );
    return Math.sin( params.value );
  }

  p.tick = function()
  {
    this.dispatchEvent( "frame", {} );
  }

  p._setupParams = function( defaultParamName, params )
  {
    if( params.__default )
    {
      params[defaultParamName] = params.__default;
    }

    return params;
  }
  
  window.CrayonProgram = CrayonProgram;

}( window ));

{'fraction_non_alphanumeric': 0.15278004239360835, 'fraction_numerical': 0.013044187184086092, 'mean_word_length': 2.5976539589442815, 'pattern_counts': {'":': 4, '<': 7, '<?xml version=': 0, '>': 11, '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': '2995653', 'n_tokens_mistral': 2126, 'n_tokens_neox': 2013, 'n_words': 415}