public override void RenderContent(RenderLayer renderContext, SpriteBatch spriteBatch) { Dictionary <string, Texture2D> brushClassOverlays = _form._brushClassOverlays; DynamicTileBrush brush = _form._brush; if (!brushClassOverlays.ContainsKey(brush.BrushClass.ClassName)) { System.Drawing.Bitmap overlayBitmap = null; if (brush.BrushClass.ClassName == "Basic") { overlayBitmap = Properties.Resources.DynBrushBasic; } else if (brush.BrushClass.ClassName == "Extended") { overlayBitmap = Properties.Resources.DynBrushExtended; } else { return; } TextureResource overlayResource = TextureResourceBitmapExt.CreateTextureResource(overlayBitmap); brushClassOverlays.Add(brush.BrushClass.ClassName, overlayResource.CreateTexture(spriteBatch.GraphicsDevice)); } Texture2D overlay = brushClassOverlays[brush.BrushClass.ClassName]; int width = (int)(overlay.Width * renderContext.LevelGeometry.ZoomFactor * (brush.TileWidth / 16.0)); int height = (int)(overlay.Height * renderContext.LevelGeometry.ZoomFactor * (brush.TileHeight / 16.0)); Microsoft.Xna.Framework.Rectangle dstRect = new Microsoft.Xna.Framework.Rectangle(0, 0, width, height); spriteBatch.Draw(overlay, dstRect, new Microsoft.Xna.Framework.Color(1f, 1f, 1f, .5f)); }
public override void MeleeEffects(Player player, Microsoft.Xna.Framework.Rectangle hitbox) { if (Main.rand.NextBool(200)) { player.AddBuff(BuffID.Mining, 300); } }
public static Microsoft.Xna.Framework.Rectangle ShrinkRectangle(Microsoft.Xna.Framework.Rectangle rectToShrink) { rectToShrink.Inflate( Math.Min(0, (1920 - rectToShrink.Width) / 2), Math.Min(0, (1200 - rectToShrink.Height) / 2)); return(rectToShrink); }
protected override void Attach() { int width = RenderRule.Width; int height = RenderRule.Height; Area = new Rectangle(Area.X, Area.Y, width, height); }
public static Microsoft.Xna.Framework.Rectangle FromTwoPoints(this Microsoft.Xna.Framework.Rectangle x, Microsoft.Xna.Framework.Point A, Microsoft.Xna.Framework.Point B) { int _MinX, _MinY; int _MaxX, _MaxY; if (A.X < B.X) { _MinX = A.X; _MaxX = B.X; } else { _MinX = B.X; _MaxX = A.X; } if (A.Y < B.Y) { _MinY = A.Y; _MaxY = B.Y; } else { _MinY = B.Y; _MaxY = A.Y; } return(new Microsoft.Xna.Framework.Rectangle(_MinX, _MinY, _MaxX - _MinX, _MaxY - _MinY)); }
void applyDeletionChanges(HistoryAction action, object obj) { TileChangesRegion changes = obj as TileChangesRegion; if (action == HistoryAction.Undo) { SelectionRectangle = new Rectangle(changes.Offset.X, changes.Offset.Y, changes.Region.Width, changes.Region.Height); } else { SelectionRectangle = Rectangle.Empty; } Rectangle offsetRect = new Rectangle(0, 0, changes.Region.Width, changes.Region.Height), changeRect = offsetRect; changeRect.X = Math.Max(0, changes.Offset.X); changeRect.Y = Math.Max(0, changes.Offset.Y); for (int x = changes.Offset.X, ox = 0; x < changes.Offset.X + changes.Region.Width; x++, ox++) { for (int y = changes.Offset.Y, oy = 0; y < changes.Offset.Y + changes.Region.Height; y++, oy++) { if (PointInWorld(x, y) && changeRect.Contains(x, y) && offsetRect.Contains(ox, oy)) { SetTile(x, y, changes.Region[ox, oy], changes.Layer); } } } SelectLayer(changes.Layer); }
public CSprite(string name) { SpriteData spriteData = SpriteManager.GetSpriteData(name); SpriteSheet = AssetManager.GetImage(spriteData.SpriteSheet); Source = new Microsoft.Xna.Framework.Rectangle(spriteData.X, spriteData.Y, spriteData.Width, spriteData.Height); }
protected override void Initialize() { Definitions.IsWideScreen = false; AddScene(new Scenes.NonGame.LoadingScene()); AddScene(new Scenes.NonGame.TitleScene()); AddScene(new Scenes.NonGame.CreditsScene()); AddScene(new Scenes.NonGame.DisplayCalibrationScene()); AddScene(new Scenes.NonGame.AvatarCustomisationScene()); AddScene(new Scenes.Gameplay.Survival.SurvivalGameplayScene()); AddScene(new Scenes.Gameplay.Survival.SurvivalAreaCompleteScene()); AddScene(new Scenes.Gameplay.Race.RaceStartScene()); AddScene(new Scenes.Gameplay.Race.RaceGameplayScene()); AddScene(new Scenes.Gameplay.Race.RaceFinishScene()); base.Initialize(); SceneTransitionCrossFadeTextureName = "pixel"; SceneBackBufferArea = new Microsoft.Xna.Framework.Rectangle(0, 0, 1440, 900); //SceneBackBufferArea = new Microsoft.Xna.Framework.Rectangle(0, 0, GraphicsAdapter.DefaultAdapter.CurrentDisplayMode.Width, GraphicsAdapter.DefaultAdapter.CurrentDisplayMode.Height); //SceneBackBufferArea = new Microsoft.Xna.Framework.Rectangle(0, 0, 1280, 768); //SceneBackBufferArea = new Microsoft.Xna.Framework.Rectangle(0, 0, 1200, 675); StartInitialScene(typeof(Scenes.NonGame.LoadingScene)); }
public ChildDialog(GraphicsControl sender, Rectangle rect, Dialog parent, DialogData data) : base(sender, rect, data) { ParentDialog = parent; //Parent = parent; ParentAttachPoint = Anchor.TopRight; }
public static Rectangle FromFramework(FrameworkRect rect) { return(new Rectangle() { X = rect.Left, Y = rect.Top, Width = rect.Width, Height = rect.Height }); }
override public void init(Microsoft.Xna.Framework.Rectangle screenSize) { int numButtons = 4; //init self base.init(screenSize); //this.Texture = TextureName.BasicButtonBackground; //init children saveButton = new Button(this, Renderer, new Microsoft.Xna.Framework.Rectangle(0, (ScreenSize.Height / numButtons) * 0, ScreenSize.Width, (ScreenSize.Height / numButtons)), "Save"); saveButton.setClick(() => { storageManager.SaveGame(); return(true); }); loadButton = new Button(this, Renderer, new Microsoft.Xna.Framework.Rectangle(0, (ScreenSize.Height / numButtons) * 1, ScreenSize.Width, (ScreenSize.Height / numButtons)), "Load"); loadButton.setClick(() => { storageManager.LoadGame(); return(true); }); resetButton = new Button(this, Renderer, new Microsoft.Xna.Framework.Rectangle(0, (ScreenSize.Height / numButtons) * 2, ScreenSize.Width, (ScreenSize.Height / numButtons)), "Reset Game"); resetButton.setClick(() => { storageManager.ResetGame(); return(true); }); backButton = new Button(this, Renderer, new Microsoft.Xna.Framework.Rectangle(0, (ScreenSize.Height / numButtons) * 3, ScreenSize.Width, (ScreenSize.Height / numButtons)), "Back"); backButton.setClick(() => { base.gameController.goToPreviousScreen(); return(true); }); }
/// <summary> /// Loads a spritesheet in from a texture 2d given the number of rows and columns. /// </summary> /// <param name="tex"></param> /// <param name="rows"></param> /// <param name="columns"></param> /// <returns></returns> public static List <Texture2D> LoadSpritesheetFromTexture(Texture2D tex, int rows, int columns) { var frames = new List <Texture2D>(); // Get the width and height of each individual texture. var imgWidth = tex.Width / columns; var imgHeight = tex.Height / rows; for (var i = 0; i < rows * columns; i++) { // Get the specific row and column from the index. var column = i / rows; var row = i % rows; var sourceRect = new Rectangle(imgWidth * column, imgHeight * row, imgWidth, imgHeight); var cropTexture = new Texture2D(GameBase.Game.GraphicsDevice, sourceRect.Width, sourceRect.Height); var data = new Color[sourceRect.Width * sourceRect.Height]; tex.GetData(0, sourceRect, data, 0, data.Length); cropTexture.SetData(data); frames.Add(cropTexture); } return(frames); }
public bool CanPlace(Microsoft.Xna.Framework.Rectangle area, bool[] validTiles, int padding = 0) { if (area.X < 0 || area.Y < 0 || (area.X + area.Width > Main.maxTilesX - 1 || area.Y + area.Height > Main.maxTilesY - 1)) { return(false); } var rectangle = new Microsoft.Xna.Framework.Rectangle(area.X - padding, area.Y - padding, area.Width + padding * 2, area.Height + padding * 2); for (var index = 0; index < this._structures.Count; ++index) { if (rectangle.Intersects(this._structures[index])) { return(false); } } for (var x = rectangle.X; x < rectangle.X + rectangle.Width; ++x) { for (var y = rectangle.Y; y < rectangle.Y + rectangle.Height; ++y) { if (Main.tile[x, y].active()) { var type = Main.tile[x, y].type; if (!validTiles[(int)type]) { return(false); } } } } return(true); }
public override void DrawTextures(Texture texture, int[] vertices, int offset, int count) { var bmp = texture.GetTexture(); if (bmp != null) { for (int i = 0; i < count; i++) { int idx = offset; int x = vertices[idx] + transX; int y = vertices[idx + 1] + transY; int width = vertices[idx + 2]; int height = vertices[idx + 3]; int srcX = vertices[idx + 4]; int srcY = vertices[idx + 5]; int srcWidth = vertices[idx + 6]; int srcHeight = vertices[idx + 7]; int trans = vertices[idx + 8]; int tint = vertices[idx + 9]; var dstRect = new Microsoft.Xna.Framework.Rectangle(x, y, width, height); var srcRect = new Microsoft.Xna.Framework.Rectangle(srcX, srcY, srcWidth, srcHeight); var c = Microsoft.Xna.Framework.Color.White; if (tint != 0xFFFFFF) { c = new Microsoft.Xna.Framework.Color((uint)tint); } if (trans > 0) { c *= (float)((255 - trans) / 256.0); } batch.Draw(bmp, dstRect, srcRect, c, 0.0f, Microsoft.Xna.Framework.Vector2.Zero, Microsoft.Xna.Framework.Graphics.SpriteEffects.None, 1.0f); offset += NUM_VERTICES; } } }
private void MapDisplay_MouseDown(object sender, MouseEventArgs e) { if (e.Button != MouseButtons.Left) { return; } MetadataDisplay.ObjectsInMap.ForEach(c => c.Selected = false); _currentPosition = _startPosition = CurrentPosition(e); var mouseSource = new Rectangle(_currentPosition.X, _currentPosition.Y, 1, 1); var actualObjectMap = MetadataDisplay.ObjectsInMap.FirstOrDefault(o => o.Source.Intersects(mouseSource)); if (actualObjectMap == null) { _isDrawing = true; } else { _isMove = true; MetadataDisplay.ActualObjectMap = actualObjectMap; MetadataDisplay.ActualObjectMap.Selected = true; _offset = _currentPosition - new Size( MetadataDisplay.ActualObjectMap.Source.X, MetadataDisplay.ActualObjectMap.Source.Y ); } }
public bool CanPlace(Microsoft.Xna.Framework.Rectangle area, bool[] validTiles, int padding = 0) { if (area.X < 0 || area.Y < 0 || (area.X + area.Width > Main.maxTilesX - 1 || area.Y + area.Height > Main.maxTilesY - 1)) { return(false); } Microsoft.Xna.Framework.Rectangle rectangle = new Microsoft.Xna.Framework.Rectangle(area.X - padding, area.Y - padding, area.Width + padding * 2, area.Height + padding * 2); for (int index = 0; index < this._structures.Count; ++index) { if (rectangle.Intersects(this._structures[index])) { return(false); } } for (int index1 = rectangle.X; index1 < rectangle.X + rectangle.Width; ++index1) { for (int index2 = rectangle.Y; index2 < rectangle.Y + rectangle.Height; ++index2) { if (Main.tile[index1, index2].active()) { ushort num = Main.tile[index1, index2].type; if (!validTiles[(int)num]) { return(false); } } } } return(true); }
public void Combine(List <Texture2D> textures, SpriteBatch spriteBatch, RenderTarget2D target, out Dictionary <Texture2D, Microsoft.Xna.Framework.Rectangle> mapping) { mapping = new Dictionary <Texture2D, Microsoft.Xna.Framework.Rectangle>(); textures.Sort((a, b) => System.Math.Max(a.Width, a.Height).CompareTo(System.Math.Max(b.Width, b.Height))); RectangleTree rectangleTree = new RectangleTree(); for (int i = 0; i < textures.Count; i++) { rectangleTree.TryInsert(i, textures[i].Width, textures[i].Height); } spriteBatch.GraphicsDevice.SetRenderTarget(target); spriteBatch.Begin(); foreach (var rectangle in rectangleTree.ClosedNodes) { var texture = textures[rectangle.ID]; spriteBatch.Draw(texture, new Microsoft.Xna.Framework.Vector2(rectangle.X, rectangle.Y), Microsoft.Xna.Framework.Color.White); var rectangleForMapping = new Microsoft.Xna.Framework.Rectangle(rectangle.X, rectangle.Y, rectangle.Width, rectangle.Height); mapping.Add(texture, rectangleForMapping); } spriteBatch.End(); }
public override void Render(Texture texture, int x, int y, int width, int height, int srcX, int srcY, int srcWidth, int srcHeight, int trans) { var bmp = texture.GetTexture(); if (bmp != null) { x += transX; y += transY; var dstRect = new Microsoft.Xna.Framework.Rectangle(x, y, width, height); var srcRect = new Microsoft.Xna.Framework.Rectangle(srcX, srcY, srcWidth, srcHeight); var col = Microsoft.Xna.Framework.Color.White; if (trans > 0) { col *= (float)((255 - trans) / 256.0); } batch.Draw(bmp, dstRect, srcRect, col, 0.0f, Microsoft.Xna.Framework.Vector2.Zero, Microsoft.Xna.Framework.Graphics.SpriteEffects.None, 1.0f); Logger.Detail("GFX", $"inside clip {x} {y} {clipRect}"); if (clipRect.IsEmpty) { Logger.Info("GFX", $"No Clip Rect!"); } } else { Logger.Detail("GFX", $"outside clip {x} {y} {clipRect}"); } }
public NinePatchImage(Texture2D texture) { _texture = texture; XnaColor[] data = new XnaColor[texture.Width * texture.Height]; texture.GetData(data); Stretch = new Area( vertical: GetLine(texture, data, 0, 1, 0, 0), horizontal: GetLine(texture, data, 1, 0, 0, 0)); Content = new Area( vertical: GetLine(texture, data, 0, 1, _texture.Width - 1, 0), horizontal: GetLine(texture, data, 1, 0, 0, _texture.Height - 1)); Width = _texture.Width - 2; Height = _texture.Height - 2; _leftTop = new XnaRectangle(1, 1, Stretch.Horizontal.Start, Stretch.Vertical.Start); _leftCenter = new XnaRectangle(1, Stretch.Vertical.Start, Stretch.Horizontal.Start, Stretch.Vertical.Size); _leftBottom = new XnaRectangle(1, Stretch.Vertical.End, Stretch.Horizontal.Start, texture.Height - 1 - Stretch.Vertical.End); _centerTop = new XnaRectangle(Stretch.Horizontal.Start, 1, Stretch.Horizontal.Size, Stretch.Vertical.Start); _center = new XnaRectangle(Stretch.Horizontal.Start, Stretch.Vertical.Start, Stretch.Horizontal.Size, Stretch.Vertical.Size); _centerBottom = new XnaRectangle(Stretch.Horizontal.Start, Stretch.Vertical.End, Stretch.Horizontal.Size, texture.Height - 1 - Stretch.Vertical.End); _rightTop = new XnaRectangle(Stretch.Horizontal.End, 1, texture.Width - 1 - Stretch.Horizontal.End, Stretch.Vertical.Start); _rightCenter = new XnaRectangle(Stretch.Horizontal.End, Stretch.Vertical.Start, texture.Width - 1 - Stretch.Horizontal.End, Stretch.Vertical.Size); _rightBottom = new XnaRectangle(Stretch.Horizontal.End, Stretch.Vertical.End, texture.Width - 1 - Stretch.Horizontal.End, texture.Height - 1 - Stretch.Vertical.End); }
public override void gameWindowSizeChanged(Microsoft.Xna.Framework.Rectangle oldBounds, Microsoft.Xna.Framework.Rectangle newBounds) { base.gameWindowSizeChanged(oldBounds, newBounds); this.setupBrushes(); this.drawPicker(); }
private static Vector2 FindPosition(Rectangle area, Points point) { switch (point) { case Points.Left: return new Vector2(area.Left, area.Top + (area.Height / 2)); case Points.Right: return new Vector2(area.Right, area.Top + (area.Height / 2)); case Points.Top: return new Vector2(area.Left + (area.Width / 2), area.Top); case Points.Bottom: return new Vector2(area.Left + (area.Width / 2), area.Bottom); case Points.Centre: return new Vector2(area.Center.X, area.Center.Y); case Points.TopLeft: return new Vector2(area.X, area.Y); case Points.TopRight: return new Vector2(area.X + area.Width, area.Y); case Points.BottomLeft: return new Vector2(area.X, area.Y + area.Height); case Points.BottomRight: return new Vector2(area.X + area.Width, area.Y + area.Height); default: return Vector2.Zero; } }
public BattleTile(Screen screen, Renderer renderer, Microsoft.Xna.Framework.Rectangle rect, Battle battle) { this.battle = battle; renderables = new List <PuppetBundle>(); captains = new List <CaptainBundle>(); //playerSquads = new List<BattlePuppetSquad>(); PuppetBundle temp; //playerSquads = battle.PlayerSquads; foreach (BattlePuppetSquad squad in battle.PlayerSquads) { foreach (BattlePuppet puppet in squad.puppets) { temp = new PuppetBundle(puppet, new RenderableElement(screen, renderer, puppet.ImageBox, puppet.Unit.Picture)); renderables.Add(temp); if (puppet.Unit.SquadPosition == 0) { CaptainBundle captainBundle = new CaptainBundle(screen, renderer, temp, squad); //captain captains.Add(captainBundle); } } } foreach (BattlePuppet puppet in battle.EnemyPuppets) { temp = new PuppetBundle(puppet, new RenderableElement(screen, renderer, puppet.ImageBox, puppet.Unit.Picture)); renderables.Add(temp); } //assign clickableElements to captains }
public void Combine(List<Texture2D> textures, SpriteBatch spriteBatch, RenderTarget2D target, out Dictionary<Texture2D, Microsoft.Xna.Framework.Rectangle> mapping) { mapping = new Dictionary<Texture2D, Microsoft.Xna.Framework.Rectangle>(); textures.Sort((a, b) => System.Math.Max(a.Width, a.Height).CompareTo(System.Math.Max(b.Width, b.Height))); RectangleTree rectangleTree = new RectangleTree(); for(int i = 0; i < textures.Count; i++) { rectangleTree.TryInsert(i, textures[i].Width, textures[i].Height); } spriteBatch.GraphicsDevice.SetRenderTarget(target); spriteBatch.Begin(); foreach(var rectangle in rectangleTree.ClosedNodes) { var texture = textures[rectangle.ID]; spriteBatch.Draw(texture, new Microsoft.Xna.Framework.Vector2(rectangle.X, rectangle.Y), Microsoft.Xna.Framework.Color.White); var rectangleForMapping = new Microsoft.Xna.Framework.Rectangle(rectangle.X, rectangle.Y, rectangle.Width, rectangle.Height); mapping.Add(texture, rectangleForMapping); } spriteBatch.End(); }
private Rectangle GetSelectedGroupRectangle() { Microsoft.Xna.Framework.Rectangle leftMost = selectedSprites[0].Bounds; Microsoft.Xna.Framework.Rectangle topMost = selectedSprites[0].Bounds; Microsoft.Xna.Framework.Rectangle rightMost = selectedSprites[0].Bounds; Microsoft.Xna.Framework.Rectangle bottomMost = selectedSprites[0].Bounds; foreach (Sprite currentSprite in selectedSprites) { if (currentSprite.Bounds.X < leftMost.X) { leftMost = currentSprite.Bounds; } if (currentSprite.Bounds.Y < topMost.Y) { topMost = currentSprite.Bounds; } if (currentSprite.Bounds.X + currentSprite.Bounds.Width > rightMost.X + rightMost.Width) { rightMost = currentSprite.Bounds; } if (currentSprite.Bounds.Y + currentSprite.Bounds.Height > bottomMost.Y + bottomMost.Width) { bottomMost = currentSprite.Bounds; } } return(new Rectangle(leftMost.X, topMost.Y, rightMost.X + rightMost.Width - leftMost.X, bottomMost.Y + bottomMost.Height - topMost.Y)); }
public MapTile(int X, int Y, int ID) { this.X = X; this.Y = Y; this.ID = ID; this.rect = TextureManager.getTileById(ID); }
/// <summary> /// Initializes a new instance of the <see cref="ImageBox"/> class. /// </summary> /// <param name="parent">This controls parent control.</param> /// <param name="texture">The texture.</param> /// <param name="colour">The colour.</param> /// <param name="sourceRectangle">The source rectangle.</param> public ImageBox(Control parent, Texture2D texture, Color colour, Rectangle? sourceRectangle) : base(parent) { Texture = texture; SourceRectangle = sourceRectangle; Colour = colour; }
internal override void Layout() { _innerTextBox.AbsoluteArea = new Rectangle(AbsoluteInputArea.X, AbsoluteInputArea.Y, Area.Width, Area.Height); _innerTextBox.SissorArea = Rectangle.Intersect(_innerTextBox.AbsoluteArea, SissorArea); base.Layout(); }
public void Draw(float alpha) { Microsoft.Xna.Framework.Rectangle destRect = new Microsoft.Xna.Framework.Rectangle(); Microsoft.Xna.Framework.Rectangle sourceRect = new Microsoft.Xna.Framework.Rectangle(); foreach (var t in Textures) { destRect.X = t.Position.X; destRect.Y = t.Position.Y; sourceRect.Width = destRect.Width = t.Texture.Width; sourceRect.Height = destRect.Height = t.Texture.Height; if (destRect.Width + destRect.X > Ogmo.CurrentLevel.Bounds.Width) { sourceRect.Width -= destRect.Width + destRect.X - Ogmo.CurrentLevel.Bounds.Width; destRect.Width -= destRect.Width + destRect.X - Ogmo.CurrentLevel.Bounds.Width; } if (destRect.Height + destRect.Y > Ogmo.CurrentLevel.Bounds.Height) { sourceRect.Height -= destRect.Height + destRect.Y - Ogmo.CurrentLevel.Bounds.Height; destRect.Height -= destRect.Height + destRect.Y - Ogmo.CurrentLevel.Bounds.Height; } Ogmo.EditorDraw.SpriteBatch.Draw(t.Texture, destRect, sourceRect, Microsoft.Xna.Framework.Color.White * alpha); } }
public void Draw(ISet<State> states, SpriteBatch spriteBatch, XnaRectangle position, XnaColor color) { int rowTopHeight = _centerTop.Height; int rowBottomHeight = _centerBottom.Height; int rowCenterHeight = position.Height - rowTopHeight - rowBottomHeight; int startY = position.Top; int rowCenterTop = startY + rowTopHeight; int rowBottomTop = startY + position.Height - rowBottomHeight; int colLeftWidth = _leftCenter.Width; int colRightWidth = _rightCenter.Width; int colCenterWidth = position.Width - colLeftWidth - colRightWidth; int startX = position.Left; int colCenterLeft = startX + colLeftWidth; int colRightLeft = startX + position.Width - colRightWidth; spriteBatch.Draw(_texture, new XnaRectangle(startX, startY, colLeftWidth, rowTopHeight), _leftTop, color); spriteBatch.Draw(_texture, new XnaRectangle(startX, rowCenterTop, colLeftWidth, rowCenterHeight), _leftCenter, color); spriteBatch.Draw(_texture, new XnaRectangle(startX, rowBottomTop, colLeftWidth, rowBottomHeight), _leftBottom, color); spriteBatch.Draw(_texture, new XnaRectangle(colCenterLeft, startY, colCenterWidth, rowTopHeight), _centerTop, color); spriteBatch.Draw(_texture, new XnaRectangle(colCenterLeft, rowCenterTop, colCenterWidth, rowCenterHeight), _center, color); spriteBatch.Draw(_texture, new XnaRectangle(colCenterLeft, rowBottomTop, colCenterWidth, rowBottomHeight), _centerBottom, color); spriteBatch.Draw(_texture, new XnaRectangle(colRightLeft, startY, colRightWidth, rowTopHeight), _rightTop, color); spriteBatch.Draw(_texture, new XnaRectangle(colRightLeft, rowCenterTop, colRightWidth, rowCenterHeight), _rightCenter, color); spriteBatch.Draw(_texture, new XnaRectangle(colRightLeft, rowBottomTop, colRightWidth, rowBottomHeight), _rightBottom, color); }
private void TilesetPictureBox_Click(object sender, EventArgs e) { if (tileset == null) { return; } MouseEventArgs mouseArgs = (MouseEventArgs)e; MonoGamePoint mousePoint = new MonoGamePoint(mouseArgs.X, mouseArgs.Y); List <MonoGameRectangle> frameRects = tileset.Frames; for (int i = 0; i < frameRects.Count; i++) { MonoGameRectangle scaledRect = frameRects[i].Scale(zoomLevels[currentZoomLevel]); if (scaledRect.Contains(mousePoint)) { selectedFrameIndex = i; TileSelect?.Invoke(tileset, selectedFrameIndex); RefreshFrames(); } } }
public NinePatch(Texture2D texture) { _texture = texture; XnaColor[] data = new XnaColor[texture.Width * texture.Height]; texture.GetData(data); Stretch = new Area( vertical: GetLine(texture, data, 1, 0, 0, 0), horizontal: GetLine(texture, data, 0, 1, 0, 0)); Content = new Area( vertical: GetLine(texture, data, 0, 1, _texture.Width - 1, 0), horizontal: GetLine(texture, data, 1, 0, 0, _texture.Height - 1)); Width = _texture.Width - 2; Height = _texture.Height - 2; _leftTop = new XnaRectangle(1, 1, Stretch.Horizontal.Start, Stretch.Vertical.Start); _leftCenter = new XnaRectangle(1, Stretch.Vertical.Start, Stretch.Horizontal.Start, Stretch.Vertical.Size); _leftBottom = new XnaRectangle(1, Stretch.Vertical.End, Stretch.Horizontal.Start, texture.Height - 1 - Stretch.Vertical.End); _centerTop = new XnaRectangle(Stretch.Horizontal.Start, 1, Stretch.Horizontal.Size, Stretch.Vertical.Start); _center = new XnaRectangle(Stretch.Horizontal.Start, Stretch.Vertical.Start, Stretch.Horizontal.Size, Stretch.Vertical.Size); _centerBottom = new XnaRectangle(Stretch.Horizontal.Start, Stretch.Vertical.End, Stretch.Horizontal.Size, texture.Height - 1 - Stretch.Vertical.End); _rightTop = new XnaRectangle(Stretch.Horizontal.End, 1, texture.Width - 1 - Stretch.Horizontal.End, Stretch.Vertical.Start); _rightCenter = new XnaRectangle(Stretch.Horizontal.End, Stretch.Vertical.Start, texture.Width - 1 - Stretch.Horizontal.End, Stretch.Vertical.Size); _rightBottom = new XnaRectangle(Stretch.Horizontal.End, Stretch.Vertical.End, texture.Width - 1 - Stretch.Horizontal.End, texture.Height - 1 - Stretch.Vertical.End); }
public override void Construct() { var font = Root.GetTileSheet("font10"); var size = font.MeasureString(Text); // TODO (mklingensmith) why do I need this padding? size.X = (int)(size.X * 1.25f); size.Y = (int)(size.Y * 1.75f); Font = "font10"; TextColor = new Microsoft.Xna.Framework.Vector4(1, 1, 1, 1); Border = "border-dark"; Rect = new Microsoft.Xna.Framework.Rectangle(0, 0, size.X, size.Y); TextVerticalAlign = Gui.VerticalAlign.Center; TextHorizontalAlign = Gui.HorizontalAlign.Center; OnUpdate = (sender, time) => { Update(DwarfTime.LastTime); }; if (OnClick == null) { OnClick = (sender, args) => { Root.DestroyWidget(this); }; } HoverTextColor = Microsoft.Xna.Framework.Color.LightGoldenrodYellow.ToVector4(); ChangeColorOnHover = true; Root.RegisterForUpdate(this); base.Construct(); }
public TileGfxPage(int x, int y, int width, int height, int page_index, Screens.TileGfxScreen.PageClickHandler onTileGfxPageHandler) { Area = new Rectangle(x, y, width, height); m_PageIndex = page_index; RenderRule.SetSize(width, height); m_OnClickHandler += onTileGfxPageHandler; }
public void Draw(SpriteBatch spriteBatch, XnaRectangle position, XnaColor color) { int rowTopHeight = _centerTop.Height; int rowBottomHeight = _centerBottom.Height; int rowCenterHeight = position.Height - rowTopHeight - rowBottomHeight; int startY = position.Top; int rowCenterTop = startY + rowTopHeight; int rowBottomTop = startY + position.Height - rowBottomHeight; int colLeftWidth = _leftCenter.Width; int colRightWidth = _rightCenter.Width; int colCenterWidth = position.Width - colLeftWidth - colRightWidth; int startX = position.Left; int colCenterLeft = startX + colLeftWidth; int colRightLeft = startX + position.Width - colRightWidth; spriteBatch.Draw(_texture, new XnaRectangle(startX, startY, colLeftWidth, rowTopHeight), _leftTop, color); spriteBatch.Draw(_texture, new XnaRectangle(startX, rowCenterTop, colLeftWidth, rowCenterHeight), _leftCenter, color); spriteBatch.Draw(_texture, new XnaRectangle(startX, rowBottomTop, colLeftWidth, rowBottomHeight), _leftBottom, color); spriteBatch.Draw(_texture, new XnaRectangle(colCenterLeft, startY, colCenterWidth, rowTopHeight), _centerTop, color); spriteBatch.Draw(_texture, new XnaRectangle(colCenterLeft, rowCenterTop, colCenterWidth, rowCenterHeight), _center, color); spriteBatch.Draw(_texture, new XnaRectangle(colCenterLeft, rowBottomTop, colCenterWidth, rowBottomHeight), _centerBottom, color); spriteBatch.Draw(_texture, new XnaRectangle(colRightLeft, startY, colRightWidth, rowTopHeight), _rightTop, color); spriteBatch.Draw(_texture, new XnaRectangle(colRightLeft, rowCenterTop, colRightWidth, rowCenterHeight), _rightCenter, color); spriteBatch.Draw(_texture, new XnaRectangle(colRightLeft, rowBottomTop, colRightWidth, rowBottomHeight), _rightBottom, color); }
protected override void Attach() { var key = _innerTextBox.RenderRule.Text ?? RenderRule.RenderManager.DefaultSkin; var height = RenderRule.RenderManager.Texts[key].SpriteFont.LineSpacing + (2 * RenderRule.BorderWidth); Area = new Rectangle(Area.X, Area.Y, Area.Width, height); }
/// <inheritdoc/> void IPresentationTarget.EndRender(RenderContext context) { if (!_rendering) return; #pragma warning disable 168 // ReSharper disable EmptyGeneralCatchClause try { var graphicsDevice = GraphicsService.GraphicsDevice; graphicsDevice.SetRenderTarget(null); context.RenderTarget = null; _renderTarget.Present(); #else int width = ClientSize.Width; int height = ClientSize.Height; var sourceRectangle = new Rectangle(0, 0, width, height); graphicsDevice.Present(sourceRectangle, null, Handle); } catch (Exception) { // Do nothing. This happens when the layout of the window changes during rendering. // For example, when the user docks windows an OutOfVideoMemoryException might occur. } finally { _rendering = false; } // ReSharper restore EmptyGeneralCatchClause #pragma warning restore 168 }
override public void init(Microsoft.Xna.Framework.Rectangle screenSize) { //init self base.init(screenSize); //this.texture = TextureName.MainScreenBackground; this.background.Texture = TextureName.MainScreenBackground; //init children var midWidth = ScreenSize.Width / 2; int numButtons = 4; title = new TextElement(this, Renderer, new Microsoft.Xna.Framework.Rectangle(0, (ScreenSize.Height / numButtons) * 0, ScreenSize.Width, (ScreenSize.Height / numButtons)), "Generic Strategy Game"); mapButton = new Button(this, Renderer, new Microsoft.Xna.Framework.Rectangle(0, (ScreenSize.Height / numButtons) * 1, ScreenSize.Width, (ScreenSize.Height / numButtons)), "Map"); mapButton.setClick(() => { base.gameController.goToScreen(ScreenState.MapScreenState); return(true); }); armyButton = new Button(this, Renderer, new Microsoft.Xna.Framework.Rectangle(0, (ScreenSize.Height / numButtons) * 2, ScreenSize.Width, (ScreenSize.Height / numButtons)), "Army"); armyButton.setClick(() => { base.gameController.goToScreen(ScreenState.ArmyScreenState); return(true); }); settingsButton = new Button(this, Renderer, new Microsoft.Xna.Framework.Rectangle(0, (ScreenSize.Height / numButtons) * 3, ScreenSize.Width, (ScreenSize.Height / numButtons)), "Settings"); settingsButton.setClick(() => { base.gameController.goToScreen(ScreenState.SettingScreenState); return(true); }); soundController.playSong("MagicalTheme"); }
public void SetPosition(Rectangle screenCoordinates, float depth = 0) { var pp = _device.PresentationParameters; var resolution = new Vector2(pp.BackBufferWidth, pp.BackBufferHeight); SetPosition(ToDeviceCoordinate(screenCoordinates.Left, screenCoordinates.Top, resolution), ToDeviceCoordinate(screenCoordinates.Right, screenCoordinates.Bottom, resolution), depth); }
public override void DrawImage(int x, int y, int w, int h, IImage image, float us, float vs, float ue, float ve, Color color, bool outLineOnly) { Texture2D texture = ((XNAImage)image).Texture; Microsoft.Xna.Framework.Rectangle destinationRectangle = new Microsoft.Xna.Framework.Rectangle(x, y, w, h); Microsoft.Xna.Framework.Color imageColor = new Microsoft.Xna.Framework.Color(color.R, color.G, color.B, color.A); Microsoft.Xna.Framework.Rectangle sourceRectangle = new Microsoft.Xna.Framework.Rectangle((int)(us * texture.Width), (int)(ue * texture.Height), (int)(vs * texture.Width), (int)(ve * texture.Height)); this.spriteBatch.Draw(texture, destinationRectangle, sourceRectangle, imageColor); }
public void Apply(ref ControlArea area, Rectangle parentArea, Points anchoredPoints) { if (AnchorControl != null) parentArea = AnchorControl.Area; Vector2 pointOnSelf = FindPosition(area.ToRectangle(), Start); Vector2 pointOnParent = FindPosition(parentArea, End); TranslateArea(ref area, pointOnParent - pointOnSelf + Offset, anchoredPoints); }
public Dialog(GraphicsControl sender, Rectangle rect, DialogData data) : base(sender, null, "dialog", data) { //Default values base.ImageType = ImageType.Border; base.Position = new Point(rect.X, rect.Y); base.Size = new Size(rect.Width, rect.Height); BackgroundVisible = true; base.RenderPriority = 512; }
public VirtualTexture(Texture2D texture, XnaRectangle uvBounds) { if (texture == null) { throw new ArgumentNullException("texture"); } XnaTexture = texture; Bounds = uvBounds; }
public Checkers(int m, int n, Point origin, Size square) { if ((m & 1) == (n & 1)) throw new Exception("Checker board must have even/odd M and N or vice versa."); WhiteColor = Color.White; BlackColor = Color.Black; OtherColor = Color.White; M = m; N = n; Square = square; Board = new Rect(origin.X, origin.Y, M * square.Width, N * square.Height); }
/// <summary> /// Create an input handler /// </summary> public InputHandler() { this.currentMousePosition = new Microsoft.Xna.Framework.Vector2(0, 0); this.mouseMovement = new Microsoft.Xna.Framework.Vector2(0, 0); this.boundingBox = new Microsoft.Xna.Framework.Rectangle(0, 0, 10, 10); this.leftClick = false; this.leftDrag = false; this.rightClick = false; this.rightDrag = false; this.releaseLeft = false; this.releaseRight = false; Microsoft.Xna.Framework.Input.Mouse.SetPosition(0, 0); this.currentMousePosition = new Microsoft.Xna.Framework.Vector2(0, 0); }
public override void Draw( Texture2D texture, Rectangle destinationRectangle, Rectangle sourceRectangle, Color color) { XnaTexture2D xnaTexture = texture.GetTexture as XnaTexture2D; XnaRectangle xnaDestination = new XnaRectangle( destinationRectangle.X, destinationRectangle.Y, destinationRectangle.Width, destinationRectangle.Height); XnaRectangle xnaSource = new XnaRectangle( sourceRectangle.X, sourceRectangle.Y, sourceRectangle.Width, sourceRectangle.Height); XnaColor xnaColor = new XnaColor(color.R, color.G, color.B, color.A); this.spriteBatch.Draw(xnaTexture, xnaDestination, xnaSource, xnaColor); }
public void Draw(Rectangle area) { var device = _vertices.GraphicsDevice; var pp = device.PresentationParameters; // ReSharper disable CompareOfFloatsByEqualityOperator if (_dirty || area != _previousArea || _screenHeight != pp.BackBufferHeight || _screenWidth != pp.BackBufferWidth) // ReSharper restore CompareOfFloatsByEqualityOperator { _screenHeight = pp.BackBufferHeight; _screenWidth = pp.BackBufferWidth; float x = (area.X / _screenWidth) * 2 - 1; float y = -((area.Y / _screenHeight) * 2 - 1); float width = (area.Width / _screenWidth) * 2; float height = (area.Height / _screenHeight) * 2; for (int i = 0; i < _data.Length; i++) { var position = new Vector3( x + (i / (float)(_data.Length - 1)) * width, (y - height) + _data[i] * height, 0); _transformedData[i] = new VertexPositionColor(position.ToXNA(), _colour); } _vertices.SetData<VertexPositionColor>(_transformedData); _dirty = false; _previousArea = area; } _effect.Techniques[0].Passes[0].Apply(); device.SetVertexBuffer(_vertices); device.DrawPrimitives(PrimitiveType.LineStrip, 0, _data.Length - 1); }
public bool CanPlace(Microsoft.Xna.Framework.Rectangle area, bool[] validTiles, int padding = 0) { if (area.X < 0 || area.Y < 0 || (area.X + area.Width > Main.maxTilesX - 1 || area.Y + area.Height > Main.maxTilesY - 1)) return false; Microsoft.Xna.Framework.Rectangle rectangle = new Microsoft.Xna.Framework.Rectangle(area.X - padding, area.Y - padding, area.Width + padding * 2, area.Height + padding * 2); for (int index = 0; index < this._structures.Count; ++index) { if (rectangle.Intersects(this._structures[index])) return false; } for (int index1 = rectangle.X; index1 < rectangle.X + rectangle.Width; ++index1) { for (int index2 = rectangle.Y; index2 < rectangle.Y + rectangle.Height; ++index2) { if (Main.tile[index1, index2].active()) { ushort num = Main.tile[index1, index2].type; if (!validTiles[(int)num]) return false; } } } return true; }
private void ReplaceSprite(Bitmap[] bmps, int frame) { var pixel = bmps[0]; //first search pixel for the bounding rectangle. var plock = pixel.LockBits(new Rectangle(0, 0, pixel.Width, pixel.Height), ImageLockMode.ReadOnly, PixelFormat.Format32bppArgb); var pdat = new byte[plock.Stride * plock.Height]; Marshal.Copy(plock.Scan0, pdat, 0, pdat.Length); int maxX = int.MinValue, maxY = int.MinValue, minX = int.MaxValue, minY = int.MaxValue; int index = 0; for (int y = 0; y < pixel.Height; y++) { for (int x = 0; x < pixel.Width; x++) { if (!(pdat[index] == 0 && pdat[index+1] == 255 && pdat[index+2] == 255)) { if (x < minX) minX = x; if (x > maxX) maxX = x; if (y < minY) minY = y; if (y > maxY) maxY = y; } index += 4; } } pixel.UnlockBits(plock); var rect = (minX == int.MaxValue) ? new Rectangle() : new Rectangle(minX, minY, (maxX - minX) + 1, (maxY - minY) + 1); var px = rect.Width * rect.Height; var locks = new BitmapData[3]; var data = new byte[3][]; var pxOut = new Microsoft.Xna.Framework.Color[px]; var depthOut = new byte[px]; for (int i=0; i<3; i++) { locks[i] = bmps[i].LockBits(rect, ImageLockMode.ReadOnly, PixelFormat.Format32bppArgb); data[i] = new byte[locks[i].Stride * locks[i].Height]; Marshal.Copy(locks[i].Scan0, data[i], 0, data[i].Length); } int scanStart = 0; int dstidx = 0; for (int y=0; y<locks[0].Height; y++) { int srcidx = scanStart; for (int j = 0; j < rect.Width; j++) { pxOut[dstidx] = new Microsoft.Xna.Framework.Color(data[0][srcidx + 2], data[0][srcidx + 1], data[0][srcidx], data[1][srcidx]); depthOut[dstidx] = data[2][srcidx]; srcidx += 4; dstidx++; } scanStart += locks[0].Stride; } //set data first. we also want to get back the a palette we can change PALT targ = null; Microsoft.Xna.Framework.Color[] used; Content.Content.Get().Changes.BlockingResMod(new ResAction(() => { var xnaRect = new Microsoft.Xna.Framework.Rectangle(rect.X, rect.Y, rect.Width, rect.Height); used = GraphicChunk.Frames[frame].SetData(pxOut, depthOut, xnaRect); var ownPalt = GraphicChunk.ChunkParent.Get<PALT>(GraphicChunk.Frames[frame].PaletteID); ushort freePalt = GraphicChunk.ChunkID; if (GraphicChunk.Frames[frame].PaletteID != 0 && ownPalt != null && ownPalt.References == 1) targ = ownPalt; else { var palts = GraphicChunk.ChunkParent.List<PALT>(); palts = (palts == null) ? new List<PALT>() : palts.OrderBy(x => x.ChunkID).ToList(); foreach (var palt in palts) { if (palt.ChunkID == freePalt) freePalt++; if (palt.PalMatch(used) || palt.References == 0) { targ = palt; break; } } } if (targ != null) { //replace existing palt. lock (targ) { if (targ.References == 0 || targ == ownPalt) targ.Colors = used; } Content.Content.Get().Changes.ChunkChanged(targ); GraphicChunk.Frames[frame].SetPalt(targ); } else { //we need to make a new PALT. //a bit hacky for now var nPalt = new PALT() { ChunkID = freePalt, ChunkLabel = GraphicChunk.ChunkLabel + " Auto PALT", AddedByPatch = true, ChunkProcessed = true, ChunkType = "PALT", RuntimeInfo = ChunkRuntimeState.Modified, Colors = used }; GraphicChunk.ChunkParent.AddChunk(nPalt); GraphicChunk.Frames[frame].SetPalt(nPalt); Content.Content.Get().Changes.ChunkChanged(nPalt); } }, GraphicChunk)); for (int i = 0; i < 3; i++) bmps[i].UnlockBits(locks[i]); }
/// <summary> /// Ends drawing the control. This is called after derived classes /// have finished their Draw method, and is responsible for presenting /// the finished image onto the screen, using the appropriate WinForms /// control handle to make sure it shows up in the right place. /// </summary> void EndDraw() { try { Rectangle sourceRectangle = new Rectangle(0, 0, ClientSize.Width, ClientSize.Height); GraphicsDevice.Present(sourceRectangle, null, this.Handle); } catch { // Present might throw if the device became lost while we were // drawing. The lost device will be handled by the next BeginDraw, // so we just swallow the exception. } }
public static void drawTo(Rectangle bounds, SpriteBatch sb) { if (!loadingPage) sb.Draw(texture, bounds, Color.White); else WebpageLoadingEffect.DrawLoadingEffect(bounds, sb, OS.currentInstance, true); }
void EndDraw( ) { try { if( GamerServicesDispatcher.IsInitialized ) { GamerServicesDispatcher.Update( ); } // The GFWL Guide only seems to work with Present with no // parameters if( m_HasGWFL ) { GraphicsDevice.Present( ); } else { Microsoft.Xna.Framework.Rectangle SourceRectangle = new Microsoft.Xna.Framework.Rectangle( 0, 0, ClientSize.Width, ClientSize.Height ); GraphicsDevice.Present( SourceRectangle, null, this.Handle ); } } catch { } }
public XnaRectangle GetContentArea(ISet<State> states, XnaRectangle area) { return new XnaRectangle( area.Left + Content.Horizontal.Start, area.Top + Content.Vertical.Start, area.Width - Content.Horizontal.Margin, area.Height - Content.Vertical.Margin); }
void EndDraw() { try { Rectangle sourceRectangle = new Rectangle(0, 0, ClientSize.Width, ClientSize.Height); GraphicsDevice.Present(sourceRectangle, null, this.Handle); } catch { } }
public ControlArea(Rectangle area) : this(area.X, area.Y, area.Width, area.Height) { }
private void UpdateAnchors() { Rectangle parentArea; var viewport = _device.Viewport; if (Parent != null) parentArea = Parent.Area; else if (RespectSafeArea) parentArea = viewport.TitleSafeArea; else parentArea = new Rectangle(0, 0, viewport.Width, viewport.Height); ControlArea area = new ControlArea(0, 0, (int)_size.X, (int)_size.Y); foreach (var side in _anchors) { if (_anchoredPoints.Selected(side.Key)) side.Value.Apply(ref area, parentArea, _anchoredPoints); } Area = area.ToRectangle(); }
private void FinishDraw() { try { Rectangle sourceRectangle = new Rectangle(0, 0, ClientSize.Width, ClientSize.Height); GraphicsDevice.Present(sourceRectangle, null, Handle); } catch { // GULP } }
public void updateTile() { //this.texture = TextureManager.getTileById(ID); this.rect = TextureManager.getTileById(ID); }
internal Microsoft.Xna.Framework.Rectangle GetScissorRectangleFor(Camera camera) { var ipso = ScissorIpso; if (ipso == null) { return new Microsoft.Xna.Framework.Rectangle( 0,0, camera.ClientWidth, camera.ClientHeight ); } else { float worldX = ipso.GetAbsoluteLeft(); float worldY = ipso.GetAbsoluteTop(); float screenX; float screenY; camera.WorldToScreen(worldX, worldY, out screenX, out screenY); int left = global::RenderingLibrary.Math.MathFunctions.RoundToInt(screenX); int top = global::RenderingLibrary.Math.MathFunctions.RoundToInt(screenY); worldX = ipso.GetAbsoluteRight(); worldY = ipso.GetAbsoluteBottom(); camera.WorldToScreen(worldX, worldY, out screenX, out screenY); int right = global::RenderingLibrary.Math.MathFunctions.RoundToInt(screenX); int bottom = global::RenderingLibrary.Math.MathFunctions.RoundToInt(screenY); left = System.Math.Max(0, left); top = System.Math.Max(0, top); right = System.Math.Max(0, right); bottom = System.Math.Max(0, bottom); left = System.Math.Min(left, camera.ClientWidth); right = System.Math.Min(right, camera.ClientWidth); top = System.Math.Min(top, camera.ClientHeight); bottom = System.Math.Min(bottom, camera.ClientHeight); if (ParentLayer != null) { var parentRectangle = ParentLayer.GetScissorRectangleFor(camera); if(top > parentRectangle.Bottom) { int m = 3; } left = System.Math.Max(left, parentRectangle.Left); right = System.Math.Min(right, parentRectangle.Right); top = System.Math.Max(top, parentRectangle.Top); bottom = System.Math.Min(bottom, parentRectangle.Bottom); } int width = System.Math.Max(0, right - left); int height = System.Math.Max(0, bottom - top); Microsoft.Xna.Framework.Rectangle thisRectangle = new Microsoft.Xna.Framework.Rectangle( left, top, width, height); return thisRectangle; } }
public override void RenderContent(RenderLayer renderContext, SpriteBatch spriteBatch) { Dictionary<string, Texture2D> brushClassOverlays = _form._brushClassOverlays; DynamicTileBrush brush = _form._brush; if (!brushClassOverlays.ContainsKey(brush.BrushClass.ClassName)) { System.Reflection.Assembly assembly = System.Reflection.Assembly.GetExecutingAssembly(); brushClassOverlays.Add(brush.BrushClass.ClassName, Texture2D.FromStream(spriteBatch.GraphicsDevice, assembly.GetManifestResourceStream("Treefrog.Icons.DynBrushOverlays." + brush.BrushClass.ClassName + ".png"))); } Texture2D overlay = brushClassOverlays[brush.BrushClass.ClassName]; int width = (int)(overlay.Width * renderContext.LevelGeometry.ZoomFactor * (brush.TileWidth / 16.0)); int height = (int)(overlay.Height * renderContext.LevelGeometry.ZoomFactor * (brush.TileHeight / 16.0)); Microsoft.Xna.Framework.Rectangle dstRect = new Microsoft.Xna.Framework.Rectangle(0, 0, width, height); spriteBatch.Draw(overlay, dstRect, new Microsoft.Xna.Framework.Color(1f, 1f, 1f, .5f)); }