平滑绘图算法 (Java2d)

发布于 2024-10-06 23:03:27 字数 324 浏览 0 评论 0原文

我正在尝试为各种函数绘制 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 技术交流群。

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

发布评论

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

评论(1

千鲤 2024-10-13 23:03:27

当我在大学学习计算机图形学时,我们做了一个基于“贝塞尔曲线”的课程作业。这可能是您正在寻找的算法。在这里查看更多详细信息:

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.

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