List of usage examples for com.badlogic.gdx.graphics Pixmap Pixmap
public Pixmap(byte[] encodedData, int offset, int len)
From source file:mobi.shad.s3lib.main.S3File.java
License:Apache License
/** * @param name/* ww w .j a v a 2s .com*/ * @param TextureSize * @param scaleMode 0 - FullScreen * @return */ public static Texture getFileTexture(String name, int TextureSize, int scaleMode) { Texture texture = new Texture(TextureSize, TextureSize, Pixmap.Format.RGBA8888); Pixmap px = new Pixmap(TextureSize, TextureSize, Pixmap.Format.RGBA8888); px.setColor(Color.RED); px.fill(); try { px = new Pixmap(S3File.getFileHandle(name)); } catch (Exception ex) { S3Log.error("S3File::getFileTexture", "Error open file texture: " + name, ex); } Pixmap px2 = new Pixmap(TextureSize, TextureSize, Pixmap.Format.RGBA8888); px2.drawPixmap(px, 0, 0, px.getWidth(), px.getHeight(), 0, 0, TextureSize, TextureSize); texture.setFilter(Texture.TextureFilter.Nearest, Texture.TextureFilter.Linear); texture.draw(px2, 0, 0); return texture; }
From source file:mobi.shad.s3lib.main.S3ResourceManager.java
License:Apache License
/** * Zwraca tekstur zaadowan z dysku/*from w w w. ja va 2 s . c om*/ * * @param fileName * @return */ public static TextureRegion getTextureRegion(String fileName) { TextureRegion textureRegion; if (regionResuorce == null) { regionResuorce = new ArrayMap<String, TextureRegion>(20); } if (!regionResuorce.containsKey(fileName) || reBindProcess == true) { if (LOG) { S3Log.trace(TAG, "Load textureRegion region: " + fileName, 3); } try { FileHandle fileHandle = S3File.getFileHandle(fileName, true, false); textureRegion = new TextureRegion(assetManager.get(fileHandle.path(), Texture.class)); textureRegion.getTexture().setFilter(Texture.TextureFilter.Linear, Texture.TextureFilter.Linear); if (USE_CACHE_RESOURCE) { if (regionResuorce.containsKey(fileName)) { regionResuorce.removeKey(fileName); } regionResuorce.put(fileName, textureRegion); } } catch (Exception e) { S3Log.error("S3ResourceManager::getTexture", "Error create textureRegion data ....", e); try { Pixmap pixmap = new Pixmap(S3Constans.proceduralTextureSizeLow, S3Constans.proceduralTextureSizeLow, Pixmap.Format.RGBA4444); pixmap.setColor(Color.RED); pixmap.fill(); Texture text2 = new Texture(pixmap); text2.setFilter(Texture.TextureFilter.Linear, Texture.TextureFilter.Linear); text2.draw(pixmap, 0, 0); textureRegion = new TextureRegion(text2); } catch (Exception ex) { textureRegion = regionResuorce.firstValue(); } } } else { if (LOG) { S3Log.trace(TAG, "Load textureRegion region from cache: " + fileName, 2); } textureRegion = regionResuorce.get(fileName); } return textureRegion; }
From source file:mobi.shad.s3lib.main.S3ResourceManager.java
License:Apache License
/** * @param fileName//from www.ja va 2 s . c o m * @param destAndroidResolution * @return */ public static Pixmap getPixmap(String fileName, int destAndroidResolution) { Pixmap pixmap; if (pixmapResuorce == null) { pixmapResuorce = new ArrayMap<String, Pixmap>(20); } if (!pixmapResuorce.containsKey(fileName) || reBindProcess == true) { if (LOG) { S3Log.trace(TAG, "Load pixmap (def size: " + destAndroidResolution + ") from file: " + fileName, 3); } try { FileHandle fileHandle = S3File.getFileHandle(fileName, true, false); pixmap = assetManager.get(fileHandle.path(), Pixmap.class); if (USE_CACHE_RESOURCE) { pixmapResuorce.put(fileName, pixmap); } } catch (Exception e) { S3Log.error("S3ResourceManager::getPixmap", "Error create pixmap data ....", e); pixmap = new Pixmap(S3Constans.proceduralTextureSizeLow, S3Constans.proceduralTextureSizeLow, Pixmap.Format.RGBA4444); pixmap.setColor(Color.RED); pixmap.fill(); } } else { if (LOG) { S3Log.trace(TAG, "Load pixmap from cache (def size: " + destAndroidResolution + ") from file: " + fileName, 1); } pixmap = pixmapResuorce.get(fileName); } if (LOG) { S3Log.trace(TAG, "Pixmap size width: " + pixmap.getWidth() + "px height: " + pixmap.getHeight() + "px ", 0); } return pixmap; }
From source file:mx.itesm.oddFellows.MenuCreditosMusicos.java
License:Creative Commons License
public void crearRegionInteraccion() { int pantAlto = (int) (pantalla.getALTO()); int pantAncho = (int) (pantalla.getANCHO()); Pixmap pixmapVerde = new Pixmap(pantAncho / 8, pantAlto / 3 + 40, Pixmap.Format.RGBA8888); pixmapVerde.setColor(0, 0f, 0f, 0f); pixmapVerde.fillRectangle(0, 0, pantAncho, pantAlto); trdOscura = new TextureRegionDrawable(new TextureRegion(new Texture(pixmapVerde))); pixmapVerde.dispose();/*from ww w.j a v a 2s . c om*/ //Jonathan imgbtnKevin = new ImageButton(trdOscura); imgbtnKevin.setPosition(170, 365); //Ruben imgbtnDoug = new ImageButton(trdOscura); imgbtnDoug.setPosition(365, 370); //Alejandro imgbtnChopin = new ImageButton(trdOscura); imgbtnChopin.setPosition(560, 370); //Angel imgbtnBeethoven = new ImageButton(trdOscura); imgbtnBeethoven.setPosition(750, 370); //Angel imgbtnFreeSound = new ImageButton(trdOscura); imgbtnFreeSound.setPosition(950, 370); imgbtnKevin.addListener(new ClickListener() { @Override public void clicked(InputEvent event, float x, float y) { Gdx.app.log("clicked", "***Kevin MacLeod***"); compositorSeleccionado = kevin; } }); imgbtnDoug.addListener(new ClickListener() { @Override public void clicked(InputEvent event, float x, float y) { Gdx.app.log("clicked", "***Doug***"); compositorSeleccionado = doug; } }); imgbtnChopin.addListener(new ClickListener() { @Override public void clicked(InputEvent event, float x, float y) { Gdx.app.log("clicked", "***Chopin***"); compositorSeleccionado = chopin; } }); imgbtnBeethoven.addListener(new ClickListener() { @Override public void clicked(InputEvent event, float x, float y) { Gdx.app.log("clicked", "***Beethoven***"); compositorSeleccionado = beethoven; } }); imgbtnFreeSound.addListener(new ClickListener() { @Override public void clicked(InputEvent event, float x, float y) { Gdx.app.log("clicked", "***Freesound***"); compositorSeleccionado = freeSound; } }); pantalla.escena.addActor(imgbtnKevin); pantalla.escena.addActor(imgbtnDoug); pantalla.escena.addActor(imgbtnChopin); pantalla.escena.addActor(imgbtnBeethoven); pantalla.escena.addActor(imgbtnFreeSound); }
From source file:name.herve.bastod.gui.components.DualScoreBar.java
License:Open Source License
@Override public Texture updateComponent() { Blending bck = Pixmap.getBlending(); Pixmap.setBlending(Blending.None);/*from w ww.java 2 s . co m*/ Pixmap p = new Pixmap(getWidth(), getHeight(), Pixmap.Format.RGBA8888); Color c = GUIResources.getInstance().getColor(GUIResources.WHITE); Color c1 = GUIResources.getInstance().getColor(player1.getColor()).cpy(); c1.a = 0.5f; Color c2 = GUIResources.getInstance().getColor(player2.getColor()).cpy(); c2.a = 0.5f; int w = player1.getScore() * (getWidth() - 2) / (player1.getScore() + player2.getScore()); p.setColor(c1); p.fillRectangle(1, 1, w, getHeight() - 2); p.setColor(c2); p.fillRectangle(w + 1, 1, getWidth() - 2 - w, getHeight() - 2); p.setColor(c); p.drawRectangle(0, 0, getWidth(), getHeight()); str1 = Integer.toString(player1.getScore()); str2 = Integer.toString(player2.getScore()); Texture t = new Texture(p); p.dispose(); Pixmap.setBlending(bck); return t; }
From source file:name.herve.bastod.gui.components.MetalBar.java
License:Open Source License
@Override public Texture updateComponent() { Blending bck = Pixmap.getBlending(); Pixmap.setBlending(Blending.None);//from w w w . j a v a2 s.c o m Pixmap p = new Pixmap(getWidth(), getHeight(), Pixmap.Format.RGBA8888); Color c1 = GUIResources.getInstance().getColor(player.getColor()).cpy(); c1.a = 1f; p.setColor(c1); p.drawRectangle(0, 0, getWidth(), getHeight()); c1.a = 0.5f; p.setColor(c1); int w = player.getMetal() * (getWidth() - 2) / player.getMaxMetal(); p.fillRectangle(1, 1, w, getHeight() - 2); strMetal = "$ " + player.getMetal(); strDeltaA = df.format(player.getMetalAddedMean(engine.getNow())); strDeltaR = df.format(-1 * player.getMetalRemovedMean(engine.getNow())); Texture t = new Texture(p); p.dispose(); Pixmap.setBlending(bck); return t; }
From source file:name.herve.bastod.gui.components.SingleScoreBar.java
License:Open Source License
@Override public Texture updateComponent() { Blending bck = Pixmap.getBlending(); Pixmap.setBlending(Blending.None);//from ww w . ja v a 2 s .com Pixmap p = new Pixmap(getWidth(), getHeight(), Pixmap.Format.RGBA8888); Color c1 = GUIResources.getInstance().getColor(player.getColor()).cpy(); c1.a = 1f; p.setColor(c1); p.drawRectangle(0, 0, getWidth(), getHeight()); c1.a = 0.5f; p.setColor(c1); int w = player.getScore() * (getWidth() - 2) / player.getMaxScore(); p.fillRectangle(1, 1, w, getHeight() - 2); str = Integer.toString(player.getScore()); Texture t = new Texture(p); p.dispose(); Pixmap.setBlending(bck); return t; }
From source file:name.herve.bastod.gui.components.UnitInfoBox.java
License:Open Source License
public UnitInfoBox(Unit u) { super(u.getName() + "-InfoBox", -1, -1, 200, 100); this.unit = u; setNeedUpdate(false);//w w w. j ava 2 s. c o m font = GUIResources.getInstance().getFont(INFOBOX_FONT); moveTo(u.getPositionOnBoard().getXInt(), u.getPositionOnBoard().getYInt()); Blending bck = Pixmap.getBlending(); Pixmap.setBlending(Blending.None); Pixmap p = new Pixmap(getWidth(), getHeight(), Pixmap.Format.RGBA8888); Color c1 = Color.YELLOW; c1.a = 1f; p.setColor(c1); p.drawRectangle(0, 0, getWidth(), getHeight()); c1 = Color.BLACK; c1.a = 0.5f; p.setColor(c1); p.fillRectangle(1, 1, getWidth() - 2, getHeight() - 2); setBackground(new Texture(p)); p.dispose(); Pixmap.setBlending(bck); }
From source file:name.herve.bastod.gui.screen.game.OverlayManager.java
License:Open Source License
public void renderDebugLoS(Vector pos) { Blending bck = Pixmap.getBlending(); Pixmap.setBlending(Blending.None);//from w w w .j a v a 2 s .c om Dimension dimG = engine.getGridDimension(); Dimension dimB = engine.getBoardDimension(); Pixmap p = new Pixmap(dimB.getW() + 1, dimB.getH() + 1, Pixmap.Format.RGBA8888); Color ok = Color.GREEN; ok.a = 0.2f; Color nok = Color.ORANGE; nok.a = 0.2f; for (int x = 0; x < dimG.getW(); x++) { for (int y = 0; y < dimG.getH(); y++) { Vector v = new Vector(x, y); if (engine.lineOfSight(pos, v)) { drawTintedSquare(p, ok, engine.fromGridToBoard(v)); } else { drawTintedSquare(p, nok, engine.fromGridToBoard(v)); } } } Texture debug = new Texture(p); p.dispose(); Pixmap.setBlending(bck); batchBegin(); draw(debug, Engine._SP_SIDE, Engine._SP_BOTTOM); batchEnd(); debug.dispose(); }
From source file:name.herve.bastod.gui.screen.game.OverlayManager.java
License:Open Source License
public void renderBuildPositions() { if (buildPositions == null) { Dimension dimB = engine.getBoardDimension(); Blending bck = Pixmap.getBlending(); Pixmap.setBlending(Blending.None); Pixmap p = new Pixmap(dimB.getW() + 1, dimB.getH() + 1, Pixmap.Format.RGBA8888); for (Player player : engine.getPlayers()) { Color c = GUIResources.getInstance().getColor(player.getColor()).cpy(); c.a = 0.2f;/*from w w w .ja va 2 s .c o m*/ List<Vector> pos = engine.getBuildPositions(player); if (pos != null) { for (Vector v : pos) { if ((Engine.PRECOMPUTE_OPEN_BUILD_POSITIONS && engine.isOpenedBuildPosition(v)) || (engine.isOpenedOnGrid(v))) { Vector vb = engine.fromGridToBoard(v); drawTintedSquare(p, c, vb); } } } } buildPositions = new Texture(p); p.dispose(); Pixmap.setBlending(bck); } batchBegin(); draw(buildPositions, Engine._SP_SIDE, Engine._SP_BOTTOM); batchEnd(); }