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:edu.lehigh.cse.lol.internals.QuickScene.java

License:Open Source License

/**
 * Internal method to draw a QuickScene//from ww w.j  ava 2s  .  c o m
 *
 * @param sb The SpriteBatch used to draw the text and pictures
 * @return true if the PauseScene was drawn, false otherwise
 */
public boolean render(SpriteBatch sb) {
    // if the scene is not visible, do nothing
    if (!mVisible)
        return false;

    // clear screen and draw images/text via HudCam
    Gdx.gl.glClearColor(0, 0, 0, 1);
    Gdx.gl.glClear(GL20.GL_COLOR_BUFFER_BIT);
    Lol.sGame.mCurrentLevel.mHudCam.update();
    sb.setProjectionMatrix(Lol.sGame.mCurrentLevel.mHudCam.combined);
    sb.begin();
    for (Renderable r : mSprites)
        r.render(sb, 0);
    sb.end();

    // DEBUG: show where the buttons' boxes are
    if (Lol.sGame.mShowDebugBoxes) {
        mShapeRender.setProjectionMatrix(Lol.sGame.mCurrentLevel.mHudCam.combined);
        mShapeRender.begin(ShapeType.Line);
        mShapeRender.setColor(Color.RED);
        for (Button b : mButtons)
            mShapeRender.rect(b.mRect.x, b.mRect.y, b.mRect.width, b.mRect.height);
        mShapeRender.end();
    }

    return true;
}

From source file:edu.lehigh.cse.lol.Level.java

License:Open Source License

/**
 * This code is called every 1/45th of a second to update the game state and
 * re-draw the screen// w  w  w  .j  a  va2  s.  co m
 *
 * @param delta The time since the last render
 */
@Override
public void render(float delta) {
    // in debug mode, any click will report the coordinates of the click...
    // this is very useful when trying to adjust screen coordinates
    if (Lol.sGame.mShowDebugBoxes) {
        if (Gdx.input.justTouched()) {
            mHudCam.unproject(mTouchVec.set(Gdx.input.getX(), Gdx.input.getY(), 0));
            Util.message("Screen Coordinates", mTouchVec.x + ", " + mTouchVec.y);
            mGameCam.unproject(mTouchVec.set(Gdx.input.getX(), Gdx.input.getY(), 0));
            Util.message("World Coordinates", mTouchVec.x + ", " + mTouchVec.y);

        }
    }

    // Make sure the music is playing... Note that we start music before the
    // PreScene shows
    playMusic();

    // Handle pauses due to pre, pause, or post scenes...
    //
    // Note that these handle their own screen touches...
    //
    // Note that win and lose scenes should come first.
    if (mWinScene != null && mWinScene.render(mSpriteBatch))
        return;
    if (mLoseScene != null && mLoseScene.render(mSpriteBatch))
        return;
    if (mPreScene != null && mPreScene.render(mSpriteBatch))
        return;
    if (mPauseScene != null && mPauseScene.render(mSpriteBatch))
        return;

    // handle accelerometer stuff... note that accelerometer is effectively
    // disabled during a popup... we could change that by moving this to the
    // top, but that's probably not going to produce logical behavior
    Lol.sGame.mCurrentLevel.mTilt.handleTilt();

    // Advance the physics world by 1/45 of a second.
    //
    // NB: in Box2d, This is the recommended rate for phones, though it
    // seems like we should be using /delta/ instead of 1/45f
    mWorld.step(1 / 45f, 8, 3);

    // now handle any events that occurred on account of the world movement
    // or screen touches
    for (LolAction pe : mOneTimeEvents)
        pe.go();
    mOneTimeEvents.clear();

    // handle repeat events
    for (LolAction pe : mRepeatEvents)
        pe.go();

    // check for end of game
    if (mEndGameEvent != null)
        mEndGameEvent.go();

    // The world is now static for this time step... we can display it!

    // clear the screen
    Gdx.gl.glClearColor(mBackground.mColor.r, mBackground.mColor.g, mBackground.mColor.b, 1);
    Gdx.gl.glClear(GL20.GL_COLOR_BUFFER_BIT);

    // prepare the main camera... we do it here, so that the parallax code
    // knows where to draw...
    adjustCamera();
    mGameCam.update();

    // draw parallax backgrounds
    mBackground.renderLayers(mSpriteBatch, delta);

    // Render the actors in order from z=-2 through z=2
    mSpriteBatch.setProjectionMatrix(mGameCam.combined);
    mSpriteBatch.begin();
    for (ArrayList<Renderable> a : mRenderables)
        for (Renderable r : a)
            r.render(mSpriteBatch, delta);
    mSpriteBatch.end();

    // draw parallax foregrounds
    mForeground.renderLayers(mSpriteBatch, delta);

    // DEBUG: draw outlines of physics actors
    if (Lol.sGame.mShowDebugBoxes)
        mDebugRender.render(mWorld, mGameCam.combined);

    // draw Controls
    mHudCam.update();
    mSpriteBatch.setProjectionMatrix(mHudCam.combined);
    mSpriteBatch.begin();
    for (Control c : mControls)
        if (c.mIsActive)
            c.render(mSpriteBatch);
    for (Display d : mDisplays)
        d.render(mSpriteBatch);
    mSpriteBatch.end();

    // DEBUG: render Controls' outlines
    if (Lol.sGame.mShowDebugBoxes) {
        mShapeRender.setProjectionMatrix(mHudCam.combined);
        mShapeRender.begin(ShapeType.Line);
        mShapeRender.setColor(Color.RED);
        for (Control pe : mControls)
            if (pe.mRange != null)
                mShapeRender.rect(pe.mRange.x, pe.mRange.y, pe.mRange.width, pe.mRange.height);
        mShapeRender.end();
    }
}

