Java Code Examples for com.badlogic.gdx.graphics.Color#equals()

The following examples show how to use com.badlogic.gdx.graphics.Color#equals() . 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 File: ColorPickerDialog.java    From gdx-skineditor with Apache License 2.0 5 votes vote down vote up
/**
 * Check if the color is already in use somewhere else in the skin
 */
public boolean isColorInUse(Color color) {

	try {
		// Check if it is already in use somewhere!
		for (String widget : SkinEditorGame.widgets) {
			String widgetStyle = "com.badlogic.gdx.scenes.scene2d.ui." + widget + "$" + widget + "Style";
			Class<?> style = Class.forName(widgetStyle);
			ObjectMap<String, ?> styles = game.skinProject.getAll(style);
			Iterator<String> it = styles.keys().iterator();
			while (it.hasNext()) {
				Object item = styles.get((String) it.next());
				Field[] fields = ClassReflection.getFields(item.getClass());
				for (Field field : fields) {

					if (field.getType() == Color.class) {

						Color c = (Color) field.get(item);
						if (color.equals(c)) {
							return true;
						}

					}

				}

			}

		}
	} catch (Exception e) {
		e.printStackTrace();

	}

	return false;
}
 
Example 2
Source File: GLTFExportTypes.java    From gdx-gltf with Apache License 2.0 4 votes vote down vote up
static float[] rgb(Color color, Color nullColor) {
	return color.equals(nullColor) ? null : rgb(color);
}
 
Example 3
Source File: GLTFMaterialExporter.java    From gdx-gltf with Apache License 2.0 4 votes vote down vote up
protected Color defaultNull(Color defaultColor, Color color) {
	return color.equals(defaultColor) ? null : color;
}
 
Example 4
Source File: TextRenderer.java    From bladecoder-adventure-engine with Apache License 2.0 4 votes vote down vote up
@Override
public void draw(SpriteBatch batch, float x, float y, float scaleX, float scaleY, float rotation, Color tint) {

	float dx = getAlignDx(getWidth(), orgAlign);
	float dy = getAlignDy(getHeight(), orgAlign);

	if (font != null && text != null) {

		if (tint != null && !tint.equals(color)) {
			color.set(tint);

			String tt = text;

			if (tt.charAt(0) == I18N.PREFIX)
				tt = world.getI18N().getString(tt.substring(1));

			if (editorTranslatedText != null)
				tt = editorTranslatedText;

			layout.setText(font, tt, color, 0, textAlign, false);
		}

		Matrix4 tm = batch.getTransformMatrix();
		tmp.set(tm);

		float originX = dx;
		float originY = layout.height + dy;

		if (textAlign == Align.right)
			originX += getWidth();
		else if (textAlign == Align.center)
			originX += getWidth() / 2;

		tm.translate(x, y, 0).rotate(0, 0, 1, rotation).scale(scaleX, scaleY, 1).translate(originX, originY, 0);

		batch.setTransformMatrix(tm);

		font.draw(batch, layout, 0, 0);

		batch.setTransformMatrix(tmp);
	} else {
		RectangleRenderer.draw(batch, x + dx * scaleX, y + dy * scaleY, getWidth() * scaleX, getHeight() * scaleY,
				Color.RED);
	}
}