Skip to content

Function: quadReach() ​

ts
function quadReach(end, halfWidth, aa, join?): number;

Experimental

How far the quad of a segment reaches beyond a vertex along the segment's axis (px): far enough for every pixel the segment draws there, and no further (mirror of the shader's computeEnd return value).

  • Cap: the cap's shape (nothing for butt, halfWidth for round and square) and its fringe. With round joins a butt cap reaches halfWidth too: on a segment shorter than that, the disc of the join at its other end covers pixels behind the cap.
  • Join: the segment draws only after the bisector through the vertex (the ownership split). Within the stroke and its fringe, |perp| < halfWidth + 0.5 * aa, the bisector lies at most (halfWidth + 0.5 * aa) * tan(θ/2) behind the vertex: at a gentle turn the quad ends half a pixel past the vertex instead of halfWidth + aa past it. Capped at the join shape plus a full ramp (extent + aa, the quad before plan E16.9), so a sharp miter's quad is what it was.

Every pixel the former quad drew is at least QUAD_SLACK inside this one, so the two draw the same image (line-join.test.ts, and the visual baselines). The shader uses this reach only for a segment whose ends have the same depth: the quad's corners carry the end points' depths, so a segment that crosses depths (a 2.5D view, a 3D scene) keeps the former quad.

Parameters ​

ParameterTypeDefault value
endSegmentEndundefined
halfWidthnumberundefined
aanumberundefined
joinLineJoin'miter'

Returns ​

number

Released under the MIT License.