private static void Draw(SpriteBatch sprites, Texture t, GameObject o, IViewport viewport) { var screenPosition = viewport.GetScreenPosition(o.World); sprites.Draw(t.Value, screenPosition.ToRectangle(), t.SourceRect, t.Tint, screenPosition.Rotation.Radians, Vector2.Zero, SpriteEffects.None, screenPosition.ZIndex.AsDepth()); }
public void Draw(IEntities entities, SpriteBatch sprites, IViewport viewport) { entities.With <BorderTexture>((o, b) => { var screenPosition = viewport.GetScreenPosition(o.World.Expanded(new Size2(b.Width, b.Width))); sprites.Draw(b.Value, screenPosition.ToRectangle(), null, Color.White, screenPosition.Rotation.Radians, Vector2.Zero, SpriteEffects.None, (screenPosition.ZIndex - 1).AsDepth()); }); }
private static void RenderText(SpriteBatch sprites, TextDisplay t, GameObject o, IViewport viewport) { var spriteFont = GameInstance.TheGame.Content.Load <SpriteFont>(t.Font); var wrapped = new WrappingText(() => spriteFont, () => o.World.WithPadding(t.Margin).ToRectangle().Width).Wrap(t.Text()); var size = spriteFont.MeasureString(wrapped); var screenPosition = viewport.GetScreenPosition(o.World.WithPadding(t.Margin)); sprites.DrawString(spriteFont, wrapped, AlignPositions[t.Align](screenPosition.ToRectangle(), size).ToPoint().ToVector2(), t.Color, screenPosition.Rotation.Radians, Vector2.Zero, 1, SpriteEffects.None, (o.World.ZIndex + 1).AsDepth()); }
public void Draw(IEntities entities, SpriteBatch sprites, IViewport viewport) { entities.With <HighlightColor>((o, h) => { var screenPosition = viewport.GetScreenPosition(o.World.Expanded(new Size2(h.Width, h.Width))); var texture = new RoundedRectangleTexture(screenPosition.Size, h.Width, h.CornerRadius, new List <Color> { Color.FromNonPremultiplied(h.Color.R, h.Color.G, h.Color.B, Math.Min(h.MaxOpacity, h.Color.A)), Color.FromNonPremultiplied(h.Color.R, h.Color.G, h.Color.B, h.MinOpacity) }).Create(); sprites.Draw(texture, screenPosition.ToRectangle(), null, Color.White, screenPosition.Rotation.Radians, Vector2.Zero, SpriteEffects.None, (screenPosition.ZIndex + h.Offset).AsDepth()); }); }