Macaw.Frame.Clip (macaw_frame v0.1.0)

Copy Markdown View Source

Clipping a layer to the plot and culling what the clip would hide (spec/03 §3.5).

Layers are not clipped by default. With clip: true every layer of the frame draws only inside the model's clip/1: [0, 0, w, h] in cartesian, geographic and layout, [−w/2, −h/2, w, h] in the polar model's centered group, each panel's own in a facet. The clip is on each layer's group (layer/2); a layer group carrying its own transform is wrapped in a plain group that carries the clip, since a clip is in its element's own user space (visualize D-211). A layer kind that clips itself (the tiles) is left as it is.

A clipped frame culls first (cull/2, visualize #839): of a run of path points beyond one edge it keeps the first and last; a shape whose box, widened by twice its stroke width and one pixel, lies outside is dropped; what cannot be bounded (a non-translate transform, an effect, a non-numeric width, a moving element) is kept. The culled picture is pixel for pixel the clipped one. Copied from visualize's Visualize.Chart.Frame.Cull and Visualize.Chart.Frame.clip_mark/2.

Summary

Types

A rectangle, {x, y, width, height}.

Functions

An element with what cannot reach rect left out (§3.5): runs of path points beyond one edge cut to their ends, shapes wholly outside dropped, what cannot be bounded kept. A text is bounded by measure, the Frame's resolved measurer (Macaw.Frame.Text.measure/2, the estimate without one), or measuring options (Macaw.Draw.Text.measurer/1) resolved once here, their faults answered.

A layer's group as a frame draws it (§3.5): as it is when the frame does not clip, or culled to the model's clip and carrying it, wrapped when it has a transform or a clip of its own. rect overrides the model's clip (a facet's panel).

Types

rect()

@type rect() :: {number(), number(), number(), number()}

A rectangle, {x, y, width, height}.

Functions

cull(element, rect, measure \\ Macaw.Draw.Text.estimate())

@spec cull(term(), term(), Macaw.Layers.Text.Measurer.t() | keyword()) ::
  Macaw.Draw.IR.Element.t() | {:error, list()}

An element with what cannot reach rect left out (§3.5): runs of path points beyond one edge cut to their ends, shapes wholly outside dropped, what cannot be bounded kept. A text is bounded by measure, the Frame's resolved measurer (Macaw.Frame.Text.measure/2, the estimate without one), or measuring options (Macaw.Draw.Text.measurer/1) resolved once here, their faults answered.

layer(model, element, rect \\ nil)

@spec layer(term(), term(), term()) :: Macaw.Draw.IR.Element.t() | {:error, list()}

A layer's group as a frame draws it (§3.5): as it is when the frame does not clip, or culled to the model's clip and carrying it, wrapped when it has a transform or a clip of its own. rect overrides the model's clip (a facet's panel).