A gauge's or compass's pointer (spec/07 §16), copied from visualize's
Visualize.Shape.Needle: one filled pointer per datum from the hub to its angle.
angle/2 is in the radial scale's domain units, radians without one; length/2,
inner_radius/2, width/2 and tail/2 are pixel accessors; hub/2 is the hub
circle's radius, the width when nil; cap/2 is :point, :round or :flat, read by
spelling, another {[], {:unknown, :cap, spelling}}.
iex> alias Macaw.Draw.Shape.Needle
iex> Needle.generate(Needle.new(), [{0, 100}])
["M3,0L-3,0L0,-100Z"]With a the angle clockwise from 12 o'clock, u = (sin a, −cos a) the ray and
p = (cos a, sin a) across it, each path runs from the base corner
(inner_radius − tail)·u + (width/2)·p, to the other corner, then to the tip by its cap,
and closes. A datum with a coordinate that is no number draws the empty path, so the
list stays one path a datum.
Summary
Functions
Sets the angle, in the scale's domain units (radians without one), accessor: a function, a field, or a number.
Sets the tip, :point, :round or :flat by spelling: {:ok, needle} or {:error, faults}.
As cap/2, the needle itself, raising Macaw.Draw.Error with its faults.
The pointers as SVG path data, one per datum.
One Macaw.Draw.IR.Path pointer per datum, in data order.
Sets the hub circle's radius accessor; nil means the width.
The hub circle about the origin for a datum, radius hub (the width when nil).
Sets the pointer's start, in pixels (default 0), accessor: a function, a field, or a number.
Sets the tip's radius, in pixels, accessor: a function, a field, or a number.
A needle reading tuple elements 0 and 1 as angle and length.
Sets the radial scale the angles map through; nil means radians.
Sets the length behind the hub, in pixels (default 0), accessor: a function, a field, or a number.
Sets the base width, in pixels (default 6), accessor: a function, a field, or a number.
Types
@type cap() :: :point | :round | :flat
@type error() :: {:error, [Macaw.Base.Fault.t()]}
A refusal: faults with their paths.
Functions
Sets the angle, in the scale's domain units (radians without one), accessor: a function, a field, or a number.
Sets the tip, :point, :round or :flat by spelling: {:ok, needle} or {:error, faults}.
As cap/2, the needle itself, raising Macaw.Draw.Error with its faults.
The pointers as SVG path data, one per datum.
@spec generate_path(t(), [term()]) :: [Macaw.Draw.IR.Path.t()] | error()
One Macaw.Draw.IR.Path pointer per datum, in data order.
Sets the hub circle's radius accessor; nil means the width.
@spec hub_path(t(), term()) :: Macaw.Draw.IR.Path.t() | error()
The hub circle about the origin for a datum, radius hub (the width when nil).
Sets the pointer's start, in pixels (default 0), accessor: a function, a field, or a number.
Sets the tip's radius, in pixels, accessor: a function, a field, or a number.
@spec new() :: t()
A needle reading tuple elements 0 and 1 as angle and length.
Sets the radial scale the angles map through; nil means radians.
Sets the length behind the hub, in pixels (default 0), accessor: a function, a field, or a number.
Sets the base width, in pixels (default 6), accessor: a function, a field, or a number.