System.Drawing.Graphics.DrawClosedCurve C# (CSharp) Method

DrawClosedCurve() public method

public DrawClosedCurve ( Pen pen, PointF points, float tension, FillMode fillmode ) : void
pen Pen
points PointF
tension float
fillmode FillMode
return void
        public void DrawClosedCurve(Pen pen, PointF [] points, float tension, FillMode fillmode)
        {
            if (pen == null)
                throw new ArgumentNullException ("pen");
            if (points == null)
                throw new ArgumentNullException ("points");

            int count = points.Length;
            if (count == 2)
                DrawPolygon (pen, points);
            else {
                int segments = (count > 3) ? (count-1) : (count-2);

                var tangents = GeomUtilities.GetCurveTangents (GraphicsPath.CURVE_MIN_TERMS, points, count, tension, CurveType.Close);
                MakeCurve (points, tangents, 0, segments, CurveType.Close);
                StrokePen (pen);
            }
        }

Same methods

Graphics::DrawClosedCurve ( Pen pen, Point points ) : void
Graphics::DrawClosedCurve ( Pen pen, Point points, float tension, FillMode fillmode ) : void
Graphics::DrawClosedCurve ( Pen pen, PointF points ) : void

Usage Example

Example #1
0
        /// <summary>
        /// Draws the shape.
        /// </summary>
        /// <param name="G">The g.</param>
        /// <param name="FillShape">The fill shape.</param>
        /// <param name="DrawShape">The draw shape.</param>
        /// <exception cref="ArgumentOutOfRangeException">
        /// FillModes - null
        /// or
        /// FillModes - null
        /// or
        /// ShapeTypes - null
        /// </exception>
        public void DrawShape(System.Drawing.Graphics G, Brush FillShape, Pen DrawShape)
        {
            foreach (List <Point> points in Points)
            {
                switch (ShapeType)
                {
                case ShapeTypes.Polygon:
                    switch (FillMode)
                    {
                    case FillModes.Fill:
                        G.FillPolygon(FillShape, points.ToArray());
                        break;

                    case FillModes.Border:
                        G.DrawPolygon(DrawShape, points.ToArray());
                        break;

                    case FillModes.Both:
                        G.FillPolygon(FillShape, points.ToArray());
                        G.DrawPolygon(DrawShape, points.ToArray());
                        break;

                    default:
                        throw new ArgumentOutOfRangeException(nameof(FillModes), FillMode, null);
                    }

                    break;

                case ShapeTypes.Spline:
                    switch (FillMode)
                    {
                    case FillModes.Fill:
                        G.FillClosedCurve(FillShape, points.ToArray());
                        break;

                    case FillModes.Border:
                        G.DrawClosedCurve(DrawShape, points.ToArray());
                        break;

                    case FillModes.Both:
                        G.FillClosedCurve(FillShape, points.ToArray());
                        G.DrawClosedCurve(DrawShape, points.ToArray());
                        break;

                    default:
                        throw new ArgumentOutOfRangeException(nameof(FillModes), FillMode, null);
                    }

                    break;

                default:
                    throw new ArgumentOutOfRangeException(nameof(ShapeTypes), ShapeType, null);
                }
            }
        }
All Usage Examples Of System.Drawing.Graphics::DrawClosedCurve