From source file:es.eucm.ead.editor.utils.ImageBorderTracer.java

License:Open Source License

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

    sb.begin();//from w w w.  j av  a 2s . com
    sb.draw(samplePixmap, 0, 0);
    sb.draw(imagePixmap, 0, 0);
    sb.end();

    renderPolygonShapes(red, Color.RED, 50, 50);
    renderPolygonShapes(blue, Color.BLUE, 200f, 200);
}

From source file:es.eucm.ead.editor.utils.ShapeEditor.java

License:Open Source License

@Override
public void render() {
    super.render();
    renderPolygonShapes(blue, Color.BLUE, 0, 0);
    renderPolygonShapes(red, Color.RED, 0, 0);

    Array<Polygon> a = new Array<Polygon>();
    a.add(GeometryUtils.createPoly(polySides, polySize, new Vector2(lastX, lastY)));
    renderPolygonShapes(a, Color.DARK_GRAY, 0, 0);

    if (Gdx.input.isTouched()) {
        int mouseX = Gdx.input.getX();
        int mouseY = height - Gdx.input.getY();
        if (Gdx.input.isButtonPressed(Input.Buttons.LEFT)) {
            pendingMerges.offer(GeometryUtils.createPoly(polySides, polySize, new Vector2(mouseX, mouseY)));
        } else if (Gdx.input.isButtonPressed(Input.Buttons.RIGHT)) {
            pendingRemoves.offer(GeometryUtils.createPoly(polySides, polySize, new Vector2(mouseX, mouseY)));
        }/* w  w w  .ja v  a  2  s .co m*/
    }

    if (updatedGeometry != null && updatedGeometry.isDone()) {
        Gdx.app.error("GeoTester", "merging in...");
        red.clear();
        for (Geometry g : updatedGeometry.get()) {
            red.add(GeometryUtils.jtsCoordsToGdx(g.getCoordinates()));
        }
        geo.clear();
        geo.addAll(updatedGeometry.get());
        updatedGeometry = null;
    } else if (!pendingMerges.isEmpty() && updatedGeometry == null) {
        updatedGeometry = executor.submit(new AsyncTask<Array<Geometry>>() {
            @Override
            public Array<Geometry> call() throws Exception {
                Array<Geometry> ga = new Array<Geometry>();
                for (Geometry g : geo) {
                    ga.add((Geometry) g.clone());
                }
                while (!pendingMerges.isEmpty()) {
                    GeometryUtils.merge(ga, pendingMerges.poll());
                }
                if (GeoTester.r(0, 10) < 4) {
                    GeometryUtils.simplify(ga, 5);
                }
                return ga;
            }
        });
    } else if (!pendingRemoves.isEmpty() && updatedGeometry == null) {
        updatedGeometry = executor.submit(new AsyncTask<Array<Geometry>>() {
            @Override
            public Array<Geometry> call() throws Exception {
                Array<Geometry> ga = new Array<Geometry>();
                for (Geometry g : geo) {
                    ga.add((Geometry) g.clone());
                }
                while (!pendingRemoves.isEmpty()) {
                    GeometryUtils.subtract(ga, pendingRemoves.poll());
                }
                if (GeoTester.r(0, 10) < 4) {
                    GeometryUtils.simplify(ga, 5);
                }
                return ga;
            }
        });
    }
}

