1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32
|
public void paintComponent(Graphics g){
g.setColor(Color.black);
int a = (int) (p1.gtX() - p2.gtX());
int b = (int) (p1.gtY() - p2.gtY());
int a2 = (int)Math.sqrt(a*a+b*b);
int x= (int) ((p1.gtX()+p2.gtX())/2)-a2/2;
int y=(int) ((p1.gtY()+p2.gtY())/2)-a2/2;
g.drawOval(x, y,a2, a2 );
Cercle c = new Cercle(x,y);
for(int i=0;i<50;i++)
{
try {
g.setColor(Color.red);
g.fillRect(0, 0, 800, 600);
c.setRayon(a2/2);
Vecteur v = new Vecteur(3,4);
v.translation(c.getCentre());
Thread.sleep(10);
g.setColor(Color.black);
g.drawOval(c.getCentre().gtX(), c.getCentre().gtY(), 2*(int)c.getRayon(),2*(int) c.getRayon());
}
catch (InterruptedException e) {
// TODO Auto-generated catch block
e.printStackTrace();
} |
Partager