public void DrawText(SpriteFont font, string[] text, Rectangle bounds, Cv_TextAlign horizontalAlign, Cv_TextAlign verticalAlign, Color color, float rotation, float scale, SpriteEffects effects, float layerDepth, bool noCamera = false) { float totalY = 0f; foreach (var line in text) { totalY += font.MeasureString(line).Y; } var currSubLayer = m_iCurrSubLayer / (MaxLayers * NUM_SUBLAYERS); var currY = -totalY / 2; foreach (var line in text) { Vector2 size = font.MeasureString(line); Vector2 pos = new Vector2(bounds.X + bounds.Width / 2, bounds.Y + bounds.Height / 2); Vector2 origin = new Vector2(size.X * 0.5f, 0); if (horizontalAlign == Cv_TextAlign.Left) { origin.X += bounds.Width / 2 - size.X / 2; } if (horizontalAlign == Cv_TextAlign.Right) { origin.X -= bounds.Width / 2 - size.X / 2; } if (verticalAlign == Cv_TextAlign.Top) { origin.Y += bounds.Height / 2 - totalY / 2; } if (verticalAlign == Cv_TextAlign.Bottom) { origin.Y -= bounds.Height / 2 - totalY / 2; } origin.Y -= currY; currY += size.Y; var newCommand = new Cv_DrawCommand(); newCommand.Type = Cv_DrawType.Text; newCommand.Text = line; newCommand.Font = font; newCommand.Dest = new Rectangle((int)pos.X, (int)pos.Y, 1, 1); newCommand.Color = color; newCommand.Rotation = rotation; newCommand.Origin = origin; newCommand.Effects = effects; newCommand.Layer = layerDepth; newCommand.TextScale = scale; newCommand.Scale = new Vector2(scale, scale); newCommand.NoCamera = noCamera; m_DrawList.Add(newCommand); } }
public void Draw(RenderTarget2D renderTarget2D, Vector2 position, Color color) { var newCommand = new Cv_DrawCommand(); newCommand.Type = Cv_DrawType.Sprite; newCommand.Texture = renderTarget2D; newCommand.Dest = new Rectangle((int)position.X, (int)position.Y, renderTarget2D.Width, renderTarget2D.Height); newCommand.Source = new Rectangle(0, 0, renderTarget2D.Width, renderTarget2D.Height); newCommand.Color = color; newCommand.Rotation = 0; newCommand.Origin = Vector2.Zero; newCommand.Effects = SpriteEffects.None; newCommand.Layer = 255; newCommand.NoCamera = false; newCommand.Scale = Vector2.One; m_DrawList.Add(newCommand); }
public void DrawText(SpriteFont font, string text, Vector2 position, Color color, bool noCamera = false) { var newCommand = new Cv_DrawCommand(); newCommand.Type = Cv_DrawType.Text; newCommand.Text = text; newCommand.Font = font; newCommand.Dest = new Rectangle((int)position.X, (int)position.Y, 1, 1); newCommand.Color = color; newCommand.Rotation = 0; newCommand.Origin = Vector2.Zero; newCommand.Effects = SpriteEffects.None; newCommand.Layer = 255; newCommand.TextScale = 1; newCommand.NoCamera = noCamera; newCommand.Scale = Vector2.One; m_DrawList.Add(newCommand); }
public void Draw(Texture2D texture, Vector3 position, Rectangle?sourceRectangle, Color color, float rotation, Vector2 origin, Vector2 scale, SpriteEffects effects, bool noCamera = false) { float width = sourceRectangle != null ? sourceRectangle.Value.Width : texture.Width; float height = sourceRectangle != null ? sourceRectangle.Value.Height : texture.Height; var newCommand = new Cv_DrawCommand(); newCommand.Type = Cv_DrawType.Sprite; newCommand.Texture = texture; newCommand.Dest = new Rectangle((int)position.X, (int)position.Y, (int)width, (int)height); newCommand.Source = sourceRectangle; newCommand.Color = color; newCommand.Rotation = rotation; newCommand.Origin = origin; newCommand.Effects = effects; newCommand.Layer = 255; newCommand.NoCamera = noCamera; newCommand.Scale = scale; m_DrawList.Add(newCommand); }
public void Draw(Texture2D texture, Rectangle destinationRectangle, Color color) { var newCommand = new Cv_DrawCommand(); newCommand.Type = Cv_DrawType.Sprite; newCommand.Texture = texture; newCommand.Dest = destinationRectangle; newCommand.Source = new Rectangle(0, 0, texture.Width, texture.Height); newCommand.Color = color; newCommand.Rotation = 0; newCommand.Origin = Vector2.Zero; newCommand.Effects = SpriteEffects.None; newCommand.Layer = 255; newCommand.NoCamera = false; var widthScale = (float)destinationRectangle.Width / texture.Width; var heightScale = (float)destinationRectangle.Height / texture.Height; newCommand.Scale = Vector2.One * new Vector2(widthScale, heightScale); m_DrawList.Add(newCommand); }
public void Draw(Texture2D texture, Rectangle destinationRectangle, Rectangle?sourceRectangle, Color color, float rotation, Vector2 scale, Vector2 origin, SpriteEffects effects, float layerDepth, bool noCamera = false) { var newCommand = new Cv_DrawCommand(); newCommand.Type = Cv_DrawType.Sprite; newCommand.Texture = texture; newCommand.Dest = destinationRectangle; newCommand.Source = sourceRectangle; newCommand.Color = color; newCommand.Rotation = rotation; newCommand.Origin = origin; newCommand.Effects = effects; newCommand.Layer = layerDepth; newCommand.NoCamera = noCamera; var widthScale = (float)destinationRectangle.Width / (sourceRectangle.HasValue ? sourceRectangle.Value.Width : texture.Width); var heightScale = (float)destinationRectangle.Height / (sourceRectangle.HasValue ? sourceRectangle.Value.Height : texture.Height); newCommand.Scale = scale * new Vector2(widthScale, heightScale); m_DrawList.Add(newCommand); }