Example usage for com.badlogic.gdx.graphics Pixmap fill

List of usage examples for com.badlogic.gdx.graphics Pixmap fill

Introduction

In this page you can find the example usage for com.badlogic.gdx.graphics Pixmap fill.

Prototype

public void fill() 

Source Link

Document

Fills the complete bitmap with the currently set color.

Usage

From source file:at.tugraz.ist.catroid.plugin.Drone.other.DroneVideoCostume.java

License:Open Source License

public void initializeTexture() {
    Pixmap pixmap = new Pixmap(320, 240, Format.RGB888);
    pixmap.setColor(Color.BLUE);//from w w w  . j a va2s .c om
    pixmap.fill();
    Texture texture = new Texture(pixmap, false);
    texture.setFilter(TextureFilter.Linear, TextureFilter.Linear);
    this.region = new TextureRegion(texture);
    this.width = this.region.getRegionWidth();
    this.height = this.region.getRegionHeight();
    this.x -= (this.width / 2f);
    this.y -= (this.height / 2f);
    this.originX = (this.width / 2f);
    this.originY = (this.height / 2f);
    pixmap.dispose();
    firstStart = false;
}

From source file:ateamproject.kezuino.com.github.render.screens.LobbyListScreen.java

private void createGui() {
    // Back to main menu.
    TextButton btnBack = new TextButton("Terug", skin);
    btnBack.addListener(new ClickListener() {
        @Override/*from   w w w. j av  a 2s  . c  om*/
        public void clicked(InputEvent event, float x, float y) {
            game.setScreen(new MainScreen(game));
        }
    });
    btnBack.setPosition(10, stage.getHeight() - btnBack.getHeight() - 10);
    this.stage.addActor(btnBack);

    // Create game button.
    TextButton btnCreateGame = new TextButton("Maak spel", skin);
    btnCreateGame.addListener(new ClickListener() {
        @Override
        public void clicked(InputEvent event, float x, float y) {

            Dialog d = new Dialog("Lobby Name", skin);
            lobbyname = new TextField("", skin);

            SelectBox<Object> clanDropdown = null;
            String dropDownResult = "";
            if (clanGame) {
                Client client = Client.getInstance();
                PacketGetClans packet = new PacketGetClans();
                client.send(packet);
                ArrayList<String> listclans = packet.getResult();

                Object[] arrayClans = new Object[listclans.size()];
                for (int i = 0; i < listclans.size(); i++) {

                    arrayClans[i] = listclans.get(i);

                }
                clanDropdown = new SelectBox<>(skin);

                clanDropdown.setItems(arrayClans);

                clanDropdown.setSelectedIndex(0);
                d.add(clanDropdown);
            }

            TextButton btnsubmit = new TextButton("Maken", skin);
            lobbyname.setSize(150, 30);

            d.add(lobbyname);
            d.add(btnsubmit);

            final SelectBox dropDownResultFinal = clanDropdown;
            btnsubmit.addListener(new ClickListener() {
                @Override
                public void clicked(InputEvent event, float x, float y) {
                    d.hide();
                    if (!lobbyname.getText().equals("")) {
                        if (clanGame) {
                            game.setScreen(new LobbyScreen(game, lobbyname.getText(),
                                    dropDownResultFinal.getSelected().toString()));
                        } else {
                            game.setScreen(new LobbyScreen(game, lobbyname.getText(), null));
                        }
                    }
                }
            });
            d.show(stage);
        }
    });

    // Create game button
    btnCreateGame.setPosition(stage.getWidth() - btnCreateGame.getWidth() - 10,
            stage.getHeight() - btnCreateGame.getHeight() - 10);
    this.stage.addActor(btnCreateGame);

    Pixmap pm1 = new Pixmap(1, 1, Pixmap.Format.RGB565);
    pm1.setColor(Color.GREEN);
    pm1.fill();

    // set table position
    scrollTable = new Table(skin);
    scrollTable.setColor(com.badlogic.gdx.graphics.Color.BLUE);
    final ScrollPane scroller = new ScrollPane(scrollTable);
    scroller.sizeBy(200, 400);
    scroller.setColor(com.badlogic.gdx.graphics.Color.BLUE);
    final Table table = new Table();
    table.setFillParent(false);
    table.add(scroller).fill().expand();
    table.setSize(stage.getWidth(), stage.getHeight() - btnCreateGame.getHeight());
    table.setColor(com.badlogic.gdx.graphics.Color.BLUE);

    // get all host from the server and put in the table
    fillHostTable();

    float x = stage.getWidth() / 2 - table.getWidth() / 2;
    float y = stage.getHeight() - table.getHeight() - btnCreateGame.getHeight() - 20;

    table.setPosition(x, y);
    this.stage.addActor(table);

}

