moduleMath.Noise.Modules.SelectwhereimportMath.Noise.NoiseGenimportMath.Noise.NoiseModuleimportMath.Noise.InterpolationimportData.MaybeimportControl.ApplicativedataSelect=Select{edgeFallOff,lowerBound,upperBound::Double,controller::NoiseModule}select=Select{edgeFallOff=0.0,lowerBound=-1.0,upperBound=1.0,controller=one}-- | Adjusts select values so that they are correct (i.e. lowerBound < upperBound, etcc...)sanitizeSelect(Select{edgeFallOff=falloff,lowerBound=l,upperBound=u,controller=c})=Select{edgeFallOff=newFalloff,lowerBound=chooseLower,upperBound=chooseUpper,controller=c}wherechooseLower|l>u=u|u>l=l|u==l=-1.0chooseUpper|l>u=l|u>l=u|u==l=1.0-- make sure that the edge falloff curves do not overlapchooseFallofffuplow|f>((up-low)/2)=(up-low)/2|otherwise=fnewFalloff=chooseFallofffalloffchooseUpperchooseLowerinstanceNoiseClassSelectwheresanitize=sanitizeSelectgetNoiseValue(Select{edgeFallOff=falloff,lowerBound=low,upperBound=up,controller=ctrl})[src1,src2]pt|up>low=selectFunc|otherwise=NothingwherecontrolVal=fromMaybe0.0$getValuectrlptsrc1Val=getValuesrc1ptsrc2Val=getValuesrc2ptlowerCurve1=low-falloffupperCurve1=low+falloffalpha1=scurve3$(controlVal-lowerCurve1)/(upperCurve1-lowerCurve1)lowerCurve2=up-falloffupperCurve2=up+falloffalpha2=scurve3$(controlVal-lowerCurve2)/(upperCurve2-lowerCurve2)maybeLinear(Justa)(Justb)alph=Just$linearabalphmaybeLinear__alph=NothingselectFunc|falloff>0.0=selectFallOff|otherwise=selectNoFallOffselectFallOff|controlVal<(low-falloff)=getValuesrc1pt|controlVal<(low+falloff)=maybeLinearsrc1Valsrc2Valalpha1|controlVal<(up-falloff)=src2Val|controlVal<(up+falloff)=maybeLinearsrc2Valsrc1Valalpha2|otherwise=src1ValselectNoFallOff|controlVal<low||controlVal>up=src1Val|otherwise=src2ValgetNoiseValues[]pt=Nothing