public Atlas(SmartTexture tx) { this.tx = tx; tx.Atlas = this; namedFrames = new Dictionary <object, RectF>(); }
public static void Add(object key, SmartTexture tx) { if (All.ContainsKey(key)) { All[key] = tx; } else { All.Add(key, tx); } }
public static SmartTexture Get(object src) { if (All.ContainsKey(src)) { return(All[src]); } var texture = src as SmartTexture; if (texture != null) { return(texture); } var tx = new SmartTexture(GetBitmap(src)); All.Add(src, tx); return(tx); }
public static SmartTexture CreateSolid(Color color) { var key = "1x1:" + color; if (All.ContainsKey(key)) { return(All[key]); } var bmp = Bitmap.CreateBitmap(1, 1, Bitmap.Config.Argb8888); bmp.EraseColor(color); var tx = new SmartTexture(bmp); All.Add(key, tx); return(tx); }
public static SmartTexture CreateGradient(int Width, int Height, params int[] colors) { var key = "" + Width + "x" + Height + ":" + colors; if (All.ContainsKey(key)) { return(All[key]); } var bmp = Bitmap.CreateBitmap(Width, Height, Bitmap.Config.Argb8888); var canvas = new Canvas(bmp); var paint = new Paint(); paint.SetShader(new LinearGradient(0, 0, 0, Height, colors, null, Shader.TileMode.Clamp)); canvas.DrawPaint(paint); var tx = new SmartTexture(bmp); All.Add(key, tx); return(tx); }
public virtual void Reload() { Id = new SmartTexture(bitmap).Id; Filter(FModeMin, FModeMax); Wrap(WModeH, WModeV); }
public static RectF UvRect(SmartTexture tx, int left, int top, int right, int bottom) { return(new RectF((float)left / tx.Width, (float)top / tx.Height, (float)right / tx.Width, (float)bottom / tx.Height)); }