Browse Source

Added PixelArray#inspect()

v1.x
Tj Holowaychuk 14 years ago
parent
commit
702db380c5
  1. 6
      lib/canvas.js
  2. 29
      lib/pixelarray.js

6
lib/canvas.js

@ -55,6 +55,12 @@ require('./context2d');
require('./image');
/**
* PixelArray implementation.
*/
require('./pixelarray');
/**
* Inspect canvas.
*

29
lib/pixelarray.js

@ -0,0 +1,29 @@
/*!
* Canvas - PixelArray
* Copyright (c) 2010 LearnBoost <tj@learnboost.com>
* MIT Licensed
*/
/**
* Module dependencies.
*/
var Canvas = require('../build/default/canvas')
, PixelArray = Canvas.CanvasPixelArray;
/**
* Custom inspect.
*/
PixelArray.prototype.inspect = function(){
var buf = '[PixelArray ';
for (var i = 0, len = this.length; i < len; ++i) {
buf += '\n ' + i + ': rgba('
+ this[i++] + ','
+ this[i++] + ','
+ this[i++] + ','
+ this[i] + ')';
}
return buf + '\n]';
};
Loading…
Cancel
Save