List of usage examples for com.badlogic.gdx.graphics Pixmap Pixmap
public Pixmap(byte[] encodedData, int offset, int len)
From source file:com.alma42.mapgen.game.WorldController.java
License:Apache License
private Pixmap createProceduralPixmap(final AGridComponent component) { final int width = 32; final int height = 32; final Pixmap pixmap = new Pixmap(width, height, Format.RGBA8888); final Integer hex = ((Integer) ((Shape) component).getBiome().getValue()); final int r = (hex >> 16) & 255; final int g = (hex >> 8) & 255; final int b = (hex & 255); pixmap.setColor(new Color(r, g, b, 1)); pixmap.fill();//from ww w . j av a2 s .c om // pixmap.drawRectangle(0, 0, width, height); return pixmap; }
From source file:com.alma42.mapgen.game.WorldController.java
License:Apache License
private Pixmap createUser(final int width, final int height) { final Pixmap pixmap = new Pixmap(width, height, Format.RGBA8888); // Fill square with red color at 50% opacity pixmap.setColor(1, 0, 0, 0.5f);/*from ww w . java 2s . c o m*/ pixmap.fill(); // Draw a yellow-colored X shape on square pixmap.setColor(1, 1, 0, 1); pixmap.drawLine(0, 0, width, height); pixmap.drawLine(width, 0, 0, height); // Draw a cyan-colored border around square pixmap.setColor(0, 1, 1, 1); pixmap.drawRectangle(0, 0, width, height); return pixmap; }
From source file:com.anathema_roguelike.main.display.Display.java
License:Open Source License
public Display(Input input) { super(UIConfig.TERM_WIDTH, UIConfig.TERM_HEIGHT); int cellWidth = UIConfig.CELL_WIDTH; int cellHeight = UIConfig.CELL_HEIGHT; batch = new SpriteBatch(); pixmap = new Pixmap(256, 128, Pixmap.Format.RGBA8888); pixmap.setColor(1, 1, 1, 1);/*from w w w . j a v a 2 s. co m*/ pixmap.fill(); tex = new Texture(pixmap); stage = new Stage(new StretchViewport(getWidth() * cellWidth, (getHeight()) * cellHeight), batch); // TextCellFactory tcf = new TextCellFactory(); // tcf.font(DefaultResources.getSmoothFont()); // TextCellFactory tcf = DefaultResources.getStretchableFont().width(cellWidth).height(cellHeight).initBySize(); //TextCellFactory tcf = DefaultResources.getStretchableFont(); //tcf.height(cellHeight).initBySize(); TextCellFactory tcf = new TextCellFactory(); tcf.fontDistanceField("Inconsolata-LGC-Custom-distance.fnt", "Inconsolata-LGC-Custom-distance.png"); display = new SquidLayers(UIConfig.TERM_WIDTH, UIConfig.TERM_HEIGHT, cellWidth, cellHeight, tcf); display.setTextSize(cellWidth, cellHeight + 1); display.setAnimationDuration(0.03f); display.setPosition(0, 0); for (int i = 0; i < DisplayLayer.values().length - 3; i++) { display.addExtraLayer(); } Gdx.input.setInputProcessor(new InputMultiplexer(stage, input.getSquidInput())); stage.addActor(display); }
From source file:com.andgate.pokeadot.PokeADot.java
License:Open Source License
private void createPauseBG() { Pixmap blackbox = new Pixmap(1, 1, Pixmap.Format.RGBA8888); blackbox.setColor(Constants.DIM_SCREEN_COLOR); blackbox.fill();/*from w ww. j a va 2 s . c om*/ pauseBG = new Texture(blackbox); }
From source file:com.android.projet.projetandroid.game.superjumper.WorldRenderer.java
License:Apache License
private void loadBackground() { int dimension = GameController.getIsntance().getBackground().getWidth(); int dimension2 = GameController.getIsntance().getBackground().getHeight(); image = GameController.getIsntance().getBackground(); int[] pixels = new int[GameController.getIsntance().getBackground().getWidth() * GameController.getIsntance().getBackground().getHeight()]; GameController.getIsntance().getBackground().getPixels(pixels, 0, dimension, 0, 0, dimension, dimension2); // Convert from ARGB to RGBA for (int i = 0; i < pixels.length; i++) { int pixel = pixels[i]; pixels[i] = (pixel << 8) | ((pixel >> 24) & 0xFF); }//from w w w .ja va 2 s.c o m pixmap = new Pixmap(GameController.getIsntance().getBackground().getWidth(), GameController.getIsntance().getBackground().getHeight(), Pixmap.Format.RGBA8888); pixmap.getPixels().asIntBuffer().put(pixels); texture = new Texture(pixmap); }
From source file:com.austinerb.project0.engine.SpriterLoader.java
License:Apache License
@Override /**/* ww w. jav a 2 s .c o m*/ * This method is now responsible for creating the pixmaps and textures. */ public void finishLoading() { final Reference[] refs = super.getRefs(); for (int i = 0; i < refs.length; i++) { final Pixmap image; Pixmap pix = this.pixmaps.get(refs[i]); if (!Gdx.graphics.isGL20Available()) { Pixmap temp = pix; image = new Pixmap(MathUtils.nextPowerOfTwo(temp.getWidth()), MathUtils.nextPowerOfTwo(temp.getHeight()), temp.getFormat()); image.drawPixmap(temp, 0, 0); this.pixmapsToDispose.put(temp, true); } else image = pix; final int index = i; this.pixmapsToDispose.put(image, false); this.createSprite(refs[index], image); if (this.packer != null) packer.pack(refs[i].fileName, image); } if (this.pack) generatePackedSprites(); this.disposePixmaps(); }
From source file:com.badlogic.gdx.tests.bullet.OcclusionBuffer.java
License:Apache License
/** Draw the depth buffer to a texture. Slow, should only be used for debugging purposes. * * @return Region of debug texture */ public TextureRegion drawDebugTexture() { if (debugPixmap == null) { debugPixmap = new Pixmap(bufferWidth, bufferHeight, Pixmap.Format.RGBA8888); debugTexture = new Texture(debugPixmap); debugTextureRegion = new TextureRegion(debugTexture); debugTextureRegion.flip(false, true); }// w w w . j a v a2 s .c o m debugPixmap.setColor(Color.BLACK); debugPixmap.fill(); // Find min/max depth values in buffer float minDepth = Float.POSITIVE_INFINITY; float maxDepth = Float.NEGATIVE_INFINITY; buffer.clear(); while (buffer.position() < buffer.capacity()) { float depth = MathUtils.clamp(buffer.get(), 0, Float.POSITIVE_INFINITY); minDepth = Math.min(depth, minDepth); maxDepth = Math.max(depth, maxDepth); } float extent = 1 / (maxDepth - minDepth); buffer.clear(); // Draw to pixmap for (int x = 0; x < bufferWidth; x++) { for (int y = 0; y < bufferHeight; y++) { float depth = MathUtils.clamp(buffer.get(x + y * bufferWidth), 0, Float.POSITIVE_INFINITY); float c = depth * extent; debugPixmap.drawPixel(x, y, Color.rgba8888(c, c, c, 1)); } } debugTexture.draw(debugPixmap, 0, 0); return debugTextureRegion; }
From source file:com.badlogic.gdx.tests.g3d.voxel.PerlinNoiseGenerator.java
License:Apache License
public static Pixmap generatePixmap(int width, int height, int min, int max, int octaveCount) { byte[] bytes = generateHeightMap(width, height, min, max, octaveCount); Pixmap pixmap = new Pixmap(width, height, Format.RGBA8888); for (int i = 0, idx = 0; i < bytes.length; i++) { byte val = bytes[i]; pixmap.getPixels().put(idx++, val); pixmap.getPixels().put(idx++, val); pixmap.getPixels().put(idx++, val); pixmap.getPixels().put(idx++, (byte) 255); }/*from w w w . ja v a2s .com*/ return pixmap; }
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;// ww w .java 2s . c om } useRed = !useRed; } texture = new Texture(pixmap, true); texture.setFilter(TextureFilter.MipMapLinearLinear, TextureFilter.Linear); }
From source file:com.badlogic.gdx.tests.ViewportTest2.java
License:Apache License
public void create() { font = new BitmapFont(); font.setColor(0, 0, 0, 1);/*from w ww . ja v a2 s. co m*/ Pixmap pixmap = new Pixmap(16, 16, Format.RGBA8888); pixmap.setColor(1, 1, 1, 1); pixmap.fill(); texture = new Texture(pixmap); batch = new SpriteBatch(); camera = new OrthographicCamera(); camera.position.set(100, 100, 0); camera.update(); viewports = ViewportTest1.getViewports(camera); viewport = viewports.first(); names = ViewportTest1.getViewportNames(); name = names.first(); Gdx.input.setInputProcessor(new InputAdapter() { public boolean keyDown(int keycode) { if (keycode == Input.Keys.SPACE) { int index = (viewports.indexOf(viewport, true) + 1) % viewports.size; name = names.get(index); viewport = viewports.get(index); resize(Gdx.graphics.getWidth(), Gdx.graphics.getHeight()); } return false; } }); }