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

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

Introduction

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

Prototype

Color RED

To view the source code for com.badlogic.gdx.graphics Color RED.

Click Source Link

Usage

From source file:mobi.shad.s3lib.gfx.node.pixmap.filter.FxNormals.java

License:Apache License

/**
 *
 */// ww w  .j av  a  2  s .com
@Override
protected void processLocal() {
    if (formGui != null) {
        amplify = formGui.getInt("FxNormalsAmplify");
    }
    if (data.pixmap == null) {
        data.pixmap = new Pixmap(S3Constans.proceduralTextureSizeHight, S3Constans.proceduralTextureSizeHight,
                Pixmap.Format.RGBA8888);
        data.pixmap.setColor(Color.RED);
        data.pixmap.fill();
        data.texture = null;
    }
    data.type = Data.Type.EFFECT_2D;
    Normals.generate(data.pixmap, amplify);
    data.textureChange = true;
}

From source file:mobi.shad.s3lib.gfx.node.pixmap.filter.FxThreshold.java

License:Apache License

/**
 *
 *///from w w w .  jav  a2s .c o m
@Override
protected void processLocal() {

    if (formGui != null) {
        threshold = formGui.getInt("FxThresholdThreshold");
        ratio = formGui.getInt("FxThresholdRatio");
        mode = formGui.getInt("FxThresholdMode");
    }
    if (data.pixmap == null) {
        data.pixmap = new Pixmap(S3Constans.proceduralTextureSizeHight, S3Constans.proceduralTextureSizeHight,
                Pixmap.Format.RGBA8888);
        data.pixmap.setColor(Color.RED);
        data.pixmap.fill();
        data.texture = null;
    }
    data.type = Data.Type.EFFECT_2D;
    Threshold.generate(data.pixmap, threshold, ratio, mode);
    data.textureChange = true;
}

From source file:mobi.shad.s3lib.gfx.pixmap.disort.RotoZoom.java

License:Apache License

/**
 *
 * @param pixmap//  www  . j  av  a2 s .c o m
 * @param amplify - The bulge value
 */
public static void generate(final Pixmap pixmap, float centerX, float centerY, float rotate, float zoomX,
        float zoomY) {

    int width = pixmap.getWidth();
    int height = pixmap.getHeight();

    //
    // Rotate
    //
    rotate = rotate * S3Math.PI2;

    //
    // Zoom
    //
    zoomX = (float) Math.pow(.5f, zoomX - 1);
    zoomY = (float) Math.pow(.5f, zoomY - 1);

    float c = (float) (Math.cos(rotate));
    float s = (float) (Math.sin(rotate));

    float tw2 = (float) width / 2.0f;
    float th2 = (float) height / 2.0f;

    float ys = s * -th2;
    float yc = c * -th2;

    Pixmap dstPixmap = new Pixmap(width, height, pixmap.getFormat());
    dstPixmap.setColor(Color.RED);
    dstPixmap.fill();

    for (int y = 0; y < height; y++) {

        //
        // x' = cos(x)-sin(y) + Center X;
        //
        float u = (((c * -tw2) - ys) * zoomX) + centerX;

        //
        // y' = sin(x)+cos(y) + Center Y;
        //
        float v = (((s * -tw2) + yc) * zoomY) + centerY;

        for (int x = 0; x < width; x++) {

            int ut = u >= 0 ? (int) u : (int) u - 1;
            int vt = v >= 0 ? (int) v : (int) v - 1;

            //
            // Texels
            // 1 | 2
            // -------
            // 3 | 4
            //

            //
            // Texel1
            //
            int rgb = pixmap.getPixel(vt, ut);
            int r = (rgb & 0xff000000) >>> 24;
            int g = (rgb & 0x00ff0000) >>> 16;
            int b = (rgb & 0x0000ff00) >>> 8;
            int a = (rgb & 0x000000ff);

            int outR = r;
            int outG = g;
            int outB = b;
            int outA = 255;

            //
            // Texel2
            //
            rgb = pixmap.getPixel(vt, ut + height);
            r = (rgb & 0xff000000) >>> 24;
            g = (rgb & 0x00ff0000) >>> 16;
            b = (rgb & 0x0000ff00) >>> 8;

            outR += r;
            outG += g;
            outB += b;

            //
            // Texel3
            //
            rgb = pixmap.getPixel((vt + width), ut);
            r = (rgb & 0xff000000) >>> 24;
            g = (rgb & 0x00ff0000) >>> 16;
            b = (rgb & 0x0000ff00) >>> 8;

            outR += r;
            outG += g;
            outB += b;

            //
            // Texel 4
            //
            rgb = pixmap.getPixel(vt + width, ut + height);
            r = (rgb & 0xff000000) >>> 24;
            g = (rgb & 0x00ff0000) >>> 16;
            b = (rgb & 0x0000ff00) >>> 8;

            outR += r;
            outG += g;
            outB += b;

            //
            // Clamp
            //
            outR = (outR < 255) ? outR : 255;
            outR = (outR > 0) ? outR : 0;
            outG = (outG < 255) ? outG : 255;
            outG = (outG > 0) ? outG : 0;
            outB = (outB < 255) ? outB : 255;
            outB = (outB > 0) ? outB : 0;

            dstPixmap.drawPixel(x, y, ((int) outR << 24) | ((int) outG << 16) | ((int) outB << 8) | outA);

            //
            // Vectors X
            //
            u += c * zoomX;
            v += s * zoomY;
        }
        //
        // Vectors Y
        //
        ys += s;
        yc += c;
    }
    pixmap.drawPixmap(dstPixmap, 0, 0);
}

From source file:mobi.shad.s3lib.gfx.pixmap.filter.Gradient.java

License:Apache License

/**
 * @param pixmap/*from   ww w  .  j  ava2  s . com*/
 */
@Override
public void generate(final Pixmap pixmap) {
    generate(pixmap, Color.RED, Color.YELLOW, Color.BLUE, Color.PINK, 1.0f);
}

From source file:mobi.shad.s3lib.gfx.pixmap.filter.Gradient.java

License:Apache License

/**
 * @param pixmap//w  w w.j  a v a2s.  c  o  m
 */
@Override
public void filter(final Pixmap pixmap) {
    generate(pixmap, Color.RED, Color.YELLOW, Color.BLUE, Color.PINK, 1.0f);
}

From source file:mobi.shad.s3lib.gfx.pixmap.filter.Gradient.java

License:Apache License

/**
 * @param pixmap//from w w  w  . j  a  v  a  2 s  . c o m
 */
@Override
public void random(final Pixmap pixmap) {
    generate(pixmap, Color.RED, Color.YELLOW, Color.BLUE, Color.PINK, 1.0f);
}

From source file:mobi.shad.s3lib.gui.dialog.Editor2d.java

License:Apache License

public void create(Texture areaTexture, final float startX, final float startY, final float width,
        final float height, final ChangeListener changeListener) {

    super.create();

    backendWindow = GuiResource.windowBackend();
    backendWindow.setColor(1f, 1f, 1f, 0f);
    backendWindow.setVisible(false);//from w  ww.j a  va 2  s  .  c  om
    S3.stage.addActor(backendWindow);

    mainWindow = GuiResource.window("WidgetBase", "WidgetBase");
    mainWindow.setColor(1f, 1f, 1f, 0f);
    mainWindow.setVisible(false);
    mainWindow.setModal(true);
    mainWindow.setMovable(false);

    this.currentX = startX;
    this.currentY = startY;
    this.currentWidth = width;
    this.currentHeight = height;
    //
    // Grid Layer
    //
    Pixmap pixmap = new Pixmap(10, 10, Pixmap.Format.RGBA8888);
    pixmap.setColor(Color.WHITE);
    pixmap.fill();
    gridtextureLayer = new Texture(pixmap);

    gridLayer = new Widget() {

        @Override
        public void draw(Batch batch, float parentAlpha) {
            batch.setColor(0.8f, 0.8f, 0.8f, 0.3f);
            batch.draw(gridtextureLayer, 0, S3Constans.gridY1, S3Screen.width, 1);
            batch.draw(gridtextureLayer, 0, S3Constans.gridY2, S3Screen.width, 1);
            batch.draw(gridtextureLayer, 0, S3Constans.gridY3, S3Screen.width, 1);
            batch.draw(gridtextureLayer, 0, S3Constans.gridY4, S3Screen.width, 1);
            batch.draw(gridtextureLayer, 0, S3Constans.gridY5, S3Screen.width, 3);
            batch.draw(gridtextureLayer, 0, S3Constans.gridY6, S3Screen.width, 1);
            batch.draw(gridtextureLayer, 0, S3Constans.gridY7, S3Screen.width, 1);
            batch.draw(gridtextureLayer, 0, S3Constans.gridY8, S3Screen.width, 1);
            batch.draw(gridtextureLayer, 0, S3Constans.gridY9, S3Screen.width, 1);

            batch.draw(gridtextureLayer, S3Constans.gridX1, 0, 1, S3Screen.height);
            batch.draw(gridtextureLayer, S3Constans.gridX2, 0, 1, S3Screen.height);
            batch.draw(gridtextureLayer, S3Constans.gridX3, 0, 1, S3Screen.height);
            batch.draw(gridtextureLayer, S3Constans.gridX4, 0, 1, S3Screen.height);
            batch.draw(gridtextureLayer, S3Constans.gridX5, 0, 3, S3Screen.height);
            batch.draw(gridtextureLayer, S3Constans.gridX6, 0, 1, S3Screen.height);
            batch.draw(gridtextureLayer, S3Constans.gridX7, 0, 1, S3Screen.height);
            batch.draw(gridtextureLayer, S3Constans.gridX8, 0, 1, S3Screen.height);
            batch.draw(gridtextureLayer, S3Constans.gridX9, 0, 1, S3Screen.height);
        }
    };
    gridLayer.setX(0);
    gridLayer.setY(0);
    gridLayer.setWidth(S3Screen.width);
    gridLayer.setHeight(S3Screen.height);

    //
    //
    //
    final TextureRegion areaRegion = new TextureRegion(areaTexture);

    areaImage = new Widget() {

        @Override
        public void draw(Batch batch, float parentAlpha) {
            Color color = getColor();
            batch.setColor(color.r, color.g, color.b, parentAlpha);
            batch.draw(areaRegion, getX(), getY(), getOriginX(), getOriginY(), getWidth(), getHeight(),
                    getScaleX(), getScaleY(), getRotation());
        }
    };
    areaImage.setX(currentX);
    areaImage.setY(currentY);
    areaImage.setWidth(currentWidth);
    areaImage.setHeight(currentHeight);

    //
    // Create texture
    //
    Pixmap redPixmap = new Pixmap(32, 32, Pixmap.Format.RGBA8888);
    redPixmap.setColor(Color.RED);
    redPixmap.fillCircle(16, 16, 14);
    Texture redTexture = new Texture(redPixmap);
    Pixmap yellowPixmap = new Pixmap(32, 32, Pixmap.Format.RGBA8888);
    yellowPixmap.setColor(Color.YELLOW);
    yellowPixmap.fillCircle(16, 16, 14);
    Texture yellowTexture = new Texture(yellowPixmap);
    Pixmap greenPixmap = new Pixmap(32, 32, Pixmap.Format.RGBA8888);
    greenPixmap.setColor(Color.GREEN);
    greenPixmap.fillCircle(16, 16, 14);
    Texture greenTexture = new Texture(greenPixmap);

    //
    //
    //
    TextButton textButtonOk = GuiResource.textButton("Save", "Save");
    TextButton textButtonFullScreen = GuiResource.textButton("Full", "Full");
    TextButton textButtonCenter = GuiResource.textButton("Center", "Center");
    TextButton textButtonCancel = GuiResource.textButton("Cancel", "Cancel");

    //
    //
    //
    textButtonOk.addListener(new ChangeListener() {
        @Override
        public void changed(ChangeEvent event, Actor actor) {
            S3Log.log("Editor2d::textButtonOk::clicked", " event: " + event + " actor: " + actor.toString(), 2);
            hide();
            if (changeListener != null) {
                changeListener.changed(event, areaImage);
            }
        }
    });

    textButtonFullScreen.addListener(new ClickListener() {
        @Override
        public void clicked(InputEvent event, float x, float y) {
            S3Log.log("Editor2d::textButtonFullScreen::clicked", " event: " + event + " x: " + x + " y: " + y,
                    2);
            currentX = 0;
            currentY = 0;
            currentWidth = S3Screen.width;
            currentHeight = S3Screen.height;
            setAreaPosistion();
            setTouchPosistion();
        }
    });

    textButtonCenter.addListener(new ClickListener() {
        @Override
        public void clicked(InputEvent event, float x, float y) {
            S3Log.log("Editor2d::textButtonCenter::clicked", " event: " + event + " x: " + x + " y: " + y, 2);
            currentX = S3Screen.centerX - (float) S3Screen.centerX / 2;
            currentY = S3Screen.centerY - (float) S3Screen.centerY / 2;
            currentWidth = (float) S3Screen.centerX;
            currentHeight = (float) S3Screen.centerY;
            setAreaPosistion();
            setTouchPosistion();
        }
    });

    textButtonCancel.addListener(new ClickListener() {
        @Override
        public void clicked(InputEvent event, float x, float y) {
            S3Log.log("Editor2d::textButtonCancel::clicked", " event: " + event + " x: " + x + " y: " + y, 2);
            currentX = startX;
            currentY = startY;
            currentWidth = width;
            currentHeight = height;
            hide();
        }
    });

    sizeElementLabel = GuiResource.label("X: Y: Width: Height:", "sizeElementLabel");
    mainWindow.row();
    mainWindow.add(textButtonOk);
    mainWindow.add(textButtonFullScreen);
    mainWindow.add(textButtonCenter);
    mainWindow.add(textButtonCancel);
    mainWindow.row();
    mainWindow.add(sizeElementLabel).colspan(4).left();
    GuiUtil.windowPosition(mainWindow, 0, 0);

    S3.stage.addActor(gridLayer);
    S3.stage.addActor(areaImage);

    //
    // Create AreaPlot
    //
    dotLeftImage = createAreaPoint("dotLeftImage", redTexture, (int) (currentX - 16),
            (int) (currentY + (currentHeight / 2) - 16));
    dotRightImage = createAreaPoint("dotRightImage", redTexture, (int) (currentX + currentWidth - 16),
            (int) (currentY + (currentHeight / 2) - 16));

    dotTopImage = createAreaPoint("dotTopImage", redTexture, (int) (currentX + (currentWidth / 2) - 16),
            (int) (currentY + currentHeight - 16));
    dotBottomImage = createAreaPoint("dotBottomImage", redTexture, (int) (currentX + (currentWidth / 2) - 16),
            (int) (currentY - 16));

    dotTopLeftImage = createAreaPoint("dotTopLeftImage", yellowTexture, (int) (currentX - 16),
            (int) (currentY + currentHeight - 16));
    dotTopRightImage = createAreaPoint("dotTopRightImage", yellowTexture, (int) (currentX + currentWidth - 16),
            (int) (currentY + currentHeight - 16));

    dotBottomLeftImage = createAreaPoint("dotBottomLeftImage", yellowTexture,
            (int) (currentX + currentWidth - 16), (int) (currentY - 16));
    dotBottomRightImage = createAreaPoint("dotBottomRightImage", yellowTexture,
            (int) (currentX + currentWidth - 16), (int) (currentY - 16));

    dotCenterImage = createAreaPoint("dotCenter", greenTexture, (int) (currentX + (currentWidth / 2) - 16),
            (int) (currentY + (currentHeight / 2) - 16));

    S3.stage.addActor(mainWindow);

    //
    // Assign Listener
    //
    mainWindow.addListener(new InputListener() {
        @Override
        public void touchDragged(InputEvent event, float x, float y, int pointer) {

            lastPointX = pointX;
            lastPointY = pointY;
            pointX = x;
            pointY = y;

            deltaX = pointX - lastPointX;
            deltaY = pointY - lastPointY;

            S3Log.log("dotCenterImage::touchDragged", " event: " + event + " x: " + x + " y: " + y
                    + " pointer: " + pointer + " deltaX: " + deltaX + " deltaY: " + deltaY, 3);

            if (pointClick != null) {
                S3Log.log("dotCenterImage::touchDragged",
                        " Point click: " + pointClickName + " aX: " + aspectRatioX + " aY: " + aspectRatioY, 2);
                if (pointClickName.equalsIgnoreCase("dotLeftImage")) {
                    if (currentX > 0 && deltaX < 0 && currentWidth >= 32) {
                        currentX += deltaX;
                        currentWidth -= deltaX;
                    } else if (currentX < S3Screen.width && deltaX > 0 && currentWidth > 32) {
                        currentX += deltaX;
                        currentWidth -= deltaX;
                    }
                    setAreaPosistion();
                    setTouchPosistion();
                } else if (pointClickName.equalsIgnoreCase("dotRightImage")) {
                    if (currentX + currentWidth > 0 && currentX + currentWidth < S3Screen.width
                            && currentWidth >= 32 && currentX > -1 && deltaX > 0) {
                        currentWidth += deltaX;
                    } else if (currentX + currentWidth > 0 && currentX + currentWidth <= S3Screen.width
                            && currentWidth >= 32 && currentX > -1 && deltaX < 0) {
                        currentWidth += deltaX;
                    }
                    setAreaPosistion();
                    setTouchPosistion();
                } else if (pointClickName.equalsIgnoreCase("dotTopImage")) {
                    if (currentY + currentHeight > 0 && currentY + currentHeight < S3Screen.height
                            && currentHeight >= 32 && currentY > -1 && deltaY > 0) {
                        currentHeight += deltaY;
                    } else if (currentY + currentHeight > 0 && currentY + currentHeight <= S3Screen.height
                            && currentHeight >= 32 && currentY > -1 && deltaY < 0) {
                        currentHeight += deltaY;
                    }
                    setAreaPosistion();
                    setTouchPosistion();
                } else if (pointClickName.equalsIgnoreCase("dotBottomImage")) {
                    if (currentY > 0 && deltaY < 0 && currentHeight >= 32) {
                        currentY += deltaY;
                        currentHeight -= deltaY;
                    } else if (currentY < S3Screen.height && deltaY > 0 && currentHeight > 32) {
                        currentY += deltaY;
                        currentHeight -= deltaY;
                    }
                    setAreaPosistion();
                    setTouchPosistion();
                } else if (pointClickName.equalsIgnoreCase("dotTopRightImage")) {
                    float delta = (deltaX + deltaY) / 2;
                    currentHeight += delta * aspectRatioY;
                    currentWidth += delta * aspectRatioX;
                    setAreaPosistion();
                    setTouchPosistion();
                } else if (pointClickName.equalsIgnoreCase("dotBottomLeftImage")) {
                    float delta = (deltaX + deltaY) / 2;
                    currentX += delta * aspectRatioX;
                    currentY += delta * aspectRatioY;
                    currentHeight -= delta * aspectRatioY;
                    currentWidth -= delta * aspectRatioX;
                    setAreaPosistion();
                    setTouchPosistion();
                } else if (pointClickName.equalsIgnoreCase("dotCenter")) {
                    currentX += deltaX;
                    currentY += deltaY;
                    setAreaPosistion();
                    setTouchPosistion();
                } else if (pointClickName.equalsIgnoreCase("dotTopLeftImage")) {
                    float delta = (deltaX - deltaY) / 2;
                    currentX += delta * aspectRatioY;
                    currentHeight -= delta * aspectRatioY;
                    currentWidth -= delta * aspectRatioY;
                    setAreaPosistion();
                    setTouchPosistion();
                } else if (pointClickName.equalsIgnoreCase("dotBottomRightImage")) {
                    float delta = (deltaX - deltaY) / 2;
                    currentY -= delta * aspectRatioY;
                    currentHeight += delta * aspectRatioY;
                    currentWidth += delta * aspectRatioY;
                    setAreaPosistion();
                    setTouchPosistion();
                }

                //
                // dotBottomRightImage

            } else if (isAreaImageClick) {
                currentX += deltaX;
                currentY += deltaY;
                setAreaPosistion();
                setTouchPosistion();
            }
        }

        @Override
        public boolean touchDown(InputEvent event, float x, float y, int pointer, int button) {
            S3Log.log("dotCenterImage::touchDown", " event: " + event + " x: " + x + " y: " + y + " pointer: "
                    + pointer + " button: " + button, 3);

            pointX = x;
            pointY = y;
            lastPointX = x;
            lastPointY = y;

            isAreaImageClick = checkAreaClick(x, y);
            pointClick = checkPointClick(x, y);
            return true;
        }

        @Override
        public void touchUp(InputEvent event, float x, float y, int pointer, int button) {
            S3Log.log("dotCenterImage::touchUp", " event: " + event + " x: " + x + " y: " + y + " pointer: "
                    + pointer + " button: " + button, 2);
            isAreaImageClick = false;
            pointClick = null;
            pointClickName = "";
        }
    });

    setAreaPosistion();
    setTouchPosistion();
}

