@Override public int hashCode () { int result = super.hashCode(); result = 953 * result + color.toIntBits(); return result; }
@Override public int hashCode () { int result = super.hashCode(); result = 953 * result + color.toIntBits(); return result; }
public static int encode (Color color) { if (color == null) return 0; return color.toIntBits(); }
@Override public int hashCode () { int result = super.hashCode(); result = 953 * result + color.toIntBits(); return result; }
@Override public boolean equals(Object other) { return (other instanceof SColor || other instanceof Color) && toIntBits() == ((Color) other).toIntBits(); }
public String getName() { StringBuffer name = new StringBuffer(); name.append(ttfName).append("_").append(textSize).append("_").append(color.toIntBits()) .append("_").append(booleanToInt(isFakeBoldText)).append("_") .append(booleanToInt(isUnderlineText)); if (strokeColor != null) { name.append("_").append(strokeColor.toIntBits()).append("_").append(strokeWidth); } return name.toString(); }
/** * Given a Color or SColor object and an alpha multiplier to affect that color (between 0f and 1f, inclusive and * clamped in that range), this makes a packed float color that has the same red, green, and blue channels but has * its own alpha multiplied by {@code alpha}, without constructing any objects along the way. * * @param color a libGDX Color (or SColor); will not be modified * @param alpha between 0.0 and 1.0 inclusive, the alpha to multiply the color's own alpha by * @return a color encoded as a packed float, using color's RGB channels but with its A channel times {@code alpha} */ public static float multiplyAlpha(Color color, float alpha) { return NumberTools.intBitsToFloat(color.toIntBits() & 0xFFFFFF | (MathUtils.clamp((int) (color.a * 255f * alpha), 0, 255) << 24 & 0xFE000000)); }
/** * Given a Color or SColor object and a desired alpha to set for that color (between 0f and 1f, inclusive and * clamped in that range), this makes a packed float color that has the same red, green, and blue channels but has * been set to the given alpha, without constructing any objects along the way. * * @param color a libGDX Color (or SColor); will not be modified * @param alpha between 0.0 and 1.0 inclusive, the alpha to set into the returned packed color * @return a color encoded as a packed float, using color's RGB channels and the given alpha */ public static float translucentColor(Color color, float alpha) { return NumberTools.intBitsToFloat(color.toIntBits() & 0xFFFFFF | (MathUtils.clamp((int) (255f * alpha), 0, 255) << 24 & 0xFE000000)); }
/** * Returns a filled rectangular texture for the provided {@link Color} * * @param color * The {@link Color} to fetch a texture of * @return A new {@link Texture} if this is first time it has been * requested, otherwise it will return a cached instance of the * {@link Texture} for the given {@link Color} */ public Texture getFilledRectangleTexture(Color color) { int bits = color.toIntBits(); if (!filledRectangleTextures.containsKey(bits)) { Pixmap pixmap = new Pixmap(1, 1, Pixmap.Format.RGBA8888); pixmap.setColor(color); pixmap.fillRectangle(0, 0, 1, 1); filledRectangleTextures.put(bits, new Texture(pixmap)); pixmap.dispose(); } return filledRectangleTextures.get(bits); } }