use of com.b3dgs.lionengine.graphic.ColorRgba in project lionengine by b3dgs.
the class GraphicAwt method getColor.
@Override
public ColorRgba getColor() {
final Color color = g.getColor();
if (colorCacheAwt.containsKey(color)) {
return colorCacheAwt.get(color);
}
final ColorRgba colorRgba = new ColorRgba(color.getRGB());
colorCacheAwt.put(color, colorRgba);
return colorRgba;
}
use of com.b3dgs.lionengine.graphic.ColorRgba in project lionengine by b3dgs.
the class MinimapConfigTest method testExportsImports.
/**
* Test exports imports.
*/
@Test
void testExportsImports() {
final Map<Integer, ColorRgba> tiles = new HashMap<>();
tiles.put(Integer.valueOf(0), ColorRgba.RED);
tiles.put(Integer.valueOf(1), ColorRgba.BLUE);
tiles.put(Integer.valueOf(0), ColorRgba.GREEN);
tiles.put(Integer.valueOf(1), ColorRgba.GREEN);
final Media config = Medias.create("minimap.xml");
MinimapConfig.exports(config, tiles);
assertEquals(tiles, MinimapConfig.imports(config));
assertTrue(config.getFile().delete());
}
use of com.b3dgs.lionengine.graphic.ColorRgba in project lionengine by b3dgs.
the class ScanlineCrt method createColor.
private static ColorRgba[][] createColor() {
final int f = 14;
final ColorRgba[][] color = new ColorRgba[][] { { new ColorRgba(5 * f / 3, 1 * f / 4, 1 * f / 3, (int) (ALPHA * 0.9)), new ColorRgba(1 * f / 3, 5 * f / 4, 1 * f / 3, (int) (ALPHA * 0.9)), new ColorRgba(1 * f / 3, 1 * f / 4, 5 * f / 3, (int) (ALPHA * 0.9)) }, { new ColorRgba(10 * f / 2, 2 * f / 2, 2 * f / 2, (int) (ALPHA * 0.75)), new ColorRgba(2 * f / 2, 10 * f / 2, 2 * f / 2, (int) (ALPHA * 0.75)), new ColorRgba(2 * f / 2, 2 * f / 2, 10 * f / 2, (int) (ALPHA * 0.75)) }, { new ColorRgba(18 * f, 4 * f, 4 * f, (int) (ALPHA * 0.5)), new ColorRgba(4 * f, 18 * f, 4 * f, (int) (ALPHA * 0.5)), new ColorRgba(4 * f, 4 * f, 18 * f, (int) (ALPHA * 0.5)) }, { new ColorRgba(12 * f, 3 * f, 3 * f, (int) (ALPHA * 0.6)), new ColorRgba(3 * f, 12 * f, 3 * f, (int) (ALPHA * 0.6)), new ColorRgba(3 * f, 3 * f, 12 * f, (int) (ALPHA * 0.6)) }, { new ColorRgba(8 * f / 2, 5 * f / 2, 2 * f / 2, (int) (ALPHA * 0.8)), new ColorRgba(2 * f / 2, 8 * f / 2, 2 * f / 2, (int) (ALPHA * 0.8)), new ColorRgba(2 * f / 2, 2 * f / 2, 8 * f / 2, (int) (ALPHA * 0.8)) } };
return color;
}
use of com.b3dgs.lionengine.graphic.ColorRgba in project lionengine by b3dgs.
the class Minimap method computeSheet.
/**
* Compute the current sheet.
*
* @param colors The colors data.
* @param sheetId The sheet id.
*/
private void computeSheet(Map<Integer, ColorRgba> colors, int sheetId) {
final SpriteTiled tiles = map.getSheet(sheetId);
final ImageBuffer tilesSurface = tiles.getSurface();
final int tw = map.getTileWidth();
final int th = map.getTileHeight();
int number = 0;
for (int i = 0; i < tilesSurface.getWidth(); i += tw) {
for (int j = 0; j < tilesSurface.getHeight(); j += th) {
final int h = number * tw % tiles.getWidth();
final int v = number / tiles.getTilesHorizontal() * th;
final ColorRgba color = UtilColor.getWeightedColor(tilesSurface, h, v, tw, th);
if (!(NO_TILE.equals(color) || color.getAlpha() == 0)) {
colors.put(Integer.valueOf(number), color);
}
number++;
}
}
}
use of com.b3dgs.lionengine.graphic.ColorRgba in project lionengine by b3dgs.
the class MinimapConfig method imports.
/**
* Create the minimap data from node.
*
* @param configMinimap The minimap configuration media (must not be <code>null</code>).
* @return The minimap data.
* @throws LionEngineException If unable to read data.
*/
public static Map<Integer, ColorRgba> imports(Media configMinimap) {
Check.notNull(configMinimap);
final Map<Integer, ColorRgba> colors = new HashMap<>();
final XmlReader nodeMinimap = new XmlReader(configMinimap);
final Collection<XmlReader> children = nodeMinimap.getChildren(NODE_COLOR);
for (final XmlReader nodeColor : children) {
final ColorRgba color = new ColorRgba(nodeColor.getInteger(ATT_COLOR_RED), nodeColor.getInteger(ATT_COLOR_GREEN), nodeColor.getInteger(ATT_COLOR_BLUE));
for (final XmlReader nodeTile : nodeColor.getChildren(TileConfig.NODE_TILE)) {
final Integer tile = Integer.valueOf(TileConfig.imports(nodeTile));
colors.put(tile, color);
}
}
children.clear();
return colors;
}
Aggregations