Example usage for com.badlogic.gdx.graphics Pixmap fillRectangle

List of usage examples for com.badlogic.gdx.graphics Pixmap fillRectangle

Introduction

In this page you can find the example usage for com.badlogic.gdx.graphics Pixmap fillRectangle.

Prototype

public void fillRectangle(int x, int y, int width, int height) 

Source Link

Document

Fills a rectangle starting at x, y extending by width to the right and by height downwards (y-axis points downwards) using the current color.

Usage

From source file:com.badlogic.gdx.tests.gles2.MipMap2D.java

License:Apache License

private void createTexture() {
    Pixmap pixmap = new Pixmap(256, 256, Format.RGB565);
    boolean useRed = true;
    for (int y = 0; y < 256; y += 8) {
        for (int x = 0; x < 256; x += 8) {
            pixmap.setColor(useRed ? 1 : 0, 0, useRed ? 0 : 1, 1);
            pixmap.fillRectangle(x, y, 8, 8);
            useRed = !useRed;/*from   w w  w .  j  a  v a  2  s  .  co m*/
        }
        useRed = !useRed;
    }
    texture = new Texture(pixmap, true);
    texture.setFilter(TextureFilter.MipMapLinearLinear, TextureFilter.Linear);
}

From source file:com.bladecoder.engine.util.RectangleRenderer.java

License:Apache License

private static Texture makePixel() {
    Texture _temp;//from  ww w .j  av a 2 s  .  c  om
    Pixmap p = new Pixmap(1, 1, Pixmap.Format.RGBA8888);
    p.setColor(Color.WHITE);
    p.fillRectangle(0, 0, 1, 1);
    _temp = new Texture(p, true);
    p.dispose();
    return _temp;
}

From source file:com.digitale.screens.MissionScreen.java

License:Open Source License

public Texture generateDynamicTexture(String iconFilename, String category, int quality) {
    Pixmap baseImage;// w w w .j av  a2  s . c om
    if (category.equals("blueprint")) {
        FileHandle baseFile = Gdx.files.internal("data/blueprint.png");
        baseImage = new Pixmap(baseFile);
    } else {
        baseImage = new Pixmap(64, 64, Format.RGBA8888);
    }
    FileHandle iconFile = Gdx.files.internal(iconFilename);
    FileHandle iconGlowFile = Gdx.files.internal(iconFilename);

    if (Stardust3d.DEEPDEBUG)
        System.out.println("base format" + baseImage.getFormat());
    Pixmap imgA = new Pixmap(iconGlowFile);
    if (Stardust3d.DEEPDEBUG)
        System.out.println("a format" + imgA.getFormat());
    Pixmap imgB = new Pixmap(iconFile);

    if (Stardust3d.DEEPDEBUG)
        System.out.println("b " + iconFilename + " format" + imgB.getFormat());
    // overdraw rectangle to tint icon where needed
    // if(tintcolour !null){imgB.SetColor(tintcolour);

    imgB.fillRectangle(0, 0, 64, 64);

    // set colour for quality marker
    switch (quality) {
    case 0:
        imgB.setColor(.5f, .5f, .5f, 1f);
        break;
    case 1:
        imgB.setColor(.75f, .75f, .75f, 1f);
        break;
    case 2:
        imgB.setColor(1f, 1f, 1f, 1f);
        break;
    case 3:
        imgB.setColor(0f, .5f, 0f, 1f);
        break;
    case 4:
        imgB.setColor(0f, 1f, 0f, 1f);
        break;
    case 5:
        imgB.setColor(0f, 0f, 1f, 1f);
        break;
    case 6:
        imgB.setColor(0f, 0f, .5f, 1f);
        break;
    case 7:
        imgB.setColor(.5f, 0f, 1f, 1f);
        break;
    case 8:
        imgB.setColor(1f, .5f, 0f, 1f);
        break;
    case 9:
        imgB.setColor(1f, 0.5f, 0f, 1f);
        break;
    }
    // draw quality indicator
    imgB.fillRectangle(0, 54, 10, 10);
    baseImage.setColor(0f, 1f, 0f, .2f);
    // baseImage.drawPixmap(imgA, 0, 0, 64, 64, 0, 0, 64, 64);
    // superimpose item's icon
    baseImage.drawPixmap(imgB, 0, 0, 64, 64, 0, 0, 64, 64);
    Texture dynamicTexture = new Texture(baseImage);

    baseImage.dispose();
    imgA.dispose();
    imgB.dispose();

    return dynamicTexture;
}

From source file:com.github.skittishSloth.openSkies.maps.MapGenerator.java

public Texture generateTexture(final int width, final int height, final int tileSize) {
    final TerrainTile[][] tiles = generateTiles(width, height);

    final Pixmap pm = new Pixmap(width * tileSize, height * tileSize, Pixmap.Format.RGBA8888);
    for (int x = 0; x < width; ++x) {
        for (int y = 0; y < height; ++y) {
            final TerrainTile tile = tiles[x][y];
            final Color c = tile.getTemperatureColor();
            pm.setColor(c);/* w  w  w . j ava  2  s  .c  o m*/
            pm.fillRectangle(x * tileSize, y * tileSize, tileSize, tileSize);
        }
    }
    final Texture res = new Texture(pm);
    pm.dispose();
    return res;
}

