开发者

Algorithm for smooth plotting (Java2d)

开发者 https://www.devze.com 2023-01-30 04:53 出处:网络
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

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 essential开发者_高级运维ly drawing a polygon so there is only so much Java2D can do.

Is there anything more I can do to improve this?


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.

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号