public virtual void DrawLine(string color, float lineWidth, PointF ScreenFrom, PointF ScreenTo) { #if DOTNET // try to call the draw primitive DrawPrimitives?.DrawLine(color, lineWidth, ScreenFrom, ScreenTo); // normal GDI Pen p = new Pen(Brushes.Blue, lineWidth); oGraphics?.DrawLine(p, ScreenFrom, ScreenTo); #else this.context.save(); this.context.lineWidth = lineWidth; this.context.beginPath(); this.context.strokeStyle = color; this.context.moveTo(ScreenFrom.X, ScreenFrom.Y); this.context.lineTo(ScreenTo.X, ScreenTo.Y); this.context.closePath(); this.context.stroke(); this.context.restore(); #endif }
protected override void Draw(GameTime gameTime) { GraphicsDevice.Clear(Color.CornflowerBlue); spriteBatch.Begin(SpriteSortMode.Deferred, BlendState.NonPremultiplied, SamplerState.PointClamp, null, null, null, null); //player.Draw(gameTime); int pointsCount = 0; foreach (Point p in points) { pointsCount++; DrawPrimitives.DrawPoint(p, 2, Color.White); } DrawPrimitives.DrawPoint(line.P1, 2, Color.Red); DrawPrimitives.DrawPoint(line.P2, 2, Color.Blue); DrawPrimitives.DrawPoint(check, 5, Color.Green); DrawPrimitives.DrawLine(line, 2); spriteBatch.DrawString(console, pointsCount.ToString(), Vector2.Zero, Color.Black); spriteBatch.DrawString(console, pointsCount.ToString(), Vector2.Zero, Color.Black); spriteBatch.End(); base.Draw(gameTime); }