<commit_before>;(function($$){ 'use strict';

  var CanvasRenderer = $$('renderer', 'canvas');

  CanvasRenderer.prototype.getPixelRatio = function(){ 
    var canvas = this.data.canvases[0];
    var context = canvas.getContext('2d');

    var backingStore = context.backingStorePixelRatio ||
      context.webkitBackingStorePixelRatio ||
      context.mozBackingStorePixelRatio ||
      context.msBackingStorePixelRatio ||
      context.oBackingStorePixelRatio ||
      context.backingStorePixelRatio || 1;

    //console.log(window.devicePixelRatio, backingStore);

    var isFirefox = typeof InstallTrigger !== 'undefined';

    if( isFirefox ){ // because ff can't scale canvas properly
      return 1;
    }

    return (window.devicePixelRatio || 1) / backingStore;
  }

  CanvasRenderer.prototype.paintCache = function(context){
    var caches = this.paintCaches = this.paintCaches || [];
    var needToCreateCache = true;
    var cache;

    for(var i = 0; i < caches.length; i++ ){
      cache = caches[i];

      if( cache.context === context ){
        needToCreateCache = false;
        break;
      }
    }

    if( needToCreateCache ){
      cache = {
        context: context
      };
      caches.push( cache );
    }

    return cache;
  };

  // TODO use this
  CanvasRenderer.prototype.fillStyle = function(context, r, g, b, a){
    context.fillStyle = 'rgba(' + r + ',' + g + ',' + b + ',' + a + ')';
    return; // turn off for now, seems context does its own caching

    var cache = this.paintCache(context);

    var fillStyle = 'rgba(' + r + ',' + g + ',' + b + ',' + a + ')';

    if( cache.fillStyle !== fillStyle ){
      context.fillStyle = cache.fillStyle = fillStyle;
    }
  };

  // TODO test and implement as above
  CanvasRenderer.prototype.strokeStyle = function(context, r, g, b, a){
    context.strokeStyle = 'rgba(' + r + ',' + g + ',' + b + ',' + a + ')';
    return; // turn off for now, seems context does its own caching

    var cache = this.paintCache(context);

    var strokeStyle = 'rgba(' + r + ',' + g + ',' + b + ',' + a + ')';

    if( cache.strokeStyle !== strokeStyle ){
      context.strokeStyle = cache.strokeStyle = strokeStyle;
    }
  };

  // Resize canvas
  CanvasRenderer.prototype.matchCanvasSize = function(container) {
    var data = this.data; var width = container.clientWidth; var height = container.clientHeight;
    
    var canvas, canvasWidth = width, canvasHeight = height;
    var pixelRatio = this.getPixelRatio();

    // apply pixel ratio
    canvasWidth *= pixelRatio;
    canvasHeight *= pixelRatio;

    var canvasContainer = data.canvasContainer;
    canvasContainer.style.width = width + 'px';
    canvasContainer.style.height = height + 'px';

    for (var i = 0; i < CanvasRenderer.CANVAS_LAYERS; i++) {

      canvas = data.canvases[i];
      
      if (canvas.width !== canvasWidth || canvas.height !== canvasHeight) {
        
        canvas.width = canvasWidth;
        canvas.height = canvasHeight;

        canvas.style.width = width + 'px';
        canvas.style.height = height + 'px';
      }
    }
    
    for (var i = 0; i < CanvasRenderer.BUFFER_COUNT; i++) {
      
      canvas = data.bufferCanvases[i];
      
      if (canvas.width !== canvasWidth || canvas.height !== canvasHeight) {
        
        canvas.width = canvasWidth;
        canvas.height = canvasHeight;<commit_msg>fix #475<commit_after>;(function($$){ 'use strict';

  var CanvasRenderer = $$('renderer', 'canvas');

  CanvasRenderer.prototype.getPixelRatio = function(){ 
    var canvas = this.data.canvases[0];
    var context = canvas.getContext('2d');

    var backingStore = context.backingStorePixelRatio ||
      context.webkitBackingStorePixelRatio ||
      context.mozBackingStorePixelRatio ||
      context.msBackingStorePixelRatio ||
      context.oBackingStorePixelRatio ||
      context.backingStorePixelRatio || 1;

    //console.log(window.devicePixelRatio, backingStore);

    var isFirefox = typeof InstallTrigger !== 'undefined';

    if( isFirefox ){ // because ff can't scale canvas properly
      return 1;
    }

    return (window.devicePixelRatio || 1) / backingStore;
  }

  CanvasRenderer.prototype.paintCache = function(context){
    var caches = this.paintCaches = this.paintCaches || [];
    var needToCreateCache = true;
    var cache;

    for(var i = 0; i < caches.length; i++ ){
      cache = caches[i];

      if( cache.context === context ){
        needToCreateCache = false;
        break;
      }
    }

    if( needToCreateCache ){
      cache = {
        context: context
      };
      caches.push( cache );
    }

    return cache;
  };

  // TODO use this
  CanvasRenderer.prototype.fillStyle = function(context, r, g, b, a){
    context.fillStyle = 'rgba(' + r + ',' + g + ',' + b + ',' + a + ')';
    return; // turn off for now, seems context does its own caching

    var cache = this.paintCache(context);

    var fillStyle = 'rgba(' + r + ',' + g + ',' + b + ',' + a + ')';

    if( cache.fillStyle !== fillStyle ){
      context.fillStyle = cache.fillStyle = fillStyle;
    }
  };

  // TODO test and implement as above
  CanvasRenderer.prototype.strokeStyle = function(context, r, g, b, a){
    context.strokeStyle = 'rgba(' + r + ',' + g + ',' + b + ',' + a + ')';
    return; // turn off for now, seems context does its own caching

    var cache = this.paintCache(context);

    var strokeStyle = 'rgba(' + r + ',' + g + ',' + b + ',' + a + ')';

    if( cache.strokeStyle !== strokeStyle ){
      context.strokeStyle = cache.strokeStyle = strokeStyle;
    }
  };

  // Resize canvas
  CanvasRenderer.prototype.matchCanvasSize = function(container) {
    var data = this.data; var width = container.clientWidth; var height = container.clientHeight;
    
    var canvas, canvasWidth = width, canvasHeight = height;
    var pixelRatio = this.getPixelRatio();

    // apply pixel ratio
    canvasWidth *= pixelRatio;
    canvasHeight *= pixelRatio;

    var canvasContainer = data.canvasContainer;
    canvasContainer.style.width = width + 'px';
    canvasContainer.style.height = height + 'px';

    for (var i = 0; i < CanvasRenderer.CANVAS_LAYERS; i++) {

      canvas = data.canvases[i];
      
      if (canvas.width !== canvasWidth || canvas.height !== canvasHeight) {
        
        canvas.width = canvasWidth;
        canvas.height = canvasHeight;

        canvas.style.width = width + 'px';
        canvas.style.height = height + 'px';
      }
    }
    
    for (var i = 0; i < CanvasRenderer.BUFFER_COUNT; i++) {
      
      canvas = data.bufferCanvases[i];
      
      if (canvas.width !== canvasWidth || canvas.height !== canvasHeight) {
        
        canvas.width = canvasWidth;
        canvas.height = canvasHeight;

        canvas.style.width = width + 'px';
        canvas.style.height = height + 'px';
{'fraction_non_alphanumeric': 0.13782519731072787, 'fraction_numerical': 0.002776965799473838, 'mean_word_length': 2.6225516146109054, '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': '1209100', 'n_tokens_mistral': 2110, 'n_tokens_neox': 2023, 'n_words': 498}