Example usage for com.badlogic.gdx.graphics.g2d TextOnPath TextOnPath

List of usage examples for com.badlogic.gdx.graphics.g2d TextOnPath TextOnPath

Introduction

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

Prototype

public TextOnPath(String Text, GL_Path path, ext_Paint fill2, ext_Paint stroke2, boolean center) 

Source Link

Usage

From source file:CB_UI_Base.graphics.TextDrawable.java

License:Open Source License

@Override
public boolean draw(Batch batch, float x, float y, float width, float height, float rotated) {
    if (isDisposed)
        return true;

    if (Cache == null) {
        Cache = new TextOnPath(Text, workPath, fill, stroke, center);
        GL.that.RunOnGL(new IRunOnGL() {
            @Override/*from ww w  .j  av  a 2  s  .  com*/
            public void run() {
                workPath.dispose();
            }
        });
    }
    if (Cache != null) {

        float scaleWidth = width / DEFAULT_WIDTH;
        float scaleHeight = height / DEFAULT_HEIGHT;

        transform.setToTranslation(x, y, 0);

        if (rotated != 0) {

            float[] center = Cache.getCenterPoint();
            transform.scale(scaleWidth, scaleHeight, 1);
            transform.translate(center[0], center[1], 0);
            transform.rotate(0, 0, 1, rotated);
            transform.translate(-center[0], -center[1], 0);
        } else {
            transform.scale(scaleWidth, scaleHeight, 1);
        }

        Cache.draw(batch, transform);
        return false;
    } else {
        return true;
    }
}

From source file:CB_UI_Base.graphics.TextDrawableFlipped.java

License:Open Source License

@Override
public boolean draw(Batch batch, float x, float y, float width, float height, float rotated) {
    if (isDisposed)
        return true;

    float direction = MathUtils.LegalizeDegreese(pathDirection + rotated);

    if (direction >= 180) {
        isFlipped = true;/*from  ww w .ja  v a  2 s.c  o m*/
    } else {
        isFlipped = false;
    }

    float scaleWidth = width / DEFAULT_WIDTH;
    float scaleHeight = height / DEFAULT_HEIGHT;

    transform.setToTranslation(x, y, 0);
    transform.scale(scaleWidth, scaleHeight, 1);

    if (isFlipped) {
        if (flippedCache == null) {
            workPath.revert();
            flippedCache = new TextOnPath(this.Text, workPath, fill, stroke, center);
        }
        if (flippedCache != null) {
            if (flippedCache.PathToClose())
                return true;
            flippedCache.draw(batch, transform);
        } else {
            return true;
        }
    } else {
        if (Cache == null) {
            Cache = new TextOnPath(Text, workPath, fill, stroke, center);
        }
        if (Cache != null) {

            if (Cache.PathToClose())
                return true;
            Cache.draw(batch, transform);
        } else {
            return true;
        }
    }

    if (workPath != null && Cache != null && flippedCache != null) {
        // all Caches created, can dispose Path
        workPath.dispose();
        workPath = null;
    }
    return false;
}