Example usage for com.badlogic.gdx.graphics Color Color

List of usage examples for com.badlogic.gdx.graphics Color Color

Introduction

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

Prototype

public Color(float r, float g, float b, float a) 

Source Link

Document

Constructor, sets the components of the color

Usage

From source file:com.o2d.pkayjava.editor.view.stage.Sandbox.java

License:Apache License

public void initView() {
    //TODO fix and uncomment
    //        getCamera().position.set(0, 0, 0);

    selectionRec = new PixelRect(0, 0);
    selectionRec.setFillColor(new Color(1, 1, 1, 0.1f));
    selectionRec.setOpacity(0.0f);/*from   ww  w. ja  v  a  2 s .c om*/
    selectionRec.setTouchable(Touchable.disabled);
    uiStage.midUI.addActor(selectionRec);

}

From source file:com.o2d.pkayjava.editor.view.ui.box.resourcespanel.draggable.box.BoxItemResource.java

License:Apache License

public BoxItemResource() {
    sandbox = Sandbox.getInstance();//from ww w  .ja  v a2s . com
    rc = new PixelRect(thumbnailSize, thumbnailSize);
    rc.setFillColor(new Color(1, 1, 1, 0.2f));
    rc.setBorderColor(new Color(1, 1, 1, 0.4f));
    addActor(rc);
    setWidth(thumbnailSize);
    setHeight(thumbnailSize);
}

From source file:com.o2d.pkayjava.editor.view.ui.properties.panels.UIScenePropertiesMediator.java

License:Apache License

protected void translateObservableDataToView(SceneVO item) {
    PhysicsPropertiesVO physicsVO = item.physicsPropertiesVO;

    viewComponent.setPixelsPerWorldUnit(Sandbox.getInstance().getPixelPerWU());

    viewComponent.setGravityXValue(physicsVO.gravityX + "");
    viewComponent.setGravityYValue(physicsVO.gravityY + "");
    viewComponent.setPhysicsEnable(physicsVO.enabled);
    viewComponent.setSleepVelocityValue(physicsVO.sleepVelocity + "");
    viewComponent.setAmbientColor(//  www .j a v  a  2 s .c o  m
            new Color(item.ambientColor[0], item.ambientColor[1], item.ambientColor[2], item.ambientColor[3]));

    viewComponent.setLightsEnabled(item.lightSystemEnabled);
    viewComponent.setDiffuse(Sandbox.getInstance().sceneControl.isDiffuse());
}

From source file:com.o2d.pkayjava.editor.view.ui.widget.actors.basic.PixelRect.java

License:Apache License

public PixelRect(float width, float height) {
    facade = Overlap2DFacade.getInstance();
    projectManager = facade.retrieveProxy(ProjectManager.NAME);
    EditorTextureManager tm = facade.retrieveProxy(EditorTextureManager.NAME);
    lines[0] = new PixelLine(tm, 0, 0, width, 0);
    lines[1] = new PixelLine(tm, 0, 0, 0, height);
    lines[2] = new PixelLine(tm, width, 0, width, height);
    lines[3] = new PixelLine(tm, 0, height, width, height);

    fill = new Image(tm.getEditorAsset("pixel"));
    fill.setColor(new Color(0, 0, 0, 0));

    addActor(fill);//from ww w  . jav  a 2 s.  c  o m

    addActor(lines[0]);
    addActor(lines[1]);
    addActor(lines[2]);
    addActor(lines[3]);

    super.setWidth(width);
    super.setHeight(height);

    setOrigin(getWidth() / 2, getHeight() / 2);
    fill.setScaleX(getWidth());
    fill.setScaleY(getHeight());
}

From source file:com.o2d.pkayjava.editor.view.ui.widget.actors.GridView.java

License:Apache License

