0

I have written a fully functional first-person-shooter (2.5D styled), though I'd like for sprites to be darkened at a distance from the camera(inverse-square function).

I've got the math down, but with little experience using BufferedImages, I do not know how to go about lowering pixel values (with alpha) or simply tinting them black.

Note: I am also buffering to a canvas(Image) with a Graphics2D

All insight is appreciated.

Luft
  • 185
  • 4
  • 17

1 Answers1

1

To darken a bufferedimage, you can just use a rescaleop. This snippet will darken it by 20%.

float factor = .8f; 
RescaleOp op = new RescaleOp(factor, 0, null);
image= op.filter(bufferedImage, null);
Kyranstar
  • 1,650
  • 2
  • 14
  • 35