com.watabou.gltextures.SmartTexture Java Examples

The following examples show how to use com.watabou.gltextures.SmartTexture. 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: Halo.java    From YetAnotherPixelDungeon with GNU General Public License v3.0 6 votes vote down vote up
public Halo() {
	super();
	
	if (!TextureCache.contains( CACHE_KEY )) {
		Bitmap bmp = Bitmap.createBitmap( RADIUS * 2, RADIUS * 2, Bitmap.Config.ARGB_8888 );
		Canvas canvas = new Canvas( bmp );
		Paint paint = new Paint();
		paint.setColor( 0xFFFFFFFF );
		canvas.drawCircle( RADIUS, RADIUS, RADIUS * 0.75f, paint );
		paint.setColor( 0x88FFFFFF );
		canvas.drawCircle( RADIUS, RADIUS, RADIUS, paint );
		TextureCache.add( CACHE_KEY, new SmartTexture( bmp ) );
	}
	
	texture( CACHE_KEY );
	
	origin.set( RADIUS );
}
 
Example #2
Source File: BitmapText.java    From shattered-pixel-dungeon with GNU General Public License v3.0 6 votes vote down vote up
public Font( SmartTexture tx, int width, int height, String chars ) {
	super( tx );
	
	texture = tx;
	
	int length = chars.length();
	
	float uw = (float)width / tx.width;
	float vh = (float)height / tx.height;
	
	float left = 0;
	float top = 0;
	float bottom = vh;
	
	for (int i=0; i < length; i++) {
		RectF rect = new RectF( left, top, left += uw, bottom );
		add( chars.charAt( i ), rect );
		if (left >= 1) {
			left = 0;
			top = bottom;
			bottom += vh;
		}
	}
	
	lineHeight = baseLine = height;
}
 
Example #3
Source File: Halo.java    From pixel-dungeon with GNU General Public License v3.0 6 votes vote down vote up
public Halo() {
	super();
	
	if (!TextureCache.contains( CACHE_KEY )) {
		Bitmap bmp = Bitmap.createBitmap( RADIUS * 2, RADIUS * 2, Bitmap.Config.ARGB_8888 );
		Canvas canvas = new Canvas( bmp );
		Paint paint = new Paint();
		paint.setColor( 0xFFFFFFFF );
		canvas.drawCircle( RADIUS, RADIUS, RADIUS * 0.75f, paint );
		paint.setColor( 0x88FFFFFF );
		canvas.drawCircle( RADIUS, RADIUS, RADIUS, paint );
		TextureCache.add( CACHE_KEY, new SmartTexture( bmp ) );
	}
	
	texture( CACHE_KEY );
	
	origin.set( RADIUS );
}
 
Example #4
Source File: TextureFilm.java    From remixed-dungeon with GNU General Public License v3.0 6 votes vote down vote up
public TextureFilm( Object tx, int width, int height ) {
	
	SmartTexture texture = TextureCache.get( tx );
	
	texWidth = texture.width;
	texHeight = texture.height;
	
	float uw = (float)width / texWidth;
	float vh = (float)height / texHeight;
	int cols = texWidth / width;
	int rows = texHeight / height;
	
	for (int i=0; i < rows; i++) {
		for (int j=0; j < cols; j++) {
			RectF rect = new RectF( j * uw, i * vh, (j+1) * uw, (i+1) * vh );
			add( i * cols + j, rect );
		}
	}
}
 
Example #5
Source File: CircleMask.java    From remixed-dungeon with GNU General Public License v3.0 6 votes vote down vote up
public static void ensureTexture() {
	if (!TextureCache.contains( CACHE_KEY )) {

		Bitmap bmp = Bitmap.createBitmap( RADIUS * 2, RADIUS * 2, Bitmap.Config.ARGB_8888 );
		Canvas canvas = new Canvas( bmp );
		Paint paint = new Paint();
		canvas.drawColor(Color.WHITE, PorterDuff.Mode.SRC);

		paint.setXfermode(new PorterDuffXfermode(PorterDuff.Mode.SRC));
		paint.setColor( 0xf7ffffff);
		canvas.drawCircle( RADIUS, RADIUS, RADIUS, paint );

		paint.setColor( 0x77ffffff);
		canvas.drawCircle( RADIUS, RADIUS, RADIUS*0.75f, paint );

		paint.setColor( 0x00ffffff);
		canvas.drawCircle( RADIUS, RADIUS, RADIUS*0.5f, paint );
		TextureCache.add( CACHE_KEY, new SmartTexture( bmp ) );
	}
}
 
