简体   繁体   English

是否可以提高AWT图形绘制操作的精度?

[英]Is it possible to increase precision of AWT graphics drawing operations?

I am writing a java program to generate parabolic curves (essentially "curves" made of lots of straight lines to simulate the appearance of a curve, AKA straight line curves: see https://larc.unt.edu/ian/art/4ants/ ), and I am displaying it via a BufferedImage. 我正在编写一个Java程序来生成抛物线(基本上是由许多直线组成的“曲线”,以模拟曲线的外观,又称为直线曲线):请参见https://larc.unt.edu/ian/art/4ants / ),然后通过BufferedImage显示它。

Disappointingly, the lines drawn by the drawLine method come out very blocky and staggered when at any sort of angle (see screenshot, particularly, top left and bottom right corners of the image, but also any of the angled lines in the middle). 令人失望的是,当以任何角度倾斜时,drawLine方法绘制的线条非常杂乱且交错(请参见屏幕截图,尤其是图像的左上角和右下角,以及中间的任何倾斜线)。

Is there any way to get around this effect? 有什么办法可以避免这种影响? Possibly by performing higher precision drawing operations? 可能通过执行更高精度的绘制操作?

在此处输入图片说明

Set your Graphics2D object's rendering hints, using the setRenderingHint method, before drawing your lines. 在绘制线条之前,使用setRenderingHint方法设置Graphics2D对象的呈现提示。

Since you're drawing lines, there are three rendering hints you'll want to set: 由于要绘制线条,因此需要设置三个渲染提示:

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM