This commit is contained in:
HORVILLE 2022-10-14 17:25:23 +02:00
parent a3cf02fac4
commit a2f0837add
7 changed files with 21707 additions and 24 deletions

View File

@ -9,7 +9,7 @@ public class Flocon extends Polygon {
super(); super();
} }
private int floc(int n, int offset) { private int floc(int n, int offset, int aoffset) {
if (n < 0) return offset+1; if (n < 0) return offset+1;
Vector2 local = ptable[offset].toLocal(ptable[offset+1]); Vector2 local = ptable[offset].toLocal(ptable[offset+1]);
local.div(3); local.div(3);
@ -18,34 +18,34 @@ public class Flocon extends Polygon {
ptable[offset+1] = s1; ptable[offset+1] = s1;
if (n > 0) { if (n > 0) {
offset = floc(n-1, offset); offset = floc(n-1, offset, aoffset);
} else offset++; } else offset++;
Vector2 s2 = Vector2.add(s1, Vector2.rotate(local, -60)); Vector2 s2 = Vector2.add(s1, Vector2.rotate(local, -60 - aoffset));
ptable[offset+1] = s2; ptable[offset+1] = s2;
if (n > 0) { if (n > 0) {
offset = floc(n-1, offset); offset = floc(n-1, offset, aoffset);
} else offset++; } else offset++;
Vector2 s3 = Vector2.add(s2, Vector2.rotate(local, 60)); Vector2 s3 = Vector2.add(s2, Vector2.rotate(local, 60 + aoffset));
ptable[offset+1] = s3; ptable[offset+1] = s3;
if (n > 0) { if (n > 0) {
offset = floc(n-1, offset); offset = floc(n-1, offset, aoffset);
} else offset++; } else offset++;
Vector2 s4 = Vector2.add(s3, local); Vector2 s4 = Vector2.add(s3, local);
ptable[offset+1] = s4; ptable[offset+1] = s4;
if (n > 0) { if (n > 0) {
offset = floc(n-1, offset); offset = floc(n-1, offset, aoffset);
} else offset++; } else offset++;
return offset; return offset;
} }
public void createFloc(int x, int y, int r, int n) { public void createFloc(int x, int y, int r, int n, int aoffset) {
int size = 4; int size = 4;
for (int i = 0; i < n; i++) size = size * 4 - 3; for (int i = 0; i < n; i++) size = size * 4 - 3;
this.ptable = new Vector2[size]; this.ptable = new Vector2[size];
@ -53,13 +53,13 @@ public class Flocon extends Polygon {
ptable[0] = Vector2.rotate(new Vector2(0, -r),-60).add(new Vector2(x, y)); ptable[0] = Vector2.rotate(new Vector2(0, -r),-60).add(new Vector2(x, y));
ptable[1] = Vector2.rotate(new Vector2(0, -r), 60).add(new Vector2(x, y)); ptable[1] = Vector2.rotate(new Vector2(0, -r), 60).add(new Vector2(x, y));
offset = floc(n-1, offset); offset = floc(n-1, offset, aoffset);
ptable[offset+1] = Vector2.rotate(new Vector2(0, -r), 180).add(new Vector2(x, y)); ptable[offset+1] = Vector2.rotate(new Vector2(0, -r), 180).add(new Vector2(x, y));
offset = floc(n-1, offset); offset = floc(n-1, offset, aoffset);
ptable[offset+1] = Vector2.rotate(new Vector2(0, -r), -60).add(new Vector2(x, y)); ptable[offset+1] = Vector2.rotate(new Vector2(0, -r), -60).add(new Vector2(x, y));
floc(n-1, offset); floc(n-1, offset, aoffset);
for (Vector2 v : ptable) { for (Vector2 v : ptable) {
@ -76,11 +76,29 @@ public class Flocon extends Polygon {
f.setSize(1200, 1200); f.setSize(1200, 1200);
Flocon p = new Flocon(); Flocon p = new Flocon();
p.createFloc(f.getWidth() / 2, f.getHeight() / 2 - 100, 500, 5); p.createFloc(f.getWidth() / 2, f.getHeight() / 2 - 100, 500, 4, 0);
FloconPanel fp = new FloconPanel(p);
f.add(new FloconPanel(p)); f.add(fp);
f.setVisible(true); f.setVisible(true);
int a = 0;
while(true) {
try {
Thread.sleep(16);
} catch (Exception e) {
}
a += 1;
p.xpoints = new int[0];
p.ypoints = new int[0];
p.npoints = 0;
p.createFloc(f.getWidth() / 2, f.getHeight() / 2 - 100, 500, 4, a);
fp.repaint();
}
} }
} }

14745
DEV 3.4/Ex5/DC.mdj Normal file

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

View File

@ -0,0 +1,6 @@
Le jardinier Papé14 visionne la parcelle initiale du jardin.
Il constate qu'elle est divisée verticalement.
Il sélectionne la parcelle de gauche.
Il affiche les informations de la parcelle P1.
Il constate qu'elle est divisée horizontalement.
Il décide donc de réunir la parcelle P1.

View File

@ -1,6 +1,4 @@
import java.awt.BorderLayout; import java.awt.BorderLayout;
import java.awt.Color;
import java.awt.Dimension;
import javax.swing.JFrame; import javax.swing.JFrame;
/** /**
@ -9,15 +7,25 @@ import javax.swing.JFrame;
public class Fun { public class Fun {
public static void main(String[] args) { public static void main(String[] args) {
FunPanel p = new FunPanel();
JFrame frame = new JFrame(); JFrame frame = new JFrame();
frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
frame.setLocation(100, 100); frame.setLocation(100, 100);
frame.setSize(700, 700); frame.setSize(700, 700);
frame.add(p); FunPanel p = new FunPanel();
frame.add(p, BorderLayout.CENTER);
frame.setVisible(true); frame.setVisible(true);
while (true) {
FunPanel.table += 0.001d;
p.repaint(); p.repaint();
try {
Thread.sleep(16L);
} catch (Exception e) {
}
}
} }
} }

View File

@ -2,8 +2,8 @@ import javax.swing.JPanel;
import java.awt.*; import java.awt.*;
public class FunPanel extends JPanel { public class FunPanel extends JPanel {
private int table = 3; public static double table = 50;
private int limit = 150; public static int limit = 30;
public FunPanel() { public FunPanel() {
super(); super();
@ -18,14 +18,25 @@ public class FunPanel extends JPanel {
gg.fillRect(this.getX(), this.getY(), getWidth(), getHeight()); gg.fillRect(this.getX(), this.getY(), getWidth(), getHeight());
} }
double size = (double)getX(); double size = (double)(getWidth() > getHeight() ? getHeight() : getWidth()) / 2.5d;
System.out.println(size);
gg.setColor(Color.RED); gg.setColor(Color.BLACK);
for (double i = 0; i < limit; i++) { for (double i = 0; i < limit; i++) {
double theta = (i / (double)limit) * Math.PI * 2; double theta = (i / (double)limit) * Math.PI * 2;
gg.fillOval((int)(Math.cos(theta) * size) + getX() / 2, (int)(Math.sin(theta) * size) + getY() / 2, 10, 10); gg.fillOval((int)(Math.cos(theta) * size) + getWidth() / 2, (int)(Math.sin(theta) * size) + getHeight() / 2, 6, 6);
for (double j = 0; j < limit; j++) {
double theta2 = (table * j / (double)limit) * Math.PI * 2;
int x1 = (int)(Math.cos(theta) * size) + getWidth() / 2;
int x2 = (int)(Math.cos(theta2) * size) + getWidth() / 2;
int y1 = (int)(Math.sin(theta) * size) + getHeight() / 2;
int y2 = (int)(Math.sin(theta2) * size) + getHeight() / 2;
gg.drawLine(x1 + 3, y1 + 3, x2 + 3, y2 + 3);
}
} }
} }
} }

20
Fun/pointeurs.c Normal file
View File

@ -0,0 +1,20 @@
#include <stdio.h>
#include <stdlib.h>
struct t {
int a;
int b;
char c;
};
typedef struct t quatre;
int main(int argc, char** argv) {
quatre katr = {2, 3, 'q'};
printf("%d\n", katr.a);
quatre* katreu = &katr;
printf("%d\n", katreu->b);
}