Files
projet-dev/src/Ligne.java

52 lines
950 B
Java
Raw Normal View History

2026-02-02 11:40:03 +01:00
package linea;
2026-02-02 11:19:18 +01:00
import java.awt.BasicStroke;
import java.awt.Color;
import java.awt.Graphics;
import java.awt.Graphics2D;
import java.util.ArrayList;
public class Ligne extends ObjetGraphique {
2026-02-02 11:19:18 +01:00
protected int nbSegments = 400;
protected double xCercle = 400;
2026-02-02 11:19:18 +01:00
protected Segment SegCourant;
protected ArrayList<Segment> listeSegments = new ArrayList<Segment>();
2026-02-02 11:19:18 +01:00
public Ligne(){
double x = 800;
double y = 200;
double dx,dy;
2026-02-02 11:19:18 +01:00
Segment s;
for (int i=0; i<nbSegments; i++){
dx = Math.random()*20+80;
dy = Math.random()*40-20;
s = new Segment(x,y,dx,dy);
s.setCouleur(new Color(0.2f,0.2f,0.2f));
listeSegments.add(s);
2026-02-02 11:19:18 +01:00
x+=dx;
y+=dy;
}
}
@Override
public void Afficher(Graphics g){
Graphics2D g2D = (Graphics2D) g;
g2D.setStroke(new BasicStroke(3.0f));
for(Segment s : listeSegments) {
s.Afficher(g);
}
2026-02-02 11:19:18 +01:00
}
@Override
public void Animer() {
for(Segment s : listeSegments) {
s.Animer();
}
2026-02-02 11:19:18 +01:00
}
}