Type Method

noiseWithNoiseSource:gradientColors:

Creates a noise object with the specified noise source, with colors for later use in generating noise textures.

Declaration

iOS, Mac Catalyst, tvOS
+ (instancetype)noiseWithNoiseSource:(GKNoiseSource *)noiseSource gradientColors:(NSDictionary<NSNumber *,UIColor *> *)gradientColors;
macOS
+ (instancetype)noiseWithNoiseSource:(GKNoiseSource *)noiseSource gradientColors:(NSDictionary<NSNumber *,NSColor *> *)gradientColors;

Parameters

noiseSource

The noise source defining the style and configuration of noise to generate.

gradientColors

A dictionary that specifies a gradient ramp for colorizing generated noise. Each key in this dictionary specifies a value in the generated noise field, and the corresponding value for that key is the color to associate with that noise value when generating textures or images from the noise field. For more details, see the gradientColors property.

Return Value

A new noise object.

Discussion

To sample from the newly created object’s noise field or generate texture images, create a GKNoiseMap object from this noise object. Optionally, before doing so you can apply operations to process or transform the noise field, or combine it with other noise objects, to create a more complex or natural noise pattern. For details, see Applying Operations to Noise Values, Applying Operations that Combine Noise, Applying Operations that Distort Noise, Applying Geometric Transformations, and Creating Noise by Combining Noise.

The gradientColors parameter specifies a color ramp as metadata to accompany the noise object. When you later create a GKNoiseMap object from this noise object and use the textureWithNoiseMap: method to generate a texture image from the noise map, the SKTexture class automatically uses the gradient colors from the noise map’s underlying noise objects. If you combine noise objects using the noiseWithComponentNoises:selectionNoise: method before generating a noise map, texture generation automatically uses the color gradient corresponding to each component noise for the regions of the noise map where that noise appears.

Figure 1

Specifying gradient colors to produce a colorize texture

See Also

Creating Noise

- initWithNoiseSource:

Initializes a noise object with the specified noise source.

- initWithNoiseSource:gradientColors:

Initializes a noise object with the specified noise source, with colors for later use in generating noise textures.

+ noiseWithNoiseSource:

Creates a noise object with the specified noise source.