Question

I'm using Corona SDK, which fairly recently disabled antialiasing, without a way to re-enable it. I have several apps that use rotated rectangles and lines, and would like a way for to not look jagged. This image shows the difference:

enter image description here

Is there a way to add some sort of antialiasing to these rectangles in Corona? I'd much prefer an antialias hack and be able to use new Corona features and fixes than use an old build with antialiasing.]

Thanks!

Was it helpful?

Solution

You can use masks to your rects or images, it can minimize aliasing and it's a good alternative in anti-aliasing

I test the rect without a mask, it's ugly and when I added the mask it improved the rect

display.newRect(0,0,320,480) --Background

local rmask = graphics.newMask( "mask.png" ) --Mask

local w = math.random(100,300) --Your random width of your rect
local h = math.random(100,300) --Your random height of your rect
local r = display.newRect(100,100,w,h) --Rect
r:setFillColor(0,0,0)
r:setMask(rmask)

--This will resize the mask to your rect's dimensions, make sure you know your mask's width and height
r.maskScaleX = w/200 --the 200 is the mask's width
r.maskScaleY = h/200 --the 200 is the mask's height

transition.to(r,{time = 100000, rotation = 360*10}) --To test the aliasing when it rotates

I used this mask, you can test it for yourself

200x200 mask

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top