From source file:es.eucm.ead.editor.utils.TexturedShapeEditor.java

License:Open Source License

@Override
public void render() {
    super.render();
    renderPolygonSprite();/*from   w  w  w  .  java2 s .  c  o m*/

    renderTriangles(red.get(0), triangles);
    renderPolygonShapes(blue, Color.BLUE, 0, 0);
    renderPolygonShapes(red, Color.RED, 0, 0);

    Array<Polygon> a = new Array<Polygon>();
    a.add(GeometryUtils.createPoly(6, polySize, new Vector2(lastX, lastY)));
    renderPolygonShapes(a, Color.DARK_GRAY, 0, 0);

    if (Gdx.input.isTouched()) {
        int mouseX = Gdx.input.getX();
        int mouseY = height - Gdx.input.getY();
        if (Gdx.input.isButtonPressed(Input.Buttons.LEFT)) {
            pendingMerges.offer(GeometryUtils.createPoly(6, polySize, new Vector2(mouseX, mouseY)));
        } else if (Gdx.input.isButtonPressed(Input.Buttons.RIGHT)) {
            pendingRemoves.offer(GeometryUtils.createPoly(6, polySize, new Vector2(mouseX, mouseY)));
        }
    }

    if (updatedRegion != null && updatedRegion.isDone()) {
        Gdx.app.error("GeoTester", "merging in...");
        poly.setRegion(updatedRegion.get());
        triangles = updatedRegion.get().getTriangles();
        red.clear();
        red.add(new Polygon(updatedRegion.get().getVertices()));
        updatedRegion = null;
    } else if (!pendingMerges.isEmpty() && updatedRegion == null) {
        updatedRegion = executor.submit(new AsyncTask<PolygonRegion>() {
            @Override
            public PolygonRegion call() throws Exception {
                long t0 = System.nanoTime();
                while (!pendingMerges.isEmpty()) {
                    GeometryUtils.merge(geo, pendingMerges.poll());
                }
                Geometry collapsed = GeometryUtils.collapse(geo);
                GeometryUtils.simplify(geo, 3);
                Polygon p = GeometryUtils.jtsCoordsToGdx(collapsed.getCoordinates());
                short[] ts = GeometryUtils.triangulate(collapsed);
                PolygonRegion polyReg = new PolygonRegion(new TextureRegion(textureSolid), p.getVertices(), ts);
                long t1 = System.nanoTime() - t0;
                Gdx.app.error("GeoTester", "ready to display triangles worth " + ts.length
                        + " vertices after merge in " + (t1 / 1000000) + " ms");
                return polyReg;
            }
        });
    } else if (!pendingRemoves.isEmpty() && updatedRegion == null) {
        updatedRegion = executor.submit(new AsyncTask<PolygonRegion>() {
            @Override
            public PolygonRegion call() throws Exception {
                long t0 = System.nanoTime();
                while (!pendingRemoves.isEmpty()) {
                    GeometryUtils.subtract(geo, pendingRemoves.poll());
                }
                Geometry collapsed = GeometryUtils.collapse(geo);
                if (GeoTester.r(0, 10) < 4) {
                    GeometryUtils.simplify(geo, 3);
                }
                Polygon p = GeometryUtils.jtsCoordsToGdx(collapsed.getCoordinates());
                short[] ts = GeometryUtils.triangulate(collapsed);
                PolygonRegion polyReg = new PolygonRegion(new TextureRegion(textureSolid), p.getVertices(), ts);
                long t1 = System.nanoTime() - t0;
                Gdx.app.error("GeoTester", "ready to display triangles worth " + ts.length
                        + " vertices after removal in " + (t1 / 1000000) + " ms");
                return polyReg;
            }
        });
    }
}