From source file:mobi.shad.s3lib.gui.widget.HtmlView.java

License:Apache License

/**
 * @param node/*from w ww.j av  a 2s.c  om*/
 * @return
 */
private CssStyle parseCssStyle(final Element node) {
    final CssStyle style = new CssStyle();

    //
    // Color
    //
    String color = node.getAttribute("color", "");
    if (color.equalsIgnoreCase("yellow")) {
        style.color = Color.YELLOW;
    } else if (color.equalsIgnoreCase("red")) {
        style.color = Color.RED;
    } else if (color.equalsIgnoreCase("green")) {
        style.color = Color.GREEN;
    } else if (color.equalsIgnoreCase("cyan")) {
        style.color = Color.CYAN;
    } else if (color.equalsIgnoreCase("blue")) {
        style.color = Color.BLUE;
    } else if (color.equalsIgnoreCase("gray")) {
        style.color = Color.GRAY;
    } else if (color.equalsIgnoreCase("light_gray")) {
        style.color = Color.LIGHT_GRAY;
    } else if (color.equalsIgnoreCase("dark_gray")) {
        style.color = Color.DARK_GRAY;
    } else if (color.equalsIgnoreCase("orange")) {
        style.color = Color.ORANGE;
    } else if (color.equalsIgnoreCase("magenta")) {
        style.color = Color.MAGENTA;
    } else if (color.equalsIgnoreCase("pink")) {
        style.color = Color.PINK;
    }

    //
    // Align
    //
    String align = node.getAttribute("align", "");
    if (align.equalsIgnoreCase("right")) {
        style.align = Align.right;
    } else if (align.equalsIgnoreCase("left")) {
        style.align = Align.left;
    } else if (align.equalsIgnoreCase("center")) {
        style.align = Align.center;
    } else {
        style.align = Align.left;
    }

    //
    // Font
    //
    String font = node.getAttribute("font", "");
    //      if (font.equalsIgnoreCase("sans12")){
    //         style.font="sans12";
    //      } else if (font.equalsIgnoreCase("sans13")){
    //         style.font="sans13";
    //      } else if (font.equalsIgnoreCase("sans14")){
    //         style.font="sans14";
    //      } else if (font.equalsIgnoreCase("sans15")){
    //         style.font="sans15";
    //      } else if (font.equalsIgnoreCase("droid14")){
    //         style.font="droid14";
    //      } else if (font.equalsIgnoreCase("droid15")){
    //         style.font="droid15";
    //      } else if (font.equalsIgnoreCase("droid16")){
    //         style.font="droid16";
    //      } else if (font.equalsIgnoreCase("droid17")){
    //         style.font="droid17";
    //      } else if (font.equalsIgnoreCase("droid18")){
    //         style.font="droid18";
    //      } else if (font.equalsIgnoreCase("droid22")){
    //         style.font="droid22";
    //      } else if (font.equalsIgnoreCase("droid24")){
    //         style.font="droid24";
    //      }

    //
    // CollSpan
    //
    int collSpan = node.getIntAttribute("collspan", 1);
    if (collSpan > 1) {
        style.collSpan = collSpan;
    }

    return style;
}

