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

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

Introduction

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

Prototype

Color RED

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

Click Source Link

Usage

From source file:net.shad.s3rend.gfx.pixmap.disort.RotoZoom.java

License:Apache License

/**
 *
 * @param pixmap/*from  ww  w .  jav a 2s .c  om*/
 * @param amplify - The bulge value
 */
public static void generate(final Pixmap pixmap, float centerX, float centerY, float rotate, float zoomX,
        float zoomY) {

    int width = pixmap.getWidth();
    int height = pixmap.getHeight();

    //
    // Rotate
    //
    rotate = rotate * PI2;

    //
    // Zoom
    //
    zoomX = (float) Math.pow(.5f, zoomX - 1);
    zoomY = (float) Math.pow(.5f, zoomY - 1);

    float c = (float) (Math.cos(rotate));
    float s = (float) (Math.sin(rotate));

    float tw2 = (float) width / 2.0f;
    float th2 = (float) height / 2.0f;

    float ys = s * -th2;
    float yc = c * -th2;

    Pixmap dstPixmap = new Pixmap(width, height, pixmap.getFormat());
    dstPixmap.setColor(Color.RED);
    dstPixmap.fill();

    for (int y = 0; y < width; y++) {

        //
        // x' = cos(x)-sin(y) + Center X;
        //
        float u = (((c * -tw2) - ys) * zoomX) + centerX;

        //
        // y' = sin(x)+cos(y) + Center Y;
        //
        float v = (((s * -tw2) + yc) * zoomY) + centerY;

        for (int x = 0; x < height; x++) {

            int ut = u >= 0 ? (int) u : (int) u - 1;
            int vt = v >= 0 ? (int) v : (int) v - 1;

            //
            // Texels
            // 1 | 2
            // -------
            // 3 | 4
            //

            //
            // Texel1
            //
            int rgb = pixmap.getPixel(vt, ut);
            int r = (rgb & 0xff000000) >>> 24;
            int g = (rgb & 0x00ff0000) >>> 16;
            int b = (rgb & 0x0000ff00) >>> 8;
            int a = (rgb & 0x000000ff);

            int outR = r;
            int outG = g;
            int outB = b;
            int outA = 255;

            //
            // Texel2
            //
            rgb = pixmap.getPixel(vt, ut + height);
            r = (rgb & 0xff000000) >>> 24;
            g = (rgb & 0x00ff0000) >>> 16;
            b = (rgb & 0x0000ff00) >>> 8;

            outR += r;
            outG += g;
            outB += b;

            //
            // Texel3
            //
            rgb = pixmap.getPixel((vt + width), ut);
            r = (rgb & 0xff000000) >>> 24;
            g = (rgb & 0x00ff0000) >>> 16;
            b = (rgb & 0x0000ff00) >>> 8;

            outR += r;
            outG += g;
            outB += b;

            //
            // Texel 4
            //
            rgb = pixmap.getPixel(vt + width, ut + height);
            r = (rgb & 0xff000000) >>> 24;
            g = (rgb & 0x00ff0000) >>> 16;
            b = (rgb & 0x0000ff00) >>> 8;

            outR += r;
            outG += g;
            outB += b;

            //
            // Clamp
            //
            outR = (outR < 255) ? outR : 255;
            outR = (outR > 0) ? outR : 0;
            outG = (outG < 255) ? outG : 255;
            outG = (outG > 0) ? outG : 0;
            outB = (outB < 255) ? outB : 255;
            outB = (outB > 0) ? outB : 0;

            dstPixmap.drawPixel(x, y, ((int) outR << 24) | ((int) outG << 16) | ((int) outB << 8) | outA);

            //
            // Vectors X
            //
            u += c * zoomX;
            v += s * zoomY;
        }
        //
        // Vectors Y
        //
        ys += s;
        yc += c;
    }
    pixmap.drawPixmap(dstPixmap, 0, 0);
}

From source file:nl.endroid.app.platform.screen.GameScreen.java