From source file:com.github.skittishSloth.openSkies.maps.MapGenerator.java

public Texture generateElevationTexture(final TerrainTile[][] tiles, final int width, final int height,
        final int tileSize) {
    final Pixmap pm = new Pixmap(width * tileSize, height * tileSize, Pixmap.Format.RGBA8888);
    for (int x = 0; x < width; ++x) {
        for (int y = 0; y < height; ++y) {
            final TerrainTile tile = tiles[x][y];
            final Color c = tile.getElevationColor();
            pm.setColor(c);/*from  w  w  w.j  a va  2s . c o  m*/
            pm.fillRectangle(x * tileSize, y * tileSize, tileSize, tileSize);
        }
    }
    final Texture res = new Texture(pm);
    pm.dispose();
    return res;
}

From source file:com.github.skittishSloth.openSkies.maps.MapGenerator.java

public Texture generateRawElevationTexture(final TerrainTile[][] tiles, final int width, final int height,
        final int tileSize) {
    final Pixmap pm = new Pixmap(width * tileSize, height * tileSize, Pixmap.Format.RGBA8888);
    for (int x = 0; x < width; ++x) {
        for (int y = 0; y < height; ++y) {
            final TerrainTile tile = tiles[x][y];
            final Color c = tile.getRawElevationColor();
            pm.setColor(c);//from   w ww.ja v  a2  s.  c  o m
            pm.fillRectangle(x * tileSize, y * tileSize, tileSize, tileSize);
        }
    }
    final Texture res = new Texture(pm);
    pm.dispose();
    return res;
}

From source file:com.github.skittishSloth.openSkies.maps.MapGenerator.java

public Texture generateTemperatureTexture(final TerrainTile[][] tiles, final int width, final int height,
        final int tileSize) {
    final Pixmap pm = new Pixmap(width * tileSize, height * tileSize, Pixmap.Format.RGBA8888);
    for (int x = 0; x < width; ++x) {
        for (int y = 0; y < height; ++y) {
            final TerrainTile tile = tiles[x][y];
            final Color c = tile.getTemperatureColor();
            pm.setColor(c);/*  www  .j  ava2 s .  co  m*/
            pm.fillRectangle(x * tileSize, y * tileSize, tileSize, tileSize);
        }
    }
    final Texture res = new Texture(pm);
    pm.dispose();
    return res;
}

From source file:com.github.skittishSloth.openSkies.maps.MapGenerator.java

public Texture generateRainfallTexture(final TerrainTile[][] tiles, final int width, final int height,
        final int tileSize) {
    final Pixmap pm = new Pixmap(width * tileSize, height * tileSize, Pixmap.Format.RGBA8888);
    for (int x = 0; x < width; ++x) {
        for (int y = 0; y < height; ++y) {
            final TerrainTile tile = tiles[x][y];
            final Color c = tile.getRainfallColor();
            pm.setColor(c);/*from  ww w. j  a  v a  2  s . c  o  m*/
            pm.fillRectangle(x * tileSize, y * tileSize, tileSize, tileSize);
        }
    }
    final Texture res = new Texture(pm);
    pm.dispose();
    return res;
}

From source file:com.github.skittishSloth.openSkies.maps.MapGenerator.java

public Texture generateElevationGrayscaleTexture(final TerrainTile[][] tiles, final int width, final int height,
        final int tileSize) {
    final Pixmap pm = new Pixmap(width * tileSize, height * tileSize, Pixmap.Format.RGBA8888);
    for (int x = 0; x < width; ++x) {
        for (int y = 0; y < height; ++y) {
            final TerrainTile tile = tiles[x][y];
            final Color c = tile.getElevationGrayscale();
            pm.setColor(c);/*from w  w  w.  j a v a2 s.c  om*/
            pm.fillRectangle(x * tileSize, y * tileSize, tileSize, tileSize);
        }
    }
    final Texture res = new Texture(pm);
    pm.dispose();
    return res;
}

From source file:com.github.skittishSloth.openSkies.maps.MapGenerator.java

public Texture generateLatitudeTexture(final TerrainTile[][] tiles, final int width, final int height,
        final int tileSize) {
    final Pixmap pm = new Pixmap(width * tileSize, height * tileSize, Pixmap.Format.RGBA8888);
    for (int x = 0; x < width; ++x) {
        for (int y = 0; y < height; ++y) {
            final TerrainTile tile = tiles[x][y];
            final Color c = tile.getLatitudeColor();
            pm.setColor(c);//from   ww w  . j a  va  2 s . c  o  m
            pm.fillRectangle(x * tileSize, y * tileSize, tileSize, tileSize);
        }
    }
    final Texture res = new Texture(pm);
    pm.dispose();
    return res;
}