Esempio n. 1
0
        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);
            }
        }
        /// <summary>
        /// Fill a pie on the canvas
        /// </summary>
        /// <param name="canvas">The canvas in which a pie is filled</param>
        public void Fill(System.Drawing.Graphics canvas)
        {
            double	startAngle, endAngle;

            startAngle = System.Math.Atan2(m_points[2].y - (m_points[1].y + m_points[0].y) / 2, m_points[2].x - (m_points[1].x + m_points[0].x) / 2);
            if (startAngle < 0)
            {
                startAngle += System.Math.PI * 2;
            }
            startAngle = (startAngle / Math.PI) * 180;

            endAngle = System.Math.Atan2(m_points[3].y - (m_points[1].y + m_points[0].y) / 2, m_points[3].x - (m_points[1].x + m_points[0].x) / 2);
            if (endAngle < 0)
            {
                endAngle += System.Math.PI * 2;
            }
            endAngle = (endAngle / Math.PI) * 180;

            endAngle -= startAngle;
            if (endAngle < 0)
            {
                endAngle += 360;
            }

            canvas.FillPie(m_style.fillingStyle, m_points[0].x, m_points[0].y, m_points[1].x - m_points[0].x, m_points[1].y - m_points[0].y, (float)startAngle, (float)endAngle);
        }
Esempio n. 3
0
                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;
                        }
                }
Esempio n. 4
0
        public void Paint(System.Drawing.Graphics grfx, float width, float height)
        {
            coordinateSystem.ComputeMinMaxBox(out min, out max);

            width -= 2 * padding;
            height -= 2 * padding;
            ratio = (float)Math.Min(width / (max.X - min.X), height / (max.Y - min.Y));

            foreach (Point point in coordinateSystem.PartialMap.Points)
            {
                System.Drawing.SizeF sz = new System.Drawing.SizeF(1, 1);
                System.Drawing.PointF pt = PointToScreen(point);
                pt.X -= sz.Width / 2;
                pt.Y -= sz.Height / 2;
                System.Drawing.RectangleF rect = new System.Drawing.RectangleF(pt, sz);
                grfx.FillPie(System.Drawing.Brushes.Gray, pt.X, pt.Y, sz.Width, sz.Height, 0, 360);
            }
            foreach (Edge edge in coordinateSystem.PartialMap.Edges)
                grfx.DrawLine(System.Drawing.Pens.Black, PointToScreen(edge.P1), PointToScreen(edge.P2));
            foreach (Zeebot zeebot in zeebots)
            {
                System.Drawing.SizeF sz = new System.Drawing.SizeF(4, 4);
                System.Drawing.PointF pt = PointToScreen(zeebot.Location);
                pt.X -= sz.Width / 2;
                pt.Y -= sz.Height / 2;
                System.Drawing.RectangleF rect = new System.Drawing.RectangleF(pt, sz);
                grfx.FillPie(System.Drawing.Brushes.Green, pt.X, pt.Y, sz.Width, sz.Height, 0, 360);
            }
        }