From source file:es.eucm.ead.editor.view.builders.scene.components.variablesWidgets.BooleanExpressionWidget.java

License:Open Source License

public BooleanExpressionWidget(Controller cont) {
    super(true);//from   w  w  w  . j  ava2 s  .co  m
    this.controller = cont;
    this.i18N = controller.getApplicationAssets().getI18N();
    this.skin = controller.getApplicationAssets().getSkin();

    ModelEntity game = controller.getModel().getGame();
    variables = Q.getComponent(game, Variables.class);
    variablesList = variables.getVariablesDefinitions();

    variablesBox = new SelectBox<String>(skin);
    variablesBox.addListener(new ChangeListener() {
        @Override
        public void changed(ChangeEvent event, Actor actor) {
            if (variablesBox.getSelected().equals(i18N.m("new.variable") + "...")) {
                controller.action(CreateVariable.class, BooleanExpressionWidget.this);
            }
        }
    });
    loadItems();

    Array states = new Array();
    states.addAll(i18N.m(TRUE), i18N.m(FALSE));
    Array colors = new Array();
    colors.addAll(Color.GREEN, Color.RED);
    value = new MultiStateButton(skin, states, colors, PAD * 2);

    add(variablesBox).expandX().marginRight(PAD);
    add(value).marginRight(PAD);
    value.setVisible(false);

    controller.getModel().addListListener(variablesList, this);

    setComputeInvisibles(true);
    variablesBox.addListener(new ChangeListener() {
        @Override
        public void changed(ChangeEvent event, Actor actor) {
            if (variablesBox.getSelected().toString().equals(" ")) {
                value.setVisible(false);
            } else {
                value.setVisible(true);
            }
        }
    });
}

From source file:es.eucm.ead.editor.view.widgets.draw.SlideColorPicker.java

License:Open Source License

/**
 * Create a {@link SlideColorPicker} with defined style.
 * //www.j av  a2 s  .c  om
 * @param slideColorPickerStyle
 *            the style to use
 */
public SlideColorPicker(SlideColorPickerStyle slideColorPickerStyle) {

    SliderStyle sliderStyle = slideColorPickerStyle.slider;
    setSliderSpace(slideColorPickerStyle.sliderSpace);
    setPad(slideColorPickerStyle.pad);

    hueSlider = new Slider(0, SLIDER_MAX_VALUE, 1, false, new SliderStyle(sliderStyle)) {
        @Override
        public float getPrefHeight() {
            return 0;
        }
    };
    hueSlider.setValue(SLIDER_MAX_VALUE);
    hueSlider.setUserObject(this);
    hueSlider.addInputListener(listener);

    saturationSlider = new Slider(0, SLIDER_MAX_VALUE, 1, false, new SliderStyle(sliderStyle)) {
        @Override
        public float getPrefHeight() {
            return 0;
        }
    };
    saturationSlider.setValue(SLIDER_MAX_VALUE);
    saturationSlider.setUserObject(this);
    saturationSlider.addInputListener(listener);

    brightnessSlider = new Slider(0, SLIDER_MAX_VALUE, 1, false, new SliderStyle(sliderStyle)) {
        @Override
        public float getPrefHeight() {
            return 0;
        }
    };
    brightnessSlider.setValue(SLIDER_MAX_VALUE);
    brightnessSlider.setUserObject(this);
    brightnessSlider.addInputListener(listener);
    color.set(Color.RED);

    addActor(hueSlider);
    addActor(saturationSlider);
    addActor(brightnessSlider);
}

From source file:es.eucm.ead.mockup.core.control.screens.camara.Recording.java

License:Open Source License

