DrawRectangles() public static method

public static DrawRectangles ( Graphics graphics, List rectangles, Color color ) : void
graphics System.Drawing.Graphics
rectangles List
color System.Drawing.Color
return void
Ejemplo n.º 1
0
        public void Draw(Graphics graphics, Camera camera, IMassiveBody parentBody)
        {
            var poweredTrails = new List <RectangleF>();
            var coastTrails   = new List <RectangleF>();

            for (int i = 0; i < _trailAngles.Count; i++)
            {
                double angle    = _trailAngles[i] + parentBody.Pitch;
                double distance = _trailDistances[i];

                DVector2 worldPoint = DVector2.FromAngle(angle) * distance + parentBody.Position;

                if (camera.Contains(worldPoint))
                {
                    PointF localPoint = RenderUtils.WorldToScreen(worldPoint, camera.Bounds);

                    if (_trailPowered[i])
                    {
                        poweredTrails.Add(new RectangleF(localPoint.X, localPoint.Y, 2, 2));
                    }
                    else
                    {
                        coastTrails.Add(new RectangleF(localPoint.X, localPoint.Y, 2, 2));
                    }
                }
            }

            RenderUtils.DrawRectangles(graphics, poweredTrails, Color.Red);
            RenderUtils.DrawRectangles(graphics, coastTrails, Color.White);
        }
Ejemplo n.º 2
0
        public void Draw(Graphics graphics, RectangleD cameraBounds)
        {
            var particleBounds = new List <RectangleF>();

            float particleScale;

            // Scale particle size with viewport width
            if (cameraBounds.Width > 1000)
            {
                particleScale = 1;
            }
            else
            {
                particleScale = (float)(1.22e-6 * cameraBounds.Width * cameraBounds.Width - 4.8e-3 * cameraBounds.Width + 4.4);
            }

            float halfParticleScale = particleScale * 0.5f;

            foreach (Particle particle in _particles)
            {
                if (particle.IsActive)
                {
                    if (cameraBounds.Contains(particle.Position))
                    {
                        PointF localPoint = RenderUtils.WorldToScreen(particle.Position, cameraBounds);

                        particleBounds.Add(new RectangleF(localPoint.X - halfParticleScale,
                                                          localPoint.Y - halfParticleScale,
                                                          particleScale, particleScale));
                    }
                }
            }

            RenderUtils.DrawRectangles(graphics, particleBounds, Color.FromArgb(200, 255, 255, 0));
        }
Ejemplo n.º 3
0
        public void Draw(Graphics graphics, RectangleD cameraBounds)
        {
            var particleBounds = new List <RectangleF>();

            foreach (Particle particle in _particles)
            {
                if (particle.IsActive)
                {
                    if (cameraBounds.Contains(particle.Position))
                    {
                        PointF localPoint = RenderUtils.WorldToScreen(particle.Position, cameraBounds);

                        particleBounds.Add(new RectangleF(localPoint.X, localPoint.Y, 1.5f, 1.5f));
                    }
                }
            }

            RenderUtils.DrawRectangles(graphics, particleBounds, Color.FromArgb(200, 255, 255, 0));
        }