Developpement/23DEV1.1/TPS2/TP01/Dessin/sautoir.java

22 lines
652 B
Java
Raw Normal View History

2024-12-09 11:53:11 +01:00
import javax.swing.*;
import java.awt.*;
public class sautoir
{
@Override
protected void paintComponent(Graphics g)
{
Graphics pinceau = g.create();
if(isOpaque())
{
pinceau.setColor(getBackground());
pinceau.fillRect(0, 0, getWidth(), getHeight());
}
pinceau.setColor(Color.CYAN);
int[] triangleXPoints = {0, getWidth()/2, getWidth()};
int[] topTriangleXPoints = {0, getHeight()/2, 0};
pinceau.fillPolygon(triangleXPoints, topTriangleXPoints, 3);
int[] bottomTriangleXPoints = {getHeight(), getHeight()/2, getHeight()};
pinceau.fillPolygon(triangleXPoints, bottomTriangleXPoints, 3);
}
}