From source file:mobi.shad.s3lib.main.S3File.java

License:Apache License

/**
 * @param name//from  w w  w  . ja  v  a  2  s .c  om
 * @param TextureSize
 * @param scaleMode   0 - FullScreen
 * @return
 */
public static Texture getFileTexture(String name, int TextureSize, int scaleMode) {
    Texture texture = new Texture(TextureSize, TextureSize, Pixmap.Format.RGBA8888);
    Pixmap px = new Pixmap(TextureSize, TextureSize, Pixmap.Format.RGBA8888);
    px.setColor(Color.RED);
    px.fill();
    try {
        px = new Pixmap(S3File.getFileHandle(name));
    } catch (Exception ex) {
        S3Log.error("S3File::getFileTexture", "Error open file texture: " + name, ex);
    }
    Pixmap px2 = new Pixmap(TextureSize, TextureSize, Pixmap.Format.RGBA8888);
    px2.drawPixmap(px, 0, 0, px.getWidth(), px.getHeight(), 0, 0, TextureSize, TextureSize);
    texture.setFilter(Texture.TextureFilter.Nearest, Texture.TextureFilter.Linear);
    texture.draw(px2, 0, 0);
    return texture;
}

From source file:mobi.shad.s3lib.main.S3ResourceManager.java

License:Apache License

