2013-07-09 83 views
2

我使用Corona SDK,它最近禁用了抗鋸齒功能,但沒有辦法重新啓用它。我有幾個應用程序使用旋轉的矩形和線條,並希望不要看起來鋸齒狀的方式。此圖顯示的區別:將'假'抗鋸齒添加到旋轉矩形

enter image description here

有沒有一種方法,以某種抗鋸齒添加到電暈這些矩形?我更喜歡antialias黑客,並能夠使用新的Corona功能和修復,而不是使用具有抗鋸齒功能的舊版本。]

Thanks!

回答

1

您可以使用masks您rects或圖像,它可以最大限度地減少失真,它是在抗鋸齒的良好替代

我測試RECT不戴面具,它的醜陋,當我加入面具它提高了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 

我用這個面膜,你可以測試它自己

200x200 mask

+0

這絕對是一個跨我認爲它確實可以最大限度地減少鋸齒。有沒有辦法動態生成蒙版? (可能不是,但我的應用程序中的矩形可以是任何隨機尺寸,並且爲每個尺寸創建幷包含遮罩圖像都是不可行的。) – penguinrob

+0

您可以動態生成蒙版或圖像,我通過使用「顯示」來發現它。 save()',這會將顯示組保存爲圖像,並且可以將保存的圖像用作掩碼。 http://docs.coronalabs.com/api/library/display/save.html – NaviRamyle

+0

我不知道你能做到這一點,這很好。對於每個矩形大小生成一個蒙版,保存並應用它聽起來相當耗費資源。雖然可能是最好的選擇。 – penguinrob