A continuous linear scale, a numeric domain to a numeric range (spec/06 §4).
{:ok, scale} = Macaw.Draw.Scale.Linear.new() |> Macaw.Draw.Scale.Linear.domain([0, 100])
{:ok, scale} = Macaw.Draw.Scale.Linear.range(scale, [0, 500])
Macaw.Draw.Scale.Linear.apply(scale, 50)
#=> 250.0apply/2 is total: a value that is not a number answers nil. ticks/2 and nice/1
are the one tick rule's, Macaw.Draw.Ticks (spec/06 §16).
Summary
Functions
The range value of value: r0 + t · (r1 − r0), t the value's position in the domain,
0.5 in a collapsed one, clamped to [0, 1] when the scale clamps. Always a float; a
value that is not a number answers nil.
0: a linear scale has no bandwidth.
Sets clamping; answers the struct.
Sets the domain, two numbers: {:ok, scale} or {:error, faults} (spec/06 §2.2).
domain/2, answering the scale or raising Macaw.Draw.Error.
The domain value of a range value, d0 + t · (d1 − d0); never clamps, nil for a non-number.
The default scale: domain [0, 1], range [0, 1], no clamping.
The domain widened to nice values at count 10, keeping its orientation (spec/06 §16).
Identity: a linear scale has no padding.
Sets the range, two numbers: {:ok, scale} or {:error, faults}.
range/2, answering the scale or raising Macaw.Draw.Error.
About count nice ticks over the domain: Macaw.Draw.Ticks.ticks/3 (spec/06 §16).
Types
@type error() :: {:error, [Macaw.Base.Fault.t()]}
A refusal: faults with their paths.
Functions
The range value of value: r0 + t · (r1 − r0), t the value's position in the domain,
0.5 in a collapsed one, clamped to [0, 1] when the scale clamps. Always a float; a
value that is not a number answers nil.
0: a linear scale has no bandwidth.
Sets clamping; answers the struct.
Sets the domain, two numbers: {:ok, scale} or {:error, faults} (spec/06 §2.2).
domain/2, answering the scale or raising Macaw.Draw.Error.
The domain value of a range value, d0 + t · (d1 − d0); never clamps, nil for a non-number.
@spec new() :: t()
The default scale: domain [0, 1], range [0, 1], no clamping.
The domain widened to nice values at count 10, keeping its orientation (spec/06 §16).
Identity: a linear scale has no padding.
Sets the range, two numbers: {:ok, scale} or {:error, faults}.
range/2, answering the scale or raising Macaw.Draw.Error.
About count nice ticks over the domain: Macaw.Draw.Ticks.ticks/3 (spec/06 §16).