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

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

Introduction

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

Prototype

Color BLUE

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

Click Source Link

Usage

From source file:releasethekraken.ui.renderer.GameRenderer.java

@Override
public void render(float delta) {
    this.renderTime++;
    this.runTime += delta;

    //The width of the sidebar in local camera units
    float sidebarLocalWidth = 0.2F * this.camera.viewportWidth;

    //The amount to offset the player focus so that it is centered on the screen taking into account the sidebar
    float playerXOffset = sidebarLocalWidth / 2;

    if (this.world.getPlayer() != null) {
        //Calculate the center position of the camera
        float cameraX = MathUtils.clamp(this.world.getPlayer().getPos().x - playerXOffset,
                this.camera.viewportWidth / 2 - sidebarLocalWidth,
                this.world.getWidth() - this.camera.viewportWidth / 2);
        float cameraY = MathUtils.clamp(this.world.getPlayer().getPos().y, this.camera.viewportHeight / 2,
                this.world.getHeight() - this.camera.viewportHeight / 2);

        //Position the camera
        this.camera.position.set(cameraX, cameraY, 0);
        this.camera.update();
    } // end if//from   w  w  w .j  av  a 2 s .  c  o  m

    //Clears screen buffer
    Gdx.gl.glClearColor(0, 0, 0, 1);
    Gdx.gl.glClear(GL20.GL_COLOR_BUFFER_BIT);

    //Update the renderer's projection matrices
    this.worldSpriteBatch.setProjectionMatrix(this.camera.combined);
    this.worldShapeRenderer.setProjectionMatrix(this.camera.combined);

    //Render tiles
    this.tiledMapRenderer.setView(this.camera);
    this.tiledMapRenderer.render();

    //Render paths
    //Enable OpenGL alpha blending
    Gdx.gl.glEnable(Gdx.gl.GL_BLEND);
    Gdx.gl.glBlendFunc(Gdx.gl.GL_SRC_ALPHA, Gdx.gl.GL_ONE_MINUS_SRC_ALPHA);

    this.worldSpriteBatch.begin();

    this.worldSpriteBatch.draw(this.pathTexture, 0, 0, this.world.getWidth(), this.world.getHeight());

    this.worldSpriteBatch.end();

    //Disable OpenGL blending so everything else doesn't get messed up
    Gdx.gl.glDisable(Gdx.gl.GL_BLEND);

    this.worldShapeRenderer.begin(ShapeRenderer.ShapeType.Filled);

    //Draws Entity Shapes
    for (Body body : this.world.getPhysBodies()) {
        Object object = body.getUserData();
        if (object instanceof Entity)
            ((Entity) object).renderShapes(this.worldShapeRenderer, delta, this.runTime);
    }

    this.worldShapeRenderer.end();

    this.worldSpriteBatch.begin();

    //Draws Entity Sprites
    for (Body body : this.world.getPhysBodies()) {
        Object object = body.getUserData();
        if (object instanceof Entity)
            ((Entity) object).renderSprites(this.worldSpriteBatch, delta, this.runTime);
    }

    //Draw particle effects
    Array<PooledEffect> effects = this.world.getParticleEffects();

    /*
     *  Iterate backwards so that we can remove finished particle effects while iterating. 
     *  See https://github.com/libgdx/libgdx/wiki/2d-particle-effects
     */
    for (int i = effects.size - 1; i >= 0; i--) {
        PooledEffect effect = effects.get(i);
        effect.draw(this.worldSpriteBatch, delta);

        if (effect.isComplete()) {
            effect.free();
            effects.removeIndex(i);
        }
    }

    this.worldSpriteBatch.end();

    //Draw debug world overlay stuff
    if (this.debugScreenVisible) {
        this.worldShapeRenderer.begin(ShapeRenderer.ShapeType.Line);

        //Draw paths
        this.worldShapeRenderer.setColor(Color.BLUE);
        for (SeaCreaturePath scPath : this.seaCreaturePaths)
            this.worldShapeRenderer.polyline(scPath.getPolyline().getTransformedVertices());

        this.worldShapeRenderer.end();

        //Render Box2D debug renderer
        this.box2DDebugRenderer.render(this.world.getPhysWorld(), this.camera.combined);
    }

    this.renderUi(delta); //Renders the UI with the code in the superclass
}

From source file:releasethekraken.ui.tooltip.PowerUpToolTip.java

