import type { IReset } from "@thi.ng/api" ; import { AGen } from "./agen.js" ; param factor param start param offset param clamp export const madd = ( factor ? , start ? , offset ? , clamp ? ) => new MAdd ( factor , start , offset , clamp ) ; export class MAdd extends AGen < number > implements IReset { constructor ( protected _factor = 1 , protected _start = 1 , protected _offset = 0 , protected _clamp ? ) { super ( 0 ) ; this . reset ( ) ; } reset ( ) { this . _val = ( this . _start - this . _offset ) / this . _factor ; return this ; } next ( ) { let v = this . _val * this . _factor + this . _offset ; return ( this . _val = this . _clamp !== undefined ? this . _start < this . _clamp ? Math . min ( v , this . _clamp ) : Math . max ( v , this . _clamp ) : v ) ; } }