Beispiel #1
0
 public Color setGrey(int r, int g, int b) {
   int greyLv = (int) (0.299 * r + 0.587 * g + 0.114 * b);
   while (frame.getGreyIndicator() > (greyLv + 8) || frame.getGreyIndicator() < (greyLv - 8)) {
     if (greyLv < frame.getGreyIndicator()) {
       if (r != 255) {
         r = r + 1;
       }
       if (g != 255) {
         g = g + 1;
       }
       if (b != 255) {
         b = b + 1;
       }
     }
     if (greyLv > frame.getGreyIndicator()) {
       if (r != 0) {
         r = r - 1;
       }
       if (g != 0) {
         g = g - 1;
       }
       if (b != 0) {
         b = b - 1;
       }
     }
     greyLv = (int) (0.299 * r + 0.587 * g + 0.114 * b);
   }
   return new Color(r, g, b);
 }
Beispiel #2
0
 public PanelColor(Fenetre f, String name, int nbColor, Color c, int w, int h) {
   this.bgColor = c;
   choseColor.addMouseListener(this);
   this.add(choseColor);
   this.nmbColor = nbColor - 1;
   this.numColor.setText(this.numColor.getText() + this.nmbColor + " couleur(s)");
   this.add(this.numColor);
   this.frame = f;
   this.setBackground(this.bgColor);
   this.setSize(new Dimension(w, h));
   this.setName(name);
   this.setLayout(null);
   this.addMouseListener(this);
   // carreColor.setMaximumSize(new Dimension(200, 200));
   this.add(carreColor);
   System.out.println(this.carreColor.getBackground());
   this.add(colorR);
   validColor(colorR.getColor(), colorG.getColor(), colorB.getColor());
   this.add(colorChoice);
   this.next.addMouseListener(this);
   this.add(next);
   this.add(colorB);
   this.add(colorG);
   neededGrey = maxGrey / (frame.getNmbColor());
   frame.setNeededGrey(neededGrey);
   frame.map.put(frame.getGreyIndicator(), this);
 }