Skip to content

colorReplaceMultiple

colorReplaceMultiple(inputColor, sourceColors, targetColors, tolerance): Node<"vec4">

Defined in: packages/nodes/src/retro/colorReplace.ts:110

Replace multiple colors at once (palette swap). Each source color maps to a corresponding target color.

Parameters

inputColor

Node<"vec4">

The input color (vec4 with alpha)

sourceColors

[number, number, number][]

Array of colors to find (RGB tuples)

targetColors

[number, number, number][]

Array of colors to replace with (RGB tuples)

tolerance

FloatInput = 0.1

Match tolerance (default: 0.1)

Returns

Node<"vec4">

Color with all replacements applied

Example

// Swap entire character palette
colorReplaceMultiple(
color,
[[1, 0, 0], [0, 1, 0], [0, 0, 1]], // Source: red, green, blue
[[1, 0.5, 0], [0, 0.5, 0], [0.5, 0, 1]], // Target: orange, dark green, purple
0.15
)