Exemple #1
0
        public void Redraw()
        {
            const float eyesep   = 0.15f;
            const float viewDist = 3f;

            using (var g = Graphics.FromImage(_bitmap.Bitmap))
            {
                g.Clear(Color.Black);
            }

            if (IsAnaglyphic)
            {
                var left = StereoscopicMatrixL(_aspectRatio, _fov, _near, _far, eyesep,
                                               viewDist);

                DrawSinglePass(left, new MyColor(255, 0, 0), true);

                var right = StereoscopicMatrixR(_aspectRatio, _fov, _near, _far, eyesep,
                                                viewDist);

                DrawSinglePass(right, new MyColor(0, 255, 255), true);
            }
            else
            {
                var perspectiveMatrix = PerspectiveMatrix(_aspectRatio, _fov, _near, _far);
                DrawSinglePass(perspectiveMatrix, new MyColor(255, 255, 255), false);
                var middleX = _bitmap.Width / 2;
                var middleY = _bitmap.Height / 2;

                _bitmap.DrawLine(new Point(middleX - 10, middleY), new Point(middleX + 10, middleY), _cursor.Color);
                _bitmap.DrawLine(new Point(middleX, middleY - 10), new Point(middleX, middleY + 10), _cursor.Color);
            }
        }
Exemple #2
0
        public void DrawCurve(List <Vector2> parameters, DirectBitmap bitmap)
        {
            var m             = bitmap.Width;
            var mult          = (int)(m / (Math.PI * 2));
            var points        = parameters.Select(x => new Point((int)(x.X * mult), (int)(x.Y * mult))).ToList();
            var pointsClamped = points.Select(x => new Point(((x.X % m) + m) % m, ((x.Y % m) + m) % m)).ToList();

            var myColor = new MyColor(255, 255, 255);

            var lines = pointsClamped.Zip(pointsClamped.Skip(1), (x, y) => Tuple.Create(x, y))
                        .Where(x => (x.Item1.X - x.Item2.X) * (x.Item1.X - x.Item2.X) + (x.Item1.Y - x.Item2.Y) * (x.Item1.Y - x.Item2.Y) < 30).ToList();

            lines.ForEach(x => bitmap.DrawLine(x.Item1, x.Item2, myColor, false));
        }