License:Open Source License

@Override
public void show() {
    super.show();

    pool.register(Stone.class, 100);
    pool.register(Coin.class, 100);
    pool.register(Flower.class, 50);

    sky = new Sky();
    sky.setSize(width, height);//from  ww w  .  jav a2  s  .  com
    sky.setY(blockSize / 2);
    stage.addActor(sky);

    random = new Random();

    levels = new ObjectMap<Integer, String[]>();
    levelEntities = new Array<Entity>();

    AssetManager.createSound("coin", "coin.wav");
    AssetManager.createSound("jump", "jump.wav");
    AssetManager.createSound("die", "die.wav");

    world.setGravity(new Vector2(0.0f, -30.0f));

    world.setContactListener(new ContactListener() {
        @Override
        public void beginContact(Contact contact) {

        }

        @Override
        public void endContact(Contact contact) {

        }

        @Override
        public void preSolve(Contact contact, Manifold manifold) {
            Entity entity1 = (Entity) contact.getFixtureA().getBody().getUserData();
            Entity entity2 = (Entity) contact.getFixtureB().getBody().getUserData();

            if (entity1 instanceof Coin || entity2 instanceof Coin) {
                Coin coin = (entity1 instanceof Coin) ? (Coin) entity1 : (Coin) entity2;

                pool.put(coin);
                levelEntities.removeValue(coin, true);

                contact.setEnabled(false);

                score++;
                scoreLabel.setText(Integer.valueOf(score).toString());

                AssetManager.playSound("coin");
            }
        }

        @Override
        public void postSolve(Contact contact, ContactImpulse contactImpulse) {

        }
    });

    right = 0;

    loadLevels();

    createClouds();

    createBodies = true;

    addLevel(0);

    createBodies = false;

    score = 0;

    scoreLabel = application.getLabel(Integer.valueOf(score).toString(), "white");
    scoreLabel.setY(height - scoreLabel.getHeight() - 10);
    scoreLabel.setWidth(50);
    scoreLabel.setAlignment(Align.right);

    if (rayHandler != null && pointLight == null) {
        pointLight = new PointLight(rayHandler, 500, Color.RED, 500, width / 2 - 50, height / 2 + 15);
    }
}

From source file:non.plugins.graphics.java

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;
    else if ("olive".equalsIgnoreCase(name))
        return Color.OLIVE;
    else if ("purple".equalsIgnoreCase(name))
        return Color.PURPLE;
    else if ("maroon".equalsIgnoreCase(name))
        return Color.MAROON;
    else if ("teal".equalsIgnoreCase(name))
        return Color.TEAL;
    else if ("navy".equalsIgnoreCase(name))
        return Color.NAVY;
    return Color.CLEAR;
}

From source file:org.ah.gcc.rover.AndroidGCCRoverController.java

License:Open Source License

