List of usage examples for com.badlogic.gdx.graphics Pixmap Pixmap
public Pixmap(byte[] encodedData, int offset, int len)
From source file:com.trueMagic.textureGeneration.TextureGenerator.java
public static Texture projectile(int x, int y) { Pixmap pixmap = new Pixmap(x, y, Pixmap.Format.RGBA8888); pixmap.setColor(Color.RED);//from w ww . ja v a 2 s. com pixmap.fill(); return new Texture(pixmap); }
From source file:com.tumblr.oddlydrawn.stupidworm.MainMenuInterface.java
License:Apache License
private void setUpSkin() { Pixmap pixmap = new Pixmap(1, 1, Format.RGBA8888); pixmap.setColor(Color.LIGHT_GRAY); pixmap.fill();/*from ww w. ja v a2s . c o m*/ skin.add("grey", new Texture(pixmap)); titleSprite.setX(TITLE_SPRITE_POS_X); titleSprite.setY(TITLE_SPRITE_POS_Y); LabelStyle labelStyle = new LabelStyle(); skin.add("default", finePrint); labelStyle.font = skin.getFont("default"); skin.add("default", labelStyle); CheckBoxStyle checkBoxStyle = new CheckBoxStyle(); checkBoxStyle.checkboxOff = skin.newDrawable("grey", Color.LIGHT_GRAY); checkBoxStyle.checkboxOn = skin.newDrawable("grey", Color.LIGHT_GRAY); checkBoxStyle.font = skin.getFont("default"); checkBoxStyle.checkboxOff = new TextureRegionDrawable(unchecked); checkBoxStyle.checkboxOn = new TextureRegionDrawable(checked); skin.add("default", checkBoxStyle); SliderStyle sliderStyle = new SliderStyle(); sliderStyle.background = new TextureRegionDrawable(background); sliderStyle.knob = new TextureRegionDrawable(knob); skin.add("default-horizontal", sliderStyle); ButtonStyle buttonStyle = new ButtonStyle(); skin.add("default", buttonStyle); TextButtonStyle textButtonStyle = new TextButtonStyle(); textButtonStyle.font = skin.getFont("default"); textButtonStyle.up = new NinePatchDrawable(patchBox); skin.add("default", textButtonStyle); }
From source file:com.tumblr.oddlydrawn.stupidworm.screens.LicenseScreen.java
License:Apache License
public LicenseScreen(Game g) { game = g;/*from w w w . j a v a2 s . c o m*/ stage = new Stage(); skin = new Skin(); batch = new SpriteBatch(); FileHandle handle; handle = Gdx.files.internal(LICENSE_LOC); licenseString = handle.readString(); atlas = new TextureAtlas(Gdx.files.internal(TEXTURE_ATLAS_LOC)); NinePatch patchBox; patchBox = new NinePatch(atlas.createPatch(PATCH_BOX_REGION_STRING)); Gdx.input.setInputProcessor(stage); stage.setViewport(new StretchViewport(WIDTH, HEIGHT)); Table table = new Table(); table.setFillParent(true); stage.addActor(table); Pixmap pixmap = new Pixmap(1, 1, Format.RGBA8888); pixmap.setColor(Color.LIGHT_GRAY); pixmap.fill(); // The following defines the defaults for Scene2D's skin skin.add("grey", new Texture(pixmap)); skin.add("default", new BitmapFont(Gdx.files.internal(FONT_LOC))); LabelStyle labelStyle = new LabelStyle(); labelStyle.font = skin.getFont("default"); skin.add("default", labelStyle); ScrollPaneStyle scrollPaneStyle = new ScrollPaneStyle(); skin.add("default", scrollPaneStyle); ButtonStyle buttonStyle = new ButtonStyle(); skin.add("default", buttonStyle); TextButtonStyle textButtonStyle = new TextButtonStyle(); textButtonStyle.font = skin.getFont("default"); textButtonStyle.up = new NinePatchDrawable(patchBox); skin.add("default", textButtonStyle); // Creates Actors (the entire LICENSE text file) for Scene2D Label license = new Label(licenseString, skin); ScrollPane scrollPane = new ScrollPane(license, skin); scrollPane.setFlickScroll(true); table.add(scrollPane); // Creates the padding between the text and the button. table.row(); // Label padding = new Label(LABEL_PADDING, skin); // table.add(padding); // Creates the 'Okay' button table.row(); TextButton okay = new TextButton("Okay", skin); table.add(okay); okay.addListener(new ChangeListener() { public void changed(ChangeEvent event, Actor actor) { dispose(); game.setScreen(new MainMenuScreen(game)); } }); // Adds padding on top and on the bottom of the table. table.padTop(TABLE_PADDING); table.padBottom(TABLE_PADDING); table.pack(); }
From source file:com.uwsoft.editor.renderer.factory.component.ColorPrimitiveComponentFactory.java
License:Apache License
protected TextureRegionComponent createTextureRegionComponent(Entity entity, MainItemVO vo) { TextureRegionComponent component = new TextureRegionComponent(); Pixmap pixmap = new Pixmap(1, 1, Pixmap.Format.RGBA8888); pixmap.setColor(Color.WHITE); pixmap.fill();//from ww w . j a v a 2s .c o m Texture texture = new Texture(pixmap); texture.setFilter(Texture.TextureFilter.Nearest, Texture.TextureFilter.Nearest); TextureRegion textureRegion = new TextureRegion(texture); component.region = textureRegion; component.isRepeat = false; component.isPolygon = true; entity.add(component); return component; }
From source file:com.uwsoft.editor.view.ui.widget.components.color.CustomColorPicker.java
License:Apache License
private void createColorWidgets() { palettePixmap = new Pixmap(100, 100, Pixmap.Format.RGB888); paletteTexture = new Texture(palettePixmap); barPixmap = new Pixmap(1, 360, Pixmap.Format.RGB888); for (int h = 0; h < 360; h++) { ColorUtils.HSVtoRGB(360 - h, 100, 100, tmpColor); barPixmap.drawPixel(0, h, Color.rgba8888(tmpColor)); }/*from w w w .j a v a 2 s . co m*/ barTexture = new Texture(barPixmap); palette = new Palette(paletteTexture, 0, 0, 100, new ChangeListener() { @Override public void changed(ChangeEvent event, Actor actor) { //S ans V are flipped because the plate is flipped as well! sBar.setValue(palette.getV()); vBar.setValue(palette.getS()); updateHSVValuesFromFields(); updatePixmaps(); } }); verticalBar = new VerticalChannelBar(barTexture, 0, 360, new ChangeListener() { @Override public void changed(ChangeEvent event, Actor actor) { hBar.setValue(verticalBar.getValue()); updateHSVValuesFromFields(); updatePixmaps(); } }); hBar = new ColorChannelWidget("H", 360, new ColorChannelWidget.ColorChannelWidgetListener() { @Override public void updateFields() { verticalBar.setValue(hBar.getValue()); updateHSVValuesFromFields(); updatePixmaps(); } @Override public void draw(Pixmap pixmap) { for (int h = 0; h < 360; h++) { ColorUtils.HSVtoRGB(h, sBar.getValue(), vBar.getValue(), tmpColor); pixmap.drawPixel(h, 0, Color.rgba8888(tmpColor)); } } }); sBar = new ColorChannelWidget("S", 100, new ColorChannelWidget.ColorChannelWidgetListener() { @Override public void updateFields() { palette.setValue(vBar.getValue(), sBar.getValue()); updateHSVValuesFromFields(); updatePixmaps(); } @Override public void draw(Pixmap pixmap) { for (int s = 0; s < 100; s++) { ColorUtils.HSVtoRGB(hBar.getValue(), s, vBar.getValue(), tmpColor); pixmap.drawPixel(s, 0, Color.rgba8888(tmpColor)); } } }); vBar = new ColorChannelWidget("V", 100, new ColorChannelWidget.ColorChannelWidgetListener() { @Override public void updateFields() { palette.setValue(vBar.getValue(), sBar.getValue()); updateHSVValuesFromFields(); updatePixmaps(); } @Override public void draw(Pixmap pixmap) { for (int v = 0; v < 100; v++) { ColorUtils.HSVtoRGB(hBar.getValue(), sBar.getValue(), v, tmpColor); pixmap.drawPixel(v, 0, Color.rgba8888(tmpColor)); } } }); rBar = new ColorChannelWidget("R", 255, new ColorChannelWidget.ColorChannelWidgetListener() { @Override public void updateFields() { updateRGBValuesFromFields(); updatePixmaps(); } @Override public void draw(Pixmap pixmap) { for (int r = 0; r < 255; r++) { tmpColor.set(r / 255.0f, color.g, color.b, 1); pixmap.drawPixel(r, 0, Color.rgba8888(tmpColor)); } } }); gBar = new ColorChannelWidget("G", 255, new ColorChannelWidget.ColorChannelWidgetListener() { @Override public void updateFields() { updateRGBValuesFromFields(); updatePixmaps(); } @Override public void draw(Pixmap pixmap) { for (int g = 0; g < 255; g++) { tmpColor.set(color.r, g / 255.0f, color.b, 1); pixmap.drawPixel(g, 0, Color.rgba8888(tmpColor)); } } }); bBar = new ColorChannelWidget("B", 255, new ColorChannelWidget.ColorChannelWidgetListener() { @Override public void updateFields() { updateRGBValuesFromFields(); updatePixmaps(); } @Override public void draw(Pixmap pixmap) { for (int b = 0; b < 255; b++) { tmpColor.set(color.r, color.g, b / 255.0f, 1); pixmap.drawPixel(b, 0, Color.rgba8888(tmpColor)); } } }); aBar = new ColorChannelWidget("A", 255, true, new ColorChannelWidget.ColorChannelWidgetListener() { @Override public void updateFields() { if (aBar.isInputValid()) color.a = aBar.getValue() / 255.0f; updatePixmaps(); } @Override public void draw(Pixmap pixmap) { pixmap.fill(); for (int i = 0; i < 255; i++) { tmpColor.set(color.r, color.g, color.b, i / 255.0f); pixmap.drawPixel(i, 0, Color.rgba8888(tmpColor)); } } }); }
From source file:com.watabou.gltextures.Gradient.java
License:Open Source License
private static GdxTexture createTexture(int[] colors) { final Pixmap pixmap = new Pixmap(colors.length, 1, Pixmap.Format.RGBA8888); for (int i = 0; i < colors.length; i++) { final int color = colors[i]; pixmap.drawPixel(i, 0, (color << 8) | (color >>> 24)); }/* w w w . ja va2 s . c o m*/ return new GdxTexture(pixmap); }
From source file:com.watabou.gltextures.TextureCache.java
License:Open Source License
public static SmartTexture createSolid(int color) { String key = "1x1:" + color; if (all.containsKey(key)) { return all.get(key); } else {//from w w w . j a v a2 s .c om final Pixmap pixmap = new Pixmap(1, 1, Pixmap.Format.RGBA8888); // In the rest of the code ARGB is used pixmap.setColor((color << 8) | (color >>> 24)); pixmap.fill(); GdxTexture bmp = new GdxTexture(pixmap); SmartTexture tx = new SmartTexture(bmp); all.put(key, tx); return tx; } }
From source file:com.xemplar.games.android.nerdshooter.screens.ui.Button.java
License:Open Source License
public Button(BitmapFont font, String text, float x, float y, float width, float height) { super(font, text, x, y, width, height); this.text = text; this.font = font; array_pressed = new float[] { 0.5F, 0.5F, 0.5F, 1.0F }; array_not_pressed = new float[] { 0.5F, 0.5F, 0.5F, 1.0F }; Pixmap pix_not_pressed = new Pixmap((int) width, (int) height, Pixmap.Format.RGBA8888); pix_not_pressed.setColor(0.5F, 0.5F, 0.5F, 1.0F); pix_not_pressed.fill();//from w ww . j a va 2 s .com tex_not_pressed = new Texture(pix_not_pressed); Pixmap pix_pressed = new Pixmap((int) width, (int) height, Pixmap.Format.RGBA8888); pix_pressed.setColor(0.7F, 0.7F, 0.7F, 1.0F); pix_pressed.fill(); tex_pressed = new Texture(pix_pressed); }
From source file:com.xemplar.games.android.nerdshooter.screens.ui.Button.java
License:Open Source License
public Button(BitmapFont font, String text, float[] colors, float x, float y, float width, float height) { super(font, text, x, y, width, height); array_pressed = colors;/*from w ww. java2 s. co m*/ array_not_pressed = colors; Pixmap pix_not_pressed = new Pixmap((int) width, (int) height, Pixmap.Format.RGBA8888); pix_not_pressed.setColor(colors[0], colors[1], colors[2], colors[3]); pix_not_pressed.fill(); tex_not_pressed = new Texture(pix_not_pressed); Pixmap pix_pressed = new Pixmap((int) width, (int) height, Pixmap.Format.RGBA8888); pix_pressed.setColor(colors[0], colors[1], colors[2], colors[3]); pix_pressed.fill(); tex_pressed = new Texture(pix_pressed); }
From source file:com.xemplar.games.android.nerdshooter.screens.ui.Button.java
License:Open Source License
public Button(BitmapFont font, String text, float[] colors, float[] pressedColors, float x, float y, float width, float height) { super(font, text, x, y, width, height); array_pressed = colors;/* w w w. ja v a2s .c om*/ array_not_pressed = pressedColors; Pixmap pix_not_pressed = new Pixmap((int) width, (int) height, Pixmap.Format.RGBA8888); pix_not_pressed.setColor(colors[0], colors[1], colors[2], colors[3]); pix_not_pressed.fill(); tex_not_pressed = new Texture(pix_not_pressed); Pixmap pix_pressed = new Pixmap((int) width, (int) height, Pixmap.Format.RGBA8888); pix_pressed.setColor(pressedColors[0], pressedColors[1], pressedColors[2], pressedColors[3]); pix_pressed.fill(); tex_pressed = new Texture(pix_pressed); }