Skip to content

Instantly share code, notes, and snippets.

@jeesay
Created November 19, 2012 10:12
Drawing a Chessboard in JavaScript from a 8x8 image
// Drawing a chessboard in JavaScript
// Jean-Christophe Taveau
// Nov 2012
// http://crazybiocomputing.blogspot.com
var imp = IJ.createImage("chessboard 8x8", "8-bit Black", 8, 8, 1);
var ip = imp.getProcessor();
// M a i n
for (var y=0;y<8;y++) {
for (var x=0;x<8;x++) {
if ( (x+y)%2==0)
ip.set(x,y,255);
}
}
//IJ.run(imp, "Size...", "width=256 height=256 position=Center zero");
imp.setProcessor(ip.resize(256));
// Display the image
imp.show();
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment