Java Code Examples for com.badlogic.gdx.graphics.Color#rgba8888()
The following examples show how to use
com.badlogic.gdx.graphics.Color#rgba8888() .
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: SplatMap.java From Mundus with Apache License 2.0 | 6 votes |
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); }
Example 2
Source File: TextureUtil.java From seventh with GNU General Public License v2.0 | 6 votes |
/** * Applying mask into image using specified masking color. Any Color in the * image that matches the masking color will be converted to transparent. * * @param img The source image * @param keyColor Masking color * @return Masked image */ public static Pixmap applyMask(Pixmap img, Color keyColor) { Pixmap alpha = new Pixmap(img.getWidth(), img.getHeight(), Format.RGBA8888); //alpha.drawPixmap(img, 0, 0); int width = alpha.getWidth(); int height = alpha.getHeight(); int colorMask = Color.rgba8888(keyColor); //alpha.setColor(0xff00009f); for (int y = 0; y < height; y++) { for (int x = 0; x < width; x++) { int col = img.getPixel(x, y); if ( col != colorMask ) { alpha.drawPixel(x, y, img.getPixel(x, y)); } } } return alpha; }
Example 3
Source File: PaletteReducer.java From gdx-texture-packer-gui with Apache License 2.0 | 5 votes |
/** * Builds the palette information this PNG8 stores from the Color objects in {@code colorPalette}, up to 256 colors. * Alpha is not preserved except for the first item in colorPalette, and only if its r, g, b, and a values are all * 0f (fully transparent black); otherwise all items are treated as opaque. If rgbaPalette is null, empty, only has * one color, or limit is less than 2, then this defaults to DawnBringer's Aurora palette with 256 hand-chosen * colors (including transparent). * * @param colorPalette an array of Color objects; all will be used up to 256 items, limit, or the length of the array * @param limit a limit on how many Color items to use from colorPalette; useful if colorPalette is from an Array */ public void exact(Color[] colorPalette, int limit) { if (colorPalette == null || colorPalette.length < 2 || limit < 2) { exact(auroraPalette); return; } Arrays.fill(paletteArray, 0); Arrays.fill(paletteMapping, (byte) 0); final int plen = Math.min(Math.min(256, colorPalette.length), limit); int color, c2; int dist; for (int i = 0; i < plen; i++) { color = Color.rgba8888(colorPalette[i]); paletteArray[i] = color; paletteMapping[(color >>> 17 & 0x7C00) | (color >>> 14 & 0x3E0) | (color >>> 11 & 0x1F)] = (byte) i; } int rr, gg, bb; for (int r = 0; r < 32; r++) { rr = (r << 3 | r >>> 2); for (int g = 0; g < 32; g++) { gg = (g << 3 | g >>> 2); for (int b = 0; b < 32; b++) { c2 = r << 10 | g << 5 | b; if (paletteMapping[c2] == 0) { bb = (b << 3 | b >>> 2); dist = 0x7FFFFFFF; for (int i = 1; i < plen; i++) { if (dist > (dist = Math.min(dist, difference(paletteArray[i], rr, gg, bb)))) paletteMapping[c2] = (byte) i; } } } } } }
Example 4
Source File: GdxCanvas.java From seventh with GNU General Public License v2.0 | 4 votes |
@Override public int getColor() { int c = Color.rgba8888(color); return (c >>> 8) | (c<<24); }
Example 5
Source File: Colors.java From seventh with GNU General Public License v2.0 | 4 votes |
public static int toColor(float r, float g, float b, float alpha) { int c = Color.rgba8888(r,g,b, alpha); return (c >>> 8) | (c<<24); }
Example 6
Source File: Colors.java From seventh with GNU General Public License v2.0 | 2 votes |
/** * Converts the {@link Vector3f} into a int color * @param v * @param alpha * @return the int color rgba */ public static int toColor(Vector3f v, float alpha) { return Color.rgba8888(v.x, v.y, v.z, alpha); }
Example 7
Source File: Colors.java From seventh with GNU General Public License v2.0 | 2 votes |
/** * Converts the {@link Vector3f} into a int color * @param v * @return the int color rgba */ public static int toColor(Vector3f v) { return Color.rgba8888(v.x, v.y, v.z, 1.0f)<<16; }