@Override
public void render() {

    roverDriver.processJoysticks();/*  ww w .j a va  2  s  .co  m*/

    alpha++;
    if (logos) {
        logoDrawer.draw();
        logos = logoDrawer.done();
    } else {
        testConnection();

        messageCounter--;
        if (messageCounter < 0) {
            messageCounter = 5;
        }

        camera.setToOrtho(true);

        Gdx.gl.glClearColor(1, 1, 1, 1);
        Gdx.gl.glClear(GL20.GL_COLOR_BUFFER_BIT);

        batch.setProjectionMatrix(camera.combined);
        shapeRenderer.setProjectionMatrix(camera.combined);
        shapeRenderer.setAutoShapeType(true);

        String connectedStr = ROVERS[selectedRover].getName();

        shapeRenderer.begin();
        shapeRenderer.setColor(0.9f, 0.9f, 0.9f, 1f);
        //            for (int x = 0; x < Gdx.graphics.getWidth(); x = (int) (x + cellSize)) {
        //                shapeRenderer.line(x, 0, x, Gdx.graphics.getHeight());
        //            }
        //            for (int y = 0; y < Gdx.graphics.getHeight() ; y = (int) (y + cellSize)) {
        //                shapeRenderer.line(0, Gdx.graphics.getHeight() - y, Gdx.graphics.getWidth(), Gdx.graphics.getHeight() - y);
        //            }

        shapeRenderer.setColor(Color.BLACK);

        leftjoystick.draw(shapeRenderer);
        rightjoystick.draw(shapeRenderer);
        leftExpo.draw(shapeRenderer);
        rightExpo.draw(shapeRenderer);

        button1.draw(shapeRenderer);
        switchLB.draw(shapeRenderer);
        switchLT.draw(shapeRenderer);
        pov.draw(shapeRenderer);
        switchRB.draw(shapeRenderer);
        switchRT.draw(shapeRenderer);

        roverSelectButton.draw(shapeRenderer);

        shapeRenderer.end();
        batch.begin();
        glyphLayout.setText(font, connectedStr);
        if (roverControl.isConnected()) {
            font.setColor(Color.GREEN);
        } else {
            font.setColor(Color.RED);
        }
        font.draw(batch, connectedStr, (Gdx.graphics.getWidth() - glyphLayout.width) / 2, 0);
        font.setColor(Color.BLACK);
        font.draw(batch, String.format("S: " + roverSpeed), Gdx.graphics.getWidth() - 200, 0);
        font.draw(batch, String.format("D: " + roverTurningDistance), 0, 0);
        batch.end();

    }
}

From source file:org.ah.gcc.rover.desktop.DesktopGCCRoverController.java

License:Open Source License

@Override
public void render() {
    alpha++;//from   w ww .j a  va 2s .  c o  m
    if (logos) {
        logoDrawer.draw();
        logos = !logoDrawer.done();
    } else {
        messageCounter--;
        if (messageCounter < 0) {
            messageCounter = 5;
        }

        camera.setToOrtho(true);

        Gdx.gl.glClearColor(1, 1, 1, 1);
        Gdx.gl.glClear(GL20.GL_COLOR_BUFFER_BIT);

        batch.setProjectionMatrix(camera.combined);
        shapeRenderer.setProjectionMatrix(camera.combined);
        shapeRenderer.setAutoShapeType(true);

        String connectedStr = RoverHandler.ROVERS[roverDriver.getSelectedRover().getValue()].getName();

        shapeRenderer.begin();
        if (grid) {
            shapeRenderer.setColor(0.9f, 0.9f, 0.9f, 1f);
            for (int x = 0; x < Gdx.graphics.getWidth(); x = (int) (x + cellSize)) {
                shapeRenderer.line(x, 0, x, Gdx.graphics.getHeight());
            }
            for (int y = 0; y < Gdx.graphics.getHeight(); y = (int) (y + cellSize)) {
                shapeRenderer.line(0, y, Gdx.graphics.getWidth(), y);
            }
        }
        shapeRenderer.setColor(Color.BLACK);

        leftjoystick.draw(shapeRenderer);
        rightjoystick.draw(shapeRenderer);
        leftExpo.draw(shapeRenderer);
        rightExpo.draw(shapeRenderer);

        button1.draw(shapeRenderer);
        switchLB.draw(shapeRenderer);
        switchLT.draw(shapeRenderer);
        pov.draw(shapeRenderer);
        switchRB.draw(shapeRenderer);
        switchRT.draw(shapeRenderer);

        roverSelectButton.draw(shapeRenderer);

        shapeRenderer.end();
        batch.begin();
        glyphLayout.setText(font, connectedStr);
        if (roverHandler.isConnected()) {
            font.setColor(Color.GREEN);
        } else {
            font.setColor(Color.RED);
        }
        font.draw(batch, connectedStr, (Gdx.graphics.getWidth() - glyphLayout.width) / 2, 0);
        font.setColor(Color.BLACK);
        font.draw(batch, String.format("S: " + roverSpeed), Gdx.graphics.getWidth() - 200, 0);
        font.draw(batch, String.format("D: " + roverTurningDistance), 0, 0);
        batch.end();

        if (alpha % 10 == 0) {
            roverDriver.processJoysticks();
        }
    }
}

