var imageData = context.getImageData( 0, 0, w, h );
var count = 0;
for( i in 0...w )
{
for( j in 0...h )
{
count++;
for( col in 0...4 )
{
var k = count*4 + col;
var p = imageData.data[ k ];
imageData.data[ k ] = switch( col )
{
case 3: 200 + Math.round( ( 255 - 200 )*Math.sin( ( (i*k)%250 )/Math.PI/5 ) ) ;// alpha
case 0: p; // red
case 1,2: 0; // green, blue
}
}
}
}
}
context.putImageData( imageData, 0, 0 );
The fancy part is i*k, if you want just a horizontal sine just use k which is what I did initially, if you want more pointillist then i*k*j. Looking briefly at Jeash I suspect that it's better to work with the raw data (as I am) than to use the bitmapdata wrapped code which probably adds an extra overhead ( I am using drawImage to put the image on the canvas after first using untyped new Image onload callback, creatElement won't work ). Anyway just thought I would share snipit incase someone wants to try creating a js version of the lighting code.
But I guess there must be simpler approaches than/to pixel manipulation in javascript?