@Override
public void create() {
    this.navigationGroup = UIAssets.getNavigationGroup();
    this.screenController = mockupController.getScreenController();

    rec = false;//from  w  w  w .  java  2 s .c o m
    elapsedMilis = 0f;
    elapsedSecs = 0;

    recordingButton = new ImageButton(skin, "ic_record");
    recordingButton.addListener(new ClickListener() {
        @Override
        public void clicked(InputEvent event, float x, float y) {
            super.clicked(event, x, y);
            record();
            if (!rec) {
                // TODO show panel...
                if (ProjectMenu.getFROM_INITIAL_SCENE()) {
                    exitAnimation(Screens.PROJECT_MENU);
                } else {
                    if (mockupController.getPreviousScreen() == Screens.PROJECT_MENU) {
                        onBackKeyPressed();
                    } else {
                        exitAnimation(Screens.SCENE_EDITION);
                    }
                }
            }
        }
    });

    String[] res = { "480p", "720p", "1080p" };
    resolution = new SelectBox(res, skin);
    resolution.addListener(new ClickListener() {
        @Override
        public void clicked(InputEvent event, float x, float y) {
            // TODO change resolution here
            super.clicked(event, x, y);
        }
    });

    recInfoButton = new Table();
    recInfoButton.setVisible(false);
    Image recImg = new Image(skin.getRegion("ic_recording"));
    // TODO personalize toggle-recording in JSON
    recImg.setTouchable(Touchable.disabled);
    recLabel = new Label("", skin);
    recLabel.setColor(Color.RED);
    recInfoButton.add(recImg);
    recInfoButton.add(recLabel).padLeft(20f);

    rootTable = new Table();
    rootTable.setVisible(false);
    rootTable.setFillParent(true);
    rootTable.pad(10f);
    // rootTable.debug();

    rootTable.add(resolution).right().top();
    rootTable.row();
    rootTable.add(recInfoButton).right().top();
    rootTable.row();
    rootTable.add(recordingButton).bottom().expand().padBottom(10f);
    stage.addActor(rootTable);
}

From source file:eu.rubenrosado.inmisericordia.StatusBar.java

License:Open Source License

/**
 * Draw the status bar/*from   www  .ja va  2s  .  c o m*/
 * 
 * @param renderer
 *            ShapeRenderer from PlayGame
 */
public void draw(ShapeRenderer renderer) {
    renderer.begin(ShapeType.Filled);
    renderer.setColor(Color.BLACK);
    renderer.rect(PlayGame.width - SIZEBAR - 5, 25, SIZEBAR, 9);
    renderer.rect(PlayGame.width - SIZEBAR - 5, 15, SIZEBAR, 9);
    renderer.rect(PlayGame.width - SIZEBAR - 5, 5, SIZEBAR, 9);
    renderer.setColor(Color.RED);
    renderer.rect(PlayGame.width - SIZEBAR - 3, 27, PlayGame.hero.getLifePercentage() * SIZEBAR / 102, 5);
    renderer.setColor(Color.BLUE);
    renderer.rect(PlayGame.width - SIZEBAR - 3, 17, PlayGame.hero.getManaPercentage() * SIZEBAR / 102, 5);
    renderer.setColor(Color.ORANGE);
    renderer.rect(PlayGame.width - SIZEBAR - 3, 7, PlayGame.hero.getExpPercentage() * SIZEBAR / 102, 5);
    renderer.end();
}

From source file:gaia.cu9.ari.gaiaorbit.util.g3d.ModelBuilder2.java

License:Apache License

/** Convenience method to create a model with three orthonormal vectors shapes. The resources the Material might contain are not
 * managed, use {@link Model#manageDisposable(Disposable)} to add those to the model.
 * @param axisLength Length of each axis.
 * @param capLength is the height of the cap in percentage, must be in (0,1)
 * @param stemThickness is the percentage of stem diameter compared to cap diameter, must be in (0,1]
 * @param divisions the amount of vertices used to generate the cap and stem ellipsoidal bases */
public Model createXYZCoordinates(float axisLength, float capLength, float stemThickness, int divisions,
        int primitiveType, Material material, long attributes) {
    begin();/*from  ww w.j  av  a  2  s.co m*/
    MeshPartBuilder2 partBuilder;

    partBuilder = part("xyz", primitiveType, attributes, material);
    partBuilder.setColor(Color.RED);
    partBuilder.arrow(0, 0, 0, axisLength, 0, 0, capLength, stemThickness, divisions);
    partBuilder.setColor(Color.GREEN);
    partBuilder.arrow(0, 0, 0, 0, axisLength, 0, capLength, stemThickness, divisions);
    partBuilder.setColor(Color.BLUE);
    partBuilder.arrow(0, 0, 0, 0, 0, axisLength, capLength, stemThickness, divisions);

    return end();
}