/** Creates a new drawable that renders the same as this drawable tinted the specified color. */ public SpriteDrawable tint (Color tint) { Sprite newSprite; if (sprite instanceof AtlasSprite) newSprite = new AtlasSprite((AtlasSprite)sprite); else newSprite = new Sprite(sprite); newSprite.setColor(tint); newSprite.setSize(getMinWidth(), getMinHeight()); SpriteDrawable drawable = new SpriteDrawable(newSprite); drawable.setLeftWidth(getLeftWidth()); drawable.setRightWidth(getRightWidth()); drawable.setTopHeight(getTopHeight()); drawable.setBottomHeight(getBottomHeight()); return drawable; } }
/** Returns a tinted copy of a drawable found in the skin via {@link #getDrawable(String)}. */ public Drawable newDrawable (Drawable drawable, Color tint) { Drawable newDrawable; if (drawable instanceof TextureRegionDrawable) newDrawable = ((TextureRegionDrawable)drawable).tint(tint); else if (drawable instanceof NinePatchDrawable) newDrawable = ((NinePatchDrawable)drawable).tint(tint); else if (drawable instanceof SpriteDrawable) newDrawable = ((SpriteDrawable)drawable).tint(tint); else throw new GdxRuntimeException("Unable to copy, unknown drawable type: " + drawable.getClass()); if (newDrawable instanceof BaseDrawable) { BaseDrawable named = (BaseDrawable)newDrawable; if (drawable instanceof BaseDrawable) named.setName(((BaseDrawable)drawable).getName() + " (" + tint + ")"); else named.setName(" (" + tint + ")"); } return newDrawable; }
/** Creates a new drawable that renders the same as this drawable tinted the specified color. */ public Drawable tint (Color tint) { Sprite sprite; if (region instanceof AtlasRegion) sprite = new AtlasSprite((AtlasRegion)region); else sprite = new Sprite(region); sprite.setColor(tint); sprite.setSize(getMinWidth(), getMinHeight()); SpriteDrawable drawable = new SpriteDrawable(sprite); drawable.setLeftWidth(getLeftWidth()); drawable.setRightWidth(getRightWidth()); drawable.setTopHeight(getTopHeight()); drawable.setBottomHeight(getBottomHeight()); return drawable; } }
/** Returns a copy of the specified drawable. */ public Drawable newDrawable (Drawable drawable) { if (drawable instanceof TiledDrawable) return new TiledDrawable((TiledDrawable)drawable); if (drawable instanceof TextureRegionDrawable) return new TextureRegionDrawable((TextureRegionDrawable)drawable); if (drawable instanceof NinePatchDrawable) return new NinePatchDrawable((NinePatchDrawable)drawable); if (drawable instanceof SpriteDrawable) return new SpriteDrawable((SpriteDrawable)drawable); throw new GdxRuntimeException("Unable to copy, unknown drawable type: " + drawable.getClass()); }
SpriteDrawable spriteDrawable = new SpriteDrawable(new Sprite(atlasRegion)) .tint(Color.valueOf(imageModel.getTintColor())); return new Image(spriteDrawable);
/** Creates a new drawable that renders the same as this drawable tinted the specified color. */ public Drawable tint (Color tint) { Sprite sprite; if (region instanceof AtlasRegion) sprite = new AtlasSprite((AtlasRegion)region); else sprite = new Sprite(region); sprite.setColor(tint); sprite.setSize(getMinWidth(), getMinHeight()); SpriteDrawable drawable = new SpriteDrawable(sprite); drawable.setLeftWidth(getLeftWidth()); drawable.setRightWidth(getRightWidth()); drawable.setTopHeight(getTopHeight()); drawable.setBottomHeight(getBottomHeight()); return drawable; } }
/** Returns a copy of the specified drawable. */ public Drawable newDrawable (Drawable drawable) { if (drawable instanceof TiledDrawable) return new TiledDrawable((TiledDrawable)drawable); if (drawable instanceof TextureRegionDrawable) return new TextureRegionDrawable((TextureRegionDrawable)drawable); if (drawable instanceof NinePatchDrawable) return new NinePatchDrawable((NinePatchDrawable)drawable); if (drawable instanceof SpriteDrawable) return new SpriteDrawable((SpriteDrawable)drawable); throw new GdxRuntimeException("Unable to copy, unknown drawable type: " + drawable.getClass()); }
SpriteDrawable spriteDrawable = new SpriteDrawable(new Sprite(textureRegion)) .tint(Color.valueOf(imageModel.getTintColor())); return new Image(spriteDrawable);
/** Creates a new drawable that renders the same as this drawable tinted the specified color. */ public SpriteDrawable tint (Color tint) { Sprite newSprite; if (sprite instanceof AtlasSprite) newSprite = new AtlasSprite((AtlasSprite)sprite); else newSprite = new Sprite(sprite); newSprite.setColor(tint); newSprite.setSize(getMinWidth(), getMinHeight()); SpriteDrawable drawable = new SpriteDrawable(newSprite); drawable.setLeftWidth(getLeftWidth()); drawable.setRightWidth(getRightWidth()); drawable.setTopHeight(getTopHeight()); drawable.setBottomHeight(getBottomHeight()); return drawable; } }
/** Creates a new drawable that renders the same as this drawable tinted the specified color. */ public Drawable tint (Color tint) { Sprite sprite; if (region instanceof AtlasRegion) sprite = new AtlasSprite((AtlasRegion)region); else sprite = new Sprite(region); sprite.setColor(tint); sprite.setSize(getMinWidth(), getMinHeight()); SpriteDrawable drawable = new SpriteDrawable(sprite); drawable.setLeftWidth(getLeftWidth()); drawable.setRightWidth(getRightWidth()); drawable.setTopHeight(getTopHeight()); drawable.setBottomHeight(getBottomHeight()); return drawable; } }
drawable = new NinePatchDrawable(getPatch(name)); else if (region.rotate || region.packedWidth != region.originalWidth || region.packedHeight != region.originalHeight) drawable = new SpriteDrawable(getSprite(name)); Sprite sprite = optional(name, Sprite.class); if (sprite != null) drawable = new SpriteDrawable(sprite); else throw new GdxRuntimeException(
/** Returns a tinted copy of a drawable found in the skin via {@link #getDrawable(String)}. */ public Drawable newDrawable (Drawable drawable, Color tint) { Drawable newDrawable; if (drawable instanceof TextureRegionDrawable) newDrawable = ((TextureRegionDrawable)drawable).tint(tint); else if (drawable instanceof NinePatchDrawable) newDrawable = ((NinePatchDrawable)drawable).tint(tint); else if (drawable instanceof SpriteDrawable) newDrawable = ((SpriteDrawable)drawable).tint(tint); else throw new GdxRuntimeException("Unable to copy, unknown drawable type: " + drawable.getClass()); if (newDrawable instanceof BaseDrawable) { BaseDrawable named = (BaseDrawable)newDrawable; if (drawable instanceof BaseDrawable) named.setName(((BaseDrawable)drawable).getName() + " (" + tint + ")"); else named.setName(" (" + tint + ")"); } return newDrawable; }
/** Creates a new drawable that renders the same as this drawable tinted the specified color. */ public SpriteDrawable tint (Color tint) { Sprite newSprite; if (sprite instanceof AtlasSprite) newSprite = new AtlasSprite((AtlasSprite)sprite); else newSprite = new Sprite(sprite); newSprite.setColor(tint); newSprite.setSize(getMinWidth(), getMinHeight()); SpriteDrawable drawable = new SpriteDrawable(newSprite); drawable.setLeftWidth(getLeftWidth()); drawable.setRightWidth(getRightWidth()); drawable.setTopHeight(getTopHeight()); drawable.setBottomHeight(getBottomHeight()); return drawable; } }
drawable = new NinePatchDrawable(getPatch(name)); else if (region.rotate || region.packedWidth != region.originalWidth || region.packedHeight != region.originalHeight) drawable = new SpriteDrawable(getSprite(name)); Sprite sprite = optional(name, Sprite.class); if (sprite != null) drawable = new SpriteDrawable(sprite); else throw new GdxRuntimeException(
private BaseDrawable getTintedDrawable(BaseDrawable drawable, String color) { if (drawable instanceof SpriteDrawable) { return ((SpriteDrawable) drawable).tint(Color.valueOf(color)); } else if (drawable instanceof NinePatchDrawable) { return ((NinePatchDrawable) drawable).tint(Color.valueOf(color)); } return null; }
public PaletteTile(final Sprite sprite, final String resource, final int resX, final int resY, final int tilesize) { super(new SpriteDrawable(sprite)); this.resource = resource; this.resX = resX; this.resY = resY; this.tilesize = tilesize; }
/** Returns a tinted copy of a drawable found in the skin via {@link #getDrawable(String)}. */ public Drawable newDrawable (Drawable drawable, Color tint) { Drawable newDrawable; if (drawable instanceof TextureRegionDrawable) newDrawable = ((TextureRegionDrawable)drawable).tint(tint); else if (drawable instanceof NinePatchDrawable) newDrawable = ((NinePatchDrawable)drawable).tint(tint); else if (drawable instanceof SpriteDrawable) newDrawable = ((SpriteDrawable)drawable).tint(tint); else throw new GdxRuntimeException("Unable to copy, unknown drawable type: " + drawable.getClass()); if (newDrawable instanceof BaseDrawable) { BaseDrawable named = (BaseDrawable)newDrawable; if (drawable instanceof BaseDrawable) named.setName(((BaseDrawable)drawable).getName() + " (" + tint + ")"); else named.setName(" (" + tint + ")"); } return newDrawable; }
import com.badlogic.gdx.graphics.Texture; import com.badlogic.gdx.graphics.g2d.Sprite; import com.badlogic.gdx.scenes.scene2d.ui.ImageButton; import com.badlogic.gdx.scenes.scene2d.utils.Drawable; import com.badlogic.gdx.scenes.scene2d.utils.SpriteDrawable; public class myButton extends ImageButton { public myButton(Texture texture_up, Texture texture_down, Texture background) { super(new SpriteDrawable(new Sprite(texture_up)), new SpriteDrawable(new Sprite(texture_down))); this.setBackground(new SpriteDrawable(new Sprite(background)); } }
private SpriteDrawable getSpriteDrawable(FileHandle fh) { Texture tex = new Texture(fh); return new SpriteDrawable(new Sprite(tex)); }
/** Returns a copy of the specified drawable. */ public Drawable newDrawable (Drawable drawable) { if (drawable instanceof TiledDrawable) return new TiledDrawable((TiledDrawable)drawable); if (drawable instanceof TextureRegionDrawable) return new TextureRegionDrawable((TextureRegionDrawable)drawable); if (drawable instanceof NinePatchDrawable) return new NinePatchDrawable((NinePatchDrawable)drawable); if (drawable instanceof SpriteDrawable) return new SpriteDrawable((SpriteDrawable)drawable); throw new GdxRuntimeException("Unable to copy, unknown drawable type: " + drawable.getClass()); }