public NinePatchRegion2D(TextureRegion2D textureRegion, ThicknessF padding) : base( textureRegion?.Texture, textureRegion?.Name, textureRegion?.X ?? 0, textureRegion?.Y ?? 0, textureRegion?.Width ?? 0, textureRegion?.Height ?? 0) { Padding = padding; CreatePatches(textureRegion !.Bounds, SourcePatches); }
public static void Draw( this SpriteBatch spriteBatch, TextureRegion2D textureRegion, Vector2 position, Color color, RectangleF?clippingRectangle = null) { Draw(spriteBatch, textureRegion, position, color, 0, Vector2.Zero, Vector2.One, SpriteFlip.None, 0, clippingRectangle); }
public static void Draw( this SpriteBatch spriteBatch, TextureRegion2D textureRegion, Vector2 position, Color color, float rotation, Vector2 origin, Vector2 scale, SpriteFlip flip, float layerDepth, RectangleF?clippingRectangle = null) { if (textureRegion.Bounds.IsVisible(ref position, origin, scale, clippingRectangle, out RectangleF srcRect)) { //System.Console.WriteLine(srcRect); spriteBatch.Draw(textureRegion.Texture, position, srcRect, color, rotation, origin, scale, flip, layerDepth); } }
public static void Draw( this SpriteBatch spriteBatch, TextureRegion2D textureRegion, RectangleF destinationRectangle, Color color, RectangleF?clippingRectangle = null) { if (textureRegion == null) { throw new ArgumentNullException(nameof(textureRegion)); } if (textureRegion is NinePatchRegion2D ninePatchRegion) { Draw(spriteBatch, ninePatchRegion, destinationRectangle, color, clippingRectangle); } else { Draw(spriteBatch, textureRegion.Texture, textureRegion.Bounds, destinationRectangle, color, clippingRectangle); } }
public NinePatchRegion2D( TextureRegion2D textureRegion, float leftPadding, float topPadding, float rightPadding, float bottomPadding) : this(textureRegion, new ThicknessF(leftPadding, topPadding, rightPadding, bottomPadding)) { }
public NinePatchRegion2D( TextureRegion2D textureRegion, float leftRightPadding, float topBottomPadding) : this(textureRegion, leftRightPadding, topBottomPadding, leftRightPadding, topBottomPadding) { }
public NinePatchRegion2D( TextureRegion2D textureRegion, float padding) : this(textureRegion, padding, padding, padding, padding) { }