Reference getColor()

getColor()

Registers a callback to set the final color for each pixel in a filter shader. This hook can be used inside baseFilterShader().modify() and similar shader modify() calls to control the output color for each pixel. The callback receives the following arguments:

  • inputs: an object with the following properties:

    • texCoord: a two-component vector representing the texture coordinates (u, v).
    • canvasSize: a two-component vector representing the canvas size in pixels (width, height).
    • texelSize: a two-component vector representing the size of a single texel in texture space.
  • canvasContent: a texture containing the sketch's contents before the filter is applied.

Return a four-component vector [r, g, b, a] for the pixel.

This hook is available in:

Examples

Syntax

getColor(callback)

Parameters

callback
Function: A callback function which receives the inputs object and canvasContent, and should return a color array.
Notice any errors or typos? Please let us know. Please feel free to edit src/strands/p5.strands.js and open a pull request!

Related References