@Override
public void renderShapes(ShapeRenderer shapeRenderer, float delta, float runTime) {
    super.renderShapes(shapeRenderer, delta, runTime);

    if (this.visible) {
        //The mouse coordinates
        float mouseX = Gdx.input.getX(0);
        float mouseY = Gdx.input.getY(0);

        float textHeight = GameAssets.fontMain.getCapHeight();

        float boxWidth = (0.25F + 0.005F) * Gdx.graphics.getWidth();
        float boxHeight = this.descriptionHeight + GameAssets.fontMain.getCapHeight()
                + 0.08F * Gdx.graphics.getHeight();

        float boxX = mouseX + 0.05F * Gdx.graphics.getWidth();
        float boxY = Gdx.graphics.getHeight() - mouseY + (boxHeight - textHeight) / 2 + textHeight / 2;

        float triangleAlignX = boxX;

        /*//from w  w w  .j a  v  a 2  s . co m
        Starting and stopping the shape renderer multiple times and copying 
        colors might have an impact on performance.  We might want to find
        a more efficient way of doing this.  Maybe tooltips get their own
        render pass?
        */

        shapeRenderer.end(); //End the shape batch, drawing everything it has so far

        //Enable OpenGL alpha blending
        Gdx.gl.glEnable(Gdx.gl.GL_BLEND);
        Gdx.gl.glBlendFunc(Gdx.gl.GL_SRC_ALPHA, Gdx.gl.GL_ONE_MINUS_SRC_ALPHA);

        //Start a new shape batch
        shapeRenderer.begin(ShapeRenderer.ShapeType.Filled);

        //Render tooltip background
        shapeRenderer.setColor(this.color.cpy().sub(0, 0, 0, 0.35F)); //Make the color transparent
        shapeRenderer.rect(boxX, boxY - boxHeight, boxWidth, boxHeight); //Tooltip background
        shapeRenderer.triangle(mouseX, Gdx.graphics.getHeight() - mouseY, triangleAlignX, boxY, triangleAlignX,
                boxY - boxHeight); //Triangle part

        shapeRenderer.end(); //End the shape batch, drawing the transparent tooltip

        //Disable OpenGL blending so everything else doesn't get messed up
        Gdx.gl.glDisable(Gdx.gl.GL_BLEND);

        //Start a new shape batch so that it is left in the state it started in
        shapeRenderer.begin(ShapeRenderer.ShapeType.Line);

        //Draw the radius symbol            
        shapeRenderer.setColor(Color.BLUE);
        shapeRenderer.circle(boxX + 0.009F * Gdx.graphics.getWidth(),
                Gdx.graphics.getHeight() - mouseY - 0.04F * Gdx.graphics.getWidth(),
                0.008F * Gdx.graphics.getWidth());

        shapeRenderer.line(boxX + 0.009F * Gdx.graphics.getWidth(),
                Gdx.graphics.getHeight() - mouseY - 0.04F * Gdx.graphics.getWidth(),
                boxX + 0.009F * Gdx.graphics.getWidth() + 0.008F * Gdx.graphics.getWidth(),
                Gdx.graphics.getHeight() - mouseY - 0.04F * Gdx.graphics.getWidth());

        shapeRenderer.end();
        shapeRenderer.begin(ShapeRenderer.ShapeType.Filled);
    }
}

From source file:rosthouse.rosty.systems.debug.ShapeRenderSystem.java

@Override
public void processEntity(Entity entity, float deltaTime) {

    OrthographicCameraComponent cmpCamera = cmCamera.get(entity);
    shapeRenderer.setProjectionMatrix(cmpCamera.camera.combined);
    Gdx.gl20.glLineWidth(2);//from   w  ww  .jav  a2  s . c  o  m
    shapeRenderer.begin(ShapeRenderer.ShapeType.Filled);
    for (int i = 0; i < this.entities.size(); i++) {
        Entity current = entities.get(i);
        drawEntityInformation(spriteBatch, cmpCamera.camera, current);
        if (cmPolygon.has(current)) {
            shapeRenderer.setColor(Color.BLUE);
            PolygonComponent cpPolygon = cmPolygon.get(current);
            shapeRenderer.polygon(cpPolygon.polygon.getTransformedVertices());
        }
        if (cmRectangle.has(current)) {
            shapeRenderer.setColor(Color.RED);
            RectangleComponent cpRectangle = cmRectangle.get(current);
            shapeRenderer.rect(cpRectangle.rectangle.x, cpRectangle.rectangle.y, cpRectangle.rectangle.width,
                    cpRectangle.rectangle.height);
        }
        if (cmSprite.has(current)) {
            shapeRenderer.setColor(Color.GREEN);
            SpriteComponent spSprite = cmSprite.get(current);
            Rectangle boundingRectangle = spSprite.sprite.getBoundingRectangle();
            shapeRenderer.rect(boundingRectangle.x, boundingRectangle.y, boundingRectangle.width,
                    boundingRectangle.height);
            shapeRenderer.setColor(Color.PURPLE);
            shapeRenderer.point(spSprite.sprite.getOriginX(), spSprite.sprite.getOriginY(), 0);
        }
        if (cmEllipse.has(current)) {
            shapeRenderer.setColor(Color.WHITE);
            EllipseComponent cpRectangle = cmEllipse.get(current);
            shapeRenderer.ellipse(cpRectangle.ellipse.x, cpRectangle.ellipse.y, cpRectangle.ellipse.width,
                    cpRectangle.ellipse.height);
        }
    }
    shapeRenderer.end();
    spriteBatch.begin();
    renderGuiFpsCounter(spriteBatch, cmpCamera.camera);
    spriteBatch.end();
}

From source file:Screens.LoadingScreen.java

@Override
public void render(float f) {
    Gdx.gl.glClearColor(0f, 0f, 0f, 1f); //set background color
    Gdx.gl.glClear(GL20.GL_COLOR_BUFFER_BIT);

    updatePourcentage();//w ww  .j  ava  2 s  .c om

    renderer.begin(ShapeRenderer.ShapeType.Filled);
    renderer.setColor(Color.WHITE);
    renderer.rect(350, RacingGame.V_HEIGHT / 2 - 200, RacingGame.V_WIDTH / 2 - 50, 20);

    renderer.setColor(Color.BLUE);
    renderer.rect(351, RacingGame.V_HEIGHT / 2 - 199, progress * (RacingGame.V_WIDTH / 2 - 52), 18);
    renderer.end();

    stage.act();
    stage.draw();
}

From source file:spaceisnear.game.ui.console.InGameLog.java

private static Color getColorOfLevel(LogString str) {
    LogLevel level = str.getLevel();//from   ww w. ja v  a  2s.c  o m
    switch (level) {
    case DEBUG:
        return Color.GRAY;
    case TALKING:
        return Color.BLACK;
    case BROADCASTING:
        return new Color(0, 0.5f, 0, 1);
    case WARNING:
        return Color.RED;
    case OOC:
        return Color.BLUE;
    case PRIVATE:
        return Color.MAGENTA;
    default:
        return Color.GRAY;
    }
}

From source file:ta.firegreen.creation.creator.java

License:Apache License

@Override
public void render() {
    if (fileTexture != null) {
        bindTexture(mesh, fileTexture.getAbsolutePath());
        fileTexture = null;//  ww w  .j av a  2 s  .  com
    }
    if (fileMTA != null) {
        nouveau = MeshTA.loadMeshTA(fileMTA);
        fileMTA = null;
    }
    Gdx.gl.glClearColor(0, 0, 0, 1);
    Gdx.gl20.glClear(GL20.GL_COLOR_BUFFER_BIT | GL20.GL_DEPTH_BUFFER_BIT);
    cam.position.set(posX, posY, posZ);
    cam.lookAt(cibleX, cibleY, cibleZ);
    cam.update();
    if (afficheTexture)
        mesh.render(renduTexture, cam.combined);
    else
        mesh.render(rendu, cam.combined);

    if (saveIMGFile != null) {

        final Pixmap p = new Pixmap(Gdx.graphics.getWidth() - 200, Gdx.graphics.getHeight() - 200,
                Pixmap.Format.RGBA8888);
        ByteBuffer bytes = ByteBuffer.allocateDirect(p.getPixels().capacity());
        Gdx.gl20.glReadPixels(100, 100, Gdx.graphics.getWidth() - 200, Gdx.graphics.getHeight() - 200,
                GL20.GL_RGBA, GL20.GL_UNSIGNED_BYTE, bytes);
        int j = p.getPixels().capacity() - 1;
        for (int i = 0; i < p.getPixels().capacity(); i += 4) {
            p.getPixels().put(j, bytes.get(i + 3));
            j--;
            p.getPixels().put(j, bytes.get(i + 2));
            j--;
            p.getPixels().put(j, bytes.get(i + 1));
            j--;
            p.getPixels().put(j, bytes.get(i));
            j--;
        }

        if (!saveIMGFile.getName().endsWith(".png"))
            if (!saveIMGFile.renameTo(new File(saveIMGFile.getName() + ".png"))) {
                JOptionPane.showMessageDialog(null, "Le fichier n'a pas pu tre sauvegarder", "Erreur",
                        JOptionPane.ERROR_MESSAGE);
                return;
            }
        PixmapIO.writePNG(new FileHandle(saveIMGFile), p);
        saveIMGFile = null;
    }

    shape.setProjectionMatrix(cam.projection);
    shape.setTransformMatrix(cam.view);
    shape.begin(ShapeType.Line);
    shape.setColor(Color.GREEN);
    shape.line(new Vector3(-10, 0, 0), new Vector3(10, 0, 0));
    shape.setColor(Color.RED);
    shape.line(new Vector3(0, -10, 0), new Vector3(0, 10, 0));
    shape.setColor(Color.BLUE);
    shape.line(new Vector3(0, 0, -10), new Vector3(0, 0, 10));
    shape.end();
    cam.translate(0.05f, 0.05f, 0.05f);
    cam.update();
    trianglesSelected.render(rendu, cam.combined);
    cam.translate(-0.1f, -0.1f, -0.1f);
    cam.update();
    trianglesSelected.render(rendu, cam.combined);
    try {
        Thread.sleep(35);
    } catch (InterruptedException e) {
        // TODO Auto-generated catch block
        e.printStackTrace();
    }
}

