Visualize.Chart.Mark.Bend (Visualize v0.2.35)

Copy Markdown View Source

The polar transform (spec/14 §5.2, #391): a mark laid out in (angle, r) — every x an angle in radians clockwise from 12 o'clock, every y a radius from the centre — bent around the arc.

A pure function of the mark's elements, so every backend draws the same geometry: a point goes to (r · sin a, −r · cos a) (spec/04 §6.2); a straight segment is sampled at no more than 2° of angle and bent point by point, so a line wraps around the arc; a curve is sampled along its parameter, so it is interpolated in (angle, r) before it bends; a rect becomes an annular sector; a circle keeps its radius at the bent centre; a text moves to the bent point; a group's children bend, and a translate in a transform bends as a point.

iex> Visualize.Chart.Mark.Bend.point({:math.pi() / 2, 10})
{10.0, 0.0}

iex> line = Visualize.IR.Element.line(0, 10, :math.pi(), 10)
iex> %Visualize.IR.Element{type: :path, path: path} = Visualize.Chart.Mark.Bend.bend(line)
iex> length(path.commands)
91

Summary

Functions

An element bent around the arc: its geometry read as (angle, r) and drawn in the plane about the centre.

As bend/1 with options: chords: true joins the ends of a straight segment with one line instead of sampling it along the arc — a categorical angle's polygon (spec/14 §5.2, #393); a horizontal run (H, a step curve's tread) is still sampled, since a run at one radius is an arc.

One point {angle, r} bent to {x, y}: (r · sin a, −r · cos a), rounded to six decimals.

Functions

bend(element)

An element bent around the arc: its geometry read as (angle, r) and drawn in the plane about the centre.

bend(group, opts)

As bend/1 with options: chords: true joins the ends of a straight segment with one line instead of sampling it along the arc — a categorical angle's polygon (spec/14 §5.2, #393); a horizontal run (H, a step curve's tread) is still sampled, since a run at one radius is an arc.

point(arg)

@spec point({number(), number()}) :: {float(), float()}

One point {angle, r} bent to {x, y}: (r · sin a, −r · cos a), rounded to six decimals.