List of usage examples for com.badlogic.gdx.graphics Color Color
public Color(float r, float g, float b, float a)
From source file:forge.screens.SplashScreen.java
License:Open Source License
public void prepareForDialogs() { if (preparedForDialogs) { return;//from ww w . j a va 2s .c o m } //establish fallback colors for before actual colors are loaded Color defaultColor = new Color(0, 0, 0, 0); for (final FSkinColor.Colors c : FSkinColor.Colors.values()) { switch (c) { case CLR_BORDERS: case CLR_TEXT: c.setColor(FProgressBar.SEL_FORE_COLOR); break; case CLR_ACTIVE: case CLR_THEME2: c.setColor(FProgressBar.SEL_BACK_COLOR); break; case CLR_INACTIVE: c.setColor(FSkinColor.stepColor(FProgressBar.SEL_BACK_COLOR, -80)); break; default: c.setColor(defaultColor); break; } } FSkinColor.updateAll(); preparedForDialogs = true; }
From source file:gameWorld.WorldRenderer.java
License:Apache License
public WorldRenderer(SpriteBatch batch, GameWorld world) { this.rotation = GameScreen.rotation; this.world = world; this.cam = new OrthographicCamera(FRUSTUM_WIDTH, FRUSTUM_HEIGHT); this.cam.position.set(FRUSTUM_WIDTH / 2, FRUSTUM_HEIGHT / 2, 0); this.batch = batch; renderer = new OrthogonalTiledMapRenderer(world.map, 1 / 70f); // the 70 // is/* ww w . j ava 2 s. c o m*/ // because // each // tile // is // 70px followX = 0f; followY = 0f; shapeRender = new ShapeRenderer(); ghostTexture = new Texture("data/ghost_fixed.png"); ghostRegion = new TextureRegion(ghostTexture, 0, 0, 64, 64); originX = 1 / 48f * ghostTexture.getWidth() / 2f; originY = 1 / 48f * ghostTexture.getHeight() / 2f; textureWidth = 1 / 48f * 64; // texture is 64 pixels big. textureHeight = 1 / 48f * 64; dampingCounter = 0; velocity = new Vector2(); // Light setup --------------------------- RayHandler.useDiffuseLight(true); handler = new RayHandler(world.world2); handler.setAmbientLight(.1f, .1f, .1f, 1f); // handler.setAmbientLight(.06f, .06f, .06f, .05f); handler.setShadows(true); handler.setCulling(true); // handler.setBlur(true); // Renders shadows pointLight = new PointLight(handler, 290, new Color(1, 1, .8f, .6f), 15, 10, 110); pointLight.setSoft(true); pointLight.setSoftnessLenght(.3f); // lights up the tiles around the player (no shadows) pointLight2 = new PointLight(handler, 200, new Color(1, 1, .8f, .6f), 6, 10, 110); pointLight2.setSoftnessLenght(1.5f); pointLight2.setXray(true); // for debugging--------- // Box2D debug renderer. renders wireframes of the objects we create. debugRenderer = new Box2DDebugRenderer(); bitmapFont = new BitmapFont(); bitmapFont.setUseIntegerPositions(false); bitmapFont.getRegion().getTexture().setFilter(TextureFilter.Linear, TextureFilter.Linear); bitmapFont.setColor(Color.WHITE); bitmapFont.setScale(1.0f / 48.0f); }
From source file:gameWorld.WorldRenderer.java
License:Apache License
public void renderObjects() { // Draw all tiles now and black background shapeRender.begin(ShapeType.Filled); shapeRender.setColor(new Color(.1f, .1f, .1f, 1f)); shapeRender.rect(cam.position.x - 200, cam.position.y - 200, 2580, 1680); shapeRender.end();/*from w w w . j a va 2s .c o m*/ batch = (SpriteBatch) renderer.getSpriteBatch(); renderer.setView(cam.combined, cam.position.x - 20, cam.position.y - 20, cam.viewportWidth + 40, cam.viewportWidth + 40); renderer.render(); // render game objects batch.begin(); renderBob(); renderPlatforms(); renderItems(); renderCastle(); batch.end(); // Debug rendering // draw fonts debugRender(); // draw box2d world. debugRenderer.render(world.world2, cam.combined); // light rendering handler.updateAndRender(); // world2.step(1 / 60f, 6, 2); }
From source file:graphics.CargoSpace3D.java
License:Apache License
@Override public void create() { lights = new Environment(); lights.set(new ColorAttribute(ColorAttribute.AmbientLight, 0.4f, 0.4f, 0.4f, 1f)); lights.add(new DirectionalLight().set(0.8f, 0.8f, 0.8f, -1f, -0.8f, -0.2f)); modelBatch = new ModelBatch(); cam = new PerspectiveCamera(100, Gdx.graphics.getWidth(), Gdx.graphics.getHeight()); cam.position.set(10f, 10f, 10f);// w w w .j a v a 2 s.c o m cam.lookAt(0, 0, 0); cam.near = 1f; cam.far = 300f; cam.update(); // ModelBuilder modelBuilder = new ModelBuilder(); // model = modelBuilder.createBox(5f, 5f, 5f, new Material(ColorAttribute.createDiffuse(Color.GREEN)), // Usage.Position | Usage.Normal); // instance = new ModelInstance(model); ModelBuilder modelBuilder = new ModelBuilder(); MeshPartBuilder builder; List<Model> models = new ArrayList<Model>(); instances = new ArrayList<ModelInstance>(); for (float x = GRID_MIN; x <= GRID_MAX_Y; x += 1) { for (float y = GRID_MIN; y <= GRID_MAX_X; y += 1) { for (float z = GRID_MIN; z <= GRID_MAX_Z; z += 1) { if (cargoSpace.getCargoSpace()[(int) x][(int) y][(int) z] != 0) { if (cargoSpace.getCargoSpace()[(int) x][(int) y][(int) z] == 1) { drawCargoCube(modelBuilder, models, x, y, z, new Color(0.6f, .7f, .7f, 0)); } if (cargoSpace.getCargoSpace()[(int) x][(int) y][(int) z] == 2) { drawCargoCube(modelBuilder, models, x, y, z, new Color(0.3f, .7f, .9f, 0)); } if (cargoSpace.getCargoSpace()[(int) x][(int) y][(int) z] == 3) { drawCargoCube(modelBuilder, models, x, y, z, new Color(0.9f, .4f, .2f, 0)); } } } } } System.out.println("Done"); }
From source file:graphics.Shape3D.java
License:Apache License
@Override public void create() { lights = new Environment(); lights.set(new ColorAttribute(ColorAttribute.AmbientLight, 0.4f, 0.4f, 0.4f, 1f)); lights.add(new DirectionalLight().set(0.8f, 0.8f, 0.8f, -1f, -0.8f, -0.2f)); modelBatch = new ModelBatch(); cam = new PerspectiveCamera(67, Gdx.graphics.getWidth(), Gdx.graphics.getHeight()); cam.position.set(10f, 10f, 10f);/*from w w w.j av a 2 s . co m*/ cam.lookAt(0, 0, 0); cam.near = 1f; cam.far = 300f; cam.update(); // ModelBuilder modelBuilder = new ModelBuilder(); // model = modelBuilder.createBox(5f, 5f, 5f, new Material(ColorAttribute.createDiffuse(Color.GREEN)), // Usage.Position | Usage.Normal); // instance = new ModelInstance(model); ModelBuilder modelBuilder = new ModelBuilder(); MeshPartBuilder builder; List<Model> models = new ArrayList<Model>(); instances = new ArrayList<ModelInstance>(); for (float y = GRID_MIN; y <= GRID_MAX_Y; y += 1) { for (float x = GRID_MIN; x <= GRID_MAX_X; x += 1) { for (float z = GRID_MIN; z <= GRID_MAX_Z; z += 1) { if (aShape.getShape()[(int) y][(int) x][(int) z] != 0) { modelBuilder.begin(); builder = modelBuilder.part("grid", GL20.GL_TRIANGLES, Usage.Position | Usage.Normal, new Material(ColorAttribute.createDiffuse(new Color(0.9f, 0.4f, 0.2f, 0)))); builder.setColor(Color.GREEN); builder.box(y, x, z, 1f, 1f, 1f); models.add(modelBuilder.end()); instances.add(new ModelInstance(models.get(models.size() - 1))); } } } } System.out.println("Done"); }
From source file:group04.core.Renderer.java
private void clearBackground(GameData gameData) { sr.setColor(new Color(0f, 138f / 255f, 1f, 1f)); sr.rect(0, 0, gameData.getDisplayWidth(), gameData.getDisplayWidth()); }
From source file:gui.ColorUtils.java
License:Apache License
/** * Converts HSV color sytem to RGB/* w ww . j a v a 2 s. c o m*/ * * @return RGB values in Libgdx Color class */ public static Color HSV_to_RGB(float h, float s, float v) { int r, g, b; int i; float f, p, q, t; h = (float) Math.max(0.0, Math.min(360.0, h)); s = (float) Math.max(0.0, Math.min(100.0, s)); v = (float) Math.max(0.0, Math.min(100.0, v)); s /= 100; v /= 100; h /= 60; i = (int) Math.floor(h); f = h - i; p = v * (1 - s); q = v * (1 - s * f); t = v * (1 - s * (1 - f)); switch (i) { case 0: r = Math.round(255 * v); g = Math.round(255 * t); b = Math.round(255 * p); break; case 1: r = Math.round(255 * q); g = Math.round(255 * v); b = Math.round(255 * p); break; case 2: r = Math.round(255 * p); g = Math.round(255 * v); b = Math.round(255 * t); break; case 3: r = Math.round(255 * p); g = Math.round(255 * q); b = Math.round(255 * v); break; case 4: r = Math.round(255 * t); g = Math.round(255 * p); b = Math.round(255 * v); break; default: r = Math.round(255 * v); g = Math.round(255 * p); b = Math.round(255 * q); } return new Color(r / 255.0f, g / 255.0f, b / 255.0f, 1); }
From source file:it.alcacoop.backgammon.ui.UIDialog.java
License:Open Source License
public static void getYesNoDialog(BaseFSM.Events evt, String text) { Stage stage = GnuBackgammon.Instance.currentScreen.getStage(); instance.visible = true;//from w w w . j a v a 2s .c o m instance.quitWindow = false; instance.optionsWindow = false; instance.leaveWindow = false; instance.dicesWindow = false; instance.evt = evt; instance.remove(); instance.setText(text); float height = stage.getHeight() * 0.4f; float width = stage.getWidth() * 0.78f; instance.clear(); instance.setWidth(width); instance.setHeight(height); instance.setX((stage.getWidth() - width) / 2); instance.setY((stage.getHeight() - height) / 2); instance.row().padTop(width / 25); instance.add(instance.label).colspan(5).expand().align(Align.center); instance.row().pad(width / 25); instance.add(); instance.add(instance.bNo).fill().expand().height(height * 0.25f).width(width / 4); instance.add(); instance.add(instance.bYes).fill().expand().height(height * 0.25f).width(width / 4); instance.add(); stage.addActor(instance); instance.setY(stage.getHeight()); instance.addAction(MyActions.sequence(Actions.parallel(Actions.color(new Color(1, 1, 1, alpha), 0.2f), Actions.moveTo((stage.getWidth() - width) / 2, (stage.getHeight() - height) / 2, 0.2f)))); }
From source file:it.alcacoop.backgammon.ui.UIDialog.java
License:Open Source License
public static void getContinueDialog(BaseFSM.Events evt, String text) { Stage stage = GnuBackgammon.Instance.currentScreen.getStage(); instance.visible = true;/*from w w w .ja v a 2 s . c o m*/ instance.quitWindow = false; instance.optionsWindow = false; instance.leaveWindow = false; instance.dicesWindow = false; instance.evt = evt; instance.remove(); instance.setText(text); float height = stage.getHeight() * 0.4f; float width = stage.getWidth() * 0.6f; instance.clear(); instance.setWidth(width); instance.setHeight(height); instance.setX((stage.getWidth() - width) / 2); instance.setY((stage.getHeight() - height) / 2); instance.row().padTop(width / 25); instance.add(instance.label).colspan(3).expand().align(Align.center); instance.row().pad(width / 25); instance.add(); instance.add(instance.bContinue).fill().expand().height(height * 0.25f).width(width / 4); instance.add(); stage.addActor(instance); instance.setY(stage.getHeight()); instance.addAction(MyActions.sequence(Actions.parallel(Actions.color(new Color(1, 1, 1, alpha), 0.2f), Actions.moveTo((stage.getWidth() - width) / 2, (stage.getHeight() - height) / 2, 0.2f)))); }
From source file:it.alcacoop.backgammon.ui.UIDialog.java
License:Open Source License
public static void getEndGameDialog(BaseFSM.Events evt, String text, String text1, String score1, String score2) {//from w w w. j a v a 2 s .c om Stage stage = GnuBackgammon.Instance.currentScreen.getStage(); instance.visible = true; instance.quitWindow = false; instance.optionsWindow = false; instance.leaveWindow = false; instance.dicesWindow = false; instance.evt = evt; instance.remove(); float height = stage.getHeight() * 0.6f; float width = stage.getWidth() * 0.6f; instance.clear(); instance.setWidth(width); instance.setHeight(height); instance.setX((stage.getWidth() - width) / 2); instance.setY((stage.getHeight() - height) / 2); instance.row().padTop(width / 25); instance.add().expand(); instance.add(text1).colspan(2).expand().align(Align.center); instance.add().expand(); instance.row(); instance.add().expand(); instance.add("Overall Score " + text).colspan(2).expand().align(Align.center); instance.add().expand(); instance.row(); instance.add().expand(); instance.add(score1).expand().align(Align.center); instance.add(score2).expand().align(Align.center); instance.add().expand(); Table t1 = new Table(); t1.row().expand().fill(); t1.add(); t1.add(instance.bContinue).colspan(2).fill().expand().height(height * 0.15f).width(width / 3); if ((MatchState.anScore[0] >= MatchState.nMatchTo || MatchState.anScore[1] >= MatchState.nMatchTo) && (MatchState.matchType == 0)) { t1.add(); t1.add(instance.bExport).colspan(2).fill().expand().height(height * 0.15f).width(width / 3); } t1.add(); instance.row(); instance.add(t1).colspan(4).fill().padBottom(width / 25); stage.addActor(instance); instance.setY(stage.getHeight()); instance.addAction(MyActions.sequence(Actions.parallel(Actions.color(new Color(1, 1, 1, alpha), 0.2f), Actions.moveTo((stage.getWidth() - width) / 2, (stage.getHeight() - height) / 2, 0.2f)))); }