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