setQuadrantSegments method

void setQuadrantSegments(
  1. int quadSegs
)

Sets the number of line segments used to approximate an angle fillet.

  • If quadSegs >= 1, joins are round, and quadSegs indicates the number of segments to use to approximate a quarter-circle.
  • If quadSegs = 0, joins are bevelled (flat)
  • If quadSegs < 0, joins are mitred, and the value of qs indicates the mitre ration limit as
    mitreLimit = |quadSegs|
    
For round joins, quadSegs determines the maximum error in the approximation to the true buffer curve. The default value of 8 gives less than 2% max error in the buffer distance. For a max error of < 1%, use QS = 12. For a max error of < 0.1%, use QS = 18. The error is always less than the buffer distance (in other words, the computed buffer curve is always inside the true curve).

@param quadSegs the number of segments in a fillet for a quadrant

Implementation

void setQuadrantSegments(int quadSegs) {
  quadrantSegments = quadSegs;

  /**
   * Indicates how to construct fillets.
   * If qs >= 1, fillet is round, and qs indicates number of
   * segments to use to approximate a quarter-circle.
   * If qs = 0, fillet is bevelled flat (i.e. no filleting is performed)
   * If qs < 0, fillet is mitred, and absolute value of qs
   * indicates maximum length of mitre according to
   *
   * mitreLimit = |qs|
   */
  if (quadrantSegments == 0) joinStyle = JOIN_BEVEL;
  if (quadrantSegments < 0) {
    joinStyle = JOIN_MITRE;
    mitreLimit = quadrantSegments.abs().toDouble();
  }

  if (quadSegs <= 0) {
    quadrantSegments = 1;
  }

  /**
   * If join style was set by the quadSegs value,
   * use the default for the actual quadrantSegments value.
   */
  if (joinStyle != JOIN_ROUND) {
    quadrantSegments = DEFAULT_QUADRANT_SEGMENTS;
  }
}