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

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

Introduction

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

Prototype

public float getTotalHeight() 

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;//from  w ww.j a  va2 s . c o  m

    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 .j  av a 2  s .co  m*/

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

    return img;
}