Bug 7075: anti alias of lines using GC [message #448016] |
Thu, 23 December 2004 23:18 |
Nick Lerissa Messages: 6 Registered: July 2009 |
Junior Member |
|
|
I've been creating application that needs to draw curved lines.
Since there is no built-in GC support for drawing curved lines, I am
estimating the curve using the java.awt.geom classes::
import java.awt.geom.*;
....
CubicCurve2D curve = new CubicCurve2D.Double(x0,y0, x1,y1,x2,y2,x3,y3);
PathIterator itr = curve.getPathIterator(null, .1f);
float array[] = new float[2];
int last[] = null;
while (!itr.isDone()) {
itr.currentSegment(array);
int x = Math.round(array[0]);
int y = Math.round(array[1]);
if (last != null) {
gc.drawLine(x,y,last[0],last[1]);
}
last = new int[] { x, y}; itr.next();
}
The problem is that some curve look pretty bad since there is no
antialiasing support. I see that
the following bug has been filed. Just incase it doesn't get fixed does
anyone have a suggestion for
drawing a smoother curve.
https://bugs.eclipse.org/bugs/show_bug.cgi?id=7075
|
|
|
Re: Bug 7075: anti alias of lines using GC [message #448040 is a reply to message #448016] |
Tue, 28 December 2004 11:16 |
Markus Kuhn Messages: 3 Registered: July 2009 |
Junior Member |
|
|
As AWT Java 2D supports anti aliasing, you could use Java 2D with the
org.eclipse.swt.awt.SWT_AWT bridge.
Markus
Nick Lerissa wrote:
> I've been creating application that needs to draw curved lines.
> Since there is no built-in GC support for drawing curved lines, I am
> estimating the curve using the java.awt.geom classes::
>
> import java.awt.geom.*;
> ...
> CubicCurve2D curve = new CubicCurve2D.Double(x0,y0, x1,y1,x2,y2,x3,y3);
> PathIterator itr = curve.getPathIterator(null, .1f);
> float array[] = new float[2];
> int last[] = null;
>
> while (!itr.isDone()) {
> itr.currentSegment(array);
> int x = Math.round(array[0]);
> int y = Math.round(array[1]);
>
> if (last != null) {
> gc.drawLine(x,y,last[0],last[1]);
> }
> last = new int[] { x, y}; itr.next();
> }
>
> The problem is that some curve look pretty bad since there is no
> antialiasing support. I see that
> the following bug has been filed. Just incase it doesn't get fixed does
> anyone have a suggestion for
> drawing a smoother curve.
>
> https://bugs.eclipse.org/bugs/show_bug.cgi?id=7075
>
>
|
|
|
Powered by
FUDForum. Page generated in 0.03527 seconds