WorldToScreen() public static méthode

public static WorldToScreen ( DVector2 point, RectangleD cameraBounds ) : PointF
point VectorMath.DVector2
cameraBounds VectorMath.RectangleD
Résultat System.Drawing.PointF
Exemple #1
0
        public void Draw(Graphics graphics, Camera camera)
        {
            if (camera.Contains(_position))
            {
                camera.ApplyScreenRotation(graphics);

                PointF flameSource = RenderUtils.WorldToScreen(_position, camera.Bounds);
                flameSource.X -= (float)(40 / camera.Zoom);
                flameSource.Y += (float)(121 / camera.Zoom);

                float  scale    = (float)(_throttle / camera.Zoom);
                float  flameX   = (float)(Math.Cos(_retrograde) * scale);
                float  flameY   = (float)(Math.Sin(_retrograde) * scale);
                PointF flameTip = new PointF(flameSource.X + flameX, flameSource.Y + flameY);

                Color colSupersonic = Color.FromArgb(63, 195, 135, 255);
                //Brush brSupersonic = new SolidBrush(colSupersonic);

                //GraphicsPath graphPath = new GraphicsPath();
                //PointF corner1 = new PointF(flameSource.X - flameX / 10f, flameSource.Y + flameY / 10);
                //graphPath.AddLine(flameSource, corner1);
                //PointF corner2 = new PointF(flameTip.X - flameX / 10f, flameTip.Y + flameY / 10);
                //graphPath.AddLine(flameSource, corner2);
                //PointF corner3 = new PointF(flameTip.X + flameX / 10f, flameTip.Y - flameY / 10);
                //graphPath.AddLine(flameSource, corner3);
                //PointF corner4 = new PointF(flameSource.X + flameX / 10f, flameSource.Y - flameY / 10);
                //graphPath.AddLine(flameSource, corner4);

                //graphics.FillPath(brSupersonic, graphPath);

                graphics.DrawLine(new Pen(colSupersonic, scale / 50), flameSource, flameTip);

                graphics.ResetTransform();
            }
        }
Exemple #2
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);
        }
Exemple #3
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));
        }
Exemple #4
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));
        }