Hakushi.Ink (Hakushi v0.6.0)

Copy Markdown View Source

The geometry of a stroke of ink (Hakushi.Kits.Ink): its outline, as the d of an SVG path, whose width follows the pen's pressure.

The browser draws a stroke in progress with the same outline (the bundle's ink.ts): the stroke a person sees as they draw it, and the node it becomes when the pen lifts, are the same shape.

A point is [x, y, pressure], the pressure from 0 to 1 (0.5 for a pointer with none, a mouse); [x, y] is a point of no pressure.

Summary

Types

A point of a stroke: [x, y, pressure] or [x, y].

Functions

The line through a stroke's points, as the d of an SVG path: to aim at it.

A number as a path writes it: to a tenth, halves away from zero, without a .0 (as the browser writes it).

The outline of a stroke: the points on each side of its line, as far from it as the pressure says (thinner with less), joined by curves through their middles, with a round cap at each end. flat (a highlighter) keeps one width.

How far a stroke's outline reaches from its points: the most it is wide, halved.

Types

point()

@type point() :: [number()]

A point of a stroke: [x, y, pressure] or [x, y].

Functions

centerline(points)

@spec centerline([point()]) :: String.t()

The line through a stroke's points, as the d of an SVG path: to aim at it.

fmt(value)

@spec fmt(number()) :: String.t()

A number as a path writes it: to a tenth, halves away from zero, without a .0 (as the browser writes it).

outline(points, size, flat \\ false)

@spec outline([point()], number(), boolean()) :: String.t()

The outline of a stroke: the points on each side of its line, as far from it as the pressure says (thinner with less), joined by curves through their middles, with a round cap at each end. flat (a highlighter) keeps one width.

reach(size, bool)

@spec reach(number(), boolean()) :: number()

How far a stroke's outline reaches from its points: the most it is wide, halved.