use of org.terasology.rendering.nui.Color in project Terasology by MovingBlocks.
the class ColorTypeHandlerTest method testDeserializeHex.
@Test
public void testDeserializeHex() {
PersistedData data = new PersistedString("DEADBEEF");
Color color = handler.deserialize(data, deserializationContext);
Assert.assertEquals(0xDEADBEEF, color.rgba());
}
use of org.terasology.rendering.nui.Color in project Terasology by MovingBlocks.
the class ColorTypeHandlerTest method testSerialize.
@Test
public void testSerialize() {
SerializationContext serializationContext = Mockito.mock(SerializationContext.class);
handler.serialize(new Color(0x010380FF), serializationContext);
Mockito.verify(serializationContext).create(1, 3, 128, 255);
}
use of org.terasology.rendering.nui.Color in project Terasology by MovingBlocks.
the class ColorTypeHandlerTest method testDeserializeArray.
@Test
public void testDeserializeArray() {
JsonArray array = new Gson().fromJson("[12, 34, 56, 78]", JsonArray.class);
PersistedData data = new GsonPersistedDataArray(array);
Color color = handler.deserialize(data, deserializationContext);
Assert.assertEquals(12, color.r());
Assert.assertEquals(34, color.g());
Assert.assertEquals(56, color.b());
Assert.assertEquals(78, color.a());
}
use of org.terasology.rendering.nui.Color in project Terasology by MovingBlocks.
the class TextureDataFactoryTest method testRedColorNoAlphaTransformedToTextureUri.
@Test
public void testRedColorNoAlphaTransformedToTextureUri() throws Exception {
Color expectedColor = Color.RED;
int expectedRed = -1;
int expectedGreen = 0;
int expectedBlue = 0;
int expectedAlpha = -1;
testRepeatedColorInDataTexture(expectedColor, expectedRed, expectedGreen, expectedBlue, expectedAlpha);
}
use of org.terasology.rendering.nui.Color 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