1 package net
.sourceforge
.desert
;
3 import java
.awt
.image
.BufferedImage
;
7 * @author codistmonk (creation 2010-04-17)
9 public class ParticleRenderer
{
11 private final int[] colorComponents
= new int[4];
13 private BufferedImage buffer
;
20 public final void draw(final Particle particle
) {
21 if (this.getBuffer() == null) {
25 final int x
= (int) particle
.getX();
26 final int y
= this.getBuffer().getHeight() - (int) particle
.getY() - 1;
28 this.getBuffer().getRaster().setPixel(x
, y
, this.getColorComponents(particle
));
37 public final BufferedImage
getBuffer() {
47 public final void setBuffer(final BufferedImage buffer
) {
59 private final int[] getColorComponents(final Particle particle
) {
60 this.colorComponents
[0] = particle
.getType().getColor().getRed();
61 this.colorComponents
[1] = particle
.getType().getColor().getGreen();
62 this.colorComponents
[2] = particle
.getType().getColor().getBlue();
63 this.colorComponents
[3] = particle
.getType().getColor().getAlpha();
65 return this.colorComponents
;