push
This commit is contained in:
BIN
DEV2.1/CTRLBLANC/Exo4/CrocsCars.class
Normal file
BIN
DEV2.1/CTRLBLANC/Exo4/CrocsCars.class
Normal file
Binary file not shown.
43
DEV2.1/CTRLBLANC/Exo4/CrocsCars.java
Normal file
43
DEV2.1/CTRLBLANC/Exo4/CrocsCars.java
Normal file
@@ -0,0 +1,43 @@
|
||||
import javax.swing.*;
|
||||
import java.awt.*;
|
||||
|
||||
public class CrocsCars extends JComponent{
|
||||
|
||||
private Image pingouin;
|
||||
|
||||
public CrocsCars(){
|
||||
super();
|
||||
this.pingouin = Toolkit.getDefaultToolkit().getImage("tuile.png");
|
||||
}
|
||||
@Override
|
||||
protected void paintComponent(Graphics pinceau){
|
||||
Graphics secondPinceau = pinceau.create();
|
||||
if (this.isOpaque()){
|
||||
secondPinceau.setColor(this.getBackground());
|
||||
secondPinceau.fillRect(0, 0, this.getWidth(), this.getHeight());
|
||||
}
|
||||
secondPinceau.drawImage(this.pingouin, 0, 0,this);
|
||||
secondPinceau.drawImage(this.pingouin, 512, 0,this);
|
||||
secondPinceau.drawImage(this.pingouin, 0, 512,this);
|
||||
secondPinceau.drawImage(this.pingouin, 512, 512,this);
|
||||
|
||||
if(this.getHeight() >= 1024){
|
||||
secondPinceau.drawImage(this.pingouin, 0, 1024,this);
|
||||
secondPinceau.drawImage(this.pingouin, 512, 1024,this);
|
||||
if(this.getWidth() >= 1024){
|
||||
secondPinceau.drawImage(this.pingouin, 1024, 1024,this);
|
||||
|
||||
}
|
||||
if(this.getWidth() >= 1024){
|
||||
secondPinceau.drawImage(this.pingouin, 1024, 0,this);
|
||||
secondPinceau.drawImage(this.pingouin, 1024, 512,this);
|
||||
if(this.getHeight() >= 1024){
|
||||
secondPinceau.drawImage(this.pingouin, 1024, 1024,this);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
BIN
DEV2.1/CTRLBLANC/Exo4/Tuile.class
Normal file
BIN
DEV2.1/CTRLBLANC/Exo4/Tuile.class
Normal file
Binary file not shown.
14
DEV2.1/CTRLBLANC/Exo4/Tuile.java
Normal file
14
DEV2.1/CTRLBLANC/Exo4/Tuile.java
Normal file
@@ -0,0 +1,14 @@
|
||||
import javax.swing.*;
|
||||
import java.awt.*;
|
||||
|
||||
public class Tuile{
|
||||
public static void main(String[] args) {
|
||||
JFrame fenetre = new JFrame();
|
||||
fenetre.setSize(1920,1080);
|
||||
fenetre.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
|
||||
CrocsCars cadre = new CrocsCars();
|
||||
fenetre.add(cadre);
|
||||
fenetre.setVisible(true);
|
||||
|
||||
}
|
||||
}
|
29
DEV2.1/CTRLBLANC/Exo4/lexodugayla/TileBackground.java
Normal file
29
DEV2.1/CTRLBLANC/Exo4/lexodugayla/TileBackground.java
Normal 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);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
13
DEV2.1/CTRLBLANC/Exo4/lexodugayla/Tuile2.java
Normal file
13
DEV2.1/CTRLBLANC/Exo4/lexodugayla/Tuile2.java
Normal 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);
|
||||
}
|
||||
}
|
BIN
DEV2.1/CTRLBLANC/Exo4/tuile.jpg
Normal file
BIN
DEV2.1/CTRLBLANC/Exo4/tuile.jpg
Normal file
Binary file not shown.
After Width: | Height: | Size: 36 KiB |
BIN
DEV2.1/CTRLBLANC/Exo4/tuile.png
Normal file
BIN
DEV2.1/CTRLBLANC/Exo4/tuile.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 244 KiB |
Reference in New Issue
Block a user