From 4be9e494746d332ee434aab54b63877306fb9503 Mon Sep 17 00:00:00 2001 From: Simoes Lukas Date: Thu, 9 Oct 2025 16:14:30 +0200 Subject: [PATCH] flocon --- DEV3.2/TP02/05_Flocon/Fenetre.class | Bin 0 -> 569 bytes DEV3.2/TP02/05_Flocon/JFlocon.class | Bin 0 -> 1977 bytes DEV3.2/TP02/05_Flocon/JFlocon.java | 65 +++++++++++++++++++++++++++- DEV3.2/TP02/05_Flocon/Main.class | Bin 0 -> 408 bytes 4 files changed, 63 insertions(+), 2 deletions(-) create mode 100644 DEV3.2/TP02/05_Flocon/Fenetre.class create mode 100644 DEV3.2/TP02/05_Flocon/JFlocon.class create mode 100644 DEV3.2/TP02/05_Flocon/Main.class diff --git a/DEV3.2/TP02/05_Flocon/Fenetre.class b/DEV3.2/TP02/05_Flocon/Fenetre.class new file mode 100644 index 0000000000000000000000000000000000000000..2c99afaab236a5692ab0686d3a78d8f1a81c3b7e GIT binary patch literal 569 zcmX^0Z`VEs1_pBm9WDk|1~E%QjC^^+F6U5V*l=Yhloc^I@9v>6%Lp%yYSFl&IE$zGgV5}a9;%E-W~;R$v)cX4Wo zPkwS@NoIZ?BZEY7YKco~T4HHViE~bVajJhoY7tb56QmGqDId#mFGQAjrVT zAjH7Hkk7!%z{J47V6C;Cfl*6(D+803AmbN7#xL6#n6(5_1X8v!uxPPuV_?(T&A=YX z!m^!#V;cjf)@}x_Na^hi+}jv literal 0 HcmV?d00001 diff --git a/DEV3.2/TP02/05_Flocon/JFlocon.class b/DEV3.2/TP02/05_Flocon/JFlocon.class new file mode 100644 index 0000000000000000000000000000000000000000..12913be157160524fa4aae670a4033e38072d9a2 GIT binary patch literal 1977 zcmX^0Z`VEs1_pD6QZ5Ds21`x`c?K(X25T+`W(dcIi@}h=mWx52!45>&gSZYLmLrI8 z0&$%=8C)1#L0mVGHg^!=!Oq~x$sow!1tPrJ8GN`HL>PQQs{Oba1R4B6sslg@1KAun z7{GvwA&4QE%|QapVPIznVP^lsE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Y!bQ!e3F{965%3#3Y zz+lAS#bC@3!eGJ>$6&_52+HyhM>1+Na4@hlFfd$~oy8yl3N-C)43gm>h7O3aoZ$e- zO|05m7=$u(wlD}Ku;qX_!XS=t0vpILRxBVTAQfN*tT`eKQac!Aw6`z_>ug~VPHE2; zVUW%5OMwX_z*K;ggS5d_Y-bR+VucyT3X;x9V9NpN195~w9FP(=Ep15_S(X$~fJm}P zvcj0Gl58+0n+}8p3LHqJn=$Z$(>e=-6$3AWHG?FBErSh%6N4XvGeZG`3qvP^C&L;B nKZb1#{tO2h0vOIP1TtJ>2nI(s8v~Q%Z-zY#j11=BTx0 points; + private int[] coordX; + private int[] coordY; public JFlocon(int ordre) { this.ordre = ordre; + this.points = new ArrayList(); } @Override @@ -14,10 +19,66 @@ public class JFlocon extends JComponent { Graphics secondPinceau = pinceau.create(); if (this.isOpaque()) { - this.setColor(this.getBackgroundColor()); - this.fillRect(0, 0, this.getWidth(), this.getHeight()); + secondPinceau.setColor(this.getBackground()); + secondPinceau.fillRect(0, 0, this.getWidth(), this.getHeight()); } + secondPinceau.setColor(Color.BLUE); + this.calculCoordonnees(); + + int[] coordX = new int[this.points.size()]; + int[] coordY = new int[this.points.size()]; + + for (int i = 0; i != this.points.size(); i++) { + coordX[i] = points.get(i).x; + coordY[i] = points.get(i).y; + } + + Polygon p = new Polygon(coordX, coordY, this.points.size()); + + secondPinceau.drawPolygon(p); + + } + + public void calculCoordonnees() { + Point a = new Point(this.getWidth()/4, this.getHeight()/4); + Point b = new Point(this.getWidth()/4*3, this.getHeight()/4); + Point c = new Point( + this.getWidth()/2, + this.getHeight()/4*3 + ); + segment(a, b, this.ordre); + segment(b, c, this.ordre); + segment(c, a, this.ordre); } + + public void segment(Point debut, Point fin, int ordre) { + if (ordre == 0) { + this.points.add(debut); + this.points.add(fin); + } else { + Point p2 = new Point( + (2 * debut.x + fin.x) / 3, + (2 * debut.y + fin.y) / 3 + ); + + Point p3 = new Point( + (debut.x + fin.x) / 2 - (int) (Math.sqrt(3) * (debut.y - fin.y) / 6), + (debut.y + fin.y) / 2 - (int) (Math.sqrt(3) * (fin.x - debut.x) / 6) + ); + + + + Point p4 = new Point( + (debut.x + 2 * fin.x) / 3, + (debut.y + 2 * fin.y) / 3 + ); + + segment(debut, p2, ordre-1); + segment(p2, p3, ordre-1); + segment(p3, p4, ordre-1); + segment(p4, fin, ordre-1); + } + } } \ No newline at end of file diff --git a/DEV3.2/TP02/05_Flocon/Main.class b/DEV3.2/TP02/05_Flocon/Main.class new file mode 100644 index 0000000000000000000000000000000000000000..717bdfa816ccf28c38537732a7adffd7bef81a16 GIT binary patch literal 408 zcmX^0Z`VEs1_pBmIW7iv1_5>kK`sU%24OA+CI%4@A5} zp&7==z~Y>rlFG=y?~|FA>Q|bZlv)&$n3R*s$iR}Dn3>1OAf^%Rla*MOsGpOVm#!aN zQk0pOZVl4N6`WsMl$`382~y1Io0yrW2U5qwz`?-D$iVKFnwMHql*-N^!NVZQAO#YZ z=3$UwkY!|G0V!r=5CAEM80(*um6}|_$RLOi^2{qqO;0UiWZ)=BEGka*%qwAJ5Y@oq z6i-G577b6Zi;7cA!ZM39A