Example usage for com.badlogic.gdx.graphics Color rgba8888

List of usage examples for com.badlogic.gdx.graphics Color rgba8888

Introduction

In this page you can find the example usage for com.badlogic.gdx.graphics Color rgba8888.

Prototype

public static int rgba8888(float r, float g, float b, float a) 

Source Link

Usage

From source file:base.Engine.java

License:Open Source License

public static Pixmap generatePatternPixmap(PatternEntry basedOn, Color color) {
    Pixmap returnPixmap = new Pixmap(basedOn.getWrapper().getW(), basedOn.getWrapper().getH(),
            Pixmap.Format.RGBA8888);
    returnPixmap.setColor(Color.rgba8888(0, 0, 0, 0));
    returnPixmap.fill();//from   w  w  w.  ja va 2  s  . c  o m

    returnPixmap.setColor(Color.DARK_GRAY);
    returnPixmap.drawPixel(0, 0);

    returnPixmap.setColor(color);

    for (int x = 0; x < basedOn.getWrapper().getW(); x++)
        for (int y = 0; y < basedOn.getWrapper().getH(); y++)
            if (basedOn.getCells()[x][y] != 0)
                returnPixmap.drawPixel(x, y);

    return returnPixmap;
}

From source file:com.md.crypto.PixmapCrypto.java

License:Apache License

/**
 * Sets the color for the following drawing operations.
 * //from w ww .  j  a v  a2  s .c  om
 * @param color
 *            The color.
 */
public void setColor(Color color) {
    this.color = Color.rgba8888(color.r, color.g, color.b, color.a);
}

From source file:mobi.shad.s3lib.gfx.effect.Copper.java

License:Apache License

/**
 * Generate color bar on the bitmap/*w  w w.  j av  a 2 s.co  m*/
 *
 * @param colorOutside
 * @param colorInside
 * @param texPerRow
 * @param tex_per_column
 * @param index
 * @param localPixmap
 * @param localSizeX
 * @param localSizeY
 */
private void calculateCopperBarTexture2D(Color colorOutside, Color colorInside, Color colorInside2,
        Color colorOutside2, int texPerRow, int tex_per_column, int index, Pixmap localPixmap, int localSizeX,
        int localSizeY) {

    float xStep = (float) localSizeX / texPerRow;
    float yStep = (float) localSizeY / tex_per_column;
    float x = index % texPerRow;
    float y = index / texPerRow;
    float xMin = (x * xStep);
    float xMax = xMin + (xStep);
    float yMin = (y * yStep);
    float yMax = yMin + (yStep);

    Color color = Color.BLACK;
    for (int py = (int) yMin; py <= (int) yMax; py++) {
        float procent = (py - yMin) / yStep;
        switch (mode) {
        default:
            color = GradientUtil.linearGradientColor(colorOutside, colorInside, colorOutside, procent);
            break;
        case 1:
            color = GradientUtil.linearGradientColor(colorInside, colorOutside, procent);
            break;
        case 2:
            color = GradientUtil.linearGradientColor(colorOutside, colorInside, colorOutside2, procent);
            break;
        case 3:
            color = GradientUtil.linearGradientColor(colorOutside, colorInside, colorInside2, colorOutside2,
                    procent);
            break;
        case 4:
            if (index % 4 == 0) {
                color = GradientUtil.linearGradientColor(Color.BLACK, colorOutside, Color.BLACK, procent);
            } else if (index % 4 == 1) {
                color = GradientUtil.linearGradientColor(Color.BLACK, colorInside, Color.BLACK, procent);
            } else if (index % 4 == 2) {
                color = GradientUtil.linearGradientColor(Color.BLACK, colorInside2, Color.BLACK, procent);
            } else {
                color = GradientUtil.linearGradientColor(Color.BLACK, colorOutside2, Color.BLACK, procent);
            }
            break;
        case 5:
            color = GradientUtil.getColorPallete(procent, (int) (colorOutside.a * 42));
            break;
        case 6:
            if (procent < 0.5f) {
                color = GradientUtil.getColorPallete(procent * 0.5f, (int) (colorOutside.a * 42));
            } else {
                color = GradientUtil.getColorPallete(1f - procent * 0.5f, (int) (colorOutside.a * 42));
            }
            break;
        case 7:
            if (index % 2 == 0) {
                color = GradientUtil.getColorPallete(procent, (int) (colorOutside.a * 42));
            } else if (index % 2 == 1) {
                color = GradientUtil.getColorPallete(procent, (int) (colorOutside.a * 42) + 2);
            }
            break;
        case 8:
            if (index % 4 == 0) {
                color = GradientUtil.getColorPallete(procent, (int) (colorOutside.a * 42));
            } else if (index % 4 == 1) {
                color = GradientUtil.getColorPallete(procent, (int) (colorOutside.a * 42) + 1);
            } else if (index % 4 == 2) {
                color = GradientUtil.getColorPallete(procent, (int) (colorOutside.a * 42) + 2);
            } else if (index % 4 == 3) {
                color = GradientUtil.getColorPallete(procent, (int) (colorOutside.a * 42) + 3);
            }
            break;

        }
        int pixelColor = Color.rgba8888(color.r, color.g, color.b, color.a);
        for (int px = (int) xMin; px <= (int) xMax; px++) {
            localPixmap.drawPixel(px, py, pixelColor);
        }
    }
}