1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49
| public class ListenerBleuC extends JPanel{
private final BufferedImage image;
int xp1=1, xp2=1;
int xpg1=1, xph1=1, xpb1=1, xpd1=1, xpg2=1, xpd2=1, xph2=1, xpb2=1;
int xg1=xpg1-25, xg2=xpg2;
int xd1=xpd1+25, xd2=xpd2;
int xh1=xph1, xh2=xph2-25;
int xb1=xpb1, xb2=xpb2+25;
List<Point> tabcp = new ArrayList<>();
int cppd = -16776961;
public ListenerBleuC(BufferedImage image) {
this.image=image;
System.out.println("HelloB");
eerc();
for(int i=0; i<tabcp.size(); i++) {
System.out.print(tabcp.get(i).x+" "+tabcp.get(i).y+" ");
}
System.out.println();
}
public void eerc() {
if (xg1 >=0) {
Color cpg = new Color(image.getRGB(xg1, xg2));
int pr2=cpg.getRed();
int pg2=cpg.getGreen();
int pb2=cpg.getBlue();
int cpg1 = new Color(pr2,pg2,pb2).getRGB();
while (cpg1 == cppd) {
tabcp.clear();
Color cpgg = new Color(image.getRGB(xg1, xg2));
int pr22=cpgg.getRed();
int pg22=cpgg.getGreen();
int pb22=cpgg.getBlue();
int cpg11 = new Color(pr22,pg22,pb22).getRGB();
if (cpg11 != cppd) {
break;
}
g.setColor(new Color(pr2,pg2,pb2));
g.fillRect(xpg1, xpg2, 24, 24);
g.fillRect(xg1, xg2, 24, 24);
tabcp.add(new Point(xg1, xg2));
xpg1-=25;
xg1-=25;
cpg1=cpg11;
}
} |
Partager