diff --git a/Affichage/Affiche.class b/Affichage/Affiche.class new file mode 100644 index 0000000..95e24ea Binary files /dev/null and b/Affichage/Affiche.class differ diff --git a/Affichage/Affiche.java b/Affichage/Affiche.java new file mode 100644 index 0000000..a402deb --- /dev/null +++ b/Affichage/Affiche.java @@ -0,0 +1,55 @@ +import javax.swing.*; +import java.awt.*; + +class Affiche extends JComponent { + + @Override + protected void paintComponent(Graphics g) { + super.paintComponent(g); + + if (isOpaque()) { + g.setColor(getBackground()); + g.fillRect(0, 0, getWidth(), getHeight()); + } + + Graphics2D pinceau = (Graphics2D) g.create(); + + int pionTaille = 50; + int pas = 70; + int yBase = 60; + int tabJeu[][] = {{0,0,1,2,0,0,0,0,0}, + {0,1,2,1,2,0,0,0,0}, + {0,2,1,2,1,2,1,0,0}, + {0,1,2,1,2,1,2,1,2}, + {1,2,1,2,0,2,1,2,1}, + {2,1,2,1,2,1,2,1,0}, + {0,0,1,2,1,2,1,2,0}, + {0,0,0,0,2,1,2,1,0}, + {0,0,0,0,0,2,1,0,0}}; + + for (int i = 0; i < pionsParLigne.length; i++) { + int nbPions = pionsParLigne[i]; + int x = 60 + decalageLigne[i]; + int y = yBase + i * pas; + + for (int j = 0; j < nbPions; j++) { + if ((i+j) % 2 == 0) + pinceau.setColor(Color.BLUE); + else + pinceau.setColor(Color.RED); + + pinceau.fillOval(x + j * pas, y, pionTaille, pionTaille); + } + } + + pinceau.dispose(); + } + + public static void main(String[] args) { + JFrame fenetre = new JFrame("Forme diagonale miroir"); + fenetre.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); + fenetre.setSize(900, 800); + fenetre.add(new Affiche()); + fenetre.setVisible(true); + } +} diff --git a/Affichage/Test.class b/Affichage/Test.class new file mode 100644 index 0000000..594955f Binary files /dev/null and b/Affichage/Test.class differ diff --git a/Affichage/Test.java b/Affichage/Test.java new file mode 100644 index 0000000..3b5317d --- /dev/null +++ b/Affichage/Test.java @@ -0,0 +1,15 @@ +import javax.swing.*; + +public class Test { + public static void main(String[] args) { + JFrame fenetre = new JFrame(); + fenetre.setSize(1500, 1050); + fenetre.setLocation(150, 30); + fenetre.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); + + Affiche aff = new Affiche(); + fenetre.add(aff); + + fenetre.setVisible(true); + } +} \ No newline at end of file