public static void Initialize(GraphicsDevice graphics, SubTexture2D whitePixel = null) { //1px x 1px white texture if (whitePixel != null) { WhitePixel = whitePixel; } else { Texture2D pixel; #if WINDOWS_PHONE pixel = new Texture2D(graphics, 1, 1); pixel.SetData(new [] { 0xffffffff }); #else pixel = Texture2D.FromStream(graphics, new MemoryStream(Convert.FromBase64String("iVBORw0KGgoAAAANSUhEUgAAAAEAAAABCAIAAACQd1PeAAAAAXNSR0IArs4c6QAAAAxJREFUCNdj+P//PwAF/gL+3MxZ5wAAAABJRU5ErkJggg=="))); #endif WhitePixel = new SubTexture2D(pixel); } }
public static void Draw(this SpriteBatch spriteBatch, SubTexture2D texture, Vector2 position, Color? color = null, float rotation = 0, Vector2? origin = null, float? scale = null, SpriteEffects spriteEffects = SpriteEffects.None, float depth = 0) { spriteBatch.Draw(texture.Texture, position, texture.Rectangle, color ?? Color.White, rotation, (origin ?? Vector2.Zero) * texture.ResolutionScale, (scale ?? 1) * texture.ResolutionScaleInv, spriteEffects, depth); }