Java Code Examples for org.andengine.opengl.texture.atlas.bitmap.source.IBitmapTextureAtlasSource#getTextureHeight()

The following examples show how to use org.andengine.opengl.texture.atlas.bitmap.source.IBitmapTextureAtlasSource#getTextureHeight() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: LinearGradientFillBitmapTextureAtlasSourceDecorator.java    From tilt-game-android with MIT License 6 votes vote down vote up
public LinearGradientFillBitmapTextureAtlasSourceDecorator(final IBitmapTextureAtlasSource pBitmapTextureAtlasSource, final IBitmapTextureAtlasSourceDecoratorShape pBitmapTextureAtlasSourceDecoratorShape, final int[] pColors, final float[] pPositions, final LinearGradientDirection pLinearGradientDirection, final TextureAtlasSourceDecoratorOptions pTextureAtlasSourceDecoratorOptions) {
	super(pBitmapTextureAtlasSource, pBitmapTextureAtlasSourceDecoratorShape, pTextureAtlasSourceDecoratorOptions);
	this.mColors = pColors;
	this.mPositions = pPositions;
	this.mLinearGradientDirection = pLinearGradientDirection;

	this.mPaint.setStyle(Style.FILL);

	final int right = pBitmapTextureAtlasSource.getTextureWidth() - 1;
	final int bottom = pBitmapTextureAtlasSource.getTextureHeight() - 1;

	final float fromX = pLinearGradientDirection.getFromX(right);
	final float fromY = pLinearGradientDirection.getFromY(bottom);
	final float toX = pLinearGradientDirection.getToX(right);
	final float toY = pLinearGradientDirection.getToY(bottom);

	this.mPaint.setShader(new LinearGradient(fromX, fromY, toX, toY, pColors, pPositions, TileMode.CLAMP));
}
 
Example 2
Source File: RadialGradientFillBitmapTextureAtlasSourceDecorator.java    From tilt-game-android with MIT License 6 votes vote down vote up
public RadialGradientFillBitmapTextureAtlasSourceDecorator(final IBitmapTextureAtlasSource pBitmapTextureAtlasSource, final IBitmapTextureAtlasSourceDecoratorShape pBitmapTextureAtlasSourceDecoratorShape, final int[] pColors, final float[] pPositions, final RadialGradientDirection pRadialGradientDirection, final TextureAtlasSourceDecoratorOptions pTextureAtlasSourceDecoratorOptions) {
	super(pBitmapTextureAtlasSource, pBitmapTextureAtlasSourceDecoratorShape, pTextureAtlasSourceDecoratorOptions);
	this.mColors = pColors;
	this.mPositions = pPositions;
	this.mRadialGradientDirection = pRadialGradientDirection;

	this.mPaint.setStyle(Style.FILL);

	final int width = pBitmapTextureAtlasSource.getTextureWidth();
	final int height = pBitmapTextureAtlasSource.getTextureHeight();

	final float centerX = width * 0.5f;
	final float centerY = height * 0.5f;

	final float radius = Math.max(centerX, centerY);

	switch (pRadialGradientDirection) {
		case INSIDE_OUT:
			this.mPaint.setShader(new RadialGradient(centerX, centerY, radius, pColors, pPositions, TileMode.CLAMP));
			break;
		case OUTSIDE_IN:
			ArrayUtils.reverse(pColors);
			this.mPaint.setShader(new RadialGradient(centerX, centerY, radius, pColors, pPositions, TileMode.CLAMP));
			break;
	}
}
 
Example 3
Source File: RepeatingSpriteBackground.java    From 30-android-libraries-in-30-days with Apache License 2.0 6 votes vote down vote up
private Sprite loadSprite(final float pCameraWidth, final float pCameraHeight, final TextureManager pTextureManager, final IBitmapTextureAtlasSource pBitmapTextureAtlasSource, final VertexBufferObjectManager pVertexBufferObjectManager) throws IllegalArgumentException {
	this.mBitmapTextureAtlas = new BitmapTextureAtlas(pTextureManager, pBitmapTextureAtlasSource.getTextureWidth(), pBitmapTextureAtlasSource.getTextureHeight(), BitmapTextureFormat.RGBA_8888, TextureOptions.REPEATING_NEAREST);
	final ITextureRegion textureRegion = BitmapTextureAtlasTextureRegionFactory.createFromSource(this.mBitmapTextureAtlas, pBitmapTextureAtlasSource, 0, 0);

	final int width = Math.round(pCameraWidth / this.mScale);
	final int height = Math.round(pCameraHeight / this.mScale);

	textureRegion.setTextureWidth(width);
	textureRegion.setTextureHeight(height);

	this.mBitmapTextureAtlas.load();

	final Sprite sprite = new Sprite(0, 0, width, height, textureRegion, pVertexBufferObjectManager);
	sprite.setScaleCenter(0, 0);
	sprite.setScale(this.mScale);
	return sprite;
}
 
