Description

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

Example

// @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, y, width, height, data): void;
    getTypeName(): string;
    getWidth(): number;
    isOfType(type): boolean;
    isSame(other): boolean;
    setPixels(x, y, width, height, data): void;
}

Hierarchy (view full)

Methods

  • Returns number

    Description

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

  • Returns number

    Description

    Returns the height of the texture in pixels.

  • Parameters

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

    Returns void

    Exposes User Data

    Description

    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.

  • Returns number

    Description

    Returns the width of the texture in pixels.

  • Parameters

    • type: string

    Returns boolean

    Description

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

  • Parameters

    Returns boolean

    Description

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

  • Parameters

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

    Returns void

    Description

    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.

Generated using TypeDoc