This commit is contained in:
2022-03-08 17:15:30 +01:00
parent a5665f3b23
commit ae43ed1b4f
18 changed files with 185 additions and 19 deletions

Binary file not shown.

View File

@@ -0,0 +1,20 @@
import javax.swing.*;
import java.awt.*;
public class Cercles {
public static void main(String[] args) {
JFrame f = new JFrame("Cercles");
f.setSize(500, 500);
f.setLocation(100, 100);
f.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
f.setLayout(null);
Circles c = new Circles();
c.setSize(485, 460);
c.setLocation(0, 0);
f.add(c);
f.setResizable(false);
f.setVisible(true);
}
}

Binary file not shown.

View File

@@ -0,0 +1,31 @@
import javax.swing.*;
import java.awt.*;
public class Circles extends JComponent {
public Circles() {
super();
}
@Override
protected void paintComponent(Graphics brush) {
Graphics newBrush = brush.create();
if (this.isOpaque()) {
newBrush.setColor(this.getBackground());
newBrush.fillRect(0, 0, this.getWidth(), this.getHeight());
}
for (int x = 0; x < 5; x++) {
for (int y = 0; y < 5; y++) {
Color c = new Color(0, 70 + 37 * y, 70 + 37 * x);
int sizeX = getWidth() / 5;
int sizeY = getHeight() / 5;
newBrush.setColor(c);
newBrush.fillOval(sizeX * x, sizeY * y, sizeX, sizeY);
newBrush.setColor(Color.WHITE);
newBrush.fillOval(sizeX * x + sizeX / 4, sizeY * y + sizeY / 4, sizeX / 2, sizeY / 2);
}
}
}
}