Search in sources :

Example 21 with Settings

use of com.badlogic.gdx.tools.texturepacker.TexturePacker.Settings in project ultimate-java by pantinor.

the class TexturePackerTest method render.

public void render() {
    Gdx.gl.glClear(GL20.GL_COLOR_BUFFER_BIT);
    Settings settings = new Settings();
    settings.fast = false;
    settings.pot = false;
    settings.maxWidth = 1024;
    settings.maxHeight = 1024;
    settings.rotation = false;
    settings.paddingX = 0;
    if (pages == null) {
        Random random = new Random(1243);
        Array<Rect> inputRects = new Array();
        for (int i = 0; i < 240; i++) {
            Rect rect = new Rect();
            rect.name = "rect" + i;
            rect.height = 16 + random.nextInt(120);
            rect.width = 16 + random.nextInt(240);
            inputRects.add(rect);
        }
        for (int i = 0; i < 10; i++) {
            Rect rect = new Rect();
            rect.name = "rect" + (40 + i);
            rect.height = 400 + random.nextInt(340);
            rect.width = 1 + random.nextInt(10);
            inputRects.add(rect);
        }
        long s = System.nanoTime();
        pages = new MaxRectsPacker(settings).pack(inputRects);
        long e = System.nanoTime();
        System.out.println("fast: " + settings.fast);
        System.out.println((e - s) / 1e6f + " ms");
        System.out.println();
    }
    int x = 20, y = 20;
    for (Page page : pages) {
        renderer.setColor(Color.GRAY);
        renderer.begin(ShapeType.Filled);
        for (int i = 0; i < page.outputRects.size; i++) {
            Rect rect = page.outputRects.get(i);
            renderer.rect(x + rect.x + settings.paddingX, y + rect.y + settings.paddingY, rect.width - settings.paddingX, rect.height - settings.paddingY);
        }
        renderer.end();
        renderer.setColor(Color.RED);
        renderer.begin(ShapeType.Line);
        for (int i = 0; i < page.outputRects.size; i++) {
            Rect rect = page.outputRects.get(i);
            renderer.rect(x + rect.x + settings.paddingX, y + rect.y + settings.paddingY, rect.width - settings.paddingX, rect.height - settings.paddingY);
        }
        renderer.setColor(Color.GREEN);
        renderer.rect(x, y, page.width + settings.paddingX * 2, page.height + settings.paddingY * 2);
        renderer.end();
        x += page.width + 20;
    }
}
Also used : Array(com.badlogic.gdx.utils.Array) Rect(com.badlogic.gdx.tools.texturepacker.TexturePacker.Rect) Random(java.util.Random) Page(com.badlogic.gdx.tools.texturepacker.TexturePacker.Page) Settings(com.badlogic.gdx.tools.texturepacker.TexturePacker.Settings)

Example 22 with Settings

use of com.badlogic.gdx.tools.texturepacker.TexturePacker.Settings in project Eidolons by IDemiurge.

the class TexturePackerLaunch method getSetting.

private static Settings getSetting() {
    Settings settings = new Settings();
    settings.maxHeight = (int) Math.pow(2, 14);
    settings.maxWidth = (int) Math.pow(2, 14);
    settings.atlasExtension = ATLAS_EXTENSION;
    settings.stripWhitespaceY = TRIM;
    settings.stripWhitespaceX = TRIM;
    settings.square = false;
    settings.format = Format.RGBA4444;
    settings.limitMemory = false;
    // settings.jpegQuality = 0.7f;
    return settings;
}
Also used : Settings(com.badlogic.gdx.tools.texturepacker.TexturePacker.Settings)

Aggregations

Settings (com.badlogic.gdx.tools.texturepacker.TexturePacker.Settings)22 File (java.io.File)17 FileProcessor (com.badlogic.gdx.tools.FileProcessor)9 ArrayList (java.util.ArrayList)7 TexturePacker (com.badlogic.gdx.tools.texturepacker.TexturePacker)5 GdxRuntimeException (com.badlogic.gdx.utils.GdxRuntimeException)4 BufferedImage (java.awt.image.BufferedImage)4 TreeMap (java.util.TreeMap)3 Matcher (java.util.regex.Matcher)3 Pattern (java.util.regex.Pattern)3 Page (com.badlogic.gdx.tools.texturepacker.TexturePacker.Page)2 Rect (com.badlogic.gdx.tools.texturepacker.TexturePacker.Rect)2 Array (com.badlogic.gdx.utils.Array)2 IOException (java.io.IOException)2 Random (java.util.Random)2 ApplicationListener (com.badlogic.gdx.ApplicationListener)1 LwjglApplication (com.badlogic.gdx.backends.lwjgl.LwjglApplication)1 LwjglApplicationConfiguration (com.badlogic.gdx.backends.lwjgl.LwjglApplicationConfiguration)1 FileHandle (com.badlogic.gdx.files.FileHandle)1 Json (com.badlogic.gdx.utils.Json)1