public override void Render(DrawBatch drawBatch, float zoomFactor) { if (IsDisposed) return; InitializeResources(drawBatch.GraphicsDevice); Rectangle rect = new Rectangle( (int)(Math.Min(_data.Start.X, _data.End.X) * zoomFactor), (int)(Math.Min(_data.Start.Y, _data.End.Y) * zoomFactor), (int)(Math.Abs(_data.End.X - _data.Start.X) * zoomFactor), (int)(Math.Abs(_data.End.Y - _data.Start.Y) * zoomFactor) ); if (FillGlow != null) drawBatch.FillRectangle(FillGlow, new Rectangle(rect.X - 1, rect.Y - 1, rect.Width + 2, rect.Height + 2)); if (Fill != null) drawBatch.FillRectangle(Fill, rect); if (OutlineGlow != null) drawBatch.DrawRectangle(OutlineGlow, rect); if (Outline != null) { if (Outline is PrimitivePen) drawBatch.DrawPrimitiveRectangle(Outline, rect); else drawBatch.DrawRectangle(Outline, rect); } }
public override void Render(DrawBatch drawBatch, float zoomFactor) { if (IsDisposed) return; InitializeResources(drawBatch.GraphicsDevice); Vector2 center = new Vector2((int)(_data.Center.X * zoomFactor), (int)(_data.Center.Y * zoomFactor)); float size = _data.Size; Rectangle rect = new Rectangle((int)(center.X - size), (int)(center.Y - size), (int)(size * 2), (int)(size * 2)); if (FillGlow != null) drawBatch.FillRectangle(FillGlow, new Rectangle(rect.X - 1, rect.Y - 1, rect.Width + 2, rect.Height + 2)); if (Fill != null) drawBatch.FillRectangle(Fill, rect); if (OutlineGlow != null) drawBatch.DrawRectangle(OutlineGlow, rect); if (Outline != null) { if (Outline is PrimitivePen) drawBatch.DrawPrimitiveRectangle(Outline, rect); else drawBatch.DrawRectangle(Outline, rect); } }
public override void Draw(DrawBatch drawBatch) { drawBatch.DrawLine(_thickBlue, new CCVector2(50, 50), new CCVector2(250, 50)); drawBatch.DrawPath(_wavyPath); drawBatch.DrawRectangle(_thickMagenta, new CCRect(50, 160, 200, 100)); drawBatch.DrawCircle(_thickBlack, new CCVector2(350, 100), 50); drawBatch.DrawCircle(_thickDarkGray, new CCVector2(350, 225), 50, 16); drawBatch.DrawRectangle(_thickGreen, new CCRect(50, 350, 200, 100), (float)Math.PI / 4f); }
protected override void RenderContent(DrawBatch drawBatch) { ILevelGeometry geometry = LevelGeometry; Rectangle levelBounds = geometry.LevelBounds.ToXnaRectangle(); Rectangle bounds = new Rectangle( (int)Math.Ceiling(levelBounds.X * geometry.ZoomFactor), (int)Math.Ceiling(levelBounds.Y * geometry.ZoomFactor), (int)(levelBounds.Width * geometry.ZoomFactor), (int)(levelBounds.Height * geometry.ZoomFactor) ); if (levelBounds.X != 0) drawBatch.DrawLine(Pens.Gray, new Vector2(0, bounds.Top), new Vector2(0, bounds.Bottom)); if (levelBounds.Y != 0) drawBatch.DrawLine(Pens.Gray, new Vector2(bounds.Left, 0), new Vector2(bounds.Right, 0)); drawBatch.DrawRectangle(Pens.Black, bounds); }
private void DrawObjectAction(DrawBatch drawBatch) { if (_sourceImage == null) return; drawBatch.GraphicsDevice.ScissorRectangle = Xna.Rectangle.Empty; if (_objectBrush == null) _objectBrush = new TextureBrush(_sourceImage.CreateTexture(_drawControl.GraphicsDevice)) { OwnsTexture = true }; if (_maskPen == null) _maskPen = new Pen(new CheckerBrush(_drawControl.GraphicsDevice, Xna.Color.Black, Xna.Color.White, 4, .75f), true); int originX = (_drawControl.Width - _sourceImage.Width) / 2; int originY = (_drawControl.Height - _sourceImage.Height) / 2; _objectBrush.Transform = Xna.Matrix.CreateTranslation(-(float)originX / _sourceImage.Width, -(float)originY / _sourceImage.Height, 0); drawBatch.Begin(); drawBatch.FillRectangle(_objectBrush, new Xna.Rectangle(originX, originY, _sourceImage.Width, _sourceImage.Height)); drawBatch.DrawRectangle(_maskPen, new Microsoft.Xna.Framework.Rectangle( originX - 1 + (_maskLeft ?? 0) + (_originX ?? 0), originY - 1 + (_maskTop ?? 0) + (_originY ?? 0), 1 + (_maskRight - _maskLeft) ?? 0, 1 + (_maskBottom - _maskTop) ?? 0)); drawBatch.FillCircle(Brush.White, new Xna.Vector2(originX + _originX ?? 0, originY + _originY ?? 0), 4, 12); drawBatch.FillCircle(Brush.Black, new Xna.Vector2(originX + _originX ?? 0, originY + _originY ?? 0), 3, 12); drawBatch.End(); }