本文整理匯總了Java中com.badlogic.gdx.graphics.Pixmap.drawPixmap方法的典型用法代碼示例。如果您正苦於以下問題:Java Pixmap.drawPixmap方法的具體用法?Java Pixmap.drawPixmap怎麽用?Java Pixmap.drawPixmap使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類com.badlogic.gdx.graphics.Pixmap
的用法示例。
在下文中一共展示了Pixmap.drawPixmap方法的6個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。
示例1: draw
import com.badlogic.gdx.graphics.Pixmap; //導入方法依賴的package包/類
public void draw(Coordinates<Integer> coords, Pixmap map) {
int terrainID = world.get(coords.y).get(coords.x);
// tileID runs 0 through 8, conveniently in the
// same order as our split tiles texture...
int ty = (int) terrainID / 3;
int tx = terrainID % 3;
TextureRegion tileRegion = tileRegions[ty][tx];
map.drawPixmap(tilesPixmap,
coords.x * tileSize,
coords.y * tileSize,
tileRegion.getRegionX(),
tileRegion.getRegionY(),
tileRegion.getRegionWidth(),
tileRegion.getRegionHeight());
}
示例2: draw
import com.badlogic.gdx.graphics.Pixmap; //導入方法依賴的package包/類
public void draw(int dx, int dy){
if(dx < 0 || dy < 0 || dx >= pixmap.getWidth() || dy >= pixmap.getHeight()){
return;
}
Gdx.gl.glBindTexture(GL20.GL_TEXTURE_2D, texture.getTextureObjectHandle());
int dstWidth = brushSize*2-1;
int dstHeight = brushSize*2-1;
int width = pixmap.getWidth(), height = pixmap.getHeight();
int x = dx - dstWidth/2;
int y = dy - dstHeight/2;
if (x + dstWidth > width){
x = width - dstWidth;
}else if (x < 0){
x = 0;
}
if (y + dstHeight > height){
dstHeight = height - y;
}else if (y < 0){
dstHeight += y;
y = 0;
}
pixmap.fillCircle(dx, dy, brushSize-1);
Pixmap dst = brush(brushSize);
dst.drawPixmap(pixmap, x, y, dstWidth, dstHeight, 0, 0, dstWidth, dstHeight);
Gdx.gl.glTexSubImage2D(GL20.GL_TEXTURE_2D, 0, x, y, dstWidth, dstHeight,
dst.getGLFormat(), dst.getGLType(), dst.getPixels());
}
示例3: resizeTexture
import com.badlogic.gdx.graphics.Pixmap; //導入方法依賴的package包/類
public static Texture resizeTexture(String internalPath, int width, int height) {
Pixmap pixmap = new Pixmap(width, height, Pixmap.Format.RGBA8888);
Pixmap origPixmap = new Pixmap(Gdx.files.internal(internalPath));
pixmap.drawPixmap(origPixmap, 0, 0, origPixmap.getWidth(), origPixmap.getHeight(),
0, 0, width, height);
return new Texture(pixmap);
}
示例4: generate
import com.badlogic.gdx.graphics.Pixmap; //導入方法依賴的package包/類
protected static void generate(FileHandle file, float strength) {
Pixmap blocks = new Pixmap(INDIVIDUAL_SIZE * 3, INDIVIDUAL_SIZE * 3, AOTextureGenerator.FORMAT);
Pixmap gaussian = new Pixmap(INDIVIDUAL_SIZE, INDIVIDUAL_SIZE, AOTextureGenerator.FORMAT);
Pixmap output = new Pixmap(TEXTURE_SIZE, TEXTURE_SIZE, AOTextureGenerator.FORMAT);
double[][] gwm = AOTextureGenerator.gaussianWeightMatrix(SIGMA);
int gaussianRadius = (gwm.length - 1) / 2;
Color blockColor = new Color(strength, strength, strength, 1f);
for (int i = 0; i < TOTAL; i++) {
String n = name(i);
System.out.print(n + " ");
AOTextureGenerator.clearPixmap(blocks);
AOTextureGenerator.clearPixmap(gaussian);
AOTextureGenerator.setupPixmap(blocks, i, blockColor);
AOTextureGenerator.gaussianPixmap(blocks, gaussian, gwm, gaussianRadius);
// PixmapIO.writePNG(folder.child(n + "_blocks_" + sigma + ".png"),
// blocks);
// PixmapIO.writePNG(folder.child(n + "_gaussian_" + sigma +
// ".png"), gaussian);
output.drawPixmap(gaussian, (i % SQRT_TOTAL) * INDIVIDUAL_SIZE, (i / SQRT_TOTAL) * INDIVIDUAL_SIZE, 0, 0,
INDIVIDUAL_SIZE, INDIVIDUAL_SIZE);
if (i % SQRT_TOTAL == SQRT_TOTAL - 1)
System.out.println();
}
PixmapIO.writePNG(file, output);
output.dispose();
blocks.dispose();
gaussian.dispose();
}
示例5: createTextureFromBytes
import com.badlogic.gdx.graphics.Pixmap; //導入方法依賴的package包/類
/**
* Transforms byte[] to Texture Region.
* <p>
* If you are going to call this method inside firebase callback remember to wrap it<p>
* into {@code Gdx.app.postRunnable(Runnable)}.
* The texture will be changed so that it has sides with length of power of 2.
*
* @param bytes Byte array with image description
* @return Texture region representation of given byte array
*/
public static TextureRegion createTextureFromBytes(byte[] bytes)
{
Pixmap pixmap = new Pixmap(bytes, 0, bytes.length);
final int orgWidth = pixmap.getWidth();
final int orgHeight = pixmap.getHeight();
int width = MathUtils.nextPowerOfTwo(orgWidth);
int height = MathUtils.nextPowerOfTwo(orgHeight);
final Pixmap potPixmap = new Pixmap(width, height, pixmap.getFormat());
potPixmap.drawPixmap(pixmap, 0, 0, 0, 0, pixmap.getWidth(), pixmap.getHeight());
pixmap.dispose();
TextureRegion region = new TextureRegion(new Texture(potPixmap), 0, 0, orgWidth, orgHeight);
potPixmap.dispose();
return region;
}
示例6: generate
import com.badlogic.gdx.graphics.Pixmap; //導入方法依賴的package包/類
protected static void generate(FileHandle file, float strength) {
Pixmap blocks = new Pixmap(INDIVIDUAL_SIZE * 3, INDIVIDUAL_SIZE * 3, AOTextureGenerator.FORMAT);
Pixmap gaussian = new Pixmap(INDIVIDUAL_SIZE, INDIVIDUAL_SIZE, AOTextureGenerator.FORMAT);
Pixmap output = new Pixmap(TEXTURE_SIZE, TEXTURE_SIZE, AOTextureGenerator.FORMAT);
double[][] gwm = AOTextureGenerator.gaussianWeightMatrix(SIGMA);
int gaussianRadius = (gwm.length - 1) / 2;
Color blockColor = new Color(strength, strength, strength, 1f);
for (int i = 0; i < TOTAL; i++) {
String n = name(i);
System.out.print(n + " ");
AOTextureGenerator.clearPixmap(blocks);
AOTextureGenerator.clearPixmap(gaussian);
AOTextureGenerator.setupPixmap(blocks, i, blockColor);
AOTextureGenerator.gaussianPixmap(blocks, gaussian, gwm, gaussianRadius);
//PixmapIO.writePNG(folder.child(n + "_blocks_" + sigma + ".png"), blocks);
//PixmapIO.writePNG(folder.child(n + "_gaussian_" + sigma + ".png"), gaussian);
output.drawPixmap(gaussian, (i % SQRT_TOTAL) * INDIVIDUAL_SIZE, (i / SQRT_TOTAL) * INDIVIDUAL_SIZE, 0, 0, INDIVIDUAL_SIZE, INDIVIDUAL_SIZE);
if (i % SQRT_TOTAL == SQRT_TOTAL - 1) System.out.println();
}
PixmapIO.writePNG(file, output);
output.dispose();
blocks.dispose();
gaussian.dispose();
}