From source file:org.ah.gcc.rover.RoverController.java

License:Open Source License

@Override
public void render() {

    alpha++;//ww  w . j a v  a 2  s  . c  om
    if (logos) {
        camera.setToOrtho(false);

        Gdx.gl.glClearColor(1, 1, 1, 1);
        Gdx.gl.glClear(GL20.GL_COLOR_BUFFER_BIT);

        batch.setProjectionMatrix(camera.combined);
        batch.begin();

        if (alpha < 30) {
            float scale = calculateScale(gccimg);
            int y = (int) ((Gdx.graphics.getHeight() - (gccimg.getHeight() * scale)) / 2);
            int x = (int) ((Gdx.graphics.getWidth() - (gccimg.getWidth() * scale)) / 2);
            batch.draw(gccimg, x, y, gccimg.getWidth() * scale, gccimg.getHeight() * scale);
        } else if (alpha < 60) {
            float scale = Gdx.graphics.getHeight() / creativesphereimg.getHeight();
            int y = (int) ((Gdx.graphics.getHeight() - (creativesphereimg.getHeight() * scale)) / 2);
            int x = (int) ((Gdx.graphics.getWidth() - (creativesphereimg.getWidth() * scale)) / 2);
            batch.draw(creativesphereimg, x, y, creativesphereimg.getWidth() * scale,
                    creativesphereimg.getHeight() * scale);
        } else if (alpha < 90) {
            float scale = Gdx.graphics.getHeight() / bobimg.getHeight();
            int y = (int) ((Gdx.graphics.getHeight() - (bobimg.getHeight() * scale)) / 2);
            int x = (int) ((Gdx.graphics.getWidth() - (bobimg.getWidth() * scale)) / 2);
            batch.draw(bobimg, x, y, bobimg.getWidth() * scale, bobimg.getHeight() * scale);
        } else if (alpha > 120) {
            logos = false;
        }

        batch.end();
    } else {
        testConnection();

        messageCounter--;
        if (messageCounter < 0) {
            messageCounter = 5;
            processJoysticks();
        }

        camera.setToOrtho(true);

        Gdx.gl.glClearColor(1, 1, 1, 1);
        Gdx.gl.glClear(GL20.GL_COLOR_BUFFER_BIT);

        batch.setProjectionMatrix(camera.combined);
        shapeRenderer.setProjectionMatrix(camera.combined);
        shapeRenderer.setAutoShapeType(true);

        String connectedStr = ROVERS[selectedRover].getName();

        shapeRenderer.begin();
        shapeRenderer.setColor(0.9f, 0.9f, 0.9f, 1f);
        for (int x = 0; x < Gdx.graphics.getWidth(); x = (int) (x + cellSize)) {
            shapeRenderer.line(x, 0, x, Gdx.graphics.getHeight());
        }
        for (int y = Gdx.graphics.getHeight(); y > 0; y = (int) (y - cellSize)) {
            shapeRenderer.line(0, y, Gdx.graphics.getWidth(), y);
        }

        shapeRenderer.setColor(Color.BLACK);

        leftjoystick.draw(shapeRenderer);
        rightjoystick.draw(shapeRenderer);
        leftExpo.draw(shapeRenderer);
        rightExpo.draw(shapeRenderer);

        button1.draw(shapeRenderer);
        switchLB.draw(shapeRenderer);
        switchLT.draw(shapeRenderer);
        switch2.draw(shapeRenderer);
        roverSelectButton.draw(shapeRenderer);

        shapeRenderer.end();
        batch.begin();
        glyphLayout.setText(font, connectedStr);
        if (roverControl.isConnected()) {
            font.setColor(Color.GREEN);
        } else {
            font.setColor(Color.RED);
        }
        font.draw(batch, connectedStr, (Gdx.graphics.getWidth() - glyphLayout.width) / 2, 0);
        font.setColor(Color.BLACK);
        font.draw(batch, String.format("S: " + roverSpeed), Gdx.graphics.getWidth() - 200, 0);
        font.draw(batch, String.format("D: " + roverTurningDistance), 0, 0);
        batch.end();

    }
}

