Macaw.Draw.Scale.Radial (macaw_draw v0.1.0)

Copy Markdown View Source

An angle scale: a cyclic quantity (a compass bearing, an hour of the day, a day of the year) to radians (spec/06 §15, visualize D-30).

The mapping is Macaw.Draw.Scale.Linear's with a range in radians, one full turn by default. Angles follow Macaw.Draw.Shape.Arc's convention, clockwise from 12 o'clock, so a bearing domain [0, 360] puts north at the top and east at the right. ticks/2 are exactly count equal divisions of the domain, not the nice-step sequence, and nice/1 is identity: the domain of a cyclic quantity is its period.

bearing = Macaw.Draw.Scale.Radial.new() |> Macaw.Draw.Scale.Radial.domain!([0, 360])
Macaw.Draw.Scale.Radial.ticks(bearing, 4)
#=> [0.0, 90.0, 180.0, 270.0]

Summary

Types

A refusal: faults with their paths.

t()

Functions

The angle of a domain value: Macaw.Draw.Scale.Linear.apply/2 over the domain and range.

0: a radial scale has no bandwidth.

Sets clamping; answers the struct.

Sets the domain, two numbers: {:ok, scale} or {:error, faults}.

domain/2, answering the scale or raising Macaw.Draw.Error.

The domain value of an angle: Macaw.Draw.Scale.Linear.invert/2; never clamps.

A radial scale: domain [0, 1], range [0, 2π].

Identity: the domain of a cyclic quantity is its period.

Identity: a radial scale has no padding.

Sets the range, two angles in radians: {:ok, scale} or {:error, faults}.

range/2, answering the scale or raising Macaw.Draw.Error.

Exactly count equal divisions of the domain from d0: the last, d1, omitted when the range is a full turn, where it falls on the first, and kept otherwise. A count below 1 answers [] (spec/06 §15.2).

Types

error()

@type error() :: {:error, [Macaw.Base.Fault.t()]}

A refusal: faults with their paths.

t()

@type t() :: %Macaw.Draw.Scale.Radial{
  clamp?: boolean(),
  domain: [number()],
  range: [number()]
}

Functions

apply(scale, value)

@spec apply(t(), term()) :: float() | nil | error()

The angle of a domain value: Macaw.Draw.Scale.Linear.apply/2 over the domain and range.

bandwidth(arg1)

@spec bandwidth(t()) :: 0 | error()

0: a radial scale has no bandwidth.

clamp(scale, clamp?)

@spec clamp(t(), boolean()) :: t() | error()

Sets clamping; answers the struct.

domain(scale, domain)

@spec domain(t(), term()) :: {:ok, t()} | error()

Sets the domain, two numbers: {:ok, scale} or {:error, faults}.

domain!(scale, domain)

@spec domain!(t(), term()) :: t()

domain/2, answering the scale or raising Macaw.Draw.Error.

invert(scale, value)

@spec invert(t(), term()) :: float() | nil | error()

The domain value of an angle: Macaw.Draw.Scale.Linear.invert/2; never clamps.

new()

@spec new() :: t()

A radial scale: domain [0, 1], range [0, 2π].

nice(scale)

@spec nice(t()) :: t() | error()

Identity: the domain of a cyclic quantity is its period.

padding(scale, padding)

@spec padding(t(), number()) :: t() | error()

Identity: a radial scale has no padding.

range(scale, range)

@spec range(t(), term()) :: {:ok, t()} | error()

Sets the range, two angles in radians: {:ok, scale} or {:error, faults}.

range!(scale, range)

@spec range!(t(), term()) :: t()

range/2, answering the scale or raising Macaw.Draw.Error.

ticks(scale, count)

@spec ticks(t(), number()) :: [float()] | error()

Exactly count equal divisions of the domain from d0: the last, d1, omitted when the range is a full turn, where it falls on the first, and kept otherwise. A count below 1 answers [] (spec/06 §15.2).