平滑绘图算法 (Java2d)
我正在尝试为各种函数绘制 y = f(x) 的曲线,并且我希望该图的质量尽可能好。也就是说,出于性能原因,我宁愿避免在 Java 代码中渲染单个像素。
换句话说,我想从 Java2D 中榨取尽可能多的质量。
目前我正在计算 x 方向上每个像素的 float (x,y) 值。然后,我通过在这些点之间绘制线条来创建形状(使用点坐标的浮点值)。我有双线性插值、抗锯齿和质量渲染的渲染提示。
结果并不可怕,只是还过得去,但我见过更好的。我认为问题是,尽管我使用的是浮点坐标,但我本质上是在绘制一个多边形,所以 Java2D 能做的就只有这么多。
我还能做些什么来改善这一点吗?
I am trying to plot a curve of y = f(x) for various functions, and I want the plot to be as good quality as possible. That said, I would prefer to avoid rendering individual pixels in my Java code for performance reasons.
In other words, I want to squeeze as much quality as I can out of Java2D.
Currently I am calculating float (x,y) values for each pixel in the x direction. Then I am creating a Shape by drawing lines between these points (using float values for the point coords). I have render hints for bilinear interpolation, anti-aliasing and quality rendering.
The result isn't terrible, it is just about passable, but I have seen better. I think the problem is, even though I am using float coordinates I am essentially drawing a polygon so there is only so much Java2D can do.
Is there anything more I can do to improve this?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
当我在大学学习计算机图形学时,我们做了一个基于“贝塞尔曲线”的课程作业。这可能是您正在寻找的算法。在这里查看更多详细信息:
http://en.wikipedia.org/wiki/Bézier_curve
基本上它是一个方法如何用平滑曲线替换多边形。
When I was studying computer graphics at university, we did a coursework based on "Bézier Curve". It may be an algorithm you are looking for. Look here for more detail:
http://en.wikipedia.org/wiki/Bézier_curve
Basically it is a way how to replace a polygon with a smooth curve.