MCPcopy Create free account
hub / github.com/OpenEndedGroup/Field2 / lineRange

Method lineRange

src/main/java/field/utility/Drivers.kt:80–105  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

78 val linear : (Double) -> Double = {it}
79
80 @JvmOverloads
81 @JvmStatic
82 @Documentation("returns a number sequence that goes smoothly from `start` to `end` in `over` steps")
83 fun lineRange(start: Double, end: Double, over: Int = 100, ease : (Double) -> Double = {it}): ThreadSync2.TrappedSet<Double> {
84 return object : ThreadSync2.TrappedSet<Double> {
85 var tick = 0
86 var lastValue = start;
87
88 override fun next(): Double? {
89 val d = start + (end - start) * ease(tick / over.toDouble())
90 lastValue = d
91 tick++
92 return if (tick < over + 2) d else null
93 }
94
95 override fun hasNext(): Boolean {
96 return tick < over + 1
97 }
98
99 override fun reset() {
100 tick = 0
101 }
102
103 override fun toString(): String = "line, $start -> $end / $over frames; at $lastValue"
104 }
105 }
106
107 @JvmOverloads
108 @JvmStatic

Callers 1

cooked.box.jsFile · 0.80

Calls

no outgoing calls

Tested by

no test coverage detected