From source file:tilo.modules.graphics.java

License:Open Source License

public Color color(String name) {
    if (name.startsWith("#"))
        return Color.valueOf(name.replace("#", ""));
    if ("clear".equalsIgnoreCase(name))
        return Color.CLEAR;
    else if ("white".equalsIgnoreCase(name))
        return Color.WHITE;
    else if ("black".equalsIgnoreCase(name))
        return Color.BLACK;
    else if ("red".equalsIgnoreCase(name))
        return Color.RED;
    else if ("green".equalsIgnoreCase(name))
        return Color.GREEN;
    else if ("blue".equalsIgnoreCase(name))
        return Color.BLUE;
    else if ("lightgray".equalsIgnoreCase(name))
        return Color.LIGHT_GRAY;
    else if ("gray".equalsIgnoreCase(name))
        return Color.GRAY;
    else if ("darkgray".equalsIgnoreCase(name))
        return Color.DARK_GRAY;
    else if ("pink".equalsIgnoreCase(name))
        return Color.PINK;
    else if ("orange".equalsIgnoreCase(name))
        return Color.ORANGE;
    else if ("yellow".equalsIgnoreCase(name))
        return Color.YELLOW;
    else if ("magenta".equalsIgnoreCase(name))
        return Color.MAGENTA;
    else if ("cyan".equalsIgnoreCase(name))
        return Color.CYAN;
    return Color.CLEAR;
}

From source file:util.Utils.java

public static void animateMagicAttack(Stage stage, final CombatScreen scr, PartyMember attacker, Direction dir,
        int x, int y, Spell spell, int minDamage, int maxDamage) {

    final AttackVector av = Utils.castSpellAttack(scr.combatMap, attacker, dir, x, y, minDamage, maxDamage,
            spell);/*from   ww  w . ja va  2  s  .  com*/

    Color color = Color.BLUE;
    switch (spell) {
    case FULGAR:
        color = Color.RED;
        break;
    case DECORP:
        color = Color.VIOLET;
        break;
    }

    final ProjectileActor p = new ProjectileActor(scr, color, x, y, av.result);

    Vector3 v = scr.getMapPixelCoords(av.x, av.y);

    p.addAction(sequence(moveTo(v.x, v.y, av.distance * .1f), new Action() {
        public boolean act(float delta) {

            switch (p.res) {
            case HIT:
                p.resultTexture = Exodus.magicHitTile;
                break;
            case MISS:
                p.resultTexture = Exodus.missTile;
                break;
            }

            //scr.replaceTile(av.leaveTileName, av.x, av.y);
            scr.finishPlayerTurn();

            return true;
        }
    }, fadeOut(.2f), removeActor(p)));

    stage.addActor(p);
}

From source file:vault.clockwork.editor.props.HillProp.java

License:Open Source License

/**
 * @param gizmo 
 */
@Override
public void draw(ShapeRenderer gizmo) {
    gizmo.setColor(Color.BLUE);
    gizmo.circle(position.x, position.y, radius);
}