I'm trying to render some 2D shapes to a scaled up low resolution canvas. I'm using the canvas's 2d context functions "beginPath", "moveTo", "lineTo" and "fill" for this purpose. However I experienced that every shape I'm rendering will be rendered with antialiasing at the shape edges which I don't need and want in this case.
I tried to disable imagesmoothing by setting "context.imageSmoothingEnabled = false" and added "image-rendering: pixelated" to the style of the canvas but neither of these seem to help. Is there a way to render shapes without antialiasing or can't this feature be disabled. If not this would be pretty bad.
function drawOne(){
var canvas = document.getElementById("canvas");
canvas.style.imageRendering = "pixelated";
var ctx = canvas.getContext("2d");
ctx.imageSmoothingEnabled = false;
ctx.beginPath();
ctx.moveTo(2, 2);
ctx.lineTo(30, 10);
ctx.lineTo(12, 30);
ctx.closePath();
ctx.fillStyle = "#FF0000";
ctx.fill();
}
drawOne();
<canvas id="canvas" width="32" height="32" style="width:512px;height:512px;background-color:#000000;"></canvas>
Some additional info: I'm trying to realize a 3D affine texture mapper (like the good ol PSone) and therefore need the native rendering performance of the canvas context.