java.lang.Object
org.spongepowered.noise.module.NoiseModule
org.spongepowered.noise.module.modifier.Clamp

public class Clamp extends NoiseModule
Noise module that clamps the output value from a source module to a range of values.

The range of values in which to clamp the output value is called the clamping range.

If the output value from the source module is less than the lower bound of the clamping range, this noise module clamps that value to the lower bound. If the output value from the source module is greater than the upper bound of the clamping range, this noise module clamps that value to the upper bound.

To specify the upper and lower bounds of the clamping range, call the setLowerBound(double) and setUpperBound(double) methods.

Source Modules
This module requires one source module.
  • Field Details

    • DEFAULT_LOWER_BOUND

      public static final double DEFAULT_LOWER_BOUND
      Default lower bound of the clamping range for the Clamp noise module.
      See Also:
    • DEFAULT_UPPER_BOUND

      public static final double DEFAULT_UPPER_BOUND
      Default upper bound of the clamping range of the Clamp noise module.
      See Also:
  • Constructor Details

    • Clamp

      public Clamp()
    • Clamp

      public Clamp(NoiseModule source)
      Create a new Clamp module with the source modules pre-configured.
      Parameters:
      source - the input module
  • Method Details

    • lowerBound

      public double lowerBound()
      Get the lower bound of the clamping range.

      If the output value from the source module is less than the lower bound of the clamping range, this noise module clamps that value to the lower bound.

      Returns:
      the lower bound
    • setLowerBound

      public void setLowerBound(double lowerBound)
      Set the lower bound of the clamping range.

      The lower bound must be less than or equal to the upper bound.

      Parameters:
      lowerBound - the lower bound
    • upperBound

      public double upperBound()
      Get the upper bound of the clamping range.

      If the output value from the source module is greater than the upper bound of the clamping range, this noise module clamps that value to the upper bound.

      Returns:
      the upper bound
    • setUpperBound

      public void setUpperBound(double upperBound)
      Set the upper bound of the clamping range.

      The upper bound must be greater than or equal to the lower bound.

      Parameters:
      upperBound - the upper bound
    • get

      public double get(double x, double y, double z)
      Description copied from class: NoiseModule
      Generates an output value given the coordinates of the specified input value.

      All source modules required by this module must have been connected with the NoiseModule.setSourceModule(int, NoiseModule) method. If these source modules are not connected, this method will throw a NoModuleException.

      To determine the number of source modules required by this noise module, call the NoiseModule.sourceModuleCount() method.

      Specified by:
      get in class NoiseModule
      Parameters:
      x - the x coordinate of the input value
      y - the y coordinate of the input value
      z - the z coordinate of the input value
      Returns:
      the output value