C# Class LibNoise.Renderer.ImageRenderer

Renders an image from a noise map. This class renders an image given the contents of a noise-map object. An application can configure the output of the image in three ways: - Specify the color gradient. - Specify the light source parameters. - Specify the background image. Specify the color gradient This class uses a color gradient to calculate the color for each pixel in the destination image according to the value from the corresponding position in the noise map. A color gradient is a list of gradually-changing colors. A color gradient is defined by a list of gradient points. Each gradient point has a position and a color. In a color gradient, the colors between two adjacent gradient points are linearly interpolated. For example, suppose this class contains the following color gradient: - -1.0 maps to dark blue. - -0.2 maps to light blue. - -0.1 maps to tan. - 0.0 maps to green. - 1.0 maps to white. The value 0.5 maps to a greenish-white color because 0.5 is halfway between 0.0 (mapped to green) and 1.0 (mapped to white). The value -0.6 maps to a medium blue color because -0.6 is halfway between -1.0 (mapped to dark blue) and -0.2 (mapped to light blue). The color gradient requires a minimum of two gradient points. @note The color value ie the gradient color has an alpha channel. This alpha channel specifies how a pixel in the background image (if specified) is blended with the calculated color. If the alpha value is high, this class weighs the blend towards the calculated color, and if the alpha value is low, this class weighs the blend towards the color from the corresponding pixel in the background image. Specify the light source parameters This class contains a parallel light source that lights the image. It interprets the noise map as a bump map. To enable or disable lighting, pass a Boolean value to the EnableLight property. To set the position of the light source in the "sky", use the LightAzimuth and LightElevation properties. To set the color of the light source, use the LightColor property. To set the intensity of the light source, use the LightIntensity property. A good intensity value is 2.0, although that value tends to "wash out" very light colors from the image. To set the contrast amount between areas in light and areas in shadow, use the LightContrast property. Determining the correct contrast amount requires some trial and error, but if your application interprets the noise map as a height map that has its elevation values measured in meters and has a horizontal resolution of h meters, a good contrast amount to use is ( 1.0 / h ). Specify the background image To specify a background image, pass an Image object to the BackgroundImage property. This class determines the color of a pixel in the destination image by blending the calculated color with the color of the corresponding pixel from the background image. The blend amount is determined by the alpha of the calculated color. If the alpha value is high, this class weighs the blend towards the calculated color, and if the alpha value is low, this class weighs the blend towards the color from the corresponding pixel in the background image. Rendering the image To render the image, perform the following steps: - Pass a GradientColor object to the Gradient property. - Pass a IMap2D{Single} object to the NoiseMap property. - Pass an IMap2D{Color} object to the Image property. - Pass an Image object to the BackgroundImage property (optional) - Call the Render() method.
Inheritance: AbstractImageRenderer
Afficher le fichier Open project: everbytes/LibNoise Class Usage Examples

Méthodes publiques

Méthode Description
ImageRenderer ( ) : System

Default constructor

Render ( ) : void

Renders the destination image using the contents of the source noise map and an optional background image. @pre NoiseMap has been defined. @pre Image has been defined. @pre There are at least two gradient points in the color gradient. @pre No two gradient points have the same position. @pre If a background image was specified, it has the exact same size as the source height map. @post The original contents of the destination image is destroyed. @throw ArgumentException See the preconditions. The background image and the destination image can safely refer to the same image, although in this case, the destination image is irretrievably blended into the background image.

Private Methods

Méthode Description
CalcDestColor ( IColor sourceColor, IColor backgroundColor, float lightValue ) : IColor

Calculates the destination color.

CalcLightIntensity ( float center, float left, float right, float down, float up ) : float

Calculates the intensity of the light given some elevation values.

Method Details

ImageRenderer() public méthode

Default constructor
public ImageRenderer ( ) : System
Résultat System

Render() public méthode

Renders the destination image using the contents of the source noise map and an optional background image. @pre NoiseMap has been defined. @pre Image has been defined. @pre There are at least two gradient points in the color gradient. @pre No two gradient points have the same position. @pre If a background image was specified, it has the exact same size as the source height map. @post The original contents of the destination image is destroyed. @throw ArgumentException See the preconditions. The background image and the destination image can safely refer to the same image, although in this case, the destination image is irretrievably blended into the background image.
public Render ( ) : void
Résultat void