ActionScript 渐变带问题

发布于 2024-09-01 22:15:17 字数 488 浏览 9 评论 0原文

我在渐变的某些颜色之间出现条带时遇到一个奇怪的问题。

为了创建渐变,我从中心到边界绘制均匀间隔的圆楔形,并从循环中的位图线渐变像素填充每个圆楔形。

我正在创建一个包含 3600 个楔子的圆,尽管根据从红色到黄色数字渐变生成的橙色屏幕截图来看,它看起来并不像它。在红色和黄色之间添加橙色数字没有帮助。但如果我只用 360 个楔子创建圆,则渐变带会更加明显。 3600 可能有点矫枉过正,并且并没有真正添加更多细节,例如,制作 1440 楔形的圆圈,但我不知道有任何其他方法可以稍微提升此条带问题。

我有什么想法可以解决这个问题,或者我做错了什么?难道是circleMatrix旋转造成的?

替代文本 http://www.freeimagehosting.net/uploads/7e3382befe.jpg

i'm having a strange issue with banding between certain colors of a gradient.

to create the gradient, i'm drawing evenly spaced circle wedges from the center to the border, and filling each circle wedge from a bitmap line gradient pixel in a loop.

i'm creating a circle with 3600 wedges, although it doesn't look like it based on the screen shot within the orange color that is produced from gradating from red to yellow numbers. adding a orange number between red and yellow doesn't help. but if i create the circle with only 360 wedges, the gradient banding is much more obvious. 3600 is probably overkill, and doesn't really add more detail over, say, making the circle of 1440 wedges, but i don't know any other way to slightly elevate this banding issue.

any ideas how i can fix this, or what i'm doing wrong? could it be caused by the circleMatrix rotation?

alt text http://www.freeimagehosting.net/uploads/7e3382befe.jpg

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

忆离笙 2024-09-08 22:15:17

编辑:
由于精度误差,可能会出现一些伪影,因为您只有 255 个值的范围可供分配。

为了最小化这种视觉效果,您可以尝试在色带中添加一些模糊,但要注意左侧和右侧之间的连接:

//...

//Assign bitmapData to the leftToRightLine
var leftToRightLineBitmapData:BitmapData = 
                   new BitmapData(leftToRightLine.width,leftToRightLine.height);
leftToRightLineBitmapData.draw(leftToRightLine);

// add some blur filter to the color band
leftToRightLine.filters=[new BlurFilter(2,0, 3)];

// copy the color band on the bitmap but but starting at 1 pixel right to avoid
// the blur on the start
leftToRightLineBitmapData.draw(leftToRightLine, new Matrix(1,0,0,1, 1));

for(var i:int = 1; i < (DEFAULT_BANDING_QUALITY + 1); i++)
{
  //...

没有完整的代码来测试,很难知道我的目标是否正确;)

  • 有弧度转换中出现错误,它是 i*Math.pi/180 而不是 /1800,因此现在您可以转到 360 而不是 < code>3600
  • 为什么从1开始而不是从0开始?

  • 尝试调整线条粗细并使用 lineGradientStyle

  • 您引用了 objMatrix 但创建了 CircleMatrix

Edit:
Due to precision error some artifact can appear since you have only a range of 255 values to distribute.

To minimize this visual effect you can try to add some blur to your color band, but beware of the join between the left and the right side :

//...

//Assign bitmapData to the leftToRightLine
var leftToRightLineBitmapData:BitmapData = 
                   new BitmapData(leftToRightLine.width,leftToRightLine.height);
leftToRightLineBitmapData.draw(leftToRightLine);

// add some blur filter to the color band
leftToRightLine.filters=[new BlurFilter(2,0, 3)];

// copy the color band on the bitmap but but starting at 1 pixel right to avoid
// the blur on the start
leftToRightLineBitmapData.draw(leftToRightLine, new Matrix(1,0,0,1, 1));

for(var i:int = 1; i < (DEFAULT_BANDING_QUALITY + 1); i++)
{
  //...

Without full code to test, hard to know if i aim in the right direction ;)

  • There is an error in your radian conversion it's i*Math.pi/180 and not /1800, so now you can go to 360 and not 3600
  • why start from 1 and not from 0 ?

  • try to play with the line thickness and use the lineGradientStyle

  • You referer to an objMatrix but create a circleMatrix

甜味拾荒者 2024-09-08 22:15:17

我认为条带是由你的比率引起的。

试试这个:

graphics.beginGradientFill(GradientType.LINEAR, [nColor, nColor], [1, 1], [0, 255], objMatrix)

另外,objMatrix实际上应该是circleMatrix吗?

您可以在 LiveDoc 的

I think the banding is being caused by your ratios.

Try this:

graphics.beginGradientFill(GradientType.LINEAR, [nColor, nColor], [1, 1], [0, 255], objMatrix)

Also, should objMatrix actually be circleMatrix?

You can see the difference between [127, 255] and [0, 255] in the LiveDoc's

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文