Double绘制曲线线段

Double绘制曲线线段

本文介绍了如何使用QuadCurve2D.Double绘制曲线线段?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

这是我声明曲线的代码行:

Here is the line of code where I declare the curve:

QuadCurve2D.Double curve = new QuadCurve2D.Double(50,100,100,170,150,100);

现在我可以使用什么代码绘制此曲线?我尝试过类似的事情:

Now what code can I use to draw this curve? I tried something like:

g.draw(curve);

但是显然那是行不通的.有什么建议吗?

but obviously that didn't work. Any suggestions?

推荐答案

我已经做了一个最小的测试用例,以说明您在这里的描述.该程序可以运行,但是除非能看到您正在使用的代码,否则我无法真正为您提供帮助.

I've made a minimum test case of what I think your describing here.This program works but I can't really help you unless I can see the code you are working with.

import java.awt.geom.*;
import java.awt.*;
import javax.swing.*;

public class CurveDraw extends JFrame {
        public static void main(String[] args) {
                CurveDraw frame = new CurveDraw();
                frame.setVisible(true);
        }
        public CurveDraw() {
                setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
                setSize(400,400);
        }
        public void paint(Graphics g) {
                QuadCurve2D.Double curve = new QuadCurve2D.Double(50,100,100,170,150,100);
                ((Graphics2D)g).draw(curve);
        }
}

这篇关于如何使用QuadCurve2D.Double绘制曲线线段?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

08-31 03:24