public GridView() {
    gridSize = 50;/*w  ww.ja  v  a 2 s  . c o  m*/
    gridLinesCount = 40;

    pixelsPerWU = Sandbox.getInstance().getPixelPerWU();
    shapeRenderer = new ShapeRenderer();

    for (int i = 0; i < gridLinesCount; i++) {
        Segment tmp = new Segment(i * gridSize - (gridLinesCount / 2 - 1) * gridSize,
                -(gridLinesCount / 2 - 1) * gridSize, i * gridSize - (gridLinesCount / 2 - 1) * gridSize,
                gridSize * gridLinesCount - (gridLinesCount / 2 - 1) * gridSize);
        lines.add(tmp);
    }

    for (int i = 0; i < gridLinesCount; i++) {
        Segment tmp = new Segment(-(gridLinesCount / 2 - 1) * gridSize,
                i * gridSize - (gridLinesCount / 2 - 1) * gridSize,
                gridSize * gridLinesCount - (gridLinesCount / 2 - 1) * gridSize,
                i * gridSize - (gridLinesCount / 2 - 1) * gridSize);
        lines.add(tmp);
    }

    this.setWidth(gridSize * gridLinesCount);
    this.setHeight(gridSize * gridLinesCount);

    zeroLabel = new VisLabel("0.0");
    zeroLabel.setColor(new Color(1, 1, 1, 0.4f));
}

From source file:com.paulogaspar.ninja.screens.Credits.java

private void draw() {
    if (disposed)
        return;//from   ww  w . j av  a 2 s  . c  o m
    batch.setProjectionMatrix(camera.combined);
    batch.begin();

    font_32.draw(batch, "CREDITS", 300, pos + 200);
    font_32.draw(batch, "Created by Paulo Gaspar", 30, pos);

    font_32.draw(batch, "ART", 350, pos - 400);

    batch.draw(player.jump_texture, 40, pos - 540, 64, 64);
    font_16.draw(batch, "Ninja Sprites by Kenney", 130, pos - 520);

    batch.draw(master_texture[0], 40, pos - 640, 64, 64);
    font_16.draw(batch, "Tiles, sensei and itens by LittleSadNerd", 130, pos - 620);

    batch.draw(player.shuriken.spr_star, 40, pos - 755, 64, 64);
    font_16.draw(batch, "Go check their work! Links at website!", 130, pos - 720);

    font_32.draw(batch, "SOUND EFFECTS", 180, pos - 850);

    batch.draw(tilemap.tiles[23], 40, pos - 1005, 64, 64);
    font_16.draw(batch, "Main theme, Boss theme and Credits", 130, pos - 970);
    font_16.draw(batch, "Theme by DeadEarth", 130, pos - 1000);

    batch.draw(item_texture[0], 40, pos - 1105, 64, 64);
    font_16.draw(batch, "Itens and victory jingle sounds", 130, pos - 1070);
    font_16.draw(batch, "by Little Robot Sound Factory", 130, pos - 1100);

    batch.draw(cannonD, 40, pos - 1205, 64, 64);
    font_16.draw(batch, "Cannon ball sound by Rust Ltd", 130, pos - 1170);

    batch.draw(tilemap.tiles[29], 40, pos - 1305, 64, 64);
    font_16.draw(batch, "Jump sound by Dklon", 130, pos - 1270);

    batch.draw(cannonBall, 40, pos - 1410, 64, 64);
    font_16.draw(batch, "Clock sound by AntumDeluge", 130, pos - 1370);

    batch.draw(player.smokebomb_texture[0], 40, pos - 1490, 64, 64);
    font_16.draw(batch, "Wall sliding sound by Bart Kelsey", 130, pos - 1470);

    font_32.draw(batch, "PROGRAMMER", 220, pos - 1600);
    font_16.draw(batch, "All programmed and created by Paulo Gaspar Sena", 20, pos - 1700);
    font_16.draw(batch, "do Vale. All art and audio was found on", 20, pos - 1730);
    font_16.draw(batch, "www.opengameart.org under different licenses.", 20, pos - 1760);
    font_16.draw(batch, "Most were avaliable under CC or were pulic", 20, pos - 1790);
    font_16.draw(batch, "domain assets.", 20, pos - 1820);

    font_32.draw(batch, "THANKS FOR PLAYING", 100, pos - 2100);

    batch.draw(player.jump_texture, 300, ppos + pos, 64, 64);
    batch.draw(master_texture[0], 400, mpos + pos, 64, 64);

    if (stage_transition_alpha > 0) {
        batch.setColor(new Color(0, 0, 0, stage_transition_alpha));
        batch.draw(tilemap.tiles[0], -50, -50, 1200, 700);
        batch.setColor(Color.WHITE);
    }

    batch.end();
}

From source file:com.ray3k.skincomposer.data.JsonData.java

License:Open Source License

public void readFile(FileHandle fileHandle) throws Exception {
    main.getProjectData().setChangesSaved(false);

    //read drawables from texture atlas file
    FileHandle atlasHandle = fileHandle.sibling(fileHandle.nameWithoutExtension() + ".atlas");
    if (atlasHandle.exists()) {
        main.getProjectData().getAtlasData().readAtlas(atlasHandle);
    }//w w  w  .  ja va 2  s  .c  o m

    //folder for critical files to be copied to
    FileHandle saveFile = main.getProjectData().getSaveFile();
    FileHandle targetDirectory;
    if (saveFile != null) {
        targetDirectory = saveFile.sibling(saveFile.nameWithoutExtension() + "_data");
    } else {
        targetDirectory = Gdx.files.local("temp/" + main.getProjectData().getId() + "_data");
    }

    //read json file and create styles
    JsonReader reader = new JsonReader();
    JsonValue val = reader.parse(fileHandle);

    for (JsonValue child : val.iterator()) {
        //fonts
        if (child.name().equals(BitmapFont.class.getName())) {
            for (JsonValue font : child.iterator()) {
                FileHandle fontFile = fileHandle.sibling(font.getString("file"));
                FileHandle fontCopy = targetDirectory.child(font.getString("file"));
                if (!fontCopy.parent().equals(fontFile.parent())) {
                    fontFile.copyTo(fontCopy);
                }
                FontData fontData = new FontData(font.name(), fontCopy);

                //delete fonts with the same name
                for (FontData originalData : new Array<>(fonts)) {
                    if (originalData.getName().equals(fontData.getName())) {
                        fonts.removeValue(originalData, true);
                    }
                }

                fonts.add(fontData);

                BitmapFont.BitmapFontData bitmapFontData = new BitmapFont.BitmapFontData(fontCopy, false);
                for (String path : bitmapFontData.imagePaths) {
                    FileHandle file = new FileHandle(path);
                    main.getProjectData().getAtlasData()
                            .getDrawable(file.nameWithoutExtension()).visible = false;
                }
            }
        } //colors
        else if (child.name().equals(Color.class.getName())) {
            for (JsonValue color : child.iterator()) {
                ColorData colorData = new ColorData(color.name, new Color(color.getFloat("r", 0.0f),
                        color.getFloat("g", 0.0f), color.getFloat("b", 0.0f), color.getFloat("a", 0.0f)));

                //delete colors with the same name
                for (ColorData originalData : new Array<>(colors)) {
                    if (originalData.getName().equals(colorData.getName())) {
                        colors.removeValue(originalData, true);
                    }
                }

                colors.add(colorData);
            }
        } //tinted drawables
        else if (child.name().equals(TintedDrawable.class.getName())) {
            for (JsonValue tintedDrawable : child.iterator()) {
                DrawableData drawableData = new DrawableData(main.getProjectData().getAtlasData()
                        .getDrawable(tintedDrawable.getString("name")).file);
                drawableData.name = tintedDrawable.name;

                if (!tintedDrawable.get("color").isString()) {
                    drawableData.tint = new Color(tintedDrawable.get("color").getFloat("r", 0.0f),
                            tintedDrawable.get("color").getFloat("g", 0.0f),
                            tintedDrawable.get("color").getFloat("b", 0.0f),
                            tintedDrawable.get("color").getFloat("a", 0.0f));
                } else {
                    drawableData.tintName = tintedDrawable.getString("color");
                }

                //todo:test overwriting a base drawable that is depended on by another tint
                //delete drawables with the same name
                for (DrawableData originalData : new Array<>(
                        main.getProjectData().getAtlasData().getDrawables())) {
                    if (originalData.name.equals(drawableData.name)) {
                        main.getProjectData().getAtlasData().getDrawables().removeValue(originalData, true);
                    }
                }

                main.getProjectData().getAtlasData().getDrawables().add(drawableData);
            }
        } //styles
        else {
            int classIndex = 0;
            Class matchClass = ClassReflection.forName(child.name);
            for (Class clazz : Main.STYLE_CLASSES) {
                if (clazz.equals(matchClass)) {
                    break;
                } else {
                    classIndex++;
                }
            }

            Class clazz = Main.BASIC_CLASSES[classIndex];
            for (JsonValue style : child.iterator()) {
                StyleData data = newStyle(clazz, style.name);
                for (JsonValue property : style.iterator()) {
                    StyleProperty styleProperty = data.properties.get(property.name);
                    if (styleProperty.type.equals(Float.TYPE)) {
                        styleProperty.value = (double) property.asFloat();
                    } else if (styleProperty.type.equals(Color.class)) {
                        if (property.isString()) {
                            styleProperty.value = property.asString();
                        } else {
                            Gdx.app.error(getClass().getName(),
                                    "Can't import JSON files that do not use predefined colors.");
                        }
                    } else {
                        if (property.isString()) {
                            styleProperty.value = property.asString();
                        } else {
                            Gdx.app.error(getClass().getName(),
                                    "Can't import JSON files that do not use String names for field values.");
                        }
                    }
                }
            }
        }
    }
}

From source file:com.ray3k.skincomposer.dialog.DialogColors.java

License:Open Source License

public void populate() {
    colorTable.clear();/* ww  w.  j a v a2 s .c o m*/

    if (colors.size > 0) {
        colorTable.defaults().padTop(5.0f);
        for (ColorData color : colors) {
            Button button = new Button(skin, "color-base");
            button.addListener(main.getHandListener());
            Label label = new Label(color.toString(), skin, "white");
            label.setTouchable(Touchable.disabled);

            float brightness = Utils.brightness(color.color);
            Color borderColor;
            if (brightness > .35f) {
                borderColor = Color.BLACK;
                label.setColor(borderColor);
            } else {
                borderColor = Color.WHITE;
                label.setColor(borderColor);
            }

            Color bgColor = new Color(color.color.r, color.color.g, color.color.b, 1.0f);
            Table table = new Table(skin);
            table.setBackground("white");
            table.setColor(bgColor);
            table.add(label).pad(3.0f);

            if (styleProperty == null && !selectingForTintedDrawable) {
                table.addCaptureListener(new ChangeListener() {
                    @Override
                    public void changed(ChangeListener.ChangeEvent event, Actor actor) {
                        event.setBubbles(false);
                        populate();
                    }
                });
                table.addCaptureListener(new InputListener() {
                    @Override
                    public boolean touchDown(InputEvent event, float x, float y, int pointer, int button) {
                        event.setBubbles(false);
                        return true;
                    }
                });
            }
            Table borderTable = new Table(skin);
            borderTable.setBackground("white");
            borderTable.setColor(borderColor);
            borderTable.add(table).growX().pad(1.0f);

            button.add(borderTable).growX();

            //rename button
            Button renameButton = new Button(skin, "settings-small");
            renameButton.addListener(new ChangeListener() {
                @Override
                public void changed(ChangeListener.ChangeEvent event, Actor actor) {
                    renameDialog(color);

                    event.setBubbles(false);
                }
            });
            renameButton.addListener(new InputListener() {
                @Override
                public boolean touchDown(InputEvent event, float x, float y, int pointer, int button) {
                    event.setBubbles(false);
                    return true;
                }

            });
            button.add(renameButton).padLeft(10.0f);

            //recolor button
            Button recolorButton = new Button(skin, "colorwheel");
            recolorButton.addListener(new ChangeListener() {
                @Override
                public void changed(ChangeListener.ChangeEvent event, Actor actor) {
                    recolorDialog(color);

                    event.setBubbles(false);
                }
            });
            recolorButton.addListener(new InputListener() {
                @Override
                public boolean touchDown(InputEvent event, float x, float y, int pointer, int button) {
                    event.setBubbles(false);
                    return true;
                }

            });
            button.add(recolorButton);

            label = new Label("(" + ((int) (color.color.r * 255)) + ", " + ((int) (color.color.g * 255)) + ", "
                    + ((int) (color.color.b * 255)) + ", " + ((int) (color.color.a * 255)) + ")", skin);
            label.setTouchable(Touchable.disabled);
            label.setAlignment(Align.center);

            if (styleProperty == null && !selectingForTintedDrawable) {
                label.addCaptureListener(new ChangeListener() {
                    @Override
                    public void changed(ChangeListener.ChangeEvent event, Actor actor) {
                        event.setBubbles(false);
                        populate();
                    }
                });
                label.addCaptureListener(new InputListener() {
                    @Override
                    public boolean touchDown(InputEvent event, float x, float y, int pointer, int button) {
                        event.setBubbles(false);
                        return true;
                    }

                });
            }
            button.add(label).padLeft(5.0f).minWidth(160.0f);

            //delete color button
            Button closeButton = new Button(skin, "delete-small");
            final ColorData deleteColor = color;
            closeButton.addListener(new ChangeListener() {
                @Override
                public void changed(ChangeListener.ChangeEvent event, Actor actor) {
                    colors.removeValue(deleteColor, true);

                    //clear style properties that use this color.
                    for (Array<StyleData> datas : jsonData.getClassStyleMap().values()) {
                        for (StyleData data : datas) {
                            for (StyleProperty property : data.properties.values()) {
                                if (property != null && property.type.equals(Color.class)
                                        && property.value != null
                                        && property.value.equals(deleteColor.getName())) {
                                    property.value = null;
                                }
                            }
                        }
                    }

                    //delete tinted drawables based on this color.
                    for (DrawableData drawableData : new Array<>(projectData.getAtlasData().getDrawables())) {
                        if (drawableData.tintName != null
                                && drawableData.tintName.equals(deleteColor.getName())) {
                            projectData.getAtlasData().getDrawables().removeValue(drawableData, true);

                            //clear any style properties based on this tinted drawable.
                            for (Array<StyleData> styleDatas : jsonData.getClassStyleMap().values()) {
                                for (StyleData styleData : styleDatas) {
                                    for (StyleProperty styleProperty : styleData.properties.values()) {
                                        if (styleProperty != null && styleProperty.type.equals(Drawable.class)
                                                && styleProperty.value != null
                                                && styleProperty.value.equals(drawableData.toString())) {
                                            styleProperty.value = null;
                                        }
                                    }
                                }
                            }
                        }
                    }

                    main.getUndoableManager().clearUndoables();

                    main.getRootTable().refreshStyleProperties(true);
                    main.getRootTable().refreshPreview();

                    event.setBubbles(false);
                    populate();
                }
            });
            closeButton.addListener(new InputListener() {
                @Override
                public boolean touchDown(InputEvent event, float x, float y, int pointer, int button) {
                    event.setBubbles(false);
                    return true;
                }

            });

            button.add(closeButton).padLeft(5.0f);
            if (styleProperty == null && !selectingForTintedDrawable) {
                button.setTouchable(Touchable.childrenOnly);
            } else {
                setObject(button, color);
                final ColorData result = color;
                button.addListener(new ChangeListener() {
                    @Override
                    public void changed(ChangeListener.ChangeEvent event, Actor actor) {
                        result(result);
                        hide();
                    }
                });
            }
            colorTable.add(button).growX();
            colorTable.row();
        }
    } else {
        colorTable.add(new Label("No colors have been set!", skin, "required"));
    }
}

From source file:com.ray3k.skincomposer.RootTable.java

License:Open Source License

public void setStatusBarMessage(String text) {
    statusLabel.setColor(new Color(1.0f, 1.0f, 1.0f, statusLabel.getColor().a));
    display(text);
}

From source file:com.ray3k.skincomposer.RootTable.java

License:Open Source License

public void setStatusBarError(String text) {
    statusLabel.setColor(new Color(1.0f, 0.0f, 0.0f, statusLabel.getColor().a));
    display(text);
}