Пример #1
0
        void RenderClosedCurves(XGraphics gfx)
        {
            gfx.TranslateTransform(15, 20);

            XPen pen = new XPen(XColors.DarkBlue, 2.5);

            gfx.DrawClosedCurve(pen, XBrushes.SkyBlue,
                                new XPoint[] { new XPoint(10, 120), new XPoint(80, 30), new XPoint(220, 20), new XPoint(170, 110), new XPoint(100, 90) },
                                XFillMode.Winding, 0.7);
        }
Пример #2
0
        static void DrawClosedCurve(XGraphics gfx, int number)
        {
            BeginBox(gfx, number, "DrawClosedCurve");

            XPen pen = new XPen(XColors.DarkBlue, 2.5);

            gfx.DrawClosedCurve(pen, XBrushes.SkyBlue,
                                new XPoint[] { new XPoint(10, 120), new XPoint(80, 30), new XPoint(220, 20), new XPoint(170, 110), new XPoint(100, 90) },
                                XFillMode.Winding, 0.7);

            EndBox(gfx);
        }
Пример #3
0
        private void DrawClosedCurve(XGraphics gfx, int number)
        {
            base.BeginBox(gfx, number, "DrawClosedCurve");
            XPen pen = new XPen(XColors.DarkBlue, 2.5);

            gfx.DrawClosedCurve(pen, XBrushes.SkyBlue, new XPoint[]
            {
                new XPoint(10.0, 120.0),
                new XPoint(80.0, 30.0),
                new XPoint(220.0, 20.0),
                new XPoint(170.0, 110.0),
                new XPoint(100.0, 90.0)
            }, XFillMode.Winding, 0.7);
            base.EndBox(gfx);
        }
        /// <summary>
        /// Demonstrates the use of XGraphics.DrawClosedCurve.
        /// </summary>
        public override void RenderPage(XGraphics gfx)
        {
            base.RenderPage(gfx);

            XPoint[] points = new XPoint[]
            {
                new XPoint(50, 100),
                new XPoint(450, 120),
                new XPoint(550, 300),
                //new XPoint(150, 380),
            };

            gfx.DrawClosedCurve(properties.Pen2.Pen, properties.Brush1.Brush, points,
                                properties.General.FillMode, properties.General.Tension);
        }
Пример #5
0
        /// <summary>
        /// Source and more infos: http://www.math.dartmouth.edu/~dlittle/java/SpiroGraph/
        /// </summary>
        public override void RenderPage(XGraphics gfx)
        {
            base.RenderPage(gfx);

            //int R =  60, r =  60, p =   60, N = 270; // Cardioid
            //int R =  60, r = -45, p = -101, N = 270; // Rounded Square
            //int R =  75, r = -25, p =   85, N = 270; // Gold fish
            //int R =  75, r = -30, p =   60, N = 270; // Star fish
            //int R = 100, r =  49, p =   66, N =   7; // String of Pearls
            //int R =  90, r =   1, p =  105, N = 105; // Rotating Triangle

            //int R =  90, r =   1, p =  105, N = 105;
            int R = 60, r = 2, p = 122, N = 490;

            int revs = Math.Abs(r) / Gcd(R, Math.Abs(r));

            XPoint[] points = new XPoint[revs * N + 1];
            for (int i = 0; i <= revs * N; i++)
            {
                double t = 4 * i * Math.PI / N;
                points[i].X = ((R + r) * Math.Cos(t) - p * Math.Cos((R + r) * t / r));
                points[i].Y = ((R + r) * Math.Sin(t) - p * Math.Sin((R + r) * t / r));
            }

#if true
            // Draw as lines
            gfx.TranslateTransform(300, 250);
            gfx.DrawLines(properties.Pen2.Pen, points);

            //gfx.DrawPolygon(properties.Pen2.Pen, properties.Brush2.Brush, points, properties.General.FillMode);

            // Draw as closed curve
            gfx.TranslateTransform(0, 400);
            gfx.DrawClosedCurve(properties.Pen2.Pen, properties.Brush2.Brush, points, properties.General.FillMode,
                                properties.General.Tension);
#else
            gfx.TranslateTransform(300, 400);
            XSolidBrush dotBrush = new XSolidBrush(properties.Pen2.Pen.Color);
            float       width    = properties.Pen2.Width;
            for (int i = 0; i < revs * N; i++)
            {
                gfx.DrawEllipse(dotBrush, points[i].X, points[i].Y, width, width);
            }
#endif
        }