當前位置: 首頁>>代碼示例>>Java>>正文


Java TextureAtlas.createPatch方法代碼示例

本文整理匯總了Java中com.badlogic.gdx.graphics.g2d.TextureAtlas.createPatch方法的典型用法代碼示例。如果您正苦於以下問題:Java TextureAtlas.createPatch方法的具體用法?Java TextureAtlas.createPatch怎麽用?Java TextureAtlas.createPatch使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在com.badlogic.gdx.graphics.g2d.TextureAtlas的用法示例。


在下文中一共展示了TextureAtlas.createPatch方法的1個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: refreshPreview

import com.badlogic.gdx.graphics.g2d.TextureAtlas; //導入方法依賴的package包/類
public void refreshPreview() {

        Gdx.app.log("NinePatchEditorDialog", "refresh preview.");

        Pixmap pixmapImage = new Pixmap(100, 100, Pixmap.Format.RGBA8888);

        if (sourcePixmap != null) {
            pixmapImage = sourcePixmap;
        }


        Pixmap pixmap = new Pixmap((int) (pixmapImage.getWidth() + 2), (int) (pixmapImage.getHeight() + 2), Pixmap.Format.RGBA8888);
        pixmap.drawPixmap(pixmapImage, 1, 1);

        pixmap.setColor(Color.BLACK);

        // Range left
        int h = pixmapImage.getHeight() + 1;
        pixmap.drawLine(0, (int) (h * rangeLeft.rangeStart), 0, (int) (h * rangeLeft.rangeStop));


        // Range top
        int w = pixmapImage.getWidth() + 1;
        pixmap.drawLine((int) (w * rangeTop.rangeStart), 0, (int) (w * rangeTop.rangeStop), 0);

        // Range right
        h = pixmapImage.getHeight() + 1;
        pixmap.drawLine(pixmapImage.getWidth() + 1, (int) (h * rangeRight.rangeStart), pixmapImage.getWidth() + 1, (int) (h * rangeRight.rangeStop));

        // Range bottom
        w = pixmapImage.getWidth() + 1;
        pixmap.drawLine((int) (w * rangeBottom.rangeStart), pixmap.getHeight() - 1, (int) (w * rangeBottom.rangeStop), pixmap.getHeight() - 1);

        if (sourcePixmap != null) {
            PixmapIO.writePNG(tmpFile, pixmap);

            FileHandle fh = new FileHandle(System.getProperty("java.io.tmpdir")).child("skin_ninepatch");
            TexturePacker.Settings settings = new TexturePacker.Settings();
            TexturePacker.process(settings, fh.path(), fh.path(), "pack");

            TextureAtlas ta = new TextureAtlas(fh.child("pack.atlas"));
            NinePatch np = ta.createPatch("temp");
            SvgNinePatchDrawable drawable = new SvgNinePatchDrawable(np);
            reviewTablePreview();
            buttonPreview1.getStyle().up = drawable;

//            log.debug("Source size:" + selectedScaledSvg.toString());
//            log.debug("source width:" + sourcePixmap.getWidth());
//            log.debug("rangeTop.rangeStart:" + rangeTop.rangeStart);
//            log.debug("rangeTop.rangeStop:" + rangeTop.rangeStop);
//            log.debug("  ");
        }
    }
 
開發者ID:Longri,項目名稱:cachebox3.0,代碼行數:54,代碼來源:NinePatchEditorDialog.java


注:本文中的com.badlogic.gdx.graphics.g2d.TextureAtlas.createPatch方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。