将“假”抗锯齿添加到旋转的矩形 [英] Add 'fake' antialiasing to rotated rectangle

查看:231
本文介绍了将“假”抗锯齿添加到旋转的矩形的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在使用Corona SDK,它最近禁用了抗锯齿功能,但没有办法重新启用它。我有几个应用程序使用旋转的矩形和线条,并希望不要看起来锯齿状的方式。这张图片显示了不同:





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

解决方案

您可以使用掩盖到你的反应或图像,它可以最大限度地减少别名,这是一个抗锯齿的好选择



我没有掩码测试矩形,这是丑陋的,当我添加了面具,它改善了rect

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

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

local w = math.random(100,300) - 您的rect的随机宽度
本地h = math.random(100,300) - 您的rect的任意高度
local r = display.newRect(100,100,w,h)--Rect
r:setFillColor(0,0,0 )
r:setMask(rmask)

- 这会将面具的大小调整为你的矩形尺寸,确保你知道你的面具的宽度和高度
r.maskScaleX = w / 200 - 200是面具的宽度
r.maskScaleY = h / 200 - 200是面具的高度

transition.to(r,{time = 100000,rotation = 360 * 10}) - 测试旋转时的别名

我使用了这个面具,你可以自己测试它


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:

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!

解决方案

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

这篇关于将“假”抗锯齿添加到旋转的矩形的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