Example usage for com.badlogic.gdx.graphics.g2d NinePatch getTotalWidth

List of usage examples for com.badlogic.gdx.graphics.g2d NinePatch getTotalWidth

Introduction

In this page you can find the example usage for com.badlogic.gdx.graphics.g2d NinePatch getTotalWidth.

Prototype

public float getTotalWidth() 

Source Link

Usage

From source file:com.o2d.pkayjava.editor.plugins.ninepatch.PreviewWidget.java

License:Apache License

private float getMinScale(NinePatch horizontalPatch, float width, float height) {
    float scaleX = width / horizontalPatch.getTotalWidth();
    float scaleY = height / horizontalPatch.getTotalHeight();
    float scl = Math.min(scaleX, scaleY);
    if (scl > 1f)
        scl = 1f;/*www.  j a v  a 2s.c om*/

    return scl;
}

From source file:com.o2d.pkayjava.editor.plugins.ninepatch.PreviewWidget.java

License:Apache License

private Image fitNinePatch(NinePatch horizontalPatch, float width, float height, float scl) {
    horizontalPatch.scale(scl, scl);/*from w w w .  ja v  a 2 s . c om*/

    Image img = new Image(horizontalPatch);
    img.setScaleX(width / horizontalPatch.getTotalWidth());
    img.setScaleY(height / horizontalPatch.getTotalHeight());

    return img;
}