本文整理匯總了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(" ");
}
}