use

@useDirective

Imports a pack — a named collection of ready-made constructs, datasets and presets — and makes its public names available under that name. statistics.normal() is a construct from the statistics pack; the prefix is always written, so where a construct came from is visible at every use. A pack’s datasets are reached the same way (#statistics.anscombe.y1). Only what a pack publishes can be reached: the rest is its own workings. A pack cannot see anything in your document — its constants, its ids, its own templates are invisible to it, and yours to you.

#Attributes

packRequiredImplicit
The pack’s name, written as shorthand: @use:statistics.Can be written as shorthand: @use:value
A different prefix to call the pack’s constructs under, for when two packs share a name. It REPLACES the pack’s own name — under as: st, statistics.normal no longer resolves.

#Examples

@use:statistics

canvas.graph{
    statistics.normal(mu: 0; sigma: 1)
}(
    x domain: [-4, 4]
    y domain: [0, 0.45]
)
@use(pack: statistics; as: st)

canvas.graph{
    st.uniform(a: 0; b: 1)
}

#Notes

  • The prefix is not optional: there is no unqualified import. Two packs can therefore never collide, and a reader can always tell a pack construct from a built-in one.
  • What a pack draws is ordinary chalk — the compiled document is the same as if you had written the nodes out by hand.
  • The same pack may be imported twice only under different prefixes.