Example #6
Source File: Halo.java    From unleashed-pixel-dungeon with GNU General Public License v3.0 6 votes vote down vote up
public Halo() {
	super();
	
	if (!TextureCache.contains( CACHE_KEY )) {
		Bitmap bmp = Bitmap.createBitmap( RADIUS * 2, RADIUS * 2, Bitmap.Config.ARGB_8888 );
		Canvas canvas = new Canvas( bmp );
		Paint paint = new Paint();
		paint.setColor( 0xFFFFFFFF );
		canvas.drawCircle( RADIUS, RADIUS, RADIUS * 0.75f, paint );
		paint.setColor( 0x88FFFFFF );
		canvas.drawCircle( RADIUS, RADIUS, RADIUS, paint );
		TextureCache.add( CACHE_KEY, new SmartTexture( bmp ) );
	}
	
	texture( CACHE_KEY );
	
	origin.set( RADIUS );
}
 
Example #7
Source File: Halo.java    From remixed-dungeon with GNU General Public License v3.0 6 votes vote down vote up
public Halo() {
	if (!TextureCache.contains( CACHE_KEY )) {
		Bitmap bmp = Bitmap.createBitmap( RADIUS * 2, RADIUS * 2, Bitmap.Config.ARGB_8888 );
		Canvas canvas = new Canvas( bmp );
		Paint paint = new Paint();
		paint.setColor( 0xFFFFFFFF );
		canvas.drawCircle( RADIUS, RADIUS, RADIUS * 0.75f, paint );
		paint.setColor( 0x88FFFFFF );
		canvas.drawCircle( RADIUS, RADIUS, RADIUS, paint );
		TextureCache.add( CACHE_KEY, new SmartTexture( bmp ) );
	}
	
	texture( CACHE_KEY );
	
	origin.set( RADIUS );
}
 
Example #8
Source File: TextureFilm.java    From YetAnotherPixelDungeon with GNU General Public License v3.0 6 votes vote down vote up
public TextureFilm( Object tx, int width, int height ) {
	
	SmartTexture texture = TextureCache.get( tx );
	
	texWidth = texture.width;
	texHeight = texture.height;
	
	float uw = (float)width / texWidth;
	float vh = (float)height / texHeight;
	int cols = texWidth / width;
	int rows = texHeight / height;
	
	for (int i=0; i < rows; i++) {
		for (int j=0; j < cols; j++) {
			RectF rect = new RectF( j * uw, i * vh, (j+1) * uw, (i+1) * vh );
			add( i * cols + j, rect );
		}
	}
}
 
Example #9
Source File: TextureFilm.java    From PD-classes with GNU General Public License v3.0 6 votes vote down vote up
public TextureFilm( Object tx, int width, int height ) {
	
	SmartTexture texture = TextureCache.get( tx );
	
	texWidth = texture.width;
	texHeight = texture.height;
	
	float uw = (float)width / texWidth;
	float vh = (float)height / texHeight;
	int cols = texWidth / width;
	int rows = texHeight / height;
	
	for (int i=0; i < rows; i++) {
		for (int j=0; j < cols; j++) {
			RectF rect = new RectF( j * uw, i * vh, (j+1) * uw, (i+1) * vh );
			add( i * cols + j, rect );
		}
	}
}
 
Example #10
Source File: BitmapText.java    From shattered-pixel-dungeon-gdx with GNU General Public License v3.0 6 votes vote down vote up
public Font( SmartTexture tx, int width, int height, String chars ) {
	super( tx );
	
	texture = tx;
	
	int length = chars.length();
	
	float uw = (float)width / tx.width;
	float vh = (float)height / tx.height;
	
	float left = 0;
	float top = 0;
	float bottom = vh;
	
	for (int i=0; i < length; i++) {
		RectF rect = new RectF( left, top, left += uw, bottom );
		add( chars.charAt( i ), rect );
		if (left >= 1) {
			left = 0;
			top = bottom;
			bottom += vh;
		}
	}
	
	lineHeight = baseLine = height;
}
 
Example #11
Source File: BitmapText.java    From PD-classes with GNU General Public License v3.0 5 votes vote down vote up
public Font( SmartTexture tx, int width, int height, String chars ) {
	super( tx );
	
	texture = tx;
	
	autoUppercase = chars.equals( LATIN_UPPER );
	
	int length = chars.length();
	
	float uw = (float)width / tx.width;
	float vh = (float)height / tx.height;
	
	float left = 0;
	float top = 0;
	float bottom = vh;
	
	for (int i=0; i < length; i++) {
		RectF rect = new RectF( left, top, left += uw, bottom );
		add( chars.charAt( i ), rect );
		if (left >= 1) {
			left = 0;
			top = bottom;
			bottom += vh;
		}
	}
	
	lineHeight = baseLine = height;
}
 
