This commit is contained in:
2023-04-04 14:03:16 +02:00
parent 7021891e9c
commit e32d4de827
111 changed files with 1928 additions and 6 deletions

View File

@@ -0,0 +1,29 @@
import java.awt.;
import javax.swing.;
public class TileBackground extends JComponent {
private Image tile;
private int tileScale;
public TileBackground(int tileScale, String imagePath) {
super();
this.tile = Toolkit.getDefaultToolkit().getImage(imagePath);
this.tileScale = tileScale;
}
@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());
}
int horizontalReps = this.getWidth() / this.tileScale + 1;
int verticalReps = this.getHeight() / this.tileScale + 1;
for (int x = 0; x < horizontalReps; x++) {
for (int y = 0; y < verticalReps; y++) {
newBrush.drawImage(this.tile, x * tileScale, y * tileScale, tileScale, tileScale, this);
}
}
}
}

View File

@@ -0,0 +1,13 @@
import javax.swing.*;
public class Tuile2 {
public static void main(String[] args) {
JFrame f = new JFrame("Tuile");
f.setLocation(150, 150);
f.setSize(500, 500);
f.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
f.setVisible(true);
TileBackground tb = new TileBackground(150, "./tuile.jpg");
f.add(tb);
}
}