Ejecta icon indicating copy to clipboard operation
Ejecta copied to clipboard

why MSAAEnabled & MSAASamples no effect when I draw path?

Open finscn opened this issue 12 years ago • 2 comments

I drawpath (circle) on an offscreen-canvas, then draw it on screen.

the screen-canvas and offscreen-canvas all are set

MSAAEnabled=true; MSAASamples=4;

finscn avatar Jan 24 '14 17:01 finscn

Works for me.

// draw circle offscreen
var offscreen = document.createElement('canvas');
offscreen.MSAAEnabled = true;
offscreen.MSAASamples = 4;
offscreen.width = 100;
offscreen.height = 100;
var offscreenCtx = offscreen.getContext('2d');

offscreenCtx.fillStyle = '#fff';
offscreenCtx.beginPath();
offscreenCtx.arc(50,50,40,0,2*Math.PI);
offscreenCtx.fill();

// draw on screen
var ctx = canvas.getContext('2d');
ctx.drawImage(offscreen, 0, 0);

Remember to set .MSAAEnabled before calling .getContext()!

phoboslab avatar Jan 26 '14 16:01 phoboslab

Hi, just a quick note that if you use MSAA on the offscreen-canvas, than I think you can set MSAA to false on the main canvas (as AA was already applied). It may be a nice little optimization that allows you to only apply AA where you need.

Amit

On 1/24/14 12:04 PM, finscn wrote:

I drawpath (circle) on an offscreen-canvas, then draw it on screen.

the screen-canvas and offscreen-canvas all are set

MSAAEnabled=true; MSAASamples=4;

— Reply to this email directly or view it on GitHub https://github.com/phoboslab/Ejecta/issues/313.

apitaru avatar Jan 26 '14 16:01 apitaru