Java Code Examples for com.badlogic.gdx.graphics.Color#valueOf()
The following examples show how to use
com.badlogic.gdx.graphics.Color#valueOf() .
These examples are extracted from open source projects.
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source Project: typing-label File: Parser.java License: MIT License | 6 votes |
/** Parses a color from the given string. Returns null if the color couldn't be parsed. */ static Color stringToColor(String str) { if(str != null) { // Try to parse named color Color namedColor = Colors.get(str.toUpperCase()); if(namedColor != null) { return new Color(namedColor); } // Try to parse hex if(str.length() >= 6) { try { return Color.valueOf(str); } catch(NumberFormatException ignored) { } } } return null; }
Example 2
Source Project: beatoraja File: JSONSkinLoader.java License: GNU General Public License v3.0 | 5 votes |
private Color parseHexColor(String hex, Color fallbackColor) { try { return Color.valueOf(hex); } catch (Exception e) { return fallbackColor; } }
Example 3
Source Project: gdx-texture-packer-gui File: HexColorLmlAttribute.java License: Apache License 2.0 | 5 votes |
@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); } }
Example 4
Source Project: Mundus File: MaterialAsset.java License: Apache License 2.0 | 5 votes |
@Override public void load() { MAP.clear(); try { PropertiesUtils.load(MAP, file.reader()); // shininess & opacity try { String value = MAP.get(PROP_SHININESS, null); if (value != null) { shininess = Float.valueOf(value); } value = MAP.get(PROP_OPACITY, null); if (value != null) { opacity = Float.valueOf(value); } } catch (NumberFormatException nfe) { nfe.printStackTrace(); } // diffuse color String diffuseHex = MAP.get(PROP_DIFFUSE_COLOR); if (diffuseHex != null) { diffuseColor = Color.valueOf(diffuseHex); } // asset dependencies diffuseTextureID = MAP.get(PROP_DIFFUSE_TEXTURE, null); normalMapID = MAP.get(PROP_MAP_NORMAL, null); } catch (IOException e) { e.printStackTrace(); } }
Example 5
Source Project: bladecoder-adventure-engine File: Param.java License: Apache License 2.0 | 5 votes |
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); } }