public TextButtonStyle (TextButtonStyle style) { super(style); this.font = style.font; if (style.fontColor != null) this.fontColor = new Color(style.fontColor); if (style.downFontColor != null) this.downFontColor = new Color(style.downFontColor); if (style.overFontColor != null) this.overFontColor = new Color(style.overFontColor); if (style.checkedFontColor != null) this.checkedFontColor = new Color(style.checkedFontColor); if (style.checkedOverFontColor != null) this.checkedOverFontColor = new Color(style.checkedOverFontColor); if (style.disabledFontColor != null) this.disabledFontColor = new Color(style.disabledFontColor); } }
public void setColor (Color tint) { color.set(tint); float color = tint.toFloatBits(); final float[] vertices = this.vertices; for (int i = 2; i < vertices.length; i += Sprite.VERTEX_SIZE) vertices[i] = color; }
/** Sets the color for the following drawing operations. * * @param r The red component. * @param g The green component. * @param b The blue component. * @param a The alpha component. */ public void setColor (float r, float g, float b, float a) { color = Color.rgba8888(r, g, b, a); }
public SelectBoxStyle (SelectBoxStyle style) { this.font = style.font; this.fontColor.set(style.fontColor); if (style.disabledFontColor != null) this.disabledFontColor = new Color(style.disabledFontColor); this.background = style.background; this.backgroundOver = style.backgroundOver; this.backgroundOpen = style.backgroundOpen; this.backgroundDisabled = style.backgroundDisabled; this.scrollStyle = new ScrollPaneStyle(style.scrollStyle); this.listStyle = new ListStyle(style.listStyle); } }
public void draw (Batch batch, float x, float y, float width, float height) { Color spriteColor = sprite.getColor(); temp.set(spriteColor); sprite.setColor(spriteColor.mul(batch.getColor())); sprite.setRotation(0); sprite.setScale(1, 1); sprite.setBounds(x, y, width, height); sprite.draw(batch); sprite.setColor(temp); }
/** Tints all text currently in the cache. Does not affect subsequently added text. */ public void tint (Color tint) { float newTint = tint.toFloatBits(); if (currentTint == newTint) return; currentTint = newTint; int[] tempGlyphCount = this.tempGlyphCount; for (int i = 0, n = tempGlyphCount.length; i < n; i++) tempGlyphCount[i] = 0; for (int i = 0, n = layouts.size; i < n; i++) { GlyphLayout layout = layouts.get(i); for (int ii = 0, nn = layout.runs.size; ii < nn; ii++) { GlyphRun run = layout.runs.get(ii); Array<Glyph> glyphs = run.glyphs; float colorFloat = tempColor.set(run.color).mul(tint).toFloatBits(); for (int iii = 0, nnn = glyphs.size; iii < nnn; iii++) { Glyph glyph = glyphs.get(iii); int page = glyph.page; int offset = tempGlyphCount[page] * 20 + 2; tempGlyphCount[page]++; float[] vertices = pageVertices[page]; for (int v = 0; v < 20; v += 5) vertices[offset + v] = colorFloat; } } } }
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); } });
protected void update (float percent) { float r = startR + (end.r - startR) * percent; float g = startG + (end.g - startG) * percent; float b = startB + (end.b - startB) * percent; float a = startA + (end.a - startA) * percent; color.set(r, g, b, a); }
public int additiveBlend(int pixelColor, SplatTexture.Channel channel, float strength) { c0.set(pixelColor); if (channel == SplatTexture.Channel.BASE) { c0.sub(strength, strength, strength, strength); } else if (channel == SplatTexture.Channel.R) { c0.add(strength, 0, 0, 0); } else if (channel == SplatTexture.Channel.G) { c0.add(0, strength, 0, 0); } else if (channel == SplatTexture.Channel.B) { c0.add(0, 0, strength, 0); } else if (channel == SplatTexture.Channel.A) { c0.add(0, 0, 0, strength); } // prevent the sum to be greater than 1 final float sum = c0.r + c0.g + c0.b + c0.a; if (sum > 1f) { final float correction = 1f / sum; c0.r *= correction; c0.g *= correction; c0.b *= correction; c0.a *= correction; } return Color.rgba8888(c0); }
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 void clearChannel(SplatTexture.Channel channel) { Pixmap pixmap = getPixmap(); for (int smX = 0; smX < pixmap.getWidth(); smX++) { for (int smY = 0; smY < pixmap.getHeight(); smY++) { c0.set(pixmap.getPixel(smX, smY)); if (channel == SplatTexture.Channel.R) { c0.set(0, c0.g, c0.b, c0.a); } else if (channel == SplatTexture.Channel.G) { c0.set(c0.r, 0, c0.b, c0.a); } else if (channel == SplatTexture.Channel.B) { c0.set(c0.r, c0.g, 0, c0.a); } else if (channel == SplatTexture.Channel.A) { c0.set(c0.r, c0.g, c0.b, 0); } pixmap.drawPixel(smX, smY, Color.rgba8888(c0)); } } }
private final void addVertex (final float[] values, final int offset) { final int o = vertices.size; vertices.addAll(values, offset, stride); lastIndex = (short)(vindex++); if (vertexTransformationEnabled) { transformPosition(vertices.items, o + posOffset, posSize, positionTransform); if (norOffset >= 0) transformNormal(vertices.items, o + norOffset, 3, normalTransform); if (biNorOffset >= 0) transformNormal(vertices.items, o + biNorOffset, 3, normalTransform); if (tangentOffset >= 0) transformNormal(vertices.items, o + tangentOffset, 3, normalTransform); } final float x = vertices.items[o + posOffset]; final float y = (posSize > 1) ? vertices.items[o + posOffset + 1] : 0f; final float z = (posSize > 2) ? vertices.items[o + posOffset + 2] : 0f; bounds.ext(x, y, z); if (hasColor) { if (colOffset >= 0) { vertices.items[o + colOffset] *= color.r; vertices.items[o + colOffset + 1] *= color.g; vertices.items[o + colOffset + 2] *= color.b; if (colSize > 3) vertices.items[o + colOffset + 3] *= color.a; } else if (cpOffset >= 0) { Color.abgr8888ToColor(tempC1, vertices.items[o + cpOffset]); vertices.items[o + cpOffset] = tempC1.mul(color).toFloatBits(); } } if (hasUVTransform && uvOffset >= 0) { vertices.items[o + uvOffset] = uOffset + uScale * vertices.items[o + uvOffset]; vertices.items[o + uvOffset + 1] = vOffset + vScale * vertices.items[o + uvOffset + 1]; } }
/** Sets the alpha portion of the color used to tint this sprite. */ public void setAlpha (float a) { color.a = a; float color = this.color.toFloatBits(); vertices[C1] = color; vertices[C2] = color; vertices[C3] = color; vertices[C4] = color; }
public void draw (Batch batch, float x, float y, float width, float height) { Color spriteColor = sprite.getColor(); temp.set(spriteColor); sprite.setColor(spriteColor.mul(batch.getColor())); sprite.setRotation(0); sprite.setScale(1, 1); sprite.setBounds(x, y, width, height); sprite.draw(batch); sprite.setColor(temp); }
/** Tints all text currently in the cache. Does not affect subsequently added text. */ public void tint (Color tint) { float newTint = tint.toFloatBits(); if (currentTint == newTint) return; currentTint = newTint; int[] tempGlyphCount = this.tempGlyphCount; for (int i = 0, n = tempGlyphCount.length; i < n; i++) tempGlyphCount[i] = 0; for (int i = 0, n = layouts.size; i < n; i++) { GlyphLayout layout = layouts.get(i); for (int ii = 0, nn = layout.runs.size; ii < nn; ii++) { GlyphRun run = layout.runs.get(ii); Array<Glyph> glyphs = run.glyphs; float colorFloat = tempColor.set(run.color).mul(tint).toFloatBits(); for (int iii = 0, nnn = glyphs.size; iii < nnn; iii++) { Glyph glyph = glyphs.get(iii); int page = glyph.page; int offset = tempGlyphCount[page] * 20 + 2; tempGlyphCount[page]++; float[] vertices = pageVertices[page]; for (int v = 0; v < 20; v += 5) vertices[offset + v] = colorFloat; } } } }
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 SelectBoxStyle (SelectBoxStyle style) { this.font = style.font; this.fontColor.set(style.fontColor); if (style.disabledFontColor != null) this.disabledFontColor = new Color(style.disabledFontColor); this.background = style.background; this.backgroundOver = style.backgroundOver; this.backgroundOpen = style.backgroundOpen; this.backgroundDisabled = style.backgroundDisabled; this.scrollStyle = new ScrollPaneStyle(style.scrollStyle); this.listStyle = new ListStyle(style.listStyle); } }
/** Sets the color to transition to. Required. */ public void setEndColor (Color color) { end.set(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"); } }