List of usage examples for com.badlogic.gdx.graphics Pixmap setColor
public void setColor(float r, float g, float b, float a)
From source file:at.tugraz.ist.catroid.content.Costume.java
License:Open Source License
protected Pixmap adjustBrightness(Pixmap currentPixmap) { Pixmap newPixmap = new Pixmap(currentPixmap.getWidth(), currentPixmap.getHeight(), currentPixmap.getFormat());/*from w w w .jav a 2s. c o m*/ for (int y = 0; y < currentPixmap.getHeight(); y++) { for (int x = 0; x < currentPixmap.getWidth(); x++) { int pixel = currentPixmap.getPixel(x, y); int r = (int) (((pixel >> 24) & 0xff) + (255 * (brightnessValue - 1))); int g = (int) (((pixel >> 16) & 0xff) + (255 * (brightnessValue - 1))); int b = (int) (((pixel >> 8) & 0xff) + (255 * (brightnessValue - 1))); int a = pixel & 0xff; if (r > 255) { r = 255; } else if (r < 0) { r = 0; } if (g > 255) { g = 255; } else if (g < 0) { g = 0; } if (b > 255) { b = 255; } else if (b < 0) { b = 0; } newPixmap.setColor(r / 255f, g / 255f, b / 255f, a / 255f); newPixmap.drawPixel(x, y); } } currentPixmap.dispose(); return newPixmap; }
From source file:com.agateau.pixelwheels.PwGame.java
License:Open Source License
private void hideMouseCursor() { Pixmap pixmap = new Pixmap(2, 2, Pixmap.Format.RGBA8888); pixmap.setColor(0, 0, 0, 0); pixmap.fill();/*from w w w. j a v a2s . c o m*/ Cursor cursor = Gdx.graphics.newCursor(pixmap, 0, 0); if (cursor != null) { Gdx.graphics.setCursor(cursor); } }
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); pixmap.fill();/* w w w. j av a 2 s .co m*/ // 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.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;/*w ww . j a v a 2s . c o m*/ } 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 w w . j av a 2 s .c om 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; } }); }
From source file:com.cyphercove.doublehelix.PowerLUT.java
License:Apache License
/** W power will be in luminance, and H power will be in alpha**/ public PowerLUT(float powerW, float intensityW, float powerH, float intensityH, int width, int height) { Pixmap pixmap = new Pixmap(width, height, Format.RGBA8888); for (int i = 0; i < width; i++) { float valueW = (float) Math.pow((float) i / width, powerW) * intensityW; for (int j = 0; j < height; j++) { float valueH = (float) Math.pow((float) j / height, powerH) * intensityH; pixmap.setColor(valueW, valueH, 1.0f, 1.0f); pixmap.drawPixel(i, j);// ww w . jav a 2 s .c om } } PixmapTextureData data = new PixmapTextureData(pixmap, Format.RGBA8888, false, false, true); texture = new Texture(data); texture.setWrap(TextureWrap.ClampToEdge, TextureWrap.ClampToEdge); texture.setFilter(TextureFilter.Linear, TextureFilter.Linear); }
From source file:com.digitale.screens.MissionScreen.java
License:Open Source License
public Texture generateDynamicTexture(String iconFilename, String category, int quality) { Pixmap baseImage;/*from w ww. ja v a 2 s .co m*/ 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.gamejolt.mikykr5.ceidecpong.GameCore.java
License:Open Source License
@Override public void create() { AsyncAssetLoader loader = AsyncAssetLoader.getInstance(); // Set up rendering fields and settings. ShaderProgram.pedantic = false; // Not passing all variables to a shader will not close the game. batch = new SpriteBatch(); batch.enableBlending();/*from w ww . j a v a 2 s .c o m*/ batch.setBlendFunction(GL20.GL_SRC_ALPHA, GL20.GL_ONE_MINUS_SRC_ALPHA); pixelPerfectCamera = new OrthographicCamera(Gdx.graphics.getWidth(), Gdx.graphics.getHeight()); // Prepare the fading effect. Pixmap pixmap = new Pixmap(Gdx.graphics.getWidth(), Gdx.graphics.getHeight(), Format.RGBA4444); pixmap.setColor(0, 0, 0, 1); pixmap.fill(); fadeTexture = new Texture(pixmap); pixmap.dispose(); // Create the initial interpolators and start with a fade in effect. alpha = new MutableFloat(1.0f); fadeOut = Tween.to(alpha, 0, 0.5f).target(1.0f).ease(TweenEquations.easeInQuint); fadeIn = Tween.to(alpha, 0, 2.5f).target(0.0f).ease(TweenEquations.easeInQuint); fadeIn.start(); fading = true; // Create application states. states = new BaseState[game_states_t.getNumStates()]; try { states[game_states_t.LOGO_SCREEN.getValue()] = new LogoScreenState(this); states[game_states_t.MAIN_MENU.getValue()] = new MainMenuState(this); states[game_states_t.IN_GAME.getValue()] = new InGameState(this); states[game_states_t.LOADING.getValue()] = new LoadingState(this); states[game_states_t.QUIT.getValue()] = null; } catch (IllegalArgumentException e) { Gdx.app.error(TAG, CLASS_NAME + ".create(): Illegal argument caught creating states: ", e); System.exit(1); return; } // Register every state as an AssetsLoadedListener if the state implements the interface. for (BaseState state : states) { if (state != null && state instanceof AssetsLoadedListener) loader.addListener((AssetsLoadedListener) state); } AsyncAssetLoader.freeInstance(); loader = null; // Set the initial current and next states. currState = game_states_t.LOGO_SCREEN; nextState = null; this.setScreen(states[currState.getValue()]); // Set log level if (ProjectConstants.DEBUG) { Gdx.app.setLogLevel(Application.LOG_DEBUG); } else { Gdx.app.setLogLevel(Application.LOG_NONE); } }
From source file:com.mbrlabs.mundus.commons.terrain.SplatMap.java
License:Apache License
public void clear() { Pixmap pixmap = getPixmap(); pixmap.setColor(0, 0, 0, 0); pixmap.fillRectangle(0, 0, pixmap.getWidth(), pixmap.getHeight()); updateTexture();/*from w w w . j a v a 2 s . c o m*/ }
From source file:com.ridiculousRPG.video.cortado.CortadoPlayerAppletWrapper.java
License:Open Source License
/** * Instantiates a new video player. Don't forget to dispose the player! * /*www.j a v a 2 s. c o m*/ * @param url * url to ogg / ogv file * @param screenBounds * the screen position, width and height * @param projectToMap * Defines whether to project the video onto the map or onto the * screen coordinates * @param withAudio * if false, the audio channel will be disabled. */ public CortadoPlayerAppletWrapper(URL url, Rectangle screenBounds, boolean projectToMap, boolean withAudio, boolean drawPlaceholder) { this.screenBounds = new Rectangle(screenBounds); this.projectToMap = projectToMap; if (!projectToMap) { GameBase gb = GameBase.$(); this.screenBounds.width /= gb.getScreen().width; this.screenBounds.height /= gb.getScreen().height; this.screenBounds.x /= gb.getScreen().width; this.screenBounds.y /= gb.getScreen().height; } int width = (int) screenBounds.width; int height = (int) screenBounds.height; textureRef = TextureRegionLoader.obtainEmptyRegion(width, height, Format.RGBA8888); if (drawPlaceholder) { Pixmap placeholder = new Pixmap(width, height, Format.RGBA8888); placeholder.setColor(0, 0, 0, 1); placeholder.fillRectangle(0, 0, width, height); placeholder.setColor(.7f, .7f, .7f, 1); placeholder.fillCircle(width / 2, height / 2, Math.min(width, height) / 3); placeholder.setColor(.4f, .4f, .4f, 1); placeholder.drawRectangle(0, 0, width, height); placeholder.drawRectangle(2, 2, width - 4, height - 4); placeholder.drawLine(1, 0, width, height - 1); placeholder.drawLine(0, 1, width - 1, height); placeholder.drawLine(1, height, width, 1); placeholder.drawLine(0, height - 1, width - 1, 0); textureRef.draw(placeholder); placeholder.dispose(); } graphicsPixmap = new VideoARGBintPixmapWrapper(); player = new CortadoPlayerApplet(graphicsPixmap); initPlayer(); player.setParam("url", url.toString()); player.setParam("audio", String.valueOf(withAudio)); player.setSize(width, height); player.setStub(this); player.init(); player.start(); }