add degrade/degradeBy

This commit is contained in:
alex 2022-04-16 11:40:47 +01:00
parent c88508ace3
commit dca8b46abf

View File

@ -88,3 +88,17 @@ export const perlinWith = (pat) => {
};
export const perlin = perlinWith(time);
Pattern.prototype._degradeByWith = function (withPat, x) {
return this.fmap((a) => (_) => a).appLeft(withPat._filterValues((v) => v > x));
};
Pattern.prototype._degradeBy = function (x) {
return this._degradeByWith(rand, x);
};
Pattern.prototype._degrade = function () {
return this._degradeBy(0.5);
};
Pattern.prototype.patternified.push('degradeBy', 'degrade');