Reputation: 185
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.
Upvotes: 0
Views: 71
Reputation: 1720
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);
Upvotes: 1