Skip to content

Commit

Permalink
ES6 module migration, see phetsims/chipper#875
Browse files Browse the repository at this point in the history
  • Loading branch information
samreid committed Feb 27, 2020
1 parent 08fccbe commit 20f4e3a
Showing 1 changed file with 37 additions and 40 deletions.
77 changes: 37 additions & 40 deletions js/common/view/ImageDataRenderer.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,45 +5,42 @@
*
* @author Sam Reid (PhET Interactive Simulations)
*/
define( require => {
'use strict';

// modules
const waveInterference = require( 'WAVE_INTERFERENCE/waveInterference' );

class ImageDataRenderer {

/**
* @param {number} width
* @param {number} height
*/
constructor( width, height ) {

// @public {HTMLCanvasElement}
this.canvas = document.createElement( 'canvas' );
this.canvas.width = width;
this.canvas.height = height;

// @private
this.context = this.canvas.getContext( '2d' );

// @private
this.imageData = this.context.createImageData( width, height );

// @public {Uint8ClampedArray} - One-dimensional array containing the data in the RGBA order, with integer values
// between 0 and 255 (inclusive).
this.data = this.imageData.data;
}

/**
* Paints image data onto the canvas.
* @param {number} x
* @param {number} y
*/
putImageData( x = 0, y = 0 ) {
this.context.putImageData( this.imageData, x, y );
}

import waveInterference from '../../waveInterference.js';

class ImageDataRenderer {

/**
* @param {number} width
* @param {number} height
*/
constructor( width, height ) {

// @public {HTMLCanvasElement}
this.canvas = document.createElement( 'canvas' );
this.canvas.width = width;
this.canvas.height = height;

// @private
this.context = this.canvas.getContext( '2d' );

// @private
this.imageData = this.context.createImageData( width, height );

// @public {Uint8ClampedArray} - One-dimensional array containing the data in the RGBA order, with integer values
// between 0 and 255 (inclusive).
this.data = this.imageData.data;
}

/**
* Paints image data onto the canvas.
* @param {number} x
* @param {number} y
*/
putImageData( x = 0, y = 0 ) {
this.context.putImageData( this.imageData, x, y );
}
}

return waveInterference.register( 'ImageDataRenderer', ImageDataRenderer );
} );
waveInterference.register( 'ImageDataRenderer', ImageDataRenderer );
export default ImageDataRenderer;

0 comments on commit 20f4e3a

Please sign in to comment.