code program
import javax.swing.*;
import java.awt.*;
import java.awt.event.*;
import java.math.*;
class garis
{
double x1=0;double y1=0;double x2=0;double y2=0;
double x_inc,y_inc;
double dx,dy,max;
public void set_x_y(int x11,int y11,int x22,int y22)
{
x1=x11;y1=y11;
x2=x22;y2=y22;
}
public void d_x()
{
dx=x2-x1;
}
public void d_y()
{
dy=y2-y1;
}
public void maximum()
{
if(dx<=dy)
{
max = dy;
}
else
{
max = dx;
}
}
public void Xinc()
{
x_inc = (double)dx/(double)max;
}
public void Yinc()
{
y_inc = (double)dy/(double)max;
}
}
class bazier_4_point
{
double x1,x2,x3,x4;
double y1,y2,y3,y4;
double x,y,xt,yt;
double t=0.005;
double ax,bx,cx;
double ay,by,cy;
public void set_x_y(double x_1,double y_1,double x_2,double y_2,double x_3,double y_3,double x_4,double y_4)
{
x1=x_1;x2=x_2;x3=x_3;x4=x_4;
y1=y_1;y2=y_2;y3=y_3;y4=y_4;
}
public void hitung_abc_x()
{
cx=3.0*(x2-x1);
bx=3.0*(x3-x2)-cx;
ax=x4-x1-cx-bx;
}
public void hitung_abc_y()
{
cy=3.0*(y2-y1);
by=3.0*(y3-y2)-cy;
ay=y4-y1-cy-by;
}
}
class bazier_3_point
{
double x1,x2,x3;
double y1,y2,y3;
double x,y,xt,yt;
double t=0.005;
double ax,bx;
double ay,by;
public void set_x_y(double x_1,double y_1,double x_2,double y_2,double x_3,double y_3)
{
x1=x_1;x2=x_2;x3=x_3;
y1=y_1;y2=y_2;y3=y_3;
}
public void hitung_ab_x()
{
bx=2.0*(x2-x1);
ax=x3-x1-bx;
 : }
public void hitung_ab_y()
{
by=2.0*(y2-y1);
ay=y3-y1-by;
}
}
class canvas extends Canvas
{
private garis grs = new garis();
private bazier_4_point bzr4 = new bazier_4_point();
private bazier_3_point bzr3 = new bazier_3_point();
public void paint(Graphics g)
{
//garis tengah
/*grs.set_x_y(300,0,300,750);grs.d_x();grs.d_y();grs.maximum();grs.Xinc();grs.Yinc();
for(int i=0;i<grs.max;i++)
{
g.drawLine((int)grs.x1,(int)grs.y1,(int)Math.ceil(grs.x1+grs.x_inc),(int)Math.ceil(grs.y1+grs.y_inc));
grs.x1=grs.x1+grs.x_inc;
grs.y1=grs.y1+grs.y_inc;
}*/
//////susi kiri////
//1
grs.set_x_y(300,10,280,20);grs.d_x();grs.d_y();grs.maximum();grs.Xinc();grs.Yinc();
for(int i=0;i<grs.max;i++)
{
g.drawLine((int)grs.x1,(int)grs.y1,(int)Math.ceil(grs.x1+grs.x_inc),(int)Math.ceil(grs.y1+grs.y_inc));
grs.x1=grs.x1+grs.x_inc;
grs.y1=grs.y1+grs.y_inc;
}
//2
grs.set_x_y(280,20,285,35);grs.d_x();grs.d_y();grs.maximum();grs.Xinc();grs.Yinc();
for(int i=0;i<grs.max;i++)
{
g.drawLine((int)grs.x1,(int)grs.y1,(int)Math.ceil(grs.x1+grs.x_inc),(int)Math.ceil(grs.y1+grs.y_inc));
grs.x1=grs.x1+grs.x_inc;
grs.y1=grs.y1+grs.y_inc;
}
//3
grs.set_x_y(240,35,285,35);grs.d_x();grs.d_y();grs.maximum();grs.Xinc();grs.Yinc();
for(int i=0;i<grs.max;i++)
{
g.drawLine((int)grs.x1,(int)grs.y1,(int)Math.ceil(grs.x1+grs.x_inc),(int)Math.ceil(grs.y1+grs.y_inc));
grs.x1=grs.x1+grs.x_inc;
grs.y1=grs.y1+grs.y_inc;
}
//4
grs.set_x_y(240,35,240,65);grs.d_x();grs.d_y();grs.maximum();grs.Xinc();grs.Yinc();
for(int i=0;i<grs.max;i++)
{
g.drawLine((int)grs.x1,(int)grs.y1,(int)Math.ceil(grs.x1+grs.x_inc),(int)Math.ceil(grs.y1+grs.y_inc));
grs.x1=grs.x1+grs.x_inc;
grs.y1=grs.y1+grs.y_inc;
}
//5
grs.set_x_y(240,65,270,65);grs.d_x();grr.d_y();grs.maximum();grs.Xinc();grs.Yinc();
for(int i=0;i<grs.max;i++)
{
g.drawLine((int)grs.x1,(int)grs.y1,(int)Math.ceil(grs.x1+grs.x_inc),(int)Math.ceil(grs.y1+grs.y_inc));
grs.x1=grs.x1+grs.x_inc;
grs.y1=grs.y1+grs.y_inc;
}
//6
grs.set_x_y(270,65,260,85);grs.d_x();grs.d_y();grs.maximum();grs.Xinc();grs.Yinc();
for(int i=0;i<grs.max;i++)
{
g.drawLine((int)grs.x1,(int)grs.y1,(int)Math.ceil(grs.x1+grs.x_inc),(int)Math.ceil(grs.y1+grs.y_inc));
grs.x1=grs.x1+grs.x_inc;
grs.y1=grs.y1+grs.y_inc;
}
//7
grs.set_x_y(260,85,300,85);grs.d_x();grs.d_y();grs.maximum();grs.Xinc();grs.Yinc();
for(int i=0;i<grs.max;i++)
{
g.drawLine((int)grs.x1,(int)grs.y1,(int)Math.ceil(grs.x1+grs.x_inc),(int)Math.ceil(grs.y1+grs.y_inc));
grs.x1=grs.x1+grs.x_inc;
grs.y1=grs.y1+grs.y_inc;
}
//grs bayangan
//1
grs.set_x_y(295,5,300,10);grs.d_x();grs.d_y();grs.maximum();grs.Xinc();grs.Yinc();
for(int i=0;i<grs.max;i++)
{
g.drawLine((int)grs.x1,(int)grs.y1,(int)Math.ceil(grs.x1+grs.x_inc),(int)Math.ceil(grs.y1+grs.y_inc));
grs.x1=grs.x1+grs.x_inc;
grs.y1=grs.y1+grs.y_inc;
}
//2
grs.set_x_y(275,15,295,5);grs.d_x();grs.d_y();grs.maximum();grs.Xinc();grs.Yinc();
for(int i=0;i<grs.max;i++)
{
g.drawLine((int)grs.x1,(int)grs.y1,(int)Math.ceil(grs.x1+grs.x_inc),(int)Math.ceil(grs.y1+grs.y_inc));
grs.x1=grs.x1+grs.x_inc;
grs.y1=grs.y1+grs.y_inc;
}
//3
grs.set_x_y(275,15,280,20);grs.d_x();grs.d_y();grs.maximum();grs.Xinc();grs.Yinc();
for(int i=0;i<grs.max;i++)
{
g.drawLine((int)grs.x1,(int)grs.y1,(int)Math.ceil(grs.x1+grs.x_inc),(int)Math.ceil(grs.y1+grs.y_inc));
grs.x1=grs.x1+grs.x_inc;
grs.y1=grs.y1+grs.y_inc;
}
//4
grs.set_x_y(275,15,278,28);grs.d_x();grs.d_y();grs.maximum();grs.Xinc();grs.Yinc();
for(int i=0;i<grs.max;i++)
{
g.drawLine((int)grs.x1,(int)grs.y1,(int)Math.ceil(grs.x1+grs.x_inc),(int)Math.ceil(grs.y1+grs.y_inc));
grs.x1=grs.x1+grs.x_inc;
grs.y1=grs.y1+grs.y_inc;
}
//5
grs.set_x_y(278,28,285,35);grs.d_x();grs.d_y();grs.maximum();grs.Xinc();grs.Yinc();
for(int i=0;i<grs.max;i++)
{
g.drawLine((int)grs.x1,(int)grs.y1,(int)Math.ceil(grs.x1+grs.x_inc),(int)Math.ceil(grs.y1+grs.y_inc));
grs.x1=grs.x1+grs.x_inc;
grs.y1=grs.y1+grs.y_inc;
}
//6
grs.set_x_y(235,28,278,28);grs.d_x();grs.d_y();grs.maximum();grs.Xinc();grs.Yinc();
for(int i=0;i<grs.max;i++)
{
g.drawLine((int)grs.x1,(int)grs.y1,(int)Math.ceil(grs.x1+grs.x_inc),(int)Math.ceil(grs.y1+grs.y_inc));
grs.x1=grs.x1+grs.x_inc;
grs.y1=grs.y1+grs.y_inc;
}
//7
grs.set_x_y(235,28,240,35);grs.d_x();grs.d_y();grs.maximum();grs.Xinc();grs.Yinc();
for(int i=0;i<grs.max;i++)
{
g.drawLine((int)grs.x1,(int)grs.y1,(int)Math.ceil(grs.x1+grs.x_inc),(int)Math.ceil(grs.y1+grs.y_inc));
grs.x1=grs.x1+grs.x_inc;
grs.y1=grs.y1+grs.y_inc;
}
//8
grs.set_x_y(235,28,235,60);grs.d_x();grs.d_y();grs.maximum();grs.Xinc();grs.Yinc();
for(int i=0;i<grs.max;i++)
{
g.drawLine((int)grs.x1,(int)grs.y1,(int)Math.ceil(grs.x1+grs.x_inc),(int)Math.ceil(grs.y1+grs.y_inc));
grs.x1=grs.x1+grs.x_inc;
grs.y1=grs.y1+grs.y_inc;
}
//9
grs.set_x_y(235,60,240,65);grs.d_x();grs.d_y();grs.maximum();grs.Xinc();grs.Yinc();
for(int i=0;i<grs.max;i++)
{
g.drawLine((int)grs.x1,(int)grs.y1,(int)Math.ceil(grs.x1+grs.x_inc),(int)Math.ceil(grs.y1+grs.y_inc));
grs.x1=grs.x1+grs.x_inc;
grs.y1=grs.y1+grs.y_inc;
}
//10
grs.set_x_y(255,80,260,85);grs.d_x();grs.d_y();grs.maximum();grs.Xinc();grs.Yinc();
for(int i=0;i<grs.max;i++)
{
g.drawLine((int)grs.x1,(int)grs.y1,(int)Math.ceil(grs.x1+grs.x_inc),(int)Math.ceil(grs.y1+grs.y_inc));
grs.x1=grs.x1+grs.x_inc;
grs.y1=grs.y1+grs.y_inc;
}
//11
grs.set_x_y(255,80,263,65);grs.d_x();grs.d_y();grs.maximum();grs.Xinc();grs.Yinc();
for(int i=0;i<grs.max;i++)
{
g.drawLine((int)grs.x1,(int)grs.y1,(int)Math.ceil(grs.x1+grs.x_inc),(int)Math.ceil(grs.y1+grs.y_inc));
grs.x1=grs.x1+grs.x_inc;
grs.y1=grs.y1+grs.y_inc;
}
//lengkung dengan bazier 4 point
//1
//g.drawLine(260,70,150,78);
//g.drawLine(150,120,300,120);
bzr4.set_x_y(260,70,150,78,150,120,300,120);bzr4.hitung_abc_x();bzr4.hitung_abc_y();
bzr4.x=bzr4.x1;bzr4.y=bzr4.y1;
for(double i=bzr4.t;i<=1+bzr4.t;i+=bzr4.t)
{
bzr4.xt=(bzr4.ax*i*i*i)+(bzr4.bx*i*i)+(bzr4.cx*i)+bzr4.x1;
bzr4.yt=(bzr4.ay*i*i*i)+(bzr4.by*i*i)+(bzr4.cy*i)+bzr4.y1;
g.drawLine((int)Math.ceil(bzr4.x),(int)Math.ceil(bzr4.y),(int)Math.ceil(bzr4.xt),(int)Math.ceil(bzr4.yt));
bzr4.x=bzr4.xt;
bzr4.y=bzr4.yt;
}
//1
grs.set_x_y(183,97,230,190);grs.d_x();grs.d_y();grs.maximum();grs.Xinc();grs.Yinc();
for(int i=0;i<grs.max;i++)
{
g.drawLine((int)grs.x1,(int)grs.y1,(int)Math.ceil(grs.x1+grs.x_inc),(int)Math.ceil(grs.y1+grs.y_inc));
grs.x1=grs.x1+grs.x_inc;
grs.y1=grs.y1+grs.y_inc;
}
//2
grs.set_x_y(230,208,230,223);grs.d_x();grs.d_y();grs.maximum();grs.Xinc();grs.Yinc();
for(int i=0;i<grs.max;i++)
{
g.drawLine((int)grs.x1,(int)grs.y1,(int)Math.ceil(grs.x1+grs.x_inc),(int)Math.ceil(grs.y1+grs.y_inc));
grs.x1=grs.x1+grs.x_inc;
grs.y1=grs.y1+grs.y_inc;
}
//3
grs.set_x_y(110,590,110,615);grs.d_x();grs.d_y();grs.maximum();grs.Xinc();grs.Yinc();
for(int i=0;i<grs.max;i++)
{
g.drawLine((int)grs.x1,(int)grs.y1,(int)Math.ceil(grs.x1+grs.x_inc),(int)Math.ceil(grs.y1+grs.y_inc));
grs.x1=grs.x1+grs.x_inc;
grs.y1=grs.y1+grs.y_inc;
}
//////// sisi kanan/////
//1
grs.set_x_y(300,10,320,20);grs.d_x();grs.d_y();grs.maximum();grs.Xinc();grs.Yinc();
for(int i=0;i<grs.max;i++)
{
g.drawLine((int)grs.x1,(int)grs.y1,(int)Math.ceil(grs.x1+grs.x_inc),(int)Math.ceil(grs.y1+grs.y_inc));
grs.x1=grs.x1+grs.x_inc;
grs.y1=grs.y1+grs.y_inc;
}
//2
grs.set_x_y(320,20,315,35);grs.d_x();grs.d_y();grs.maximum();grs.Xinc();grs.Yinc();
for(int i=0;i<grs.max;i++)
{
g.drawLine((int)grs.x1,(int)grs.y1,(int)Math.ceil(grs.x1+grs.x_inc),(int)Math.ceil(grs.y1+grs.y_inc));
grs.x1=grs.x1+grs.x_inc;
grs.y1=grs.y1+grs.y_inc;
}
//3
grs.set_x_y(315,35,360,35);grs.d_x();grs.d_y();grs.maximum();grs.Xinc();grs.Yinc();
for(int i=0;i<grs.max;i++)
{
g.drawLine((int)grs.x1,(int)grs.y1,(int)Math.ceil(grs.x1+grs.x_inc),(int)Math.ceil(grs.y1+grs.y_inc));
grs.x1=grs.x1+grs.x_inc;
grs.y1=grs.y1+grs.y_inc;
}
//4
grs.set_x_y(360,35,360,65);grs.d_x();grs.d_y();grs.maximum();grs.Xinc();grs.Yinc();
for(int i=0;i<grs.max;i++)
{
g.drawLine((int)grs.x1,(int)grs.y1,(int)Math.ceil(grs.x1+grs.x_inc),(int)Math.ceil(grs.y1+grs.y_inc));
grs.x1=grs.x1+grs.x_inc;
grs.y1=grs.y1+grs.y_inc;
}
//5
grs.set_x_y(330,65,360,65);grs.d_x();grs.d_y();grs.maximum();grs.Xinc();grs.Yinc();
for(int i=0;i<grs.max;i++)
{
g.drawLine((int)grs.x1,(int)grs.y1,(int)Math.ceil(grs.x1+grs.x_inc),(int)Math.ceil(grs.y1+grs.y_inc));
grs.x1=grs.x1+grs.x_inc;
grs.y1=grs.y1+grs.y_inc;
}
//6
grs.set_x_y(330,65,340,85);grs.d_x();grs.d_y();grs.maximum();grs.Xinc();grs.Yinc();
for(int i=0;i<grs.max;i++)
{
g.drawLine((int)grs.x1,(int)grs.y1,(int)Math.ceil(grs.x1+grs.x_inc),(int)Math.ceil(grs.y1+grs.y_inc));
grs.x1=grs.x1+grs.x_inc;
grs.y1=grs.y1+grs.y_inc;
}
//7
grs.set_x_y(300,85,340,85);grs.d_x();grs.d_y();grs.maximum();grs.Xinc();grs.Yinc();
for(int i=0;i<grs.max;i++)
{
g.drawLine((int)grs.x1,(int)grs.y1,(int)Math.ceil(grs.x1+grs.x_inc),(int)Math.ceil(grs.y1+grs.y_inc));
grs.x1=grs.x1+grs.x_inc;
grs.y1=grs.y1+grs.y_inc;
}
////garis bayangan
//1
grs.set_x_y(295,5,315,15);grs.d_x();grs.d_y();grs.maximum();grs.Xinc();grs.Yinc();
for(int i=0;i<grs.max;i++)
{
g.drawLine((int)grs.x1,(int)grs.y1,(int)Math.ceil(grs.x1+grs.x_inc),(int)Math.ceil(grs.y1+grs.y_inc));
grs.x1=grs.x1+grs.x_inc;
grs.y1=grs.y1+grs.y_inc;
}
//2
grs.set_x_y(315,15,320,20);grs.d_x();grs.d_y();grs.maximum();grs.Xinc();grs.Yinc();
for(int i=0;i<grs.max;i++)
{
g.drawLine((int)grs.x1,(int)grs.y1,(int)Math.ceil(grs.x1+grs.x_inc),(int)Math.ceil(grs.y1+grs.y_inc));
grs.x1=grs.x1+grs.x_inc;
grs.y1=grs.y1+grs.y_inc;
}
//3
grs.set_x_y(355,28,360,35);grs.d_x();grs.d_y();grs.maximum();grs.Xinc();grs.Yinc();
for(int i=0;i<grs.max;i++)
{
g.drawLine((int)grs.x1,(int)grs.y1,(int)Math.ceil(grs.x1+grs.x_inc),(int)Math.ceil(grs.y1+grs.y_inc));
grs.x1=grs.x1+grs.x_inc;
grs.y1=grs.y1+grs.y_inc;
}
//4
grs.set_x_y(318,28,355,28);grs.d_x();grs.d_y();grs.maximum();grs.Xinc();grs.Yinc();
for(int i=0;i<grs.max;i++)
{
g.drawLine((int)grs.x1,(int)grs.y1,(int)Math.ceil(grs.x1+grs.x_inc),(int)Math.ceil(grs.y1+grs.y_inc));
grs.x1=grs.x1+grs.x_inc;
grs.y1=grs.y1+grs.y_inc;
}
/////gambar lengkung dengan bezier 4 point
//1
//g.drawLine(333,70,450,78);
//g.drawLine(450,120,300,120);
bzr4.set_x_y(333,70,450,78,450,120,300,120);bzr4.hitung_abc_x();bzr4.hitung_abc_y();
bzr4.x=bzr4.x1;bzr4.y=bzr4.y1;
for(double i=bzr4.t;i<=1+bzr4.t;i+=bzr4.t)
{
bzr4.xt=(bzr4.ax*i*i*i)+(bzr4.bx*i*i)+(bzr4.cx*i)+bzr4.x1;
bzr4.yt=(bzr4.ay*i*i*i)+(bzr4.by*i*i)+(bzr4.cy*i)+bzr4.y1;
g.drawLine((int)Math.ceil(bzr4.x),(int)Math.ceil(bzr4.y),(int)Math.ceil(bzr4.xt),(int)Math.ceil(bzr4.yt));
bzr4.x=bzr4.xt;
bzr4.y=bzr4.yt;
}
//1
grs.set_x_y(418,97,370,190);grs.d_x();grs.d_y();grs.maximum();grs.Xinc();grs.Yinc();
for(int i=0;i<grs.max;i++)
{
g.drawLine((int)grs.x1,(int)grs.y1,(int)Math.ceil(grs.x1+grs.x_inc),(int)Math.ceil(grs.y1+grs.y_inc));
grs.x1=grs.x1+grs.x_inc;
grs.y1=grs.y1+grs.y_inc;
}
//2
grs.set_x_y(370,208,370,223);grs.d_x();grs.d_y();grs.maximum();grs.Xinc();grs.Yinc();
for(int i=0;i<grs.max;i++)
{
g.drawLine((int)grs.x1,(int)grs.y1,(int)Math.ceil(grs.x1+grs.x_inc),(int)Math.ceil(grs.y1+grs.y_inc));
grs.x1=grs.x1+grs.x_inc;
grs.y1=grs.y1+grs.y_inc;
}
//3
grs.set_x_y(490,590,490,615);grs.d_x();grs.d_y();grs.maximum();grs.Xinc();grs.Yinc();
for(int i=0;i<grs.max;i++)
{
g.drawLine((int)grs.x1,(int)grs.y1,(int)Math.ceil(grs.x1+grs.x_inc),(int)Math.ceil(grs.y1+grs.y_inc));
grs.x1=grs.x1+grs.x_inc;
grs.y1=grs.y1+grs.y_inc;
}
////setengah lingkaran kiri dan kanan bazier 3 point
//tambahan
grs.set_x_y(244,87,244,91);grs.d_x();grs.d_y();grs.maximum();grs.Xinc();grs.Yinc();
for(int i=0;i<grs.max;i++)
{
g.drawLine((int)grs.x1,(int)grs.y1,(int)Math.ceil(grs.x1+grs.x_inc),(int)Math.ceil(grs.y1+grs.y_inc));
grs.x1=grs.x1+grs.x_inc;
grs.y1=grs.y1+grs.y_inc;
}
grs.set_x_y(354,87,354,91);grs.d_x();grs.d_y();grs.maximum();grs.Xinc();grs.Yinc();
for(int i=0;i<grs.max;i++)
{
g.drawLine((int)grs.x1,(int)grs.y1,(int)Math.ceil(grs.x1+grs.x_inc),(int)Math.ceil(grs.y1+grs.y_inc));
grs.x1=grs.x1+grs.x_inc;
grs.y1=grs.y1+grs.y_inc;
}
//1
//g.drawLine(245,91,300,105);
//g.drawLine(300,105,354,91);
bzr3.set_x_y(244,91,300,105,354,91);bzr3.hitung_ab_x();bzr3.hitung_ab_y();
bzr3.x=bzr3.x1;bzr3.y=bzr3.y1;
for(double i=bzr3.t;i<=1+bzr3.t;i+=bzr3.t)
{
bzr3.xt=(bzr3.ax*i*i)+(bzr3.bx*i)+bzr3.x1;
bzr3.yt=(bzr3.ay*i*i)+(bzr3.by*i)+bzr3.y1;
g.drawLine((int)Math.ceil(bzr3.x),(int)Math.ceil(bzr3.y),(int)Math.ceil(bzr3.xt),(int)Math.ceil(bzr3.yt));
bzr3.x=bzr3.xt;
bzr3.y=bzr3.yt;
}
//2
//g.drawLine(230,190,300,208);
//g.drawLine(300,208,370,190);
bzr3.set_x_y(230,190,300,208,370,190);bzr3.hitung_ab_x();bzr3.hitung_ab_y();
bzr3.x=bzr3.x1;bzr3.y=bzr3.y1;
for(double i=bzr3.t;i<=1+bzr3.t;i+=bzr3.t)
{
bzr3.xt=(bzr3.ax*i*i)+(bzr3.bx*i)+bzr3.x1;
bzr3.yt=(bzr3.ay*i*i)+(bzr3.by*i)+bzr3.y1;
g.drawLine((int)Math.ceil(bzr3.x),(int)Math.ceil(bzr3.y),(int)Math.ceil(bzr3.xt),(int)Math.ceil(bzr3.yt));
bzr3.x=bzr3.xt;
bzr3.y=bzr3.yt;
}
//3
//g.drawLine(230,223,300,238);
//g.drawLine(300,238,370,223);
bzr3.set_x_y(230,223,300,238,370,223);bzr3.hitung_ab_x();bzr3.hitung_ab_y();
bzr3.x=bzr3.x1;bzr3.y=bzr3.y1;
for(double i=bzr3.t;i<=1+bzr3.t;i+=bzr3.t)
{
bzr3.xt=(bzr3.ax*i*i)+(bzr3.bx*i)+bzr3.x1;
bzr3.yt=(bzr3.ay*i*i)+(bzr3.by*i)+bzr3.y1;
g.drawLine((int)Math.ceil(bzr3.x),(int)Math.ceil(bzr3.y),(int)Math.ceil(bzr3.xt),(int)Math.ceil(bzr3.yt));
bzr3.x=bzr3.xt;
bzr3.y=bzr3.yt;
}
//4
//g.drawLine(200,500,300,530);
//g.drawLine(300,530,400,500);
bzr3.set_x_y(200,500,300,530,400,500);bzr3.hitung_ab_x();bzr3.hitung_ab_y();
bzr3.x=bzr3.x1;bzr3.y=bzr3.y1;
for(double i=bzr3.t;i<=1+bzr3.t;i+=bzr3.t)
{
bzr3.xt=(bzr3.ax*i*i)+(bzr3.bx*i)+bzr3.x1;
bzr3.yt=(bzr3.ay*i*i)+(bzr3.by*i)+bzr3.y1;
g.drawLine((int)Math.ceil(bzr3.x),(int)Math.ceil(bzr3.y),(int)Math.ceil(bzr3.xt),(int)Math.ceil(bzr3.yt));
bzr3.x=bzr3.xt;
bzr3.y=bzr3.yt;
}
//5
//g.drawLine(110,590,300,675);
//g.drawLine(300,675,490,590);
bzr3.set_x_y(110,590,300,675,490,590);bzr3.hitung_ab_x();bzr3.hitung_ab_y();
bzr3.x=bzr3.x1;bzr3.y=bzr3.y1;
for(double i=bzr3.t;i<=1+bzr3.t;i+=bzr3.t)
{
bzr3.xt=(bzr3.ax*i*i)+(bzr3.bx*i)+bzr3.x1;
bzr3.yt=(bzr3.ay*i*i)+(bzr3.by*i)+bzr3.y1;
g.drawLine((int)Math.ceil(bzr3.x),(int)Math.ceil(bzr3.y),(int)Math.ceil(bzr3.xt),(int)Math.ceil(bzr3.yt));
bzr3.x=bzr3.xt;
bzr3.y=bzr3.yt;
}
//6
//g.drawLine(110,615,300,700);
//g.drawLine(300,700,490,615);
bzr3.set_x_y(110,615,300,700,490,615);bzr3.hitung_ab_x();bzr3.hitung_ab_y();
bzr3.x=bzr3.x1;bzr3.y=bzr3.y1;
for(double i=bzr3.t;i<=1+bzr3.t;i+=bzr3.t)
{
bzr3.xt=(bzr3.ax*i*i)+(bzr3.bx*i)+bzr3.x1;
bzr3.yt=(bzr3.ay*i*i)+(bzr3.by*i)+bzr3.y1;
g.drawLine((int)Math.ceil(bzr3.x),(int)Math.ceil(bzr3.y),(int)Math.ceil(bzr3.xt),(int)Math.ceil(bzr3.yt));
bzr3.x=bzr3.xt;
bzr3.y=bzr3.yt;
}
////setengah linkaran kiri dan kanan bazier 4 point
//1
//g.drawLine(260,73,180,100);
//g.drawLine(420,100,335,75);
bzr4.set_x_y(260,73,180,100,420,100,335,75);bzr4.hitung_abc_x();bzr4.hitung_abc_y();
bzr4.x=bzr4.x1;bzr4.y=bzr4.y1;
for(double i=bzr4.t;i<=1+bzr4.t;i+=bzr4.t)
{
bzr4.xt=(bzr4.ax*i*i*i)+(bzr4.bx*i*i)+(bzr4.cx*i)+bzr4.x1;
bzr4.yt=(bzr4.ay*i*i*i)+(bzr4.by*i*i)+(bzr4.cy*i)+bzr4.y1;
g.drawLine((int)Math.ceil(bzr4.x),(int)Math.ceil(bzr4.y),(int)Math.ceil(bzr4.xt),(int)Math.ceil(bzr4.yt));
bzr4.x=bzr4.xt;
bzr4.y=bzr4.yt;
}
//2
//g.drawLine(230,190,150,220);
//g.drawLine(450,220,370,190);
bzr4.set_x_y(230,190,150,220,450,220,370,190);bzr4.hitung_abc_x();bzr4.hitung_abc_y();
bzr4.x=bzr4.x1;bzr4.y=bzr4.y1;
for(double i=bzr4.t;i<=1+bzr4.t;i+=bzr4.t)
{
bzr4.xt=(bzr4.ax*i*i*i)+(bzr4.bx*i*i)+(bzr4.cx*i)+bzr4.x1;
bzr4.yt=(bzr4.ay*i*i*i)+(bzr4.by*i*i)+(bzr4.cy*i)+bzr4.y1;
g.drawLine((int)Math.ceil(bzr4.x),(int)Math.ceil(bzr4.y),(int)Math.ceil(bzr4.xt),(int)Math.ceil(bzr4.yt));
bzr4.x=bzr4.xt;
bzr4.y=bzr4.yt;
}
//3
//g.drawLine(230,208,80,255);
//g.drawLine(520,255,370,208);
bzr4.set_x_y(230,208,80,255,520,255,370,208);bzr4.hitung_abc_x();bzr4.hitung_abc_y();
bzr4.x=bzr4.x1;bzr4.y=bzr4.y1;
for(double i=bzr4.t;i<=1+bzr4.t;i+=bzr4.t)
{
bzr4.xt=(bzr4.ax*i*i*i)+(bzr4.bx*i*i)+(bzr4.cx*i)+bzr4.x1;
bzr4.yt=(bzr4.ay*i*i*i)+(bzr4.by*i*i)+(bzr4.cy*i)+bzr4.y1;
g.drawLine((int)Math.ceil(bzr4.x),(int)Math.ceil(bzr4.y),(int)Math.ceil(bzr4.xt),(int)Math.ceil(bzr4.yt));
bzr4.x=bzr4.xt;
bzr4.y=bzr4.yt;
}
//4
//g.drawLine(200,225,50,280);
//g.drawLine(550,280,400,225);
bzr4.set_x_y(200,225,50,280,550,280,400,225);bzr4.hitung_abc_x();bzr4.hitung_abc_y();
bzr4.x=bzr4.x1;bzr4.y=bzr4.y1;
for(double i=bzr4.t;i<=1+bzr4.t;i+=bzr4.t)
{
bzr4.xt=(bzr4.ax*i*i*i)+(bzr4.bx*i*i)+(bzr4.cx*i)+bzr4.x1;
bzr4.yt=(bzr4.ay*i*i*i)+(bzr4.by*i*i)+(bzr4.cy*i)+bzr4.y1;
g.drawLine((int)Math.ceil(bzr4.x),(int)Math.ceil(bzr4.y),(int)Math.ceil(bzr4.xt),(int)Math.ceil(bzr4.yt));
bzr4.x=bzr4.xt;
bzr4.y=bzr4.yt;
}
//5
//g.drawLine(205,485,80,550);
//g.drawLine(520,550,395,485);
bzr4.set_x_y(205,485,50,550,550,550,395,485);bzr4.hitung_abc_x();bzr4.hitung_abc_y();
bzr4.x=bzr4.x1;bzr4.y=bzr4.y1;
for(double i=bzr4.t;i<=1+bzr4.t;i+=bzr4.t)
{
bzr4.xt=(bzr4.ax*i*i*i)+(bzr4.bx*i*i)+(bzr4.cx*i)+bzr4.x1;
bzr4.yt=(bzr4.ay*i*i*i)+(bzr4.by*i*i)+(bzr4.cy*i)+bzr4.y1;
g.drawLine((int)Math.ceil(bzr4.x),(int)Math.ceil(bzr4.y),(int)Math.ceil(bzr4.xt),(int)Math.ceil(bzr4.yt));
bzr4.x=bzr4.xt;
bzr4.y=bzr4.yt;
}
//lengkung ke atas kanan dan kiri dengan bazier 4 point
//1 kiri
//g.drawLine(200,500,245,400);
//g.drawLine(250,350,243,265);
bzr4.set_x_y(200,500,245,400,250,350,243,265);bzr4.hitung_abc_x();bzr4.hitung_abc_y();
bzr4.x=bzr4.x1;bzr4.y=bzr4.y1;
for(double i=bzr4.t;i<=1+bzr4.t;i+=bzr4.t)
{
bzr4.xt=(bzr4.ax*i*i*i)+(bzr4.bx*i*i)+(bzr4.cx*i)+bzr4.x1;
bzr4.yt=(bzr4.ay*i*i*i)+(bzr4.by*i*i)+(bzr4.cy*i)+bzr4.y1;
g.drawLine((int)Math.ceil(bzr4.x),(int)Math.ceil(bzr4.y),(int)Math.ceil(bzr4.xt),(int)Math.ceil(bzr4.yt));
bzr4.x=bzr4.xt;
bzr4.y=bzr4.yt;
}
//1 kanan
//g.drawLine(400,500,355,400);
//g.drawLine(350,350,357,265);
bzr4.set_x_y(400,500,355,400,350,350,357,265);bzr4.hitung_abc_x();bzr4.hitung_abc_y();
bzr4.x=bzr4.x1;bzr4.y=bzr4.y1;
for(double i=bzr4.t;i<=1+bzr4.t;i+=bzr4.t)
{
bzr4.xt=(bzr4.ax*i*i*i)+(bzr4.bx*i*i)+(bzr4.cx*i)+bzr4.x1;
bzr4.yt=(bzr4.ay*i*i*i)+(bzr4.by*i*i)+(bzr4.cy*i)+bzr4.y1;
g.drawLine((int)Math.ceil(bzr4.x),(int)Math.ceil(bzr4.y),(int)Math.ceil(bzr4.xt),(int)Math.ceil(bzr4.yt));
bzr4.x=bzr4.xt;
bzr4.y=bzr4.yt;
}
//2 kiri
//g.drawLine(175,505,185,570);
//g.drawLine(105,530,110,590);
bzr4.set_x_y(175,505,185,570,105,530,110,590);bzr4.hitung_abc_x();bzr4.hitung_abc_y();
bzr4.x=bzr4.x1;bzr4.y=bzr4.y1;
for(double i=bzr4.t;i<=1+bzr4.t;i+=bzr4.t)
{
bzr4.xt=(bzr4.ax*i*i*i)+(bzr4.bx*i*i)+(bzr4.cx*i)+bzr4.x1;
bzr4.yt=(bzr4.ay*i*i*i)+(bzr4.by*i*i)+(bzr4.cy*i)+bzr4.y1;
g.drawLine((int)Math.ceil(bzr4.x),(int)Math.ceil(bzr4.y),(int)Math.ceil(bzr4.xt),(int)Math.ceil(bzr4.yt));
bzr4.x=bzr4.xt;
bzr4.y=bzr4.yt;
}
//2 kanan
//g.drawLine(425,505,415,570);
//g.drawLine(495,530,490,590);
bzr4.set_x_y(425,505,415,570,495,530,490,590);bzr4.hitung_abc_x();bzr4.hitung_abc_y();
bzr4.x=bzr4.x1;bzr4.y=bzr4.y1;
for(double i=bzr4.t;i<=1+bzr4.t;i+=bzr4.t)
{
bzr4.xt=(bzr4.ax*i*i*i)+(bzr4.bx*i*i)+(bzr4.cx*i)+bzr4.x1;
bzr4.yt=(bzr4.ay*i*i*i)+(bzr4.by*i*i)+(bzr4.cy*i)+bzr4.y1;
g.drawLine((int)Math.ceil(bzr4.x),(int)Math.ceil(bzr4.y),(int)Math.ceil(bzr4.xt),(int)Math.ceil(bzr4.yt));
bzr4.x=bzr4.xt;
bzr4.y=bzr4.yt;
}
}
}
class frame extends JFrame
{
private canvas kanvas = new canvas();
frame()
{
super("gambar garis");
setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
setBackground(Color.blue);
setLocation(800,0);
setSize(600,750);
getContentPane().setLayout(new BorderLayout());
getContentPane().add(kanvas,BorderLayout.CENTER);
show();
}
}
class demo_gambar
{
public static void main(String[] args)
{
new frame();
}
}
Tidak ada komentar:
Posting Komentar