We are about to switch to a new forum software. Until then we have removed the registration on this forum.
With code below, I am somehow unable to draw crisp shapes despite a call to noSmooth. Something's afoot...
Thanks for any advice. Alex
function setup()
{
var canvas, buf, img, col;
canvas = createCanvas(100,100);
// Draw initial ellipse in buffer
buf = createGraphics(100,100);
buf.noSmooth().fill(color(0,0,0)).ellipseMode(CORNER).ellipse(0,0,100,100);
// Get image representation and filter out black pixels
col = [0,0,0,255];
img = b.get();
for (var x=0; x<100; x++){
for (var y=0; y<100; y++){
var a = img.get(x,y);
if (a[0] == c[0] && a[1] == c[1] && a[2] == c[2] && a[3] == c[3]) {
img.set(x,y,[0,0,0,0]);
}
}
}
img.updatePixels();
// Render and observe antialiased edge despite the call to noSmooth
image(img,0,0);
}
Answers
The reference page has the same issue so it's either a bug or it hasn't been implemented yet...
I believe the canvas element itself is the problem, that there is no way to turn off antialiasing.
So it's a 'feature'. Looks like it's possible to disable on some canvas elements: stackoverflow