Instance Method

initWithColorGradientFrom:toColor:name:textureDimensions:

Initializes a texture that creates a vertical gradient between two colors.

Declaration

- (instancetype)initWithColorGradientFrom:(CGColorRef)color1 toColor:(CGColorRef)color2 name:(NSString *)name textureDimensions:(vector_int2)textureDimensions;

Parameters

color1

The color at the top of the gradient.

color2

The color at the bottom of the gradient.

name

The name property for the new texture object.

textureDimensions

The texel dimensions (width and height) of the texture image.

Return Value

A new color swatch texture object.

Discussion

Model I/O interpolates between the color1 and color2 colors by hue, saturation, and lightness to create a color gradient when generating texture data.

This initializer does not generate texel data; the MDLColorSwatchTexture class automatically generates data and caches it for reuse when you use one of the MDLTexture methods listed in Accessing Texture Data.

See Also

Creating a Color Swatch Texture

- initWithColorTemperatureGradientFrom:toColorTemperature:name:textureDimensions:

Initializes a texture that creates a vertical gradient between two color temperatures.