From source file:org.ah.gcc.rover.ui.Switch.java

License:Open Source License

public void draw(ShapeRenderer shapeRenderer) {
    shapeRenderer.set(ShapeType.Filled);
    if (orientation == Orientation.HORIZONTAL) {
        if (on) {
            shapeRenderer.set(ShapeType.Filled);
            shapeRenderer.setColor(Color.GREEN);
            shapeRenderer.rect(x, y, width / 2, width / 2);

            shapeRenderer.set(ShapeType.Filled);

            shapeRenderer.setColor(Color.DARK_GRAY);
            shapeRenderer.rect(x + width / 2, y, width / 2, width / 2);
        } else {/*from w w w.  ja  v  a 2s. c om*/
            shapeRenderer.set(ShapeType.Filled);
            shapeRenderer.setColor(Color.DARK_GRAY);
            shapeRenderer.rect(x, y, width / 2, width / 2);

            shapeRenderer.set(ShapeType.Filled);
            shapeRenderer.setColor(Color.RED);
            shapeRenderer.rect(x + width / 2, y, width / 2, width / 2);
        }
        shapeRenderer.set(ShapeType.Line);
        shapeRenderer.setColor(Color.BLACK);
        shapeRenderer.rect(x, y, width, width / 2);

    } else if (orientation == Orientation.VERTICAL) {
        if (on) {
            shapeRenderer.setColor(Color.GREEN);
            shapeRenderer.rect(x, y, width, width / 2);
            shapeRenderer.rect(x, y, width / 2, width / 2);

            shapeRenderer.setColor(Color.DARK_GRAY);
            shapeRenderer.rect(x, y + width / 2, width, width / 2);
        } else {
            shapeRenderer.setColor(Color.DARK_GRAY);
            shapeRenderer.rect(x, y, width, width / 2);
            shapeRenderer.rect(x, y, width / 2, width / 2);

            shapeRenderer.setColor(Color.RED);
            shapeRenderer.rect(x, y + width / 2, width, width / 2);
        }
        shapeRenderer.set(ShapeType.Line);
        shapeRenderer.setColor(Color.BLACK);
        shapeRenderer.rect(x, y, width / 2, width);
    }

}

From source file:org.ams.prettypaint.OutlineMerger.java

License:Open Source License

/** For debugging. */
private void debugDraw(ShapeRenderer shapeRenderer) {
    Vector2 tmp = new Vector2();
    Vector2 tmp1 = new Vector2();

    shapeRenderer.set(ShapeRenderer.ShapeType.Line);

    int n = 0;//w  w w .  j av  a 2s . c o m
    for (Array<Vector2> vertices : debug) {
        if (n == 0) {
            shapeRenderer.setColor(Color.RED);
        }
        if (n == 1) {
            shapeRenderer.setColor(Color.GREEN);
        }
        if (n == 2) {
            shapeRenderer.setColor(Color.BLUE);
        }
        if (n == 3) {
            shapeRenderer.setColor(Color.YELLOW);
        }
        n++;

        for (int i = 0; i < vertices.size; i++) {
            Util.getEdge(vertices, i, tmp, tmp1);

            shapeRenderer.line(tmp.x, tmp.y, tmp1.x, tmp1.y);

        }
    }
}

From source file:org.ams.prettypaint.OutlinePolygon.java

License:Open Source License