Example #12
Source File: Halo.java    From shattered-pixel-dungeon-gdx with GNU General Public License v3.0 5 votes vote down vote up
public Halo() {
	super();
	
	if (!TextureCache.contains( CACHE_KEY )) {
		Pixmap pixmap = new Pixmap(RADIUS * 2, RADIUS * 2, Pixmap.Format.RGBA8888);
		pixmap.setColor( 0xFFFFFF0A );
		for (int i = 0; i < 50; i++) {
			pixmap.fillCircle(RADIUS, RADIUS, (int)(RADIUS * (i+1)/50f));
		}
		TextureCache.add( CACHE_KEY, new SmartTexture( pixmap ) );
	}
	
	texture( CACHE_KEY );
}
 
Example #13
Source File: ItemSprite.java    From shattered-pixel-dungeon-gdx with GNU General Public License v3.0 5 votes vote down vote up
public static int pick( int index, int x, int y ) {
	SmartTexture tx = TextureCache.get( Assets.ITEMS );
	int rows = tx.width / SIZE;
	int row = index / rows;
	int col = index % rows;
	return tx.getPixel( col * SIZE + x, row * SIZE + y );
}
 
Example #14
Source File: HeroSprite.java    From shattered-pixel-dungeon-gdx with GNU General Public License v3.0 5 votes vote down vote up
public static TextureFilm tiers() {
	if (tiers == null) {
		SmartTexture texture = TextureCache.get( Assets.ROGUE );
		tiers = new TextureFilm( texture, texture.width, FRAME_HEIGHT );
	}
	
	return tiers;
}
 
Example #15
Source File: FogOfWar.java    From shattered-pixel-dungeon with GNU General Public License v3.0 5 votes vote down vote up
public FogOfWar( int mapWidth, int mapHeight ) {
	
	super();

	this.mapWidth = mapWidth;
	this.mapHeight = mapHeight;
	mapLength = mapHeight * mapWidth;
	
	pWidth = mapWidth * PIX_PER_TILE;
	pHeight = mapHeight * PIX_PER_TILE;
	
	width2 = 1;
	while (width2 < pWidth) {
		width2 <<= 1;
	}
	
	height2 = 1;
	while (height2 < pHeight) {
		height2 <<= 1;
	}
	
	float size = DungeonTilemap.SIZE / PIX_PER_TILE;
	width = width2 * size;
	height = height2 * size;

	//TODO might be nice to compartmentalize the pixmap access and modification into texture/texturecache
	Pixmap px = new Pixmap(width2, height2, Pixmap.Format.RGBA8888);
	px.setBlending(Pixmap.Blending.None);
	px.setColor(0x000000FF);
	px.fill();
	SmartTexture tx = new SmartTexture(px, Texture.LINEAR, Texture.CLAMP, false);
	TextureCache.add(FogOfWar.class, tx);
	texture( tx );
	
	scale.set( size, size );

	toUpdate = new ArrayList<>();
	toUpdate.add(new Rect(0, 0, mapWidth, mapHeight));
}
 
Example #16
Source File: ShadowBox.java    From shattered-pixel-dungeon with GNU General Public License v3.0 5 votes vote down vote up
public ShadowBox() {
	super( Assets.Interfaces.SHADOW, 1 );

	//If this is the first time the texture is generated, set the filtering
	if (texture.id == -1)
		texture.filter( SmartTexture.LINEAR, SmartTexture.LINEAR );
	
	scale.set( SIZE, SIZE );
}
 
Example #17
Source File: ShadowBox.java    From shattered-pixel-dungeon-gdx with GNU General Public License v3.0 5 votes vote down vote up
public ShadowBox() {
	super( Assets.SHADOW, 1 );

	//If this is the first time the texture is generated, set the filtering
	if (texture.id == -1)
		texture.filter( SmartTexture.LINEAR, SmartTexture.LINEAR );

	scale.set( SIZE, SIZE );
}
 
Example #18
Source File: HeroSprite.java    From shattered-pixel-dungeon with GNU General Public License v3.0 5 votes vote down vote up
public static TextureFilm tiers() {
	if (tiers == null) {
		SmartTexture texture = TextureCache.get( Assets.Sprites.ROGUE );
		tiers = new TextureFilm( texture, texture.width, FRAME_HEIGHT );
	}
	
	return tiers;
}
 