Example 4
Source File: LinearGradientFillBitmapTextureAtlasSourceDecorator.java    From 30-android-libraries-in-30-days with Apache License 2.0 6 votes vote down vote up
public LinearGradientFillBitmapTextureAtlasSourceDecorator(final IBitmapTextureAtlasSource pBitmapTextureAtlasSource, final IBitmapTextureAtlasSourceDecoratorShape pBitmapTextureAtlasSourceDecoratorShape, final int[] pColors, final float[] pPositions, final LinearGradientDirection pLinearGradientDirection, final TextureAtlasSourceDecoratorOptions pTextureAtlasSourceDecoratorOptions) {
	super(pBitmapTextureAtlasSource, pBitmapTextureAtlasSourceDecoratorShape, pTextureAtlasSourceDecoratorOptions);
	this.mColors = pColors;
	this.mPositions = pPositions;
	this.mLinearGradientDirection = pLinearGradientDirection;

	this.mPaint.setStyle(Style.FILL);

	final int right = pBitmapTextureAtlasSource.getTextureWidth() - 1;
	final int bottom = pBitmapTextureAtlasSource.getTextureHeight() - 1;

	final float fromX = pLinearGradientDirection.getFromX(right);
	final float fromY = pLinearGradientDirection.getFromY(bottom);
	final float toX = pLinearGradientDirection.getToX(right);
	final float toY = pLinearGradientDirection.getToY(bottom);

	this.mPaint.setShader(new LinearGradient(fromX, fromY, toX, toY, pColors, pPositions, TileMode.CLAMP));
}
 
Example 5
Source File: RadialGradientFillBitmapTextureAtlasSourceDecorator.java    From 30-android-libraries-in-30-days with Apache License 2.0 6 votes vote down vote up
public RadialGradientFillBitmapTextureAtlasSourceDecorator(final IBitmapTextureAtlasSource pBitmapTextureAtlasSource, final IBitmapTextureAtlasSourceDecoratorShape pBitmapTextureAtlasSourceDecoratorShape, final int[] pColors, final float[] pPositions, final RadialGradientDirection pRadialGradientDirection, final TextureAtlasSourceDecoratorOptions pTextureAtlasSourceDecoratorOptions) {
	super(pBitmapTextureAtlasSource, pBitmapTextureAtlasSourceDecoratorShape, pTextureAtlasSourceDecoratorOptions);
	this.mColors = pColors;
	this.mPositions = pPositions;
	this.mRadialGradientDirection = pRadialGradientDirection;

	this.mPaint.setStyle(Style.FILL);

	final int width = pBitmapTextureAtlasSource.getTextureWidth();
	final int height = pBitmapTextureAtlasSource.getTextureHeight();

	final float centerX = width * 0.5f;
	final float centerY = height * 0.5f;

	final float radius = Math.max(centerX, centerY);

	switch(pRadialGradientDirection) {
		case INSIDE_OUT:
			this.mPaint.setShader(new RadialGradient(centerX, centerY, radius, pColors, pPositions, TileMode.CLAMP));
			break;
		case OUTSIDE_IN:
			ArrayUtils.reverse(pColors);
			this.mPaint.setShader(new RadialGradient(centerX, centerY, radius, pColors, pPositions, TileMode.CLAMP));
			break;
	}
}
 
Example 6
Source File: BaseBitmapTextureAtlasSourceDecorator.java    From 30-android-libraries-in-30-days with Apache License 2.0 5 votes vote down vote up
public BaseBitmapTextureAtlasSourceDecorator(final IBitmapTextureAtlasSource pBitmapTextureAtlasSource, final TextureAtlasSourceDecoratorOptions pTextureAtlasSourceDecoratorOptions) {
	super(pBitmapTextureAtlasSource.getTextureX(), pBitmapTextureAtlasSource.getTextureY(), pBitmapTextureAtlasSource.getTextureWidth(), pBitmapTextureAtlasSource.getTextureHeight());

	this.mBitmapTextureAtlasSource = pBitmapTextureAtlasSource;
	this.mTextureAtlasSourceDecoratorOptions = (pTextureAtlasSourceDecoratorOptions == null) ? new TextureAtlasSourceDecoratorOptions() : pTextureAtlasSourceDecoratorOptions;
	this.mPaint.setAntiAlias(this.mTextureAtlasSourceDecoratorOptions.getAntiAliasing());
}