Add Gradient
photopea_add_gradientApply a linear gradient fill to an existing layer, replacing pixel content with custom hex colors distributed evenly at a specified angle.
Instructions
Apply a linear gradient fill to a layer, replacing its current pixel content. The target layer must already exist — use add_layer to create one first. Colors are distributed evenly across the gradient.
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| target | Yes | Layer name (string) or index (number) | |
| type | Yes | Gradient type (currently only 'linear' is supported) | |
| colors | Yes | Array of hex color stops distributed evenly along the gradient (minimum 2, e.g. ['#ff0000', '#0000ff']) | |
| angle | No | Gradient angle in degrees (0 = left-to-right, 90 = top-to-bottom, default 0) |