/**
 * Zwraca tekstur zaadowan z dysku/* ww w .java 2s . c  om*/
 *
 * @param fileName
 * @return
 */
public static Texture getTexture(String fileName, int destAndroidResolution) {

    Texture texture;

    if (textureResuorce == null) {
        textureResuorce = new ArrayMap<String, TextureHandle>(20);
    }

    if (!textureResuorce.containsKey(fileName) || reBindProcess == true) {

        if (LOG) {
            S3Log.trace(TAG, "Load texture (def size: " + destAndroidResolution + ") from file: " + fileName,
                    3);
        }

        try {
            if (destAndroidResolution == 0) {
                FileHandle fileHandle = S3File.getFileHandle(fileName, true, false);
                texture = new Texture(fileHandle);
                texture.setFilter(Texture.TextureFilter.Linear, Texture.TextureFilter.Linear);
            } else {
                Pixmap px = new Pixmap(S3File.getFileHandle(fileName, true, false));
                Pixmap px2 = new Pixmap(destAndroidResolution, destAndroidResolution, Pixmap.Format.RGBA8888);
                px2.drawPixmap(px, 0, 0, px.getWidth(), px.getHeight(), 0, 0, destAndroidResolution,
                        destAndroidResolution);
                texture = new Texture(px2);
                texture.setFilter(Texture.TextureFilter.Linear, Texture.TextureFilter.Linear);
                texture.draw(px2, 0, 0);
            }

            if (USE_CACHE_RESOURCE) {
                if (textureResuorce.containsKey(fileName)) {
                    textureResuorce.removeKey(fileName);
                }
                TextureHandle textureHeandle = new TextureHandle();
                textureHeandle.fileName = fileName;
                textureHeandle.texture = texture;
                textureHeandle.width = texture.getWidth();
                textureHeandle.height = texture.getHeight();
                textureHeandle.defResolution = destAndroidResolution;
                textureResuorce.put(fileName, textureHeandle);
            }

        } catch (Exception e) {
            S3Log.error("S3ResourceManager::getTexture", "Error create texture data ....", e);

            Pixmap pixmap = new Pixmap(S3Constans.proceduralTextureSizeLow, S3Constans.proceduralTextureSizeLow,
                    Pixmap.Format.RGBA4444);
            pixmap.setColor(Color.RED);
            pixmap.fill();
            texture = new Texture(pixmap);
            texture.setFilter(Texture.TextureFilter.Linear, Texture.TextureFilter.Linear);
            texture.draw(pixmap, 0, 0);
        }
    } else {

        if (LOG) {
            S3Log.trace(TAG,
                    "Load texture from cache (def size: " + destAndroidResolution + ") from file: " + fileName,
                    2);
        }
        TextureHandle textureHandle = textureResuorce.get(fileName);
        texture = textureHandle.texture;
    }
    if (LOG) {
        S3Log.trace(TAG, "Texture size width: " + texture.getWidth() + "px height: " + texture.getHeight());
    }
    return texture;
}