public void Draw( Texture2D texture, float x, float y, Rectangle?sourceRectangle = null, Color?multiplyColor = null, Color addColor = default(Color), float rotation = 0, float scaleX = 1, float scaleY = 1, float originX = 0, float originY = 0, bool mirrorX = false, bool mirrorY = false, DrawCallSortKey?sortKey = null, int?layer = null, bool?worldSpace = null, BlendState blendState = null, SamplerState samplerState = null, Material material = null ) { var drawCall = new BitmapDrawCall(texture, new Vector2(x, y)); if (sourceRectangle.HasValue) { drawCall.TextureRegion = texture.BoundsFromRectangle(sourceRectangle.Value); } drawCall.MultiplyColor = multiplyColor.GetValueOrDefault(Color.White); drawCall.AddColor = addColor; drawCall.Rotation = rotation; drawCall.Scale = new Vector2(scaleX, scaleY); drawCall.Origin = new Vector2(originX, originY); if (mirrorX || mirrorY) { drawCall.Mirror(mirrorX, mirrorY); } drawCall.SortKey = sortKey.GetValueOrDefault(NextSortKey); if (AutoIncrementSortKey) { NextSortKey.Order += 1; } Draw(ref drawCall, layer: layer, worldSpace: worldSpace, blendState: blendState, samplerState: samplerState); }
public void Draw( Texture2D texture, Rectangle destRectangle, Rectangle?sourceRectangle = null, Color?multiplyColor = null, Color addColor = default(Color), float rotation = 0, float originX = 0, float originY = 0, bool mirrorX = false, bool mirrorY = false, float sortKey = 0, int?layer = null, bool?worldSpace = null, BlendState blendState = null, SamplerState samplerState = null ) { var drawCall = new BitmapDrawCall(texture, new Vector2(destRectangle.X, destRectangle.Y)); if (sourceRectangle.HasValue) { var sr = sourceRectangle.Value; drawCall.TextureRegion = texture.BoundsFromRectangle(ref sr); drawCall.Scale = new Vector2(destRectangle.Width / (float)sr.Width, destRectangle.Height / (float)sr.Height); } else { drawCall.Scale = new Vector2(destRectangle.Width / (float)texture.Width, destRectangle.Height / (float)texture.Height); } drawCall.MultiplyColor = multiplyColor.GetValueOrDefault(Color.White); drawCall.AddColor = addColor; drawCall.Rotation = rotation; drawCall.Origin = new Vector2(originX, originY); if (mirrorX || mirrorY) { drawCall.Mirror(mirrorX, mirrorY); } drawCall.SortKey = sortKey; Draw(ref drawCall, layer: layer, worldSpace: worldSpace, blendState: blendState, samplerState: samplerState); }
public void Draw( Texture2D texture, Vector2 position, Rectangle?sourceRectangle = null, Color?multiplyColor = null, Color addColor = default(Color), float rotation = 0, Vector2?scale = null, Vector2 origin = default(Vector2), bool mirrorX = false, bool mirrorY = false, float sortKey = 0, int?layer = null, bool?worldSpace = null, BlendState blendState = null, SamplerState samplerState = null ) { var drawCall = new BitmapDrawCall(texture, position); if (sourceRectangle.HasValue) { drawCall.TextureRegion = texture.BoundsFromRectangle(sourceRectangle.Value); } drawCall.MultiplyColor = multiplyColor.GetValueOrDefault(Color.White); drawCall.AddColor = addColor; drawCall.Rotation = rotation; drawCall.Scale = scale.GetValueOrDefault(Vector2.One); drawCall.Origin = origin; if (mirrorX || mirrorY) { drawCall.Mirror(mirrorX, mirrorY); } drawCall.SortKey = sortKey; Draw(ref drawCall, layer: layer, worldSpace: worldSpace, blendState: blendState, samplerState: samplerState); }
private void GenerateCells() { for (int y = 0, i = 0; y < HeightInCells; y++) { for (int x = 0; x < WidthInCells; x++, i++) { var rectangle = new Rectangle( (CellWidth * x) + MarginLeft, (CellHeight * y) + MarginTop, CellWidth, CellHeight ); var bounds = Texture.BoundsFromRectangle(ref rectangle); var cell = new Cell(this, i, ref bounds, ref rectangle); Cells.Add(cell); } } }
public static Bounds BoundsFromRectangle(this Texture2D @this, Rectangle rectangle) { return(@this.BoundsFromRectangle(ref rectangle)); }