本文介绍了在java中绘制简单的曲线的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想在java中绘制曲线。我不想要二次曲线或三次曲线。当我画画时,它应该显示曲线而不是线条。

我正在使用(x,y),(last_x,last_y),(x1,y1)坐标。



我尝试了什么:



i am trying to draw curve in java. i don't want quadratic or cubic curve. when i am drawing, it should display curve instead of line.
and i am using (x,y),(last_x,last_y),(x1,y1) coordinates.

What I have tried:

if (pen_type==1){
           g2.fillOval( x, y, stroke_width, stroke_width );
       }  else if (pen_type==2) {
           g2.draw(new Line2D.Double(x, y, stroke_width, stroke_width));
       }
       else {
            //x1= ((76-4)/(6-0));
           // y= ((76-4)/(30-29));
           //y=((x*x*x)-(3*x));
           g2.setStroke(new BasicStroke(stroke_width, BasicStroke.CAP_ROUND,BasicStroke.JOIN_ROUND));
           g2.drawLine(last_x, last_y,x,y);
            //g2.drawArc ( 0, 0, getWidth (), getHeight (), 80, -245 );
           //g2.draw(new Line2D.Double(x, y, stroke_width, stroke_width));

            //g2.drawArc(last_x, last_y, getWidth (), getHeight (), 90, 60);

           //g2.drawArc(x1, y1, last_x, last_y,5,5);

             QuadCurve2D.Double curve = new QuadCurve2D.Double(last_x, last_y,x1,y1,x,y);
             g2.draw(curve);



           //CubicCurve2D c = new CubicCurve2D .Float();
           //c.setCurve(x1, y1, last_x, last_y, x, y,x1,y1);
          // g2.draw(c);

       };

推荐答案


这篇关于在java中绘制简单的曲线的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

05-28 15:28
查看更多