Provides a texture that can be written to or read from. Can be accessed using Texture.control on a Procedural Texture.

// @input Component.Image image

var width = 64;
var height = 64;
var channels = 4; // RGBA

var newTex = ProceduralTextureProvider.create(width, height, Colorspace.RGBA);
var newData = new Uint8Array(width * height * channels);

for (var y=0; y<height; y++) {
for (var x=0; x<width; x++) {
// Calculate index
var index = (y * width + x) * channels;

// Set R, G, B, A
newData[index] = (x / (width-1)) * 255;
newData[index+1] = (y / (height-1)) * 255;
newData[index+2] = 0;
newData[index+3] = 255;
}
}

newTex.control.setPixels(0, 0, width, height, newData);
script.image.mainPass.baseTex = newTex;
interface ProceduralTextureProvider {
    getAspect(): number;
    getHeight(): number;
    getLoadStatus(): LoadStatus;
    getPixels(x: number, y: number, width: number, height: number, data: Uint8Array): void;
    getTypeName(): string;
    getWidth(): number;
    isOfType(type: string): boolean;
    isSame(other: ScriptObject): boolean;
    setPixels(x: number, y: number, width: number, height: number, data: Uint8Array): void;
}

Hierarchy (view full)

Methods

  • Returns the texture's aspect ratio, which is calculated as width / height.

    Returns number

  • Exposes User Data

    Returns a Uint8 array containing the pixel values in a region of the texture. The region starts at the pixel coordinates x, y, and extends rightward by width and upward by height. Values returned are integers ranging from 0 to 255.

    Parameters

    • x: number
    • y: number
    • width: number
    • height: number
    • data: Uint8Array

    Returns void

  • Returns the width of the texture in pixels.

    Returns number

  • Returns true if the object matches or derives from the passed in type.

    Parameters

    • type: string

    Returns boolean

  • Returns true if this object is the same as other. Useful for checking if two references point to the same thing.

    Parameters

    Returns boolean

  • Sets a region of pixels on the texture. The region starts at the pixel coordinates x, y, and extends rightward by width and upward by height. Uses the values of the passed in Uint8Array data, which should be integer values ranging from 0 to 255.

    Parameters

    • x: number
    • y: number
    • width: number
    • height: number
    • data: Uint8Array

    Returns void