private Object castProperty (String name, String value, String type) { if (type == null) { return value; } else if (type.equals("int")) { return Integer.valueOf(value); } else if (type.equals("float")) { return Float.valueOf(value); } else if (type.equals("bool")) { return Boolean.valueOf(value); } else if (type.equals("color")) { // Tiled uses the format #AARRGGBB String opaqueColor = value.substring(3); String alpha = value.substring(1, 3); return Color.valueOf(opaqueColor + alpha); } else { throw new GdxRuntimeException("Wrong type given for property " + name + ", given : " + type + ", supported : string, bool, int, float, color"); } }
private Object castProperty (String name, String value, String type) { if (type == null) { return value; } else if (type.equals("int")) { return Integer.valueOf(value); } else if (type.equals("float")) { return Float.valueOf(value); } else if (type.equals("bool")) { return Boolean.valueOf(value); } else if (type.equals("color")) { // Tiled uses the format #AARRGGBB String opaqueColor = value.substring(3); String alpha = value.substring(1, 3); return Color.valueOf(opaqueColor + alpha); } else { throw new GdxRuntimeException("Wrong type given for property " + name + ", given : " + type + ", supported : string, bool, int, float, color"); } }
public Color read (Json json, JsonValue jsonData, Class type) { if (jsonData.isString()) return get(jsonData.asString(), Color.class); String hex = json.readValue("hex", String.class, (String)null, jsonData); if (hex != null) return Color.valueOf(hex); float r = json.readValue("r", float.class, 0f, jsonData); float g = json.readValue("g", float.class, 0f, jsonData); float b = json.readValue("b", float.class, 0f, jsonData); float a = json.readValue("a", float.class, 1f, jsonData); return new Color(r, g, b, a); } });
public Color read (Json json, JsonValue jsonData, Class type) { if (jsonData.isString()) return get(jsonData.asString(), Color.class); String hex = json.readValue("hex", String.class, (String)null, jsonData); if (hex != null) return Color.valueOf(hex); float r = json.readValue("r", float.class, 0f, jsonData); float g = json.readValue("g", float.class, 0f, jsonData); float b = json.readValue("b", float.class, 0f, jsonData); float a = json.readValue("a", float.class, 1f, jsonData); return new Color(r, g, b, a); } });
public void create () { if (spriteBatch != null) return; spriteBatch = new SpriteBatch(); shapeRenderer = new ShapeRenderer(); lineColor = com.badlogic.gdx.graphics.Color.valueOf("636363"); worldCamera = new OrthographicCamera(); textCamera = new OrthographicCamera(); pixelsPerMeter = new NumericValue(); pixelsPerMeter.setValue(1.0f); pixelsPerMeter.setAlwaysActive(true); zoomLevel = new NumericValue(); zoomLevel.setValue(1.0f); zoomLevel.setAlwaysActive(true); deltaMultiplier = new NumericValue(); deltaMultiplier.setValue(1.0f); deltaMultiplier.setAlwaysActive(true); backgroundColor = new GradientColorValue(); backgroundColor.setColors(new float[] {0f, 0f, 0f}); font = new BitmapFont(Gdx.files.getFileHandle("default.fnt", FileType.Internal), Gdx.files.getFileHandle("default.png", FileType.Internal), true); effectPanel.newExampleEmitter("Untitled", true); // if (resources.openFile("/editor-bg.png") != null) bgImage = new Image(gl, "/editor-bg.png"); OrthoCamController orthoCamController = new OrthoCamController (worldCamera); Gdx.input.setInputProcessor(new InputMultiplexer(orthoCamController, this)); }
public void create () { if (spriteBatch != null) return; spriteBatch = new SpriteBatch(); shapeRenderer = new ShapeRenderer(); lineColor = com.badlogic.gdx.graphics.Color.valueOf("636363"); worldCamera = new OrthographicCamera(); textCamera = new OrthographicCamera(); pixelsPerMeter = new NumericValue(); pixelsPerMeter.setValue(1.0f); pixelsPerMeter.setAlwaysActive(true); zoomLevel = new NumericValue(); zoomLevel.setValue(1.0f); zoomLevel.setAlwaysActive(true); deltaMultiplier = new NumericValue(); deltaMultiplier.setValue(1.0f); deltaMultiplier.setAlwaysActive(true); backgroundColor = new GradientColorValue(); backgroundColor.setColors(new float[] {0f, 0f, 0f}); font = new BitmapFont(Gdx.files.getFileHandle("default.fnt", FileType.Internal), Gdx.files.getFileHandle("default.png", FileType.Internal), true); effectPanel.newExampleEmitter("Untitled", true); // if (resources.openFile("/editor-bg.png") != null) bgImage = new Image(gl, "/editor-bg.png"); OrthoCamController orthoCamController = new OrthoCamController (worldCamera); Gdx.input.setInputProcessor(new InputMultiplexer(orthoCamController, this)); }
@Override public void create () { spriteBatch = new SpriteBatch(); // font = new BitmapFont(Gdx.files.internal("data/verdana39.fnt"), false); font = new BitmapFont(Gdx.files.internal("data/arial-32-pad.fnt"), false); // font = new FreeTypeFontGenerator(Gdx.files.internal("data/arial.ttf")).generateFont(new FreeTypeFontParameter()); font.getData().markupEnabled = true; font.getData().breakChars = new char[] {'-'}; multiPageFont = new BitmapFont(Gdx.files.internal("data/multipagefont.fnt")); // Add user defined color Colors.put("PERU", Color.valueOf("CD853F")); renderer = new ShapeRenderer(); renderer.setProjectionMatrix(spriteBatch.getProjectionMatrix()); stage = new Stage(new ScreenViewport()); Skin skin = new Skin(Gdx.files.internal("data/uiskin.json")); BitmapFont labelFont = skin.get("default-font", BitmapFont.class); labelFont.getData().markupEnabled = true; // Notice that the last [] has been deliberately added to test the effect of excessive pop operations. // They are silently ignored, as expected. label = new Label("<<[BLUE]M[RED]u[YELLOW]l[GREEN]t[OLIVE]ic[]o[]l[]o[]r[]*[MAROON]Label[][] [Unknown Color]>>", skin); label.setPosition(100, 200); stage.addActor(label); Window window = new Window("[RED]Multicolor[GREEN] Title", skin); window.setPosition(400, 300); window.pack(); stage.addActor(window); layout = new GlyphLayout(); }
Color color = Color.valueOf("878787"); backgroundColor.setColors(new float[] { color.r, color.g, color.b});
Color color = Color.valueOf("878787"); backgroundColor.setColors(new float[] { color.r, color.g, color.b});
public static Color parseColor(String color) { if (color == null || color.trim().isEmpty()) { return null; // the default color in the style will be used } switch (color.trim()) { case "black": return Color.BLACK; case "white": return Color.WHITE; default: return Color.valueOf(color); } }
public ShadowLabel(CharSequence text, LabelStyle labelStyle, String shadowColorName, float resolutionMult) { this(text, labelStyle, Color.valueOf(shadowColorName)); this.resolutionMult = resolutionMult; repositionShadowLabel(); }
private BaseDrawable getTintedDrawable(BaseDrawable drawable, String color) { if (drawable instanceof SpriteDrawable) { return ((SpriteDrawable) drawable).tint(Color.valueOf(color)); } else if (drawable instanceof NinePatchDrawable) { return ((NinePatchDrawable) drawable).tint(Color.valueOf(color)); } return null; }
public ShadowLabel(CharSequence text, LabelStyle labelStyle, String shadowColorName) { this(text, labelStyle, Color.valueOf(shadowColorName)); repositionShadowLabel(); }
public TypedGdxQuery<T> color(String string) { t.setColor(Color.valueOf(string)); return this; }
public TypedGdxQuery<T> colorTo(String string, float d) { return colorTo(Color.valueOf(string), d); }
public GdxQuery color(String string) { for(Actor actor : list()) actor.setColor(Color.valueOf(string)); return this; }
public ColoredGroup(GroupModel groupModel) { if (texture == null) createTexture(); try { color = Color.valueOf(groupModel.getColor()); } catch (NumberFormatException ignored) {} }
@Override public void changed (ChangeEvent event, Actor actor) { if (hexField.getText().length() == (allowAlphaEdit ? HEX_COLOR_LENGTH_WITH_ALPHA : HEX_COLOR_LENGTH)) { setColor(Color.valueOf(hexField.getText()), false); } } });
@Override public void process(final LmlParser parser, final LmlTag tag, final Actor actor, final String rawAttributeData) { String hexValue = parser.parseString(rawAttributeData, actor); try { Color color = Color.valueOf(hexValue); actor.setColor(color); } catch (Exception exception) { parser.throwErrorIfStrict( "Unable to parse HEX color value from string \"" + hexValue + "\"", exception); } } }
public Color read (Json json, JsonValue jsonData, Class type) { if (jsonData.isString()) return get(jsonData.asString(), Color.class); String hex = json.readValue("hex", String.class, (String)null, jsonData); if (hex != null) return Color.valueOf(hex); float r = json.readValue("r", float.class, 0f, jsonData); float g = json.readValue("g", float.class, 0f, jsonData); float b = json.readValue("b", float.class, 0f, jsonData); float a = json.readValue("a", float.class, 1f, jsonData); return new Color(r, g, b, a); } });