Clipper.Offset (gb.clipper)

Static Function Offset ( Polygons As Polygon[], Delta As Float [ , Join As Integer, Limit As Float, DoNotFix As Boolean ] ) As Polygon[]

This function offsets the Polygons parameter by the Delta amount. Positive delta values expand outer polygons and contract inner 'hole' polygons. Negative deltas do the reverse.

Edge joins is specified by the Join argument, and may be one of three jointypes:

  • Clipper.JoinMiter: Limit sets the maximum distance in multiples of delta that vertices can be offset from their original positions before squaring is applied. The default value is 2 (ie twice delta) which is also the smallest allowed value. If offsetting was allowed without any limits (ie without squaring), then offsetting at very acute angles would produce unacceptably long 'spikes'.

  • Clipper.JoinRound: Limit sets the maximum distance that rounded joins can deviate from their true arcs (since it would require an infinite number of vertices to perfectly represent an arc). The default limit is 0.25 units though realistically precision can never be better than 0.5 since arc coordinates will still be rounded to integer values. When offsetting polygons with very large coordinate values (typically as a result of scaling), it's advisable to increase limit to maintain consistent precisions at all joins because the maximum number of vertices allowed in any arc is 222. (This hard coded upper limit has been chosen because the imprecision in a circle constructed with 222 vertices will be only 1/10000th its radius and, not only is creating very large numbers of arc vertices computationally expensive, it can cause out-of-memory problems.)

  • Clipper.JoinSquare: The Limit parameter is ignored.

The polygons passed to the Offset method must not be self-intersecting and need to be oriented such that outer polygons have a true orientation and hole polygons have a false orientation. If the orientations of input polygons are incorrect, the function will return unexpected results. Likewise, 'duplicate vertices' (ie consecutive vertices with identical coordinates, including start and end vertices) cause problems with the offset algorithm.

The DoNotFix parameter when FALSE will force the function to check for and fix incorrect polygon orientations and remove duplicate vertices. However, it will not fix self-intersections. (Self-intersections can be removed by calling the Offset method.) If orientations are known to be correct and there's no likelihood of duplicate vertices, then it's advisable to set autoFix to false since 'auto-fixing' is computationally expensive.