本文整理汇总了C#中Microsoft.Xna.Framework.Graphics.SpriteBatch.DrawLine方法的典型用法代码示例。如果您正苦于以下问题:C# SpriteBatch.DrawLine方法的具体用法?C# SpriteBatch.DrawLine怎么用?C# SpriteBatch.DrawLine使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Microsoft.Xna.Framework.Graphics.SpriteBatch
的用法示例。
在下文中一共展示了SpriteBatch.DrawLine方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: Draw
public override void Draw(SpriteBatch sp)
{
Vector2 previousPosition = GetPosition(Vertices[0]);
for (int i = 1; i <= Vertices.Count; i++)
{
Vector2 position = GetPosition(i == Vertices.Count ? Vertices[0] : Vertices[i]);
sp.DrawLine(
previousPosition.X,
previousPosition.Y,
position.X,
position.Y, Color.White);
Vector2 axis = Vector2.Normalize(position - previousPosition);
sp.DrawLine(
previousPosition.X - ((previousPosition.X - position.X) / 2), previousPosition.Y - ((previousPosition.Y - position.Y) / 2),
(previousPosition.X) + axis.Y * 2000, (previousPosition.Y) - axis.X * 2000,
Color.Red);
if (_circleAxes.Count > 0)
{
sp.DrawLine(
previousPosition.X, previousPosition.Y,
(previousPosition.X) + _circleAxes[i - 1].X * 2000, (previousPosition.Y) - _circleAxes[i - 1].Y * -2000,
Color.Red);
}
previousPosition = position;
}
}
示例2: Draw
public void Draw(GameTime gameTime, GraphicsDevice graphicsDevice, SpriteBatch spriteBatch)
{
switch (_currentMap)
{
case SimulationScreenMap.Urban: _playerGame.UrbanMap.Draw(gameTime); break;
case SimulationScreenMap.Country: _playerGame.CountryMap.Draw(gameTime); break;
case SimulationScreenMap.Ocean: _playerGame.OceanMap.Draw(gameTime); break;
}
spriteBatch.DrawLine(150, 0, 150, graphicsDevice.Viewport.Height, Color.White);
spriteBatch.DrawLine(0, graphicsDevice.Viewport.Height - 100, graphicsDevice.Viewport.Width,
graphicsDevice.Viewport.Height - 100, Color.White);
/* Area selection */
Rectangle areaSelectionUrban = new Rectangle(5, graphicsDevice.Viewport.Height - 148, 43, 43);
Rectangle areaSelectionCountry = new Rectangle(53, graphicsDevice.Viewport.Height - 148, 43, 43);
Rectangle areaSelectionOcean = new Rectangle(101, graphicsDevice.Viewport.Height - 148, 43, 43);
spriteBatch.DrawRectangle(0, graphicsDevice.Viewport.Height - 174, 150, 75, Color.White);
spriteBatch.FillRectangle(areaSelectionUrban, (_currentMap == SimulationScreenMap.Urban ?
Color.LightGray : Color.Gray));
spriteBatch.DrawRectangle(areaSelectionUrban, Color.White);
spriteBatch.FillRectangle(areaSelectionCountry, (_currentMap == SimulationScreenMap.Country ?
Color.LightGray : Color.Gray));
spriteBatch.DrawRectangle(areaSelectionCountry, Color.White);
spriteBatch.FillRectangle(areaSelectionOcean, (_currentMap == SimulationScreenMap.Ocean ?
Color.LightGray : Color.Gray));
spriteBatch.DrawRectangle(areaSelectionOcean, Color.White);
}
开发者ID:jyavoc,项目名称:Project-Gaia,代码行数:28,代码来源:SimulationScreen+(Jacob+Deitloff's+conflicted+copy+2011-03-18).cs
示例3: Draw
public static void Draw( this Rectangle rectangle, SpriteBatch spriteBatch )
{
spriteBatch.DrawLine( new Vector2( rectangle.X, rectangle.Y ),
new Vector2( rectangle.X + rectangle.Width, rectangle.Y ), Color.Black );
spriteBatch.DrawLine( new Vector2( rectangle.X + rectangle.Width, rectangle.Y ),
new Vector2( rectangle.X + rectangle.Width, rectangle.Y + rectangle.Height ), Color.Black );
spriteBatch.DrawLine( new Vector2( rectangle.X + rectangle.Width, rectangle.Y + rectangle.Height ),
new Vector2( rectangle.X, rectangle.Y + rectangle.Height ), Color.Black );
spriteBatch.DrawLine( new Vector2( rectangle.X, rectangle.Y + rectangle.Height ),
new Vector2( rectangle.X, rectangle.Y ), Color.Black );
}
示例4: Draw
public void Draw(SortedDictionary<Identifier512, Peer> peers, SpriteBatch batch, Texture2D whitePixel)
{
var start = GetPosition(Start, peers);
batch.DrawLine(whitePixel, start, GetPosition(Target, peers), 2, Color.Black);
if (contacted != null)
foreach (var c in contacted)
batch.DrawLine(whitePixel, start, GetPosition(c, peers), 2, Color.Yellow);
if (heap != null)
foreach (var h in heap)
batch.DrawLine(whitePixel, start, GetPosition(h, peers), 2, Color.Green);
}
示例5: Draw
public void Draw(SpriteBatch spriteBatch, Color colour)
{
foreach(Vector2[] v in Edges)
{
spriteBatch.DrawLine(v[0], v[1], colour);
}
}
示例6: Draw
public override void Draw(SpriteBatch sp)
{
if (Vertices.Count == 0)
return;
Vector2 previousPosition = GetWorldPosition(Vertices[0]);
for (int i = 1; i <= Vertices.Count; i++)
{
Vector2 position = GetWorldPosition(i == Vertices.Count ? Vertices[0] : Vertices[i]);
sp.DrawLine(
previousPosition.X,
previousPosition.Y,
position.X,
position.Y, Color.Red);
/*
Vector2 axis = Vector2.Normalize(position - previousPosition);
sp.DrawLine(
(previousPosition.X + position.X) / 2f,
(previousPosition.Y + position.Y) / 2f,
(previousPosition.X) + axis.Y * 2000,
(previousPosition.Y) - axis.X * 2000,
Color.Red);
*/
previousPosition = position;
}
}
示例7: Draw
/// <summary>
/// Draw grid.
/// </summary>
public void Draw(SpriteBatch spriteBatch)
{
// Draw columns
for (int i = 1; i < _size.X; i++)
{
spriteBatch.DrawLine(1, Color.Gray,
_position + new Vector2(i * _cellSize, 0),
_position + new Vector2(i * _cellSize, _cellSize * _size.Y));
}
// Draw rows
for (int i = 1; i < _size.Y; i++)
{
spriteBatch.DrawLine(1, Color.Gray,
_position + new Vector2(0, i * _cellSize),
_position + new Vector2(_cellSize * _size.X, i * _cellSize));
}
}
示例8: OnDraw
/// <summary>
/// Called when drawing the HUD component.
/// </summary>
/// <param name="batch">The sprite batch instance.</param>
/// <param name="position"></param>
protected override void OnDraw(SpriteBatch batch, Vector2 position)
{
if (this.Visible)
{
// Background
batch.Draw(this.texture, new Rectangle((int)position.X, (int)position.Y, (int)this.Size.X, (int)this.Size.Y), this.color);
// Borders
batch.DrawLine(position, position + new Vector2(this.Size.X, 0), Color.Black); // topl -> topr
batch.DrawLine(position + new Vector2(this.Size.X, 0), position + new Vector2(this.Size.X, this.Size.Y), Color.Black); // topr -> botr
batch.DrawLine(position + new Vector2(this.Size.X, this.Size.Y), position + new Vector2(0, this.Size.Y), Color.Black); // botr -> botl
batch.DrawLine(position + new Vector2(0, this.Size.Y), position, Color.Black); // botl -> topl
// Font
var size = this.font.Content.MeasureString(this.Text);
batch.DrawFont(this.font.Content, position + (this.Size / 2) - new Vector2(0, size.Y / 2), FontAlignment.Center, Color.White, this.Text);
}
}
示例9: Draw
public void Draw( EditableCube.Face face, SpriteBatch spriteBatch, GameTime gameTime )
{
if ( !Started || face != mFace )
return;
Color color = ValidLine
? new Color( 0, 0, 0, 255 )
: new Color( 0, 0, 0, 128 );
spriteBatch.DrawLine( mLine, mTexture, color, 10 );
}
示例10: Draw
public override void Draw(SpriteBatch sp)
{
sp.DrawCircle(GetCenter().X, GetCenter().Y, Radius, 10, Color.White);
for (int i = 0; i < _axes.Count; i++)
{
float a = _axes[i].Y / _axes[i].X;
var x = new Vector2(GetCenter().X - (float)(Radius * Math.Cos(a)), GetCenter().Y - (float)(Radius * Math.Sin(a)));
var y = new Vector2(GetCenter().X + (float)(Radius * Math.Cos(a)), GetCenter().Y + (float)(Radius * Math.Sin(a)));
sp.DrawLine(x, y, Color.Red);
}
}
示例11: Draw
public override void Draw(SpriteBatch batch)
{
if (Points.Empty()) return;
var v2First = Points.First();
var v2A = v2First;
foreach (var v2B in Points.Skip(1))
{
batch.DrawLine(v2A, v2B, Colour, Thickness, 0, Texture);
v2A = v2B;
}
batch.DrawText(Font, Label, v2First, Colour.Invert());
}
示例12: Draw
public void Draw(SpriteBatch batch)
{
if (!IsVisible) return;
if (Vertices.Count == 0) return;
switch (Type)
{
case PrimitiveType.Pixel:
batch.PutPixel(Vertices[0], Color);
break;
case PrimitiveType.Line:
batch.DrawLine(Vertices[0], Vertices[1], Color, Thickness);
break;
}
}
示例13: Draw
public void Draw(SpriteBatch sb, GameTime gameTime)
{
foreach (Enemy e in Enemies)
{
e.Draw(sb, gameTime);
if (e != closestEnemy) continue;
sb.DrawRectangle(e.HitBox, Color.Red);
/*
Stencil.Write("D: " + Math.Round((e.Center - player.Center).Length(), 1, MidpointRounding.AwayFromZero), sb, e.X + 4, e.Y + e.Height - 3, 0.5f);
Stencil.Write("A: " + Math.Round(MathHelper.ToDegrees(player.Center.Angle(e.Center)), 1, MidpointRounding.AwayFromZero), sb, e.X + 4, e.Y + e.Height + 9, 0.5f);
Stencil.Write("L: " + e.Health, sb, e.X + 4, e.Y + e.Height + 21, 0.5F);
*/
if (e.Center.Y > 0)
sb.DrawLine(e.Center, player.Center, Color.Red);
}
}
示例14: DrawLinks
public void DrawLinks(SpriteBatch batch, ContentManager content, IDictionary<Identifier512, Peer> peers)
{
for (int i = 0; i < buckets.Length; i++)
{
if (buckets[i] != null)
{
for (int j = 0; j < buckets[i].Length; j++)
{
Peer otherPeer;
if (peers.TryGetValue(buckets[i][j], out otherPeer) && otherPeer.Position != Vector2.Zero)
{
batch.DrawLine(content.Load<Texture2D>("WhitePixel"), Position, otherPeer.Position, 1, Color.White);
}
}
}
}
}
示例15: LightningTexture
public LightningTexture(GraphicsDevice device, int width, int height)
: base(device, width, height)
{
anim = new AnimatedLightning(Vector2.Zero, new Vector2(width, height), 45, MathHelper.ToRadians(45), 0.7f, 5, 1, 10);
var sb = new SpriteBatch(device);
var target = new RenderTarget2D(GraphicsDevice, 50, 100, false
, GraphicsDevice.PresentationParameters.BackBufferFormat
, GraphicsDevice.PresentationParameters.DepthStencilFormat);
var oldTargets = GraphicsDevice.GetRenderTargets();
GraphicsDevice.SetRenderTarget(target);
sb.Begin();
foreach (var segment in anim.Segments)
{
sb.DrawLine(segment.From, segment.To, segment.Color);
}
sb.End();
GraphicsDevice.SetRenderTargets(oldTargets);
Color[] data = new Color[target.Width * target.Height];
target.GetData<Color>(data);
this.SetData<Color>(data);
}