Eu preciso fazer uma imagem em degradê, pra isso eu precisaria colocar um for para que toda vez que a cor vermelha rodasse, diminuiria -1 dela.
Só que não to conseguindo implementar isso
.
A cor vermelha tá declarada como {255,0,0}.
Segue o código:
public static void main(String[] args) throws IOException {
int width = 500;
int height = 300;
BufferedImage image= new BufferedImage(
width,
height,
BufferedImage.TYPE_INT_RGB
);
WritableRaster raster = image.getRaster();
int c = 255;
int[] green = new int[] {35,142,35};
int[] white = new int[] {255,255,255};
int[] red = new int[] {c,0,0};
for (int h = 0; h < height; h++){
for (int w = 0; w < width; w++){
if (w < 500)
{
raster.setPixel(w, h, red);
}
Essa é a parte que eu estou tentando implementar:
for (c = w; w < height; c--){
if (w < 500)
{
raster.setPixel(w, h, red);
}
}
}
}
ImageIO.write(image, "PNG",
new File("Degrade.png"));
}
