<commit_before>
import PIXI from 'pixi.js'

function createRenderer (w, h) {
  if (navigator.userAgent.match(/Gecko\//)) {
    // return new PIXI.autoDetectRenderer(w, h, { transparent: true })
    // Disable WebGL for the moment because it has some problem with rendering
    // sprite batches: https://github.com/pixijs/pixi.js/issues/1910
    return new PIXI.CanvasRenderer(w, h, { transparent: true })
  } else {
    return new PIXI.CanvasRenderer(w, h, { transparent: true })
  }
}

export class Context {
  constructor (skin) {
    this.refs       = { }
    this._skin      = skin
    this._instance  = skin.instantiate(this)
    this._renderer  = createRenderer(skin.width, skin.height)
    this.stage      = this._instance.object
    this.view       = this._renderer.view
    this._setupInteractivity()
  }
  render (data) {
    this._instance.push(data)
    this._renderer.render(this.stage)
  }
  destroy () {
    this._instance.destroy()
    this._instance = null<commit_msg>fix(scintillator): hack PIXI to make sure blendMode renders correctly<commit_after>
import PIXI from 'pixi.js'

function createRenderer (w, h) {
  hackPIXIToForceNewBlendModes()

  // For now, we are using CanvasRenderer instead of WebGLRenderer or
  // autoDetectRenderer befcause of two reasons.
  // 1. Current implementation has some problem with rendering
  //    sprite batches: https://github.com/pixijs/pixi.js/issues/1910
  // 2. It seems that Canvas performs better on some browsers, i.e. Chrome.
  //    WebGLRenderer only performs better on Firefox from the experiment.
  return new PIXI.CanvasRenderer(w, h, { transparent: true })
}

// HACK: Sometimes, when using the canvas renderer,
// the blend mode is not properly set.
function hackPIXIToForceNewBlendModes () {
  PIXI.utils.canUseNewCanvasBlendModes = () => true
}

export class Context {
  constructor (skin) {
    this.refs       = { }
    this._skin      = skin
    this._instance  = skin.instantiate(this)
    this._renderer  = createRenderer(skin.width, skin.height)
    this.stage      = this._instance.object
    this.view       = this._renderer.view
    this._setupInteractivity()
  }
  render (data) {
    this._instance.push(data)
    this._renderer.render(this.stage)
  }
  destroy () {
    this._instance.destroy()
    this._instance = null
{'fraction_non_alphanumeric': 0.10875216637781629, 'fraction_numerical': 0.004332755632582322, 'mean_word_length': 3.079505300353357, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 4, 'https://': 2, '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': '2616602', 'n_tokens_mistral': 736, 'n_tokens_neox': 721, 'n_words': 185}