From source file:base.Engine.java

License:Open Source License

public static Pixmap generatePatternPixmap(PatternEntry basedOn, Color color) {
    Pixmap returnPixmap = new Pixmap(basedOn.getWrapper().getW(), basedOn.getWrapper().getH(),
            Pixmap.Format.RGBA8888);
    returnPixmap.setColor(Color.rgba8888(0, 0, 0, 0));
    returnPixmap.fill();

    returnPixmap.setColor(Color.DARK_GRAY);
    returnPixmap.drawPixel(0, 0);//from  w  w w.  j  ava 2  s.  co m

    returnPixmap.setColor(color);

    for (int x = 0; x < basedOn.getWrapper().getW(); x++)
        for (int y = 0; y < basedOn.getWrapper().getH(); y++)
            if (basedOn.getCells()[x][y] != 0)
                returnPixmap.drawPixel(x, y);

    return returnPixmap;
}

From source file:CB_UI_Base.graphics.SolidTextureRegion.java

License:Open Source License

public SolidTextureRegion(Color color, float width, float height) {
    Pixmap pix = new Pixmap(2, 2, Format.RGB565);
    pix.setColor(color);//from  ww w . j  a  va 2 s  .  c om
    pix.fill();

    Texture tex = new Texture(pix);
    pix.dispose();

    this.setRegion(tex);
    setRegion(0, 0, width, height);
}

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);//from   w  w w  .  ja  v  a2 s  . c  o m
    pixmap.fill();
    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 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();
    // 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. j a v a2  s  .  co  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.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();
    pauseBG = new Texture(blackbox);
}

From source file:com.badlogic.gdx.tests.ViewportTest2.java

License:Apache License

public void create() {
    font = new BitmapFont();
    font.setColor(0, 0, 0, 1);/*  w  w w. j  ava 2 s . c o 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;
        }
    });
}

From source file:com.commons.color.CustomColorPicker.java

License:Apache License

private void createColorWidgets() {
    palettePixmap = new Pixmap(100, 100, Format.RGB888);
    paletteTexture = new Texture(palettePixmap);

    barPixmap = new Pixmap(1, 360, Format.RGB888);

    for (int h = 0; h < 360; h++) {
        ColorUtils.HSVtoRGB(360 - h, 100, 100, tmpColor);
        barPixmap.drawPixel(0, h, Color.rgba8888(tmpColor));
    }/*ww w .  j av a  2 s.com*/

    barTexture = new Texture(barPixmap);

    palette = new Palette(style, sizes, paletteTexture, 0, 0, 100, new ChangeListener() {
        @Override
        public void changed(ChangeEvent event, Actor actor) {
            sBar.setValue(palette.getV());
            vBar.setValue(palette.getS());

            updateHSVValuesFromFields();
            updatePixmaps();
        }
    });

    verticalBar = new VerticalChannelBar(style, sizes, barTexture, 0, 360, new ChangeListener() {
        @Override
        public void changed(ChangeEvent event, Actor actor) {
            hBar.setValue(verticalBar.getValue());
            updateHSVValuesFromFields();
            updatePixmaps();
        }
    });

    hBar = new ColorChannelWidget(style, sizes, "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(style, sizes, "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(style, sizes, "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(style, sizes, "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(style, sizes, "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(style, sizes, "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(style, sizes, "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));
                    }
                }
            });
}