fletcher.paths.path-effect()
Apply path effects (extrusion and shortening) to a CeTZ object, returning a CeTZ object.
fletcher.paths.path-effect( objs: cetz objects, stroke, fill, shorten-start: number length array, shorten-end: number length array, extrude: number length array, join: "miter" "round", corner-radius: number length none, miter-limit: number, dynamic-radius, )
objscetz objects
CeTZ objects to apply the path effect to.
A CeTZ object is an array of functions; the result of cetz.draw.line(..) or cetz.draw.merge-path(..), for example.
strokedefault auto
autoStroke style for the object, overriding the object’s intrinsic stroke style.
filldefault auto
autoFill style for the object, overriding the object’s intrinsic fill style. If auto, the fill is unchanged.
shorten-startnumber or length or array default 0
0Trim the beginning of the path by a given length.
For multi-stroke effect when extrude is an array, this may also be an array of the same length, specifying the length to shorten each offset path individually. This is useful for placing marks on multi-stroke lines correctly.
Numbers are interpreted as multiples of the stroke’s thickness.
shorten-endnumber or length or array default 0
0Trim the end of the path by a specific length.
Works just like shorten-start.
extrudenumber or length or array default 0
0Lengths to offset path by. An array of different offsets results in multiple parallel strokes.
Numbers are interpreted as multiples of the stroke’s thickness.
#import fletcher.paths: path-effect
#cetz.canvas({
import cetz.draw: *
set-style(stroke: 5pt)
let obj = line((0,0), (1,1), (2,0))
obj
path-effect(obj, extrude: (+2, -2),
stroke: blue)
})join"miter" or "round" default "miter"
"miter"How to form corners of an offset path.
If "round", corners become rounded joints with a (minimum) corner radius specified by corner-radius. If "miter", corners become miter joints or, if they are sharp enough, bevelled joints, as controlled by miter-limit.
#import fletcher.paths: path-effect
#cetz.canvas({
import cetz.draw: *
set-style(stroke: 2pt)
let obj = line((0,0), (1,1),
(1,0), (2,0))
path-effect(obj, extrude: (-1, +1),
join: "round", corner-radius: .2)
translate(y: -1.5)
path-effect(obj, extrude: (-1, +1))
translate(y: -1.5)
path-effect(obj, extrude: (-1, +1),
miter-limit: 2)
})corner-radiusnumber or length or none default 0
0The radius of round or bevelled corners.
For round corners, this is the radius of curvature. For bevelled corners, this is the radius of the tangent circle between the bevel face and the sides of the corner.
For extruded paths, the radii at each offset is adjusted so that the circles of curvature are concentric. At a corner, the inner paths have the specified radius of curvature, while outer paths have larger radii. The radius can be negative.
The value none is short for zero radius with join: "miter".
Numbers are interpreted in CeTZ canvas units.
miter-limitnumber default 4.0
4.0Miter limit, beyond which miter joints become bevelled.
The higher the limit, the pointier corners can be before being bevelled.
dynamic-radiusdefault true
trueWhether to dynamically adjust corner radii depending on corner sharpness for nicer visual results. When enabled, the corner radius is decreased for bends of less than .
#import fletcher.paths: path-effect
#cetz.canvas({
let obj = cetz.draw.line((0,0), (1,1), (2,0), (2,1), (3,0), (4,0))
let args = arguments(obj, corner-radius: 5pt, join: "round")
path-effect(..args, stroke: green)
cetz.draw.translate(y: -1)
path-effect(..args, dynamic-radius: false)
})