/** Draws anti aliased polygon edges. */
public OutlinePolygon(OutlinePolygonDef outlinePolygonDef) {

    debugRenderer = new DebugRenderer(this) {

        @Override//from w ww. ja va 2s  .c  o  m
        public void draw(ShapeRenderer shapeRenderer) {
            if (drawCullingRectangles)
                drawCullingRectangles(shapeRenderer, Color.GREEN);

            if (drawLineFromFirstToLast)
                drawLineFromFirstToLast(shapeRenderer, Color.BLUE);

            if (drawTriangleStrips)
                drawTriangleStrips(shapeRenderer, Color.RED, Color.ORANGE);

        }

        @Override
        void update() {
            super.update();
            boolean enabled = drawLineFromFirstToLast;
            enabled |= drawCullingRectangles;
            enabled |= drawTriangleStrips;

            enabled &= myParents.size == 0;

            boolean change = this.enabled != enabled;
            if (!change)
                return;

            this.enabled = enabled;

            debugColors.clear();

            if (drawCullingRectangles) {
                debugColors.add(new DebugColor(Color.GREEN, "Bounding box"));
            }
            if (drawLineFromFirstToLast) {
                debugColors.add(new DebugColor(Color.BLUE, "Line from first to last vertex in bounding box"));
            }
            if (drawTriangleStrips) {
                debugColors.add(new DebugColor(Color.RED, "Triangle strip visualization"));
                debugColors.add(new DebugColor(Color.ORANGE, "Triangle strip visualization"));

            }

        }
    };

    auxVertexFinder.setHalfWidth(this.halfWidth);

    if (outlinePolygonDef != null) {

        setDrawOutside(outlinePolygonDef.drawOutside);
        setDrawInside(outlinePolygonDef.drawInside);
        setColor(outlinePolygonDef.color);
        setClosedPolygon(outlinePolygonDef.closedPolygon);
        setHalfWidth(outlinePolygonDef.halfWidth);
        setWeight(outlinePolygonDef.weight);
        setRoundSharpCorners(outlinePolygonDef.roundSharpCorners);

        setDrawLineFromFirstToLast(outlinePolygonDef.drawLineFromFirstToLast);
        setDrawCullingRectangles(outlinePolygonDef.drawBoundingBoxes);
        setDrawTriangleStrips(outlinePolygonDef.drawTriangleStrips);

        setVisible(outlinePolygonDef.visible);
        setVertices(outlinePolygonDef.vertices);
        setScale(outlinePolygonDef.scale);
        setAngle(outlinePolygonDef.angle);
        setPosition(outlinePolygonDef.position);
        setOpacity(outlinePolygonDef.opacity);

    }
}

From source file:org.ams.prettypaint.OutlinePolygon.java

License:Open Source License

private void drawTriangleStrips(ShapeRenderer shapeRenderer, Color color, Color color1) {
    for (int i = 0; i < vertexDataArray.size; i++) {
        StripVertex bb = vertexDataArray.items[i];

        Array<Float> data = bb.insideVertexData;
        for (int j = 0; j < data.size - 3;) {

            shapeRenderer.setColor(j == 0 ? color : color1);

            tmp.x = data.items[j];/*from  w  w w  .ja va  2s  .  co  m*/
            tmp.y = data.items[j + 1];
            tmp.rotateRad(angleRad);
            tmp.scl(scale);
            tmp.add(position);

            tmp1.x = data.items[j + 3];
            tmp1.y = data.items[j + 4];
            tmp1.rotateRad(angleRad);
            tmp1.scl(scale);
            tmp1.add(position);
            j += 3;

            shapeRenderer.line(tmp, tmp1);
        }
        data = bb.outsideVertexData;
        for (int j = 0; j < data.size - 3;) {

            shapeRenderer.setColor(j == 0 ? Color.ORANGE : Color.RED);

            tmp.x = data.items[j];
            tmp.y = data.items[j + 1];
            tmp.rotateRad(angleRad);
            tmp.scl(scale);
            tmp.add(position);

            tmp1.x = data.items[j + 3];
            tmp1.y = data.items[j + 4];
            tmp1.rotateRad(angleRad);
            tmp1.scl(scale);
            tmp1.add(position);
            j += 3;

            shapeRenderer.line(tmp, tmp1);
        }

    }
}