src/Elements/Geometry/Polyline.cs
/// <summary>
/// Offset this polyline by the specified amount.
/// </summary>
/// <param name="offset">The amount to offset.</param>
/// <param name="endType">The closure type to use on the offset polygon.</param>
/// <returns>A new closed Polygon offset in all directions by offset from the polyline.</returns>
Offset this polyline by the specified amount.
Offset this polyline by the specified amount .
public virtual Polygon[] Offset(double offset, EndType endType)
        {
            var path = this.ToClipperPath();
            var solution = new List<List<IntPoint>>();
            var co = new ClipperOffset();
            ClipperLib.EndType clEndType;
            switch (endType)
            {
                case EndType.Butt:
                    clEndType = ClipperLib.EndType.etOpenButt;
                    break;
                case EndType.ClosedPolygon:
                    clEndType = ClipperLib.EndType.etClosedPolygon;
                    break;
                case EndType.Square:
                default:
                    clEndType = ClipperLib.EndType.etOpenSquare;
                    break;
            }
            co.AddPath(path, JoinType.jtMiter, clEndType);
            co.Execute(ref solution, offset * CLIPPER_SCALE);  
            var result = new Polygon[solution.Count];
            for (var i = 0; i < result.Length; i++)
            {
                result[i] = solution[i].ToPolygon();
            }
            return result;
        }
public virtual Polygon [ ] Offset ( double offset , EndType endType ) { var path = this . ToClipperPath ( ) ; var solution = new List < List < IntPoint > > ( ) ; var co = new ClipperOffset ( ) ; ClipperLib . EndType clEndType ; switch ( endType ) { case EndType . Butt : clEndType = ClipperLib . EndType . etOpenButt ; break ; case EndType . ClosedPolygon : clEndType = ClipperLib . EndType . etClosedPolygon ; break ; case EndType . Square : default : clEndType = ClipperLib . EndType . etOpenSquare ; break ; } co . AddPath ( path , JoinType . jtMiter , clEndType ) ; co . Execute ( ref solution , offset * CLIPPER_SCALE ) ; var result = new Polygon [ solution . Count ] ; for ( var i = 0 ; i < result . Length ; i ++ ) { result [ i ] = solution [ i ] . ToPolygon ( ) ; } return result ; }
Offset this polyline by the specified amount.
Offset this polyline by the specified amount .
// important, scale also used here
A new closed Polygon offset in all directions by offset from the polyline.
A new closed Polygon offset in all directions by offset from the polyline .
offset
double
The amount to offset.
The amount to offset .
endType
EndType
The closure type to use on the offset polygon.
The closure type to use on the offset polygon .