Example usage for com.badlogic.gdx.scenes.scene2d.utils TextureRegionDrawable getRegion

List of usage examples for com.badlogic.gdx.scenes.scene2d.utils TextureRegionDrawable getRegion

Introduction

In this page you can find the example usage for com.badlogic.gdx.scenes.scene2d.utils TextureRegionDrawable getRegion.

Prototype

public TextureRegion getRegion() 

Source Link

Usage

From source file:com.gdx.extension.ui.color.SlideColorPicker.java

License:Apache License

/**
 * Generate the slider background./*from w  ww .j  av a 2s .  c  om*/
 */
public void initialize() {
    pixMap = new Pixmap((int) getWidth(), (int) getHeight(), Format.RGBA8888);
    int _colorMin = (int) colorRange.x;
    int _colorMax = (int) colorRange.y;
    int _colorCount = (_colorMax - _colorMin);
    float _scaleRatio = (float) _colorCount / ((isVertical) ? pixMap.getHeight() : pixMap.getWidth());

    for (int i = 0; i <= (isVertical ? pixMap.getHeight() : pixMap.getWidth()); i++) {
        Color _color = ColorUtil.getHSBColor((i * _scaleRatio + _colorMin) / ((float) _colorMax), saturation,
                brightness);

        pixMap.setColor(_color.getRed() / 256f, _color.getGreen() / 256f, _color.getBlue() / 256f,
                _color.getAlpha() / 256f);
        if (isVertical)
            pixMap.drawLine(0, i, pixMap.getWidth(), i);
        else
            pixMap.drawLine(i, 0, i, pixMap.getHeight());
    }

    TextureRegionDrawable _background = new TextureRegionDrawable(new TextureRegion(new Texture(pixMap)));
    if (isVertical)
        _background.getRegion().flip(false, true);
    getStyle().background = _background;
    setStyle(getStyle());
    pixMap.dispose();
}

From source file:es.eucm.ead.editor.processors.EditorEmptyRendererProcessor.java

License:Open Source License

public EditorEmptyRendererProcessor(Controller controller) {
    super(controller.getEngine().getGameLoop(), controller.getEditorGameAssets());
    this.engine = controller.getEngine();
    TextureRegionDrawable blank = (TextureRegionDrawable) controller.getApplicationAssets().getSkin()
            .getDrawable("blank");
    Sprite sprite = new Sprite(blank.getRegion());
    sprite.setColor(INTERACTIVE_ZONE_COLOR);
    drawable = new SpriteDrawable(sprite);

    sprite = new Sprite(blank.getRegion());
    sprite.setColor(INTERACTIVE_ZONE_COLOR);
    sprite.setAlpha(0.25f);//  w ww  . j a  v a 2  s . co  m
    extendedDrawable = new SpriteDrawable(sprite);
}

From source file:es.eucm.ead.engine.debugger.SimpleDebugger.java

License:Open Source License

public SimpleDebugger(Game game, GameLoader gameLoader) {
    this.setTouchable(Touchable.disabled);
    this.history = new Array<String>();
    final CommandInterpreter commandInterpreter = new CommandInterpreter(game, gameLoader);
    BitmapFont font = new BitmapFont(
            Gdx.files.internal("es/eucm/ead/engine/resources/binary/fonts/ubuntu-16-bold.fnt"), true);
    this.setX(0);
    this.setY(580);

    Pixmap p = new Pixmap(10, 10, Pixmap.Format.RGBA8888);
    p.setColor(Color.BLACK);/*from   www  .j av a2 s  .c om*/
    p.fill();
    TextureRegionDrawable background = new TextureRegionDrawable(new TextureRegion(new Texture(p)));
    p.dispose();
    p = new Pixmap(2, 30, Pixmap.Format.RGBA8888);
    p.setColor(Color.WHITE);
    p.fill();
    TextureRegionDrawable cursor = new TextureRegionDrawable(new TextureRegion(new Texture(p)));
    p.dispose();

    Label.LabelStyle style = new Label.LabelStyle();
    SpriteDrawable backgroundSprite = new SpriteDrawable(new Sprite(background.getRegion()));
    backgroundSprite.getSprite().setColor(new Color(0, 0, 0, 0.5f));
    style.background = backgroundSprite;
    style.font = font;
    style.fontColor = Color.WHITE;
    result = new Label("", style);
    result.setWrap(true);
    int y = -100;

    result.setBounds(0, y, 800, -y);
    this.addActor(result);

    TextField.TextFieldStyle tfStyle = new TextField.TextFieldStyle();
    tfStyle.font = font;
    tfStyle.background = background;
    tfStyle.selection = cursor;
    tfStyle.fontColor = Color.WHITE;
    tfStyle.cursor = cursor;
    interpreter = new TextField("", tfStyle);
    interpreter.setBounds(10, 0, 800, 20);
    interpreter.getStyle().font = font;
    interpreter.addListener(new InputListener() {
        @Override
        public boolean keyDown(InputEvent event, int keycode) {
            switch (keycode) {
            case Input.Keys.ENTER:
                String command = interpreter.getText();
                if (history.size == 0 || !history.peek().equals(command)) {
                    history.add(command);
                }
                historyPointer = history.size;
                result.setText(commandInterpreter.interpret(command));
                interpreter.setText("");
                break;
            case Input.Keys.ESCAPE:
                setVisible(false);
                break;
            case Input.Keys.UP:
                previousCommand();
                break;
            case Input.Keys.DOWN:
                nextCommand();
                break;
            }
            return true;
        }
    });

    Button.ButtonStyle buttonStyle = new Button.ButtonStyle();
    Label label = new Label(">", style);
    buttonStyle.up = background;
    button = new Button(label, buttonStyle);
    button.setHeight(20);
    button.addListener(new InputListener() {
        @Override
        public boolean touchDown(InputEvent event, float x, float y, int pointer, int button) {
            setVisible(true);
            return false;
        }
    });

    this.addActor(interpreter);
    setVisible(false);
    this.addActor(button);
    ((EAdEngine) Gdx.app.getApplicationListener()).getStage().addListener(new InputListener() {
        @Override
        public boolean keyDown(InputEvent event, int keycode) {
            switch (keycode) {
            case Input.Keys.F12:
                setVisible(true);
                break;
            }
            return false;
        }
    });
}

From source file:mobi.shad.s3lib.gui.ui.Sprite.java

License:Apache License

public void setDrawable(TextureRegionDrawable drawable) {
    duration = 0;
    animation = null;
    keyFrame = drawable.getRegion();
}

From source file:org.ams.testapps.paintandphysics.physicspuzzle.PhysicsPuzzleGameMenu.java

License:Open Source License

/** Get the TextureRegion that the image is drawing. */
private TextureRegion getTextureRegion(Image image) {
    TextureRegionDrawable drawable = (TextureRegionDrawable) selectedThumbnail.getDrawable();
    return drawable.getRegion();
}