コード例 #1
0
        public override double GetWrapped(double x, double y, int wrap)
        {
            double controlValue = ControlModule.GetWrapped(x, y, wrap);
            double alpha;

            double lowerBound  = LowerBound.GetWrapped(x, y, wrap);
            double upperBound  = UpperBound.GetWrapped(x, y, wrap);
            double edgeFalloff = EdgeFalloff.GetWrapped(x, y, wrap);

            if (edgeFalloff > 0.0)
            {
                if (controlValue < (lowerBound - edgeFalloff))
                {
                    // The output value from the control module is below the selector
                    // threshold; return the output value from the first source module.
                    return(SourceModule1.GetWrapped(x, y, wrap));
                }
                else if (controlValue < (lowerBound + edgeFalloff))
                {
                    // The output value from the control module is near the lower end of the
                    // selector threshold and within the smooth curve. Interpolate between
                    // the output values from the first and second source modules.
                    double lowerCurve = (lowerBound - edgeFalloff);
                    double upperCurve = (lowerBound + edgeFalloff);
                    alpha = Loonim.Math.SCurve3((controlValue - lowerCurve) / (upperCurve - lowerCurve));
                    return(Loonim.Math.LinearInterpolate(SourceModule1.GetWrapped(x, y, wrap),
                                                         SourceModule2.GetWrapped(x, y, wrap), alpha));
                }
                else if (controlValue < (upperBound - edgeFalloff))
                {
                    // The output value from the control module is within the selector
                    // threshold; return the output value from the second source module.
                    return(SourceModule2.GetWrapped(x, y, wrap));
                }
                else if (controlValue < (upperBound + edgeFalloff))
                {
                    // The output value from the control module is near the upper end of the
                    // selector threshold and within the smooth curve. Interpolate between
                    // the output values from the first and second source modules.
                    double lowerCurve = (upperBound - edgeFalloff);
                    double upperCurve = (upperBound + edgeFalloff);
                    alpha = Loonim.Math.SCurve3(
                        (controlValue - lowerCurve) / (upperCurve - lowerCurve));
                    return(Loonim.Math.LinearInterpolate(SourceModule2.GetWrapped(x, y, wrap),
                                                         SourceModule1.GetWrapped(x, y, wrap),
                                                         alpha));
                }
                else
                {
                    // Output value from the control module is above the selector threshold;
                    // return the output value from the first source module.
                    return(SourceModule1.GetWrapped(x, y, wrap));
                }
            }
            else
            {
                if (controlValue < lowerBound || controlValue > upperBound)
                {
                    return(SourceModule1.GetWrapped(x, y, wrap));
                }
                else
                {
                    return(SourceModule2.GetWrapped(x, y, wrap));
                }
            }
        }