res/draw.js
function show (pixels, title) {
	if (typeof pixels === 'string') {
		var img = createImage(pixels);
		img.style.height = '40px';
		img.style.width = '100%';

		title && img.setAttribute('title', title);

		document.body.appendChild(img);
		return;
	}

	var canvas = document.createElement('canvas');
	var w = (pixels.length/4)|0;

	canvas.width = w;
	canvas.height = 1;
	canvas.style.height = '40px';
	canvas.style.width = '100%';

	var ctx = canvas.getContext('2d');
	var imageData = ctx.createImageData(w, 1);

	imageData.data.set(pixels);

	ctx.putImageData(imageData, 0, 0);

	title && canvas.setAttribute('title', title);

	document.body.appendChild(canvas);
	document.body.appendChild(document.createElement('br'));
}
function show (pixels, title) {
	if (typeof pixels === 'string') {
		var img = createImage(pixels);
		img.style.height = '40px';
		img.style.width = '100%';

		title && img.setAttribute('title', title);

		document.body.appendChild(img);
		return;
	}

	var canvas = document.createElement('canvas');
	var w = (pixels.length/4)|0;

	canvas.width = w;
	canvas.height = 1;
	canvas.style.height = '40px';
	canvas.style.width = '100%';

	var ctx = canvas.getContext('2d');
	var imageData = ctx.createImageData(w, 1);

	imageData.data.set(pixels);

	ctx.putImageData(imageData, 0, 0);

	title && canvas.setAttribute('title', title);

	document.body.appendChild(canvas);
	document.body.appendChild(document.createElement('br'));
}
function show ( pixels , title ) { if ( typeof pixels === 'string' ) { var img = createImage ( pixels ) ; img . style . height = '40px' ; img . style . width = '100%' ; title && img . setAttribute ( 'title' , title ) ; document . body . appendChild ( img ) ; return ; } var canvas = document . createElement ( 'canvas' ) ; var w = ( pixels . length / 4 ) | 0 ; canvas . width = w ; canvas . height = 1 ; canvas . style . height = '40px' ; canvas . style . width = '100%' ; var ctx = canvas . getContext ( '2d' ) ; var imageData = ctx . createImageData ( w , 1 ) ; imageData . data . set ( pixels ) ; ctx . putImageData ( imageData , 0 , 0 ) ; title && canvas . setAttribute ( 'title' , title ) ; document . body . appendChild ( canvas ) ; document . body . appendChild ( document . createElement ( 'br' ) ) ; }
create a canvas with the image/colordata preview
create a canvas with the image / colordata preview