-fill campagne autoroute

This commit is contained in:
2026-02-22 21:57:02 +01:00
parent 7bb44b019e
commit cb3b3d0e35
5 changed files with 158 additions and 2 deletions

48
src/linea/Voiture.java Normal file
View File

@@ -0,0 +1,48 @@
package linea;
import java.awt.BasicStroke;
import java.awt.Color;
import java.awt.Graphics;
import java.awt.Graphics2D;
import java.awt.geom.Arc2D;
public class Voiture extends Cercle { // Hérite de Cercle
// On définit les couleurs directement ici pour simplifier
private Color couleurArriere = Color.GRAY;
private Color couleurAvant = Color.GRAY;
public Voiture() {
super();
this.rayon = 25;
}
@Override
void Afficher(Graphics g) {
Graphics2D g2D = (Graphics2D) g;
g2D.setStroke(new BasicStroke(5.0f));
// 1. DESSINER LE DEMI-CERCLE ARRIERE (Au fond)
g2D.setColor(couleurArriere);
// Utilisation de rayon*2 pour la largeur et hauteur (cercle parfait)
g2D.draw(new Arc2D.Double(x - rayon, y - rayon, rayon * 2, rayon * 2, 90, 180, Arc2D.OPEN));
// 2. DESSINER LA VOITURE (Au milieu)
g.setColor(new Color(150, 50, 200));
g.fillRect((int)x - 20, (int)y - 5, 40, 12);
g.setColor(Color.CYAN);
g.fillRect((int)x - 10, (int)y - 15, 20, 10);
g.setColor(Color.DARK_GRAY);
g.fillOval((int)x - 15, (int)y + 3, 10, 10);
g.fillOval((int)x + 5, (int)y + 3, 10, 10);
g.setColor(Color.YELLOW);
g.fillOval((int)x + 15, (int)y - 2, 6, 6);
// 3. DESSINER LE DEMI-CERCLE AVANT (Par-dessus)
g2D.setColor(couleurAvant);
g2D.draw(new Arc2D.Double(x - rayon, y - rayon, rayon * 2, rayon * 2, 90, -180, Arc2D.OPEN));
}
}