Add 'fake' antialiasing to rotated rectangle

一笑奈何 提交于 2019-12-05 21:16:33

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

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!