【问题标题】:Add 'fake' antialiasing to rotated rectangle为旋转的矩形添加“假”抗锯齿
【发布时间】:2013-07-09 02:41:31
【问题描述】:

我正在使用 Corona SDK,它最近禁用了抗锯齿功能,但无法重新启用它。我有几个使用旋转矩形和线条的应用程序,并且想要一种不看起来参差不齐的方法。这张图片显示了不同之处:

有没有办法在 Corona 中为这些矩形添加某种抗锯齿?我更喜欢抗锯齿 hack,并且能够使用新的 Corona 功能和修复,而不是使用带有抗锯齿的旧版本。]

谢谢!

【问题讨论】:

    标签: graphics coronasdk antialiasing


    【解决方案1】:

    您可以将masks 用于您的矩形或图像,它可以最大程度地减少锯齿,是抗锯齿的好选择

    我在没有遮罩的情况下测试矩形,它很丑,当我添加遮罩时它改善了矩形

    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
    

    我用过这个面具,你可以自己测试一下

    【讨论】:

    • 这绝对是一个有趣的想法,我可以看到它确实最大限度地减少了混叠。有没有办法动态生成掩码? (可能不会,但我的应用程序中的矩形可以是任何随机尺寸,并且为每种尺寸创建和包含蒙版图像是不可行的。)
    • 您可以动态生成蒙版或图像,我是使用display.save()发现的,这会将显示组保存为图像,您可以将保存的图像用作蒙版。 docs.coronalabs.com/api/library/display/save.html
    • 我不知道你能做到这一点,很高兴知道。为每个矩形大小生成一个遮罩、保存并应用它,这听起来相当耗费资源。不过,这可能是最好的选择。
    • 这是一个很好的解决方案,我只是想弄清楚如何让它与小矩形大矩形一起工作。我想我会有一个小面具和一个大面具。
    • 是的,你可以做到,我很高兴能提供帮助,我也学到了一些东西。
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2011-05-16
    • 1970-01-01
    • 2012-12-12
    • 1970-01-01
    相关资源
    最近更新 更多