hatch

hatch

Fill — plotter marks via clipped parallel / cross hatch strokes. See Fills.

Imports

import { hatchParallel, hatchCross, hatch, type ParallelHatchOptions } from 'pattapatta'
// or from 'pattapatta/hatch'

hatchParallel(path, options?: ParallelHatchOptions) → Segment[]

OptionDefaultMeaning
angleπ/4Line direction (radians)
spacing0.15Perpendicular spacing
countautoLine count; omit to cover the whole path AABB
lengthbbox diagonalPre-clip half-length
centerbbox centerField center

hatchCross(path, options?)

Two perpendicular parallel fields.

Examples

Parallel

Parallel hatch

const strokes = hatchParallel(createRect(15, 15, 70, 70), {
  spacing: 6, angle: Math.PI / 4,
})

Cross

Cross hatch

const strokes = hatchCross(createRect(15, 15, 70, 70), { spacing: 8 })

Serialize with toSvg(group(segmentsToOpenPaths(strokes))).