use of org.terasology.world.viewer.color.ColorBlender in project Terasology by MovingBlocks.
the class FieldFacetLayer method render.
@Override
public void render(BufferedImage img, Region region) {
FieldFacet2D facet = region.getFacet(clazz);
int width = img.getWidth();
int height = img.getHeight();
ColorModel colorModel = img.getColorModel();
ColorBlender blender = ColorBlenders.forColorModel(ColorModels.RGBA, colorModel);
DataBufferInt dataBuffer = (DataBufferInt) img.getRaster().getDataBuffer();
for (int z = 0; z < height; z++) {
for (int x = 0; x < width; x++) {
Color col = getColor(facet, x, z);
int src = col.rgba();
int dst = dataBuffer.getElem(z * width + x);
int mix = blender.add(src, dst);
dataBuffer.setElem(z * width + x, mix);
}
}
}
use of org.terasology.world.viewer.color.ColorBlender in project Terasology by MovingBlocks.
the class NominalFacetLayer method render.
@Override
public void render(BufferedImage img, Region region) {
ObjectFacet2D<E> facet = region.getFacet(facetClass);
int width = img.getWidth();
int height = img.getHeight();
ColorModel colorModel = img.getColorModel();
ColorBlender blender = ColorBlenders.forColorModel(ColorModels.RGBA, colorModel);
DataBufferInt dataBuffer = (DataBufferInt) img.getRaster().getDataBuffer();
for (int z = 0; z < height; z++) {
for (int x = 0; x < width; x++) {
Color src = getColor(facet, x, z);
if (src != null) {
int blend = blender.get(src.rgba());
dataBuffer.setElem(z * width + x, blend);
}
}
}
}
use of org.terasology.world.viewer.color.ColorBlender in project Terasology by MovingBlocks.
the class FloraFacetLayer method render.
@Override
public void render(BufferedImage img, Region region) {
FloraFacet treeFacet = region.getFacet(FloraFacet.class);
Graphics2D g = img.createGraphics();
int width = img.getWidth();
ColorModel colorModel = img.getColorModel();
ColorBlender blender = ColorBlenders.forColorModel(ColorModels.RGBA, colorModel);
DataBufferInt dataBuffer = (DataBufferInt) img.getRaster().getDataBuffer();
for (Entry<BaseVector3i, FloraType> entry : treeFacet.getRelativeEntries().entrySet()) {
FloraType treeGen = entry.getValue();
int wx = entry.getKey().getX();
int wz = entry.getKey().getZ();
Color color = colorFunc.apply(treeGen);
int src = color.rgba();
int dst = dataBuffer.getElem(wz * width + wx);
int mix = blender.blend(src, dst);
dataBuffer.setElem(wz * width + wx, mix);
}
g.dispose();
}
Aggregations