The kit of ink: drawing on the paper with a pen, over anything on the canvas (annotate, sketch, circle a node, write by hand), with a highlighter, an eraser of whole strokes, and a lasso that selects strokes and nodes alike.
<.canvas id="board" graph={@graph} kits={[Hakushi.Kits.Notes, Hakushi.Kits.Ink]} on_change={&save/2} />The canvas gets a bar of the kit's tools (Hakushi.Kit.tools/1):
the pointer, the pen and the highlighter with their colours and widths,
the eraser and the lasso. The pen's line is smoothed as it is drawn,
thinner and thicker with a stylus's pressure, and sharp at any zoom;
when the pen lifts, its points are simplified and the stroke is a node.
A stroke is a node of type "ink-stroke": its box is around the line,
and its data is the line's points, relative to the box:
%{
"tool" => "pen",
"color" => "ink",
"size" => 4,
"points" => [[12.5, 8, 0.42], [14, 9.5, 0.5], ...]
}A point is [x, y, pressure], the pressure from 0 to 1 (0.5 for a
mouse). The colours are colors/0, the tools "pen" and
"highlighter". A stroke moves, goes in a group (drawn over a frame,
it is in it), copies, deletes and undoes as any node, through the
rules and on_change; it has no handles, so no edges.
On a shared canvas, the others see a stroke as it is drawn: it goes
in the person's awareness, as a drag does, and becomes a change when
the pen lifts. An agent draws with draw_on_canvas
(Hakushi.Issho.tools/0), and the people see its pen go.
Summary
Functions
The colours of ink, in the order of the bar.
A stroke's node, from its points on the canvas ([x, y, pressure] or
[x, y]): its box around them, and its points relative to it. Gives
{:ok, node}, or :error for points or a tool it does not draw.
Functions
@spec colors() :: [String.t()]
The colours of ink, in the order of the bar.
@spec stroke([Hakushi.Ink.point()], keyword()) :: {:ok, map()} | :error
A stroke's node, from its points on the canvas ([x, y, pressure] or
[x, y]): its box around them, and its points relative to it. Gives
{:ok, node}, or :error for points or a tool it does not draw.
Options: :tool ("pen", the default, or "highlighter"), :color
(one of colors/0) and :size (the line's width at a pressure of
0.5), each the tool's own unless given.
{:ok, node} = Hakushi.Kits.Ink.stroke([[0, 0], [40, 10], [80, 0]], color: "red")