Curves in elm-geometry are parameterized
by a value that ranges from 0 to 1. A value of 0 corresponds to the start point
of the curve and a value of 1 corresponds to the end point. This module contains
functionality for:
The parameter value 0.
ParameterValue.value ParameterValue.zero
--> 0The parameter value 0.5.
ParameterValue.value ParameterValue.half
--> 0.5The parameter value 1.
ParameterValue.value ParameterValue.one
--> 1Float valuesConvert a ParameterValue to a plain Float value between 0 and 1.
ParameterValue.value ParameterValue.half
--> 0.5Construct a valid parameter value by clamping a plain Float value to
between 0 and 1.
ParameterValue.value (ParameterValue.clamped 0.75)
--> 0.75
ParameterValue.value (ParameterValue.clamped -0.25)
--> 0
ParameterValue.value (ParameterValue.clamped 1.25)
--> 1If the given value is between 0 and 1, return Just that value as a
ParameterValue. Otherwise, return Nothing.
ParameterValue.checked 0.75
|> Maybe.map ParameterValue.value
--> Just 0.75
ParameterValue.checked -0.25
--> Nothing
ParameterValue.checked 1.25
--> NothingDirectly construct a ParameterValue from a Float without checking
whether it is valid. ParameterValue.clamped should generally be used instead,
unless you are very sure you know what you are doing and
profiling/benchmarking shows that ParameterValue.clamped is a performance
bottleneck.
Construct a list of parameter values by taking a given number of steps from 0 to 1. Note that the number of returned values will in general be one greater than the number of steps!
ParameterValue.steps 0
--> []
ParameterValue.steps 1
--> [ ParameterValue.zero, ParameterValue.one ]
Parametervalue.steps 2
--> [ ParameterValue.zero
--> , ParameterValue.half
--> , ParameterValue.one
--> ]
ParameterValue.steps 5
|> List.map ParameterValue.value
--> [ 0, 0.2, 0.4, 0.6, 0.8, 1 ]Construct a list of parameter values by dividing the range [0,1] into a given number of steps and then returning the value at the beginning of each step.
ParameterValue.leading 0
--> []
ParameterValue.leading 1
--> [ ParameterValue.zero ]
Parametervalue.leading 2
--> [ ParameterValue.zero, ParameterValue.half ]
ParameterValue.leading 5
|> List.map ParameterValue.value
--> [ 0, 0.2, 0.4, 0.6, 0.8 ]Construct a list of parameter values by dividing the range [0,1] into a given number of steps and then returning the value at the end of each step.
ParameterValue.trailing 0
--> []
ParameterValue.trailing 1
--> [ ParameterValue.one ]
Parametervalue.trailing 2
--> [ ParameterValue.half, ParameterValue.one ]
ParameterValue.trailing 5
|> List.map ParameterValue.value
--> [ 0.2, 0.4, 0.6, 0.8, 1 ]Construct a list of parameter values by dividing the range [0,1] into a given number of steps and then returning the value at the midpoint of each step.
ParameterValue.midpoints 0
--> []
ParameterValue.midpoints 1
--> [ ParameterValue.half ]
ParameterValue.midpoints 2
|> List.map ParameterValue.value
--> [ 0.25, 0.75 ]
ParameterValue.midpoints 5
|> List.map ParameterValue.value
--> [ 0.1, 0.3, 0.5, 0.7, 0.9 ]Construct a list of evenly-spaced parameter values between 0 and 1 by specifying:
This is a more general form of steps, leading and trailing; for example,
ParameterValue.steps 10is equivalent to
ParameterValue.range
{ numSteps = 10
, includeStart = True
, includeEnd = True
}and
ParameterValue.trailing 10is equivalent to
ParameterValue.range
{ numSteps = 10
, includeStart = False
, includeEnd = True
}Find the midpoint between two parameter values.
ParameterValue.midpoint
ParameterValue.zero
ParameterValue.one
--> ParameterValue.halfSubtract a parameter value from 1 to give a new parameter value.
ParameterValue.oneMinus ParameterValue.one
--> ParameterValue.zero
ParameterValue.oneMinus ParameterValue.zero
--> ParameterValue.one
ParameterValue.oneMinus ParameterValue.half
--> ParameterValue.halfThis can be thought of as the 'negation' or 'complement' of a parameter value.
For example, evaluating a reversed curve at a parameter value t is generally
equivalent to evaluating the original curve at a parameter value
1 - t, and vice versa.
A parameter value between 0 and 1. Curve types such as
Arc2dandCubicSpline3duseParameterValuearguments for curve evaluation functions such asArc2d.pointOnandCubicSpline3d.samplesAt.