Documentation
¶
Overview ¶
Package span provides helper constructs to represent ranges of values, to poll from or clamp to
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Span ¶
type Span[T any] interface { // Poll returns a pseudorandom value within this span. Poll() T // Clamp, if v lies within the boundary of this span, returns v. // Otherwise, CLamp returns a modified version of v that is rounded to the closest value // that does lie within the boundary of this span. Clamp(v T) T // Percentile returns the value along this span that is at the provided percentile through the span, // e.g. providing .5 will return the middle of the span, providing 1 will return the maximum value in // the span. Providing a value less than 0 or greater than 1 may extend the span by where it would theoretically // progress, but should not be relied upon unless a given implementation specifies what it will do. If this span // represents multiple degrees of freedom, this will pin all those degrees to the single provided percent. Percentile(float64) T // MulSpan returns this span with its entire range multiplied by the given constant. MulSpan(float64) Span[T] }
A Span represents some enumerable range.
func NewConstant ¶
NewConstant returns a span where the minimum and maximum are both i. Poll, Percentile, and Clamp will always return i.
func NewLinear ¶
NewLinear returns a linear span between min and max. The linearity implies that no point in the span is preferred, and Percentile will scale in a constant fashion from min to max.
func NewLinearColor ¶
NewLinearColor returns a linear color distribution between min and maxColor
type Spanable ¶
type Spanable interface { constraints.Float | constraints.Integer }
A Spanable must be usable in basic arithmetic-- addition, subtraction, and multiplication.
Click to show internal directories.
Click to hide internal directories.