geomotif.core.motif
¶
The motif contract: the one thing you implement to extend the library.
A motif is a parameterized recipe for geometry. Implement :meth:Motif.build
-- usually a few lines of maths -- and arc-length resampling, every spacing
curve, the transform layer, export and CLI exposure all come with it.
Two entry points, deliberately separated:
- :meth:
Motif.build-- the motif's own idea of itself, at its native resolution. This is what you write. - :meth:
Motif.generate-- what you actually plot: a specific number of points, distributed the way you asked. This is what you call.
Classes:
| Name | Description |
|---|---|
SupportsBuild |
Structural contract -- any object with |
Motif |
Convenience base: implement :meth: |
SupportsBuild
¶
Bases: Protocol
Structural contract -- any object with build() works everywhere.
Following the :class:typing.SupportsInt convention, this is the
structural twin of :class:Motif: anything that can build a design is
accepted wherever a motif is, so nobody is ever forced to inherit.
Methods:
| Name | Description |
|---|---|
build |
Return the design at its natural resolution. |
Motif
¶
Bases: ABC
Convenience base: implement :meth:build, inherit everything else.
The ABC exists to hand you :meth:generate and registration, not to
police the type -- see :class:SupportsBuild if you would rather not
inherit at all.
Methods:
| Name | Description |
|---|---|
build |
Return the design at its natural/native resolution. |
generate |
Build, then resample to |
generate
¶
generate(count: int | None = None, *, step: float | None = None, spacing: SpacingLike | None = None, distribute: Distribution = 'length', by: Placement = 'length') -> Design
Build, then resample to count points (or a fixed step distance).
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
count
|
int
|
Total number of points to return. Must be >= 2. |
None
|
step
|
float
|
Fixed real distance between consecutive points, letting the count
fall out of the geometry. Mutually exclusive with |
None
|
spacing
|
SpacingCurve or callable
|
Distribution of points along the path. Defaults to equal spacing. |
None
|
distribute
|
('length', 'even', 'per_path')
|
How |
"length"
|
by
|
('length', 'parameter')
|
Place points by real distance along the curve (the default), or by even steps through its parametrization. |
"length"
|
Returns:
| Type | Description |
|---|---|
Design
|
The resampled design, ready to plot or export. |