Add Gradient
photopea_add_gradientReplace a layer's pixel content with a linear gradient. Define evenly spaced hex color stops and set an angle for the gradient direction (0° left-to-right).
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
| 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) |