Example #19
Source File: ItemSprite.java    From shattered-pixel-dungeon with GNU General Public License v3.0 5 votes vote down vote up
public static int pick( int index, int x, int y ) {
	SmartTexture tx = TextureCache.get( Assets.Sprites.ITEMS );
	int rows = tx.width / SIZE;
	int row = index / rows;
	int col = index % rows;
	return tx.getPixel( col * SIZE + x, row * SIZE + y );
}
 
Example #20
Source File: Halo.java    From shattered-pixel-dungeon with GNU General Public License v3.0 5 votes vote down vote up
public Halo() {
	super();
	
	if (!TextureCache.contains( CACHE_KEY )) {
		Pixmap pixmap = new Pixmap(2*RADIUS+1, 2*RADIUS+1, Pixmap.Format.RGBA8888);
		pixmap.setColor( 0xFFFFFF08 );
		for (int i = 0; i < RADIUS; i+=2) {
			pixmap.fillCircle(RADIUS, RADIUS, (RADIUS - i));
		}
		TextureCache.add( CACHE_KEY, new SmartTexture( pixmap ) );
	}
	
	texture( CACHE_KEY );
}
 
Example #21
Source File: BitmapText.java    From YetAnotherPixelDungeon with GNU General Public License v3.0 5 votes vote down vote up
public Font( SmartTexture tx, int width, int height, String chars ) {
	super( tx );
	
	texture = tx;
	
	autoUppercase = chars.equals( LATIN_UPPER );
	
	int length = chars.length();
	
	float uw = (float)width / tx.width;
	float vh = (float)height / tx.height;
	
	float left = 0;
	float top = 0;
	float bottom = vh;
	
	for (int i=0; i < length; i++) {
		RectF rect = new RectF( left, top, left += uw, bottom );
		add( chars.charAt( i ), rect );
		if (left >= 1) {
			left = 0;
			top = bottom;
			bottom += vh;
		}
	}
	
	lineHeight = baseLine = height;
}
 
Example #22
Source File: HeroSprite.java    From pixel-dungeon with GNU General Public License v3.0 5 votes vote down vote up
public static TextureFilm tiers() {
	if (tiers == null) {
		SmartTexture texture = TextureCache.get( Assets.ROGUE );
		tiers = new TextureFilm( texture, texture.width, FRAME_HEIGHT );
	}
	
	return tiers;
}
 
Example #23
Source File: BitmapText.java    From PD-classes with GNU General Public License v3.0 4 votes vote down vote up
protected Font( SmartTexture tx ) {
	super( tx );
	
	texture = tx;
}
 
Example #24
Source File: BitmapText.java    From YetAnotherPixelDungeon with GNU General Public License v3.0 4 votes vote down vote up
protected Font( SmartTexture tx ) {
	super( tx );
	
	texture = tx;
}
 
Example #25
Source File: BitmapText.java    From YetAnotherPixelDungeon with GNU General Public License v3.0 4 votes vote down vote up
public Font( SmartTexture tx, int width, String chars ) {
	this( tx, width, tx.height, chars );
}
 
Example #26
Source File: TextureFilm.java    From shattered-pixel-dungeon-gdx with GNU General Public License v3.0 4 votes vote down vote up
public TextureFilm( SmartTexture texture, int width ) {
	this( texture, width, texture.height );
}
 
Example #27
Source File: Image.java    From shattered-pixel-dungeon-gdx with GNU General Public License v3.0 4 votes vote down vote up
public void texture( Object tx ) {
	texture = tx instanceof SmartTexture ? (SmartTexture)tx : TextureCache.get( tx );
	frame( new RectF( 0, 0, 1, 1 ) );
}
 
Example #28
Source File: Image.java    From YetAnotherPixelDungeon with GNU General Public License v3.0 4 votes vote down vote up
public void texture( Object tx ) {
	texture = tx instanceof SmartTexture ? (SmartTexture)tx : TextureCache.get( tx );
	frame( new RectF( 0, 0, 1, 1 ) );
}
 
Example #29
Source File: BitmapText.java    From shattered-pixel-dungeon-gdx with GNU General Public License v3.0 4 votes vote down vote up
public Font( SmartTexture tx, int width, String chars ) {
	this( tx, width, tx.height, chars );
}
 
Example #30
Source File: BitmapText.java    From shattered-pixel-dungeon-gdx with GNU General Public License v3.0 4 votes vote down vote up
protected Font( SmartTexture tx ) {
	super( tx );
	
	texture = tx;
}