public void drawWorld(System.Drawing.Graphics g, bool drawPie) { System.Drawing.Brush myBrush = new System.Drawing.SolidBrush(System.Drawing.Color.Black); Draw(g); foreach (Predator a in Player) { if (drawPie) { float arc = 180F / a.sensors.Length; float f = a.heading * (360f / (2 * (float)Math.PI)) - 90; for (int i = 0; i < a.sensors.Length; f += arc, i++) { if (a.sensors[i] > 0) { ((SolidBrush)myBrush).Color = Color.FromArgb(255, (byte)(255 * (1 - a.sensors[i])), (byte)(255 * (1 - a.sensors[i]))); g.FillPie(myBrush, a.x - a.radius, Utilities.shiftDown+(a.y - a.radius), a.radius * 2, a.radius * 2, f, arc); //g.DrawPie(Pens.Black, a.x - a.radius, a.y - a.radius, a.radius * 2, a.radius * 2, f, arc); } else g.DrawPie(Pens.Black, a.x - a.radius, Utilities.shiftDown + (a.y - a.radius), a.radius * 2, a.radius * 2, f, arc); } } System.Drawing.Pen p=new Pen(System.Drawing.Color.Red,5f); g.DrawLine(p, a.x, Utilities.shiftDown + a.y, a.x + (float)Math.Cos(a.heading) * (25), Utilities.shiftDown + a.y + (float)Math.Sin(a.heading) * (25)); a.Draw(g); } foreach(Prey p in Enemy) { p.Draw(g); } }
private static void DrawPie(Lbl.Charts.Serie Serie, System.Drawing.Graphics Canvas, System.Drawing.Size Size) { decimal Sum = Serie.GetSum(); Rectangle PieRect = new Rectangle(0, 0, Size.Width, Size.Height); if (PieRect.Width > PieRect.Height) { PieRect.X += (PieRect.Width - PieRect.Height) / 2; PieRect.Width = PieRect.Height; } else { PieRect.Y += (PieRect.Height - PieRect.Width) / 2; PieRect.Height = PieRect.Width; } float LastAngle = 0; foreach (Lbl.Charts.Element El in Serie.Elements) { float ElementAngle = (float)(El.Value / Sum * 360); Canvas.FillPie(System.Drawing.Brushes.Tomato, PieRect, LastAngle, LastAngle + ElementAngle); LastAngle += ElementAngle; } LastAngle = 0; foreach (Lbl.Charts.Element El in Serie.Elements) { float ElementAngle = (float)(El.Value / Sum * 360); Canvas.DrawPie(System.Drawing.Pens.Black, PieRect, LastAngle, LastAngle + ElementAngle); LastAngle += ElementAngle; } }