Java Code Examples for com.badlogic.gdx.graphics.Pixmap#fillRectangle()

The following examples show how to use com.badlogic.gdx.graphics.Pixmap#fillRectangle() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: Palette.java    From riiablo with Apache License 2.0 6 votes vote down vote up
/**
 * Renders a pixmap as a sheet with each pixel taking {@code cellsize} square pixels. Used to show
 * a more user-readable representation of the palette.
 */
public Texture render(int cellsize) {
  final int cells   = 16;
  final int size    = cells * cellsize;
  final int rows    = cells;
  final int columns = cells;

  Pixmap pixmap = new Pixmap(size, size, Pixmap.Format.RGBA8888);
  for (int r = 0, i = 0, x = 0, y = 0; r < rows; r++, x = 0, y += cellsize) {
    for (int c = 0; c < columns; c++, i++, x += cellsize) {
      pixmap.setColor(colors[i] | 0xFF); // Removes alpha transparency
      pixmap.fillRectangle(x, y, cellsize, cellsize);
    }
  }

  Texture texture = new Texture(pixmap);
  texture.setWrap(Texture.TextureWrap.ClampToEdge, Texture.TextureWrap.ClampToEdge);
  pixmap.dispose();
  return texture;
}
 
Example 2
Source File: ColorFadeTransition.java    From libgdx-transitions with Apache License 2.0 5 votes vote down vote up
/** @param color the {@link Color} to fade to
 * @param interpolation the {@link Interpolation} method */
public ColorFadeTransition (Color color, Interpolation interpolation) {
	this.color = new Color(Color.WHITE);
	this.interpolation = interpolation;

	texture = new Texture(1, 1, Format.RGBA8888);
	Pixmap pixmap = new Pixmap(1, 1, Format.RGBA8888);
	pixmap.setColor(color);
	pixmap.fillRectangle(0, 0, 1, 1);
	texture.draw(pixmap, 0, 0);
}
 
Example 3
Source File: AOTextureGenerator.java    From Cubes with MIT License 5 votes vote down vote up
private static void setupPixmap(Pixmap p, int i, Color c) {
  p.setColor(c);

  if ((i & AmbientOcclusion.A) == AmbientOcclusion.A) p.fillRectangle(0, 0, AmbientOcclusion.INDIVIDUAL_SIZE, AmbientOcclusion.INDIVIDUAL_SIZE);
  if ((i & AmbientOcclusion.B) == AmbientOcclusion.B) p.fillRectangle(AmbientOcclusion.INDIVIDUAL_SIZE, 0, AmbientOcclusion.INDIVIDUAL_SIZE, AmbientOcclusion.INDIVIDUAL_SIZE);
  if ((i & AmbientOcclusion.C) == AmbientOcclusion.C) p.fillRectangle(AmbientOcclusion.INDIVIDUAL_SIZE * 2, 0, AmbientOcclusion.INDIVIDUAL_SIZE, AmbientOcclusion.INDIVIDUAL_SIZE);

  if ((i & AmbientOcclusion.D) == AmbientOcclusion.D) p.fillRectangle(0, AmbientOcclusion.INDIVIDUAL_SIZE, AmbientOcclusion.INDIVIDUAL_SIZE, AmbientOcclusion.INDIVIDUAL_SIZE);
  if ((i & AmbientOcclusion.E) == AmbientOcclusion.E) p.fillRectangle(AmbientOcclusion.INDIVIDUAL_SIZE * 2, AmbientOcclusion.INDIVIDUAL_SIZE, AmbientOcclusion.INDIVIDUAL_SIZE, AmbientOcclusion.INDIVIDUAL_SIZE);

  if ((i & AmbientOcclusion.F) == AmbientOcclusion.F) p.fillRectangle(0, AmbientOcclusion.INDIVIDUAL_SIZE * 2, AmbientOcclusion.INDIVIDUAL_SIZE, AmbientOcclusion.INDIVIDUAL_SIZE);
  if ((i & AmbientOcclusion.G) == AmbientOcclusion.G) p.fillRectangle(AmbientOcclusion.INDIVIDUAL_SIZE, AmbientOcclusion.INDIVIDUAL_SIZE * 2, AmbientOcclusion.INDIVIDUAL_SIZE, AmbientOcclusion.INDIVIDUAL_SIZE);
  if ((i & AmbientOcclusion.H) == AmbientOcclusion.H) p.fillRectangle(AmbientOcclusion.INDIVIDUAL_SIZE * 2, AmbientOcclusion.INDIVIDUAL_SIZE * 2, AmbientOcclusion.INDIVIDUAL_SIZE, AmbientOcclusion.INDIVIDUAL_SIZE);
}
 
Example 4
Source File: ShapeTextureCache.java    From mini2Dx with Apache License 2.0 5 votes vote down vote up
/**
 * Returns a filled rectangular texture for the provided {@link LibgdxColor}
 *
 * @param color
 *            The {@link LibgdxColor} to fetch a texture of
 * @return A new {@link Texture} if this is first time it has been
 *         requested, otherwise it will return a cached instance of the
 *         {@link Texture} for the given {@link LibgdxColor}
 */
public Texture getFilledRectangleTexture(LibgdxColor color) {
	int bits = color.color.toIntBits();
	if (!filledRectangleTextures.containsKey(bits)) {
		Pixmap pixmap = new Pixmap(1, 1, Pixmap.Format.RGBA8888);
		pixmap.setColor(color.color);
		pixmap.fillRectangle(0, 0, 1, 1);
		filledRectangleTextures.put(bits, new Texture(pixmap));
		pixmap.dispose();
	}
	return filledRectangleTextures.get(bits);
}
 
Example 5
Source File: SplatMap.java    From Mundus with Apache License 2.0 4 votes vote down vote up
public void clear() {
    Pixmap pixmap = getPixmap();
    pixmap.setColor(0, 0, 0, 0);
    pixmap.fillRectangle(0, 0, pixmap.getWidth(), pixmap.getHeight());
    updateTexture();
}
 
Example 6
Source File: FogOfWar.java    From shattered-pixel-dungeon with GNU General Public License v3.0 4 votes vote down vote up
private void fillLeft( Pixmap fog, int x, int y, int color){
	fog.setColor((color << 8) | (color >>> 24));
	fog.fillRectangle(x * PIX_PER_TILE, y*PIX_PER_TILE, PIX_PER_TILE/2, PIX_PER_TILE);
}
 
Example 7
Source File: FogOfWar.java    From shattered-pixel-dungeon with GNU General Public License v3.0 4 votes vote down vote up
private void fillRight( Pixmap fog, int x, int y, int color){
	fog.setColor((color << 8) | (color >>> 24));
	fog.fillRectangle(x * PIX_PER_TILE + PIX_PER_TILE/2, y*PIX_PER_TILE, PIX_PER_TILE/2, PIX_PER_TILE);
}
 
Example 8
Source File: FogOfWar.java    From shattered-pixel-dungeon with GNU General Public License v3.0 4 votes vote down vote up
private void fillCell( Pixmap fog, int x, int y, int color){
	fog.setColor((color << 8) | (color >>> 24));
	fog.fillRectangle(x * PIX_PER_TILE, y*PIX_PER_TILE, PIX_PER_TILE, PIX_PER_TILE);
}