lib/index.js
function Canvas (canvasElement, fullWindow, autoInit) {
  if( !(this instanceof Canvas) ) {
    return new Canvas.apply(null, arguments);
  }

  /**
   * @type {HTMLCanvasElement}
   * @public
   */
  this.canvas = null;

  /**
   * @type {CanvasRenderingContext2D}
   * @public
   */
  this.context = null;

  /**
   * @type {boolean}
   * @private
   */
  this.fullWindow = true;

  /**
   * if a path has started - reset when drawing a path 
   * @type {boolean}
   * @private
   */
  this.pathStarted = false;

  /**
   * width of the canvas, in px
   * @type {number}
   * @public
   */
  this.width = 0;

  /**
   * height of the canvas, in px
   * @type {number}
   * @public
   */
  this.height = 0;
  

  if (canvasElement === undefined) {
    canvasElement = document.createElement("canvas");
    document.body.appendChild(canvasElement);
  }

  if (fullWindow === undefined) {
    fullWindow = true;
  }

  if (autoInit === undefined) {
    autoInit = true;
  }

  this.canvas = canvasElement;
  this.canvas.classList.add("creenv");
  this.context = this.canvas.getContext('2d');
  this.fullWindow = fullWindow;

  this.onWindowResizeHandler = this.onWindowResizeHandler.bind(this);

  if (autoInit) {
    this.init();
  }
}
function Canvas (canvasElement, fullWindow, autoInit) {
  if( !(this instanceof Canvas) ) {
    return new Canvas.apply(null, arguments);
  }

  /**
   * @type {HTMLCanvasElement}
   * @public
   */
  this.canvas = null;

  /**
   * @type {CanvasRenderingContext2D}
   * @public
   */
  this.context = null;

  /**
   * @type {boolean}
   * @private
   */
  this.fullWindow = true;

  /**
   * if a path has started - reset when drawing a path 
   * @type {boolean}
   * @private
   */
  this.pathStarted = false;

  /**
   * width of the canvas, in px
   * @type {number}
   * @public
   */
  this.width = 0;

  /**
   * height of the canvas, in px
   * @type {number}
   * @public
   */
  this.height = 0;
  

  if (canvasElement === undefined) {
    canvasElement = document.createElement("canvas");
    document.body.appendChild(canvasElement);
  }

  if (fullWindow === undefined) {
    fullWindow = true;
  }

  if (autoInit === undefined) {
    autoInit = true;
  }

  this.canvas = canvasElement;
  this.canvas.classList.add("creenv");
  this.context = this.canvas.getContext('2d');
  this.fullWindow = fullWindow;

  this.onWindowResizeHandler = this.onWindowResizeHandler.bind(this);

  if (autoInit) {
    this.init();
  }
}
function Canvas ( canvasElement , fullWindow , autoInit ) { if ( ! ( this instanceof Canvas ) ) { return new Canvas . apply ( null , arguments ) ; } /**
   * @type {HTMLCanvasElement}
   * @public
   */ this . canvas = null ; /**
   * @type {CanvasRenderingContext2D}
   * @public
   */ this . context = null ; /**
   * @type {boolean}
   * @private
   */ this . fullWindow = true ; /**
   * if a path has started - reset when drawing a path 
   * @type {boolean}
   * @private
   */ this . pathStarted = false ; /**
   * width of the canvas, in px
   * @type {number}
   * @public
   */ this . width = 0 ; /**
   * height of the canvas, in px
   * @type {number}
   * @public
   */ this . height = 0 ; if ( canvasElement === undefined ) { canvasElement = document . createElement ( "canvas" ) ; document . body . appendChild ( canvasElement ) ; } if ( fullWindow === undefined ) { fullWindow = true ; } if ( autoInit === undefined ) { autoInit = true ; } this . canvas = canvasElement ; this . canvas . classList . add ( "creenv" ) ; this . context = this . canvas . getContext ( '2d' ) ; this . fullWindow = fullWindow ; this . onWindowResizeHandler = this . onWindowResizeHandler . bind ( this ) ; if ( autoInit ) { this . init ( ) ; } }
The canvas class provides an interface to work with the html canvas API.
Most of the drawing methods of this class directly call the built-in functions,
it is just faster to write and think code using this

@param {?HTMLCanvasElement} canvasElement the html canvas element, if none
is provided, one will be added to the body
@param {?boolean} fullWindow (default = false) if the canvas fills the window
@param {?boolean} autoInit (default = true) if the canvas will be automatically
at the class instanciation. You can set this parameter to false and call the
init method manually
The canvas class provides an interface to work with the html canvas API . Most of the drawing methods of this class directly call the built - in functions it is just faster to write and think code using this