List of usage examples for com.badlogic.gdx.graphics Pixmap Pixmap
public Pixmap(byte[] encodedData, int offset, int len)
From source file:com.sertaogames.cactus2d.misc.MyTileAtlas.java
License:Apache License
private void loadTextures() { for (TileSet set : map.tileSets) { Pixmap pixmap;// = new Pixmap(inputDir.child(set.imageName)); pixmap = Cactus2DApplication.loadAsset(dir + "/" + set.imageName, Pixmap.class); int originalWidth = pixmap.getWidth(); int originalHeight = pixmap.getHeight(); if (!MathUtils.isPowerOfTwo(originalWidth) || !MathUtils.isPowerOfTwo(originalHeight)) { final int width = MathUtils.nextPowerOfTwo(originalWidth); final int height = MathUtils.nextPowerOfTwo(originalHeight); Pixmap potPixmap = new Pixmap(width, height, pixmap.getFormat()); potPixmap.drawPixmap(pixmap, 0, 0, 0, 0, width, height); pixmap.dispose();/*from w w w . j a v a 2s .co m*/ pixmap = potPixmap; } Texture texture = new Texture(pixmap); pixmap.dispose(); textures.add(texture); int idx = 0; TextureRegion[][] regions = split(texture, originalWidth, originalHeight, map.tileWidth, map.tileHeight, set.spacing, set.margin); for (int y = 0; y < regions[0].length; y++) { for (int x = 0; x < regions.length; x++) { regionsMap.put(idx++ + set.firstgid, regions[x][y]); } } } }
From source file:com.shatteredpixel.shatteredpixeldungeon.effects.Halo.java
License:Open Source License
public Halo() { super();//from w w w . j a v a2s .c om if (!TextureCache.contains(CACHE_KEY)) { Pixmap pixmap = new Pixmap(RADIUS * 2, RADIUS * 2, Pixmap.Format.RGBA8888); pixmap.setColor(0xFFFFFFFF); pixmap.fillCircle(RADIUS, RADIUS, (int) (RADIUS * 0.75f)); pixmap.setColor(0xFFFFFF88); pixmap.fillCircle(RADIUS, RADIUS, RADIUS); GdxTexture bmp = new GdxTexture(pixmap); TextureCache.add(CACHE_KEY, new SmartTexture(bmp)); } texture(CACHE_KEY); origin.set(RADIUS); }
From source file:com.softwaresemantics.diyglsllwp.ShaderGalleryActivity.java
License:Creative Commons License
/** * * *///from w w w . j a va 2 s. c o m public Pixmap getScreenshot(int x, int y, int w, int h, boolean flipY) { Gdx.gl20.glPixelStorei(GL20.GL_PACK_ALIGNMENT, 1); final Pixmap pixmap = new Pixmap(w, h, Format.RGBA8888); ByteBuffer pixels = pixmap.getPixels(); Gdx.gl20.glReadPixels(x, y, w, h, GL20.GL_RGBA, GL20.GL_UNSIGNED_BYTE, pixels); final int numBytes = w * h * 4; byte[] lines = new byte[numBytes]; if (flipY) { final int numBytesPerLine = w * 4; for (int i = 0; i < h; i++) { pixels.position((h - i - 1) * numBytesPerLine); pixels.get(lines, i * numBytesPerLine, numBytesPerLine); } pixels.clear(); pixels.put(lines); } else { pixels.clear(); pixels.get(lines); } return pixmap; }
From source file:com.steelkiwi.patheditor.gdx.BGDrawer.java
License:Apache License
public BGDrawer() { renderer = new ShapeRenderer(); Pixmap p = new Pixmap(4, 4, Format.RGBA4444); p.setColor(0.698f, 0.698f, 0.698f, 1f); p.fill();/*from ww w . java 2 s . c o m*/ overlay = new Texture(p); p.dispose(); t = new Sprite(overlay); b = new Sprite(overlay); l = new Sprite(overlay); r = new Sprite(overlay); }
From source file:com.strategames.catchdastars.screens.editor.GameEditorScreen.java
License:Open Source License
@Override protected void setupUI(Stage stage) { Game game = getGameEngine().getGame(); Skin skin = getSkin();/*from w w w . j a v a2 s . co m*/ addMenuItem("Play game"); addMenuItem("Save game"); addMenuItem("Delete game"); addMenuItem("Export game"); Array<Level> localLevels = LevelLoader.loadAllLocalLevels(game.getGameMetaData()); game.clearLevels(); for (Level level : localLevels) { level.setGameMetaData(game.getGameMetaData()); game.setLevel(level); } this.levelButtonsGrid = new GridLayout(); //Center button grid in scrollpane // this.levelButtonsGrid.setPosition((stage.getWidth() / 2f)-12f, 180f); this.levelButtonsGrid.setElementSize(gridElementSize.x, gridElementSize.y); this.levelButtonsGrid.setCenter(true); this.emptyLevelImage = new Pixmap((int) gridElementSize.x, (int) gridElementSize.y, Format.RGBA8888); this.emptyLevelImage.setColor(0, 1, 0, 0.3f); this.emptyLevelImage.fill(); this.scrollPane = new ScrollPane(this.levelButtonsGrid, skin); this.scrollPane.setHeight(400f); this.scrollPane.setWidth(stage.getWidth()); this.scrollPane.setPosition(0, 200f); stage.addActor(this.scrollPane); TextButton button = new TextButton("Main menu", skin); button.setWidth(stage.getWidth()); button.addListener(new ClickListener() { @Override public void clicked(InputEvent event, float x, float y) { getGameEngine().showMainMenu(); } }); stage.addActor(button); }
From source file:com.theosirian.ppioo.util.GUI.java
License:Open Source License
private static void loadResources(Skin skin) { FreeTypeFontGenerator gen = new FreeTypeFontGenerator(Gdx.files.internal("graduate.ttf")); FreeTypeFontGenerator.FreeTypeFontParameter param = new FreeTypeFontGenerator.FreeTypeFontParameter(); param.size = 12;/*from w ww .j av a 2 s . c o m*/ skin.add("x-small", gen.generateFont(param)); param.size = 16; skin.add("small", gen.generateFont(param)); param.size = 20; skin.add("default", gen.generateFont(param)); param.size = 24; skin.add("medium", gen.generateFont(param)); param.size = 32; skin.add("big", gen.generateFont(param)); param.size = 48; skin.add("huge", gen.generateFont(param)); param.size = 72; skin.add("x-huge", gen.generateFont(param)); skin.add("background", new SpriteDrawable(new Sprite(new Texture(Gdx.files.internal("main.png"))))); skin.add("default.up", new NinePatch(new Texture(Gdx.files.internal("button.up.default.9.png")), 16, 16, 16, 16)); skin.add("default.over", new NinePatch(new Texture(Gdx.files.internal("button.over.default.9.png")), 16, 16, 16, 16)); skin.add("default.down", new NinePatch(new Texture(Gdx.files.internal("button.down.default.9.png")), 16, 16, 16, 16)); skin.add("success.up", new NinePatch(new Texture(Gdx.files.internal("button.up.success.9.png")), 16, 16, 16, 16)); skin.add("success.over", new NinePatch(new Texture(Gdx.files.internal("button.over.success.9.png")), 16, 16, 16, 16)); skin.add("success.down", new NinePatch(new Texture(Gdx.files.internal("button.down.success.9.png")), 16, 16, 16, 16)); skin.add("warning.up", new NinePatch(new Texture(Gdx.files.internal("button.up.warning.9.png")), 16, 16, 16, 16)); skin.add("warning.over", new NinePatch(new Texture(Gdx.files.internal("button.over.warning.9.png")), 16, 16, 16, 16)); skin.add("warning.down", new NinePatch(new Texture(Gdx.files.internal("button.down.warning.9.png")), 16, 16, 16, 16)); skin.add("error.up", new NinePatch(new Texture(Gdx.files.internal("button.up.error.9.png")), 16, 16, 16, 16)); skin.add("error.over", new NinePatch(new Texture(Gdx.files.internal("button.over.error.9.png")), 16, 16, 16, 16)); skin.add("error.down", new NinePatch(new Texture(Gdx.files.internal("button.down.error.9.png")), 16, 16, 16, 16)); skin.add("window", new NinePatch(new Texture(Gdx.files.internal("window.9.png")), 32, 32, 32, 32)); skin.add("checkbox.on", new Texture(Gdx.files.internal("checkbox.on.default.png"))); skin.add("checkbox.off", new Texture(Gdx.files.internal("checkbox.off.default.png"))); skin.add("checkbox.on.disabled", new Texture(Gdx.files.internal("checkbox.on.disabled.png"))); skin.add("checkbox.off.disabled", new Texture(Gdx.files.internal("checkbox.off.disabled.png"))); skin.add("checkbox.on.slider.horizontal", new Texture(Gdx.files.internal("checkbox.on.slider.horizontal.png"))); skin.add("checkbox.off.slider.horizontal", new Texture(Gdx.files.internal("checkbox.off.slider.horizontal.png"))); skin.add("radiobutton.on", new Texture(Gdx.files.internal("radiobutton.on.default.png"))); skin.add("radiobutton.on.over", new Texture(Gdx.files.internal("radiobutton.on.over.default.png"))); skin.add("radiobutton.off", new Texture(Gdx.files.internal("radiobutton.off.default.png"))); skin.add("radiobutton.off.over", new Texture(Gdx.files.internal("radiobutton.off.over.default.png"))); skin.add("radiobutton.disabled", new Texture(Gdx.files.internal("radiobutton.disabled.default.png"))); skin.add("sound-on", new Texture(Gdx.files.internal("sound-on.png"))); skin.add("sound-off", new Texture(Gdx.files.internal("sound-off.png"))); skin.add("arrow.up", new Texture(Gdx.files.internal("arrow.up.default.png"))); skin.add("arrow.up.disabled", new Texture(Gdx.files.internal("arrow.up.disabled.png"))); skin.add("arrow.down", new Texture(Gdx.files.internal("arrow.down.default.png"))); skin.add("arrow.down.disabled", new Texture(Gdx.files.internal("arrow.down.disabled.png"))); skin.add("arrow.left", new Texture(Gdx.files.internal("arrow.left.default.png"))); skin.add("arrow.left.disabled", new Texture(Gdx.files.internal("arrow.left.disabled.png"))); skin.add("arrow.right", new Texture(Gdx.files.internal("arrow.right.default.png"))); skin.add("arrow.right.disabled", new Texture(Gdx.files.internal("arrow.right.disabled.png"))); for (ColorEnum color : ColorEnum.values()) { skin.add(color.colorName, color.getColor()); } Pixmap pixmap; pixmap = new Pixmap(1, 1, Pixmap.Format.RGBA8888); pixmap.setColor(skin.getColor("white")); pixmap.fill(); skin.add("white", new Texture(pixmap)); pixmap = new Pixmap(1, 1, Pixmap.Format.RGBA8888); pixmap.setColor(skin.getColor("transparent")); pixmap.fill(); skin.add("transparent", new Texture(pixmap)); pixmap = new Pixmap(8, 1, Pixmap.Format.RGBA8888); pixmap.setColor(Color.WHITE); pixmap.fill(); skin.add("white1x8", new Texture(pixmap)); pixmap = new Pixmap(1, 8, Pixmap.Format.RGBA8888); pixmap.setColor(Color.WHITE); pixmap.fill(); skin.add("white8x1", new Texture(pixmap)); pixmap = new Pixmap(32, 32, Pixmap.Format.RGBA8888); pixmap.setColor(Color.WHITE); pixmap.fill(); skin.add("white32s", new Texture(pixmap)); }
From source file:com.tnf.ptm.screens.controlers.PtmInputManager.java
License:Apache License
public PtmInputManager(TextureManager textureManager, OggSoundManager soundManager) { inputPointers = new InputPointer[POINTER_COUNT]; for (int i = 0; i < POINTER_COUNT; i++) { inputPointers[i] = new InputPointer(); }// ww w .j a va 2 s . c o m PtmInputProcessor sip = new PtmInputProcessor(this); Gdx.input.setInputProcessor(sip); flashInputPointer = new InputPointer(); mousePos = new Vector2(); mousePrevPos = new Vector2(); // Create an empty 1x1 pixmap to use as hidden cursor Pixmap pixmap = new Pixmap(1, 1, RGBA8888); hiddenCursor = Gdx.graphics.newCursor(pixmap, 0, 0); pixmap.dispose(); // We want the original mouse cursor to be hidden as we draw our own mouse cursor. Gdx.input.setCursorCatched(false); setMouseCursorHidden(); uiCursor = textureManager.getTexture("ui/cursor"); warnColor = new Color(PtmColor.UI_WARN); hoverSound = soundManager.getSound("engine:uiHover"); }
From source file:com.trgk.touchwave.tgengine.TGResources.java
License:Open Source License
void initRectTexture() { Pixmap map = new Pixmap(1, 1, Pixmap.Format.RGBA8888); map.setColor(1, 1, 1, 1);// w ww .j av a 2s . c om map.fill(); PixmapTextureData textureData = new PixmapTextureData(map, null, false, false, true); rectTexture = new Texture(textureData); rectTexture.setFilter(Texture.TextureFilter.Linear, Texture.TextureFilter.Linear); rectTextureRegion = new TextureRegion(rectTexture); }
From source file:com.trueMagic.textureGeneration.TextureGenerator.java
public static Texture platform(int x, int y) { Pixmap pixmap = new Pixmap(x, y, Pixmap.Format.RGBA8888); pixmap.setColor(Color.BLACK); pixmap.fill();// ww w .j av a 2s.c om return new Texture(pixmap); }
From source file:com.trueMagic.textureGeneration.TextureGenerator.java
public static Texture player(int x, int y) { Pixmap pixmap = new Pixmap(x, y, Pixmap.Format.RGBA8888); pixmap.setColor(Color.BLUE);/* w ww.j a v a 2s. co m*/ pixmap.fill(); return new Texture(pixmap); }