本文整理匯總了Java中com.badlogic.gdx.graphics.Pixmap.Format.RGBA4444屬性的典型用法代碼示例。如果您正苦於以下問題:Java Format.RGBA4444屬性的具體用法?Java Format.RGBA4444怎麽用?Java Format.RGBA4444使用的例子?那麽, 這裏精選的屬性代碼示例或許可以為您提供幫助。您也可以進一步了解該屬性所在類com.badlogic.gdx.graphics.Pixmap.Format
的用法示例。
在下文中一共展示了Format.RGBA4444屬性的14個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。
示例1: generatePlanet
public static Texture generatePlanet(int[][] tileMap, ArrayList<Tile> tiles) {
int s = tileMap.length;
Pixmap pixmap = new Pixmap(s, s, Format.RGBA4444);
// draw circle for planet
pixmap.setColor(1, 1, 1, 1);
pixmap.fillCircle(s/2,s/2,s/2-1);
//draw noise
for (int y = 0; y < s; ++y) {
for (int x = 0; x < s; ++x) {
//only draw on circle
if (pixmap.getPixel(x, y) != 0) {
pixmap.setColor(tiles.get(tileMap[x][y]).getColor());
pixmap.drawPixel(x, y);
}
}
}
Texture t = new Texture(pixmap);
pixmap.dispose();
return t;
}
示例2: generateNoise
public static Texture generateNoise(long seed, int size, double featureSize) {
OpenSimplexNoise noise = new OpenSimplexNoise(seed);
Pixmap pixmap = new Pixmap(size, size, Format.RGBA4444);
//add layer of noise
for (int y = 0; y < pixmap.getHeight(); ++y) {
for (int x = 0; x < pixmap.getWidth(); ++x) {
double nx = x / featureSize, ny = y / featureSize;
double i = noise.eval(nx, ny, 0);
i = (i * 0.5) + 0.5; // convert from range [-1:1] to [0:1]
pixmap.setColor(new Color((float) i, (float) i, (float) i, 1));
pixmap.drawPixel(x, y);
}
}
Texture t = new Texture(pixmap);
pixmap.dispose();
return t;
}
示例3: create
@Override
public void create () {
FileHandle file = Gdx.files.internal("data/bobargb8888-32x32.png");
nonMipMapped[0] = new Texture(file, Format.Alpha, false);
nonMipMapped[1] = new Texture(file, Format.LuminanceAlpha, false);
nonMipMapped[2] = new Texture(file, Format.RGB888, false);
nonMipMapped[3] = new Texture(file, Format.RGB565, false);
nonMipMapped[4] = new Texture(file, Format.RGBA8888, false);
nonMipMapped[5] = new Texture(file, Format.RGBA4444, false);
mipMapped[0] = new Texture(file, Format.Alpha, true);
mipMapped[1] = new Texture(file, Format.LuminanceAlpha, true);
mipMapped[2] = new Texture(file, Format.RGB888, true);
mipMapped[3] = new Texture(file, Format.RGB565, true);
mipMapped[4] = new Texture(file, Format.RGBA8888, true);
mipMapped[5] = new Texture(file, Format.RGBA4444, true);
batch = new SpriteBatch();
}
示例4: PostProcessor
/** Construct a new PostProcessor with the given parameters and the specified texture wrap mode */
public PostProcessor (int fboWidth, int fboHeight, boolean useDepth, boolean fsaa, boolean useAlphaChannel, boolean use32Bits,
TextureWrap u, TextureWrap v) {
if (use32Bits) {
if (useAlphaChannel) {
fbFormat = Format.RGBA8888;
} else {
fbFormat = Format.RGB888;
}
} else {
if (useAlphaChannel) {
fbFormat = Format.RGBA4444;
} else {
fbFormat = Format.RGB565;
}
}
composite = newPingPongBuffer(fboWidth, fboHeight, fbFormat, useDepth, fsaa);
setBufferTextureWrap(u, v);
pipelineState = new PipelineState();
capturing = false;
hasCaptured = false;
enabled = true;
this.useDepth = useDepth;
if (useDepth) {
clearBits |= GL20.GL_DEPTH_BUFFER_BIT;
}
setViewport(null);
}
示例5: PostProcessor
/**
* Construct a new PostProcessor with the given parameters and the specified texture wrap mode
*/
public PostProcessor(int fboWidth, int fboHeight, boolean useDepth, boolean useAlphaChannel, boolean use32Bits,
TextureWrap u, TextureWrap v) {
if (use32Bits) {
if (useAlphaChannel) {
fbFormat = Format.RGBA8888;
} else {
fbFormat = Format.RGB888;
}
} else {
if (useAlphaChannel) {
fbFormat = Format.RGBA4444;
} else {
fbFormat = Format.RGB565;
}
}
composite = newPingPongBuffer(fboWidth, fboHeight, fbFormat, useDepth);
setBufferTextureWrap(u, v);
pipelineState = new PipelineState();
capturing = false;
hasCaptured = false;
enabled = true;
this.useDepth = useDepth;
if (useDepth) {
clearBits |= GL20.GL_DEPTH_BUFFER_BIT;
}
setViewport(null);
}
示例6: generateSpaceBackgroundStars
public static Texture generateSpaceBackgroundStars(int tileX, int tileY, int tileSize, float depth) {
MathUtils.random.setSeed((long) (MyMath.getSeed(tileX, tileY) * depth));
//pixmap = new Pixmap(tileSize, tileSize, Format.RGB565);
pixmap = new Pixmap(tileSize, tileSize, Format.RGBA4444);
int numStars = 300;
pixmap.setColor(Color.WHITE);
for (int i = 0; i < numStars; ++i){
int newX = MathUtils.random(tileSize);
int newY = MathUtils.random(tileSize);
pixmap.drawPixel(newX, newY);
//pixmap.drawPixel(newX, newY, Color.rgba8888(MathUtils.random(1), MathUtils.random(1), MathUtils.random(1), 1));
}
/*
//DEBUG - fill tile to visualize boundaries
pixmap.setColor(MathUtils.random(), MathUtils.random(), MathUtils.random(), 0.5f);
pixmap.fill();
*/
//create texture and dispose pixmap to prevent memory leak
Texture t = new Texture(pixmap);
pixmap.dispose();
return t;
}
示例7: generateStar
public static Texture generateStar(long seed, int radius) {
OpenSimplexNoise noise = new OpenSimplexNoise(seed);
Pixmap pixmap = new Pixmap(radius * 2, radius * 2, Format.RGBA4444);
double scale = 20;//zoom
// draw circle for planet
pixmap.setColor(0.5f, 0.5f, 0.5f, 1);
pixmap.fillCircle(radius, radius, radius - 1);
//add layer of noise
for (int y = 0; y < pixmap.getHeight(); ++y) {
for (int x = 0; x < pixmap.getWidth(); ++x) {
//only draw on circle
if (pixmap.getPixel(x, y) != 0) {
double nx = x/scale, ny = y/scale;
double i = noise.eval(nx, ny, 0);
i = (i * 0.5) + 0.5; //convert from range [-1:1] to [0:1]
if (i > 0.5f){
pixmap.setColor(new Color(1, 1, 0, (float)i));
} else {
pixmap.setColor(new Color(1, 0, 0, (float)(1-i)));
}
pixmap.drawPixel(x, y);
}
}
}
Texture t = new Texture(pixmap);
pixmap.dispose();
return t;
}
示例8: generateHouseRow
Sprite generateHouseRow(float y, int height) {
// Bottom houses
TextureGenerator houseTexGenerator = new HouseTextureGenerator();
final int OFFSET = 70;
final int MIN_HEIGHT = (int) (height);
final int MAX_HEIGHT = (int) (MIN_HEIGHT + OFFSET);
FrameBuffer buffer = new FrameBuffer(Format.RGBA4444, Gdx.graphics.getWidth(), MAX_HEIGHT, false);
Matrix4 projectionMatrix = new Matrix4();
projectionMatrix.setToOrtho2D(0, 0, buffer.getWidth(), buffer.getHeight());
batch.setProjectionMatrix(projectionMatrix);
buffer.begin();
batch.begin();
int offsetX = (int) -(Math.random() * 250);
while (offsetX < buffer.getWidth()) {
Texture texture = houseTexGenerator.create((int)Math.round(150 + Math.random() * 50), (int)Math.round(MIN_HEIGHT + Math.random() * OFFSET));
batch.draw(texture, offsetX, 0f);
offsetX += texture.getWidth();
}
batch.end();
batch.flush();
buffer.end();
Sprite s = new Sprite(buffer.getColorBufferTexture());
s.setY(y - OFFSET);
return s;
}
示例9: defineFormat
private static Format defineFormat(boolean use32Bits, boolean alphaChannel) {
return use32Bits ? alphaChannel ? Format.RGBA8888 : Format.RGB888
: alphaChannel ? Format.RGBA4444 : Format.RGB565;
}
示例10: initialize
private void initialize(int FBO_W, int FBO_H, FrameBuffer fbo,
boolean hasDepth, boolean useBlending, boolean use32bitFBO) {
blending = useBlending;
Format format = null;
if (use32bitFBO) {
if (useBlending) {
format = Format.RGBA8888;
} else {
format = Format.RGB888;
}
} else {
if (useBlending) {
format = Format.RGBA4444;
} else {
format = Format.RGB565;
}
}
if (fbo == null) {
frameBuffer = new FrameBuffer(format, Gdx.graphics.getWidth(),
Gdx.graphics.getHeight(), hasDepth);
} else {
frameBuffer = fbo;
}
pingPongBuffer1 = new FrameBuffer(format, FBO_W, FBO_H, false);
pingPongBuffer2 = new FrameBuffer(format, FBO_W, FBO_H, false);
original = frameBuffer.getColorBufferTexture();
pingPongTex1 = pingPongBuffer1.getColorBufferTexture();
pingPongTex2 = pingPongBuffer2.getColorBufferTexture();
fullScreenQuad = createFullScreenQuad();
final String alpha = useBlending ? "alpha_" : "";
bloomShader = BloomShaderLoader.createShader("screenspace",
alpha + "bloom");
if (useAlphaChannelAsMask) {
tresholdShader = BloomShaderLoader.createShader("screenspace",
"maskedtreshold");
} else {
tresholdShader = BloomShaderLoader.createShader("screenspace",
alpha + "treshold");
}
blurShader = BloomShaderLoader.createShader("blurspace",
alpha + "gaussian");
setSize(FBO_W, FBO_H);
setBloomIntesity(2.5f);
setOriginalIntesity(0.8f);
setTreshold(0.5f);
bloomShader.begin();
{
bloomShader.setUniformi("u_texture0", 0);
bloomShader.setUniformi("u_texture1", 1);
}
bloomShader.end();
}
示例11: writeSymbolGridToFile
public static void writeSymbolGridToFile(Symbol[][] grid, String filename, int tileSize)
{
// Get size of image
int height = grid[0].length * tileSize;
int width = grid.length * tileSize;
// Create resources
Pixmap pixmap = new Pixmap(width, height, Format.RGBA4444);
// do render
for (int x = 0; x < grid.length; x++)
{
for (int y = 0; y < grid[0].length; y++)
{
Symbol s = grid[x][y];
if (s.character == '#')
{
pixmap.setColor(Color.MAROON);
}
else if (s.character == '.')
{
pixmap.setColor(Color.GREEN);
}
else
{
pixmap.setColor(Color.BLUE);
}
pixmap.fillRectangle(x*tileSize, y*tileSize, tileSize, tileSize);
// if (s.hasEnvironmentEntity())
// {
// Pixmap src = TextureToPixmap(s.getEnvironmentEntity("").sprite.getCurrentTexture());
// pixmap.drawPixmap(src,
// 0, 0, src.getWidth(), src.getHeight(),
// x*tileSize, y*tileSize, tileSize, tileSize);
// src.dispose();
// }
//
// if (s.hasGameEntity())
// {
// Pixmap src = TextureToPixmap(s.getGameEntity().sprite.getCurrentTexture());
// pixmap.drawPixmap(src,
// 0, 0, src.getWidth(), src.getHeight(),
// x*tileSize, y*tileSize, tileSize, tileSize);
// src.dispose();
// }
}
}
// Save texture
try
{
BufferedImage bi = pixmapToImage(pixmap);
File outputfile = new File(filename);
ImageIO.write(bi, "png", outputfile);
}
catch (Exception e)
{
e.printStackTrace();
}
// dispose of resources
pixmap.dispose();
}
示例12: initialize
private void initialize(int FBO_W, int FBO_H, FrameBuffer fbo,
boolean hasDepth, boolean useBlending, boolean use32bitFBO) {
blending = useBlending;
Format format = null;
if (use32bitFBO) {
if (useBlending) {
format = Format.RGBA8888;
} else {
format = Format.RGB888;
}
} else {
if (useBlending) {
format = Format.RGBA4444;
} else {
format = Format.RGB565;
}
}
if (fbo == null) {
frameBuffer = new FrameBuffer(format, Gdx.graphics.getWidth(),
Gdx.graphics.getHeight(), hasDepth);
} else {
frameBuffer = fbo;
}
pingPongBuffer1 = new FrameBuffer(format, FBO_W, FBO_H, false);
pingPongBuffer2 = new FrameBuffer(format, FBO_W, FBO_H, false);
original = frameBuffer.getColorBufferTexture();
pingPongTex1 = pingPongBuffer1.getColorBufferTexture();
pingPongTex2 = pingPongBuffer2.getColorBufferTexture();
fullScreenQuad = createFullScreenQuad();
final String alpha = useBlending ? "alpha_" : "";
bloomShader = BloomShaderLoader.createShader("screenspace",
alpha + "bloom");
if (useAlphaChannelAsMask) {
tresholdShader = BloomShaderLoader.createShader("screenspace",
"maskedtreshold");
} else {
tresholdShader = BloomShaderLoader.createShader("screenspace",
alpha + "treshold");
}
blurShader = BloomShaderLoader.createShader("blurspace",
alpha + "gaussian");
setSize(FBO_W, FBO_H);
setBloomIntesity(2.5f);
setOriginalIntesity(0.8f);
setTreshold(0.5f);
bloomShader.begin();
{
bloomShader.setUniformi("u_texture0", 0);
bloomShader.setUniformi("u_texture1", 1);
}
bloomShader.end();
}
示例13: resize
public void resize(int screenWidth, int screenHeight) {
// TODO: set up the FBOs
// TODO: what happens in case the FBO size won't be PoT?
FrameBuffer fbo = new FrameBuffer(Format.RGBA4444, screenWidth, screenHeight, false);
}
示例14: initBuffers
private void initBuffers(int width, int height) {
initialBuffer = new FrameBuffer(Format.RGBA4444, width, height, false);
bufferA = new FrameBuffer(Format.RGBA4444, width, height, false);
bufferB = new FrameBuffer(Format.RGBA4444, width, height, false);
}