hatchPathfunction
Parallel lines, spacing apart at angleDeg, cut to where inside(x, y) is true, as the data of one SVG path (a millimetre of the picture is a millimetre of the paper). Each end is found to a twentieth of a millimetre.
Import it
import { hatchPath } from "@johnmorrisdotca/chikyu-earth/sheets";
Definition
function hatchPath(bounds: Bounds, spacing: number, angleDeg: number, inside: (x: number, y: number) => boolean): string
Parameters
| Name | Type | Description |
|---|---|---|
bounds | Bounds | The box the lines are laid over. |
spacing | number | The gap between lines, in millimetres. |
angleDeg | number | The turn of the lines, in degrees from the x axis. |
inside | (x: number, y: number) => boolean | Whether a point is in the shaded part. |
Returns
string
Path data: M x y L x y for each stroke.
Examples
import { hatchPath } from "@johnmorrisdotca/chikyu-earth/sheets";
const d = hatchPath({ x0: 0, y0: 0, x1: 20, y1: 20 }, 4, 45, (x) => x < 10);
console.log(d.startsWith("M"));trueWhat it prints (run when this page was built)