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

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

Introduction

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

Prototype

Color WHITE

To view the source code for com.badlogic.gdx.graphics Color WHITE.

Click Source Link

Usage

From source file:com.bladecoder.engine.util.RectangleRenderer.java

License:Apache License

private static Texture makePixel() {
    Texture _temp;/*from  w  w  w .  j a  v  a2  s.c om*/
    Pixmap p = new Pixmap(1, 1, Pixmap.Format.RGBA8888);
    p.setColor(Color.WHITE);
    p.fillRectangle(0, 0, 1, 1);
    _temp = new Texture(p, true);
    p.dispose();
    return _temp;
}

From source file:com.bladecoder.engine.util.Utils3D.java

License:Apache License

public static void createFloor() {

    ModelBuilder modelBuilder = new ModelBuilder();
    modelBuilder.begin();/*from ww w  . j  a va2  s .c  o m*/
    MeshPartBuilder mpb = modelBuilder.part("parts", GL20.GL_TRIANGLES,
            Usage.Position | Usage.Normal | Usage.ColorUnpacked,
            new Material(ColorAttribute.createDiffuse(Color.WHITE)));
    mpb.setColor(1f, 1f, 1f, 1f);
    //      mpb.box(0, -0.1f, 0, 10, .2f, 10);
    mpb.rect(-10, 0, -10, -10, 0, 10, 10, 0, 10, 10, 0, -10, 0, 1, 0);
    floorModel = modelBuilder.end();
    floorInstance = new ModelInstance(floorModel);

    // TODO Set only when FBO is active
    floorInstance.materials.get(0).set(new BlendingAttribute(GL20.GL_SRC_ALPHA, GL20.GL_ONE_MINUS_SRC_ALPHA));
}

From source file:com.bladecoder.engineeditor.scneditor.AnimationWidget.java

License:Apache License

public void draw(Batch batch, float parentAlpha) {
    super.draw(batch, parentAlpha);

    if (renderer == null || renderer.getCurrentAnimation() == null)
        return;// w  ww. j  av  a2  s  .c o m

    Color tmp = batch.getColor();
    batch.setColor(Color.WHITE);

    renderer.update(Gdx.graphics.getDeltaTime());

    RectangleRenderer.draw((SpriteBatch) batch, getX(), getY(), getWidth(), getHeight(), Color.MAGENTA);

    float scalew = getWidth() / renderer.getWidth();
    float scaleh = getHeight() / renderer.getHeight();
    float scale = scalew > scaleh ? scaleh : scalew;
    renderer.draw((SpriteBatch) batch, getX() + renderer.getWidth() * scale / 2, getY(), scale);
    batch.setColor(tmp);
}

From source file:com.bladecoder.engineeditor.scneditor.CanvasDrawer.java

License:Apache License

public void drawBBoxWalkZone(Scene scn, boolean lineOfSight) {

    if (scn.getPolygonalNavGraph() != null) {
        drawer.setProjectionMatrix(camera.combined);
        drawer.setTransformMatrix(new Matrix4());
        drawer.begin(ShapeType.Line);

        drawer.setColor(Scene.WALKZONE_COLOR);
        drawer.polygon(scn.getPolygonalNavGraph().getWalkZone().getTransformedVertices());

        // DRAW LINEs OF SIGHT
        if (lineOfSight) {
            drawer.setColor(Color.WHITE);
            ArrayList<NavNodePolygonal> nodes = scn.getPolygonalNavGraph().getGraphNodes();
            for (NavNodePolygonal n : nodes) {
                for (NavNodePolygonal n2 : n.neighbors) {
                    drawer.line(n.x, n.y, n2.x, n2.y);
                }/*from w w w . j a  va 2 s.co  m*/
            }
        }
        drawer.end();
    }
}

From source file:com.bladecoder.engineeditor.scneditor.ScnWidget.java

License:Apache License

@Override
public void draw(Batch batch, float parentAlpha) {
    validate();//from  ww  w  .  j av  a 2s.c  o m

    Color tmp = batch.getColor();
    batch.setColor(Color.WHITE);

    if (scn != null && !loading && !loadingError) {
        // BACKGROUND
        batch.disableBlending();
        tile.draw(batch, getX(), getY(), getWidth(), getHeight());
        batch.enableBlending();

        Vector3 v = new Vector3(getX(), getY(), 0);
        v = v.prj(batch.getTransformMatrix());

        batch.end();

        HdpiUtils.glViewport((int) v.x, (int) v.y, (int) getWidth(), (int) (getHeight()));

        getStage().calculateScissors(bounds, scissors);

        if (ScissorStack.pushScissors(scissors)) {
            // WORLD CAMERA
            sceneBatch.setProjectionMatrix(camera.combined);
            sceneBatch.begin();

            Array<AtlasRegion> scnBackground = scn.getBackground();

            if (scnBackground != null) {
                sceneBatch.disableBlending();

                float x = 0;

                for (AtlasRegion tile : scnBackground) {
                    sceneBatch.draw(tile, x, 0f);
                    x += tile.getRegionWidth();
                }

                sceneBatch.enableBlending();
            }

            // draw layers from bottom to top
            List<SceneLayer> layers = scn.getLayers();
            for (int i = layers.size() - 1; i >= 0; i--) {
                SceneLayer layer = layers.get(i);

                if (!layer.isVisible())
                    continue;

                List<InteractiveActor> actors = layer.getActors();

                for (InteractiveActor a : actors) {
                    if (a instanceof SpriteActor) {
                        boolean visibility = a.isVisible();
                        a.setVisible(true);
                        ((SpriteActor) a).draw(sceneBatch);
                        a.setVisible(visibility);
                    }
                }
            }

            sceneBatch.end();
            ScissorStack.popScissors();
        }

        drawer.drawBGBounds();

        if (showWalkZone && scn.getPolygonalNavGraph() != null) {
            drawer.drawBBoxWalkZone(scn, false);

            drawer.drawPolygonVertices(scn.getPolygonalNavGraph().getWalkZone(), Color.GREEN);
        }

        drawer.drawBBoxActors(scn);

        if (selectedActor != null) {
            drawer.drawSelectedActor(selectedActor);
        }

        getStage().getViewport().apply();

        // SCREEN CAMERA
        batch.begin();

        drawFakeDepthMarkers((SpriteBatch) batch);

        if (!inScene) {
            faRenderer.draw((SpriteBatch) batch);
        }

        // DRAW COORDS
        Vector2 coords = new Vector2(Gdx.input.getX(), Gdx.input.getY());
        screenToWorldCoords(coords);
        String str = MessageFormat.format("({0}, {1})", (int) coords.x, (int) coords.y);

        textLayout.setText(defaultFont, str);

        RectangleRenderer.draw((SpriteBatch) batch, 0f, getY() + getHeight() - textLayout.height - 15,
                textLayout.width + 10, textLayout.height + 10, BLACK_TRANSPARENT);
        defaultFont.draw(batch, textLayout, 5, getHeight() + getY() - 10);

        batch.setColor(tmp);

    } else {
        background.draw(batch, getX(), getY(), getWidth(), getHeight());

        String s;

        if (loading) {
            s = "LOADING...";

            try {
                if (!EngineAssetManager.getInstance().isLoading()) {
                    loading = false;

                    scn.retrieveAssets();

                    drawer.setCamera(camera);

                    invalidate();
                }
            } catch (Exception e) {
                Message.showMsg(getStage(), "Could not load assets for scene", 4);
                e.printStackTrace();
                loadingError = true;
                loading = false;
            }

        } else if (loadingError) {
            s = "ERROR IN SCENE DATA. CANNOT DISPLAY SCENE";
        } else if (Ctx.project.getProjectDir() == null) {
            s = "CREATE OR LOAD A PROJECT";
        } else {
            s = "THERE ARE NO SCENES IN THIS CHAPTER YET";
        }

        textLayout.setText(bigFont, s);

        bigFont.draw(batch, textLayout, (getWidth() - textLayout.width) / 2,
                getHeight() / 2 + bigFont.getLineHeight() * 3);

    }

}

From source file:com.bladecoder.engineeditor.ui.components.InputPanel.java

License:Apache License

public void setError(boolean value) {
    if (value)//  www .  ja va 2s .  c  o m
        title.getStyle().fontColor = Color.RED;
    else
        title.getStyle().fontColor = Color.WHITE;
}

From source file:com.bladecoder.engineeditor.ui.SceneList.java

License:Apache License

private TextureRegion createBgIcon(String atlas, String region) {
    TextureAtlas a = new TextureAtlas(Gdx.files
            .absolute(Ctx.project.getProjectPath() + "/" + Project.ATLASES_PATH + "/1/" + atlas + ".atlas"));
    AtlasRegion r = a.findRegion(region);

    if (r == null) {
        a.dispose();/*  ww w  . ja v  a2 s .c o  m*/
        return null;
    }

    FrameBuffer fbo = new FrameBuffer(Format.RGBA8888, 200,
            (int) (r.getRegionHeight() * 200f / r.getRegionWidth()), false);

    SpriteBatch fboBatch = new SpriteBatch();
    fboBatch.setColor(Color.WHITE);
    OrthographicCamera camera = new OrthographicCamera();
    camera.setToOrtho(false, fbo.getWidth(), fbo.getHeight());
    fboBatch.setProjectionMatrix(camera.combined);

    Gdx.gl.glDisable(GL20.GL_SCISSOR_TEST);
    fbo.begin();
    fboBatch.begin();
    fboBatch.draw(r, 0, 0, fbo.getWidth(), fbo.getHeight());
    fboBatch.end();

    TextureRegion tex = ScreenUtils.getFrameBufferTexture(0, 0, fbo.getWidth(), fbo.getHeight());
    // tex.flip(false, true);

    fbo.end();
    Gdx.gl.glEnable(GL20.GL_SCISSOR_TEST);

    fbo.dispose();
    a.dispose();
    fboBatch.dispose();

    return tex;
}

From source file:com.bombinggames.clonkrageremade.View.java

/**
 * Draw a string using the color white.//from   w  w  w . j a va 2 s.c  o m
 *
 * @param msg
 * @param xPos screen space
 * @param yPos screen space
 * @param openbatch true if begin/end shoould be called
 */
public void drawString(final String msg, final int xPos, final int yPos, boolean openbatch) {
    if (openbatch) {
        //spriteBatch.setProjectionMatrix(libGDXcamera.combined);
        spriteBatch.begin();
    }
    getFont().setColor(Color.WHITE.cpy());
    getFont().draw(spriteBatch, msg, xPos, yPos);
    if (openbatch) {
        spriteBatch.end();
    }
}

From source file:com.bombinggames.clonkrageremade.View.java

/**
 * Draw a string in a color. Using open batch.
 *
 * @param msg//from   w ww.ja v a  2 s .  c o  m
 * @param xPos screen space
 * @param yPos screen space
 * @param color
 */
public void drawString(final String msg, final int xPos, final int yPos, final Color color) {
    spriteBatch.setColor(Color.WHITE.cpy());
    getFont().setColor(color);
    getFont().draw(spriteBatch, msg, xPos, yPos);
}

From source file:com.bossletsplays.rr.screens.MainMenu.java

License:Apache License

@Override
public void show() {
    stage = new Stage();
    Util.setInput(stage);/*ww  w  .  ja  v a2s . c o  m*/
    atlas = new TextureAtlas("ui/button.pack");
    skin = new Skin(atlas);
    table = new Table(skin);
    table.setBounds(0, 0, Util.getWidth(), Util.getHeight());
    buttonFont = Font.getFont("04b_08");
    headingFont = Font.getFont("terminal");

    TextButtonStyle buttonStyle = new TextButtonStyle();
    buttonStyle.up = skin.getDrawable("button.up");
    buttonStyle.down = skin.getDrawable("button.down");
    buttonStyle.pressedOffsetX = 1;
    buttonStyle.pressedOffsetY = -1;
    buttonStyle.font = buttonFont;
    buttonStyle.fontColor = Color.BLACK;

    play = new TextButton("Play", buttonStyle);
    play.pad(20);
    options = new TextButton("Options", buttonStyle);
    options.pad(20);
    exit = new TextButton("Exit", buttonStyle);
    exit.addListener(new ClickListener() {
        @Override
        public void clicked(InputEvent event, float x, float y) {
            Ragdoll.exit();
        }
    });
    exit.pad(20);

    LabelStyle headingStyle = new LabelStyle(headingFont, Color.WHITE);
    heading = new Label(Reference.TITLE, headingStyle);
    heading.setFontScale(3);

    addComponent(heading);
    addComponent(play);
    addComponent(options);
    table.add(exit);
    if (Reference.DEBUG)
        table.debug();
    stage.addActor(table);
}