Add linear gradient
add_linear_gradientDefine a directional color gradient in an SVG document by specifying color stops and optional vector endpoints, then apply it as a fill.
Instructions
Add a <linearGradient> to the document <defs> (created if absent).
When to use: defining a directional colour fade to paint with. For a centred/radial fade use
add_radial_gradient; after defining, apply it via set_fill(doc_id, ids, "url(#grad-id)").
Key params: stops is a list of {offset, color, opacity?} (≥ 1): offset a 0..1 number or
0%..100% percentage, color a validated colour, optional opacity in [0, 1]. The vector runs
(x1, y1) -> (x2, y2) (numbers or percentages; default a left-to-right sweep).
Return shape: CreateResult — object_id is the gradient id (use as url(#id) paint),
bbox=None (a def, not a drawn shape), plus the pipeline fields.
Example: add_linear_gradient(doc_id, [{"offset": 0, "color": "#fff"}, {"offset": 1, "color": "#3366cc"}])
Render and look before you trust this edit: render with render_preview (or live_render_view)
and inspect the result before relying on it; restore_snapshot reverts it if it is wrong.
Risk class: medium (reversible write-new on the working copy; original untouched).
Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| x1 | No | 0% | |
| x2 | No | 100% | |
| y1 | No | 0% | |
| y2 | No | 0% | |
| stops | Yes | ||
| doc_id | Yes | ||
| object_id | No |
Output Schema
| Name | Required | Description | Default |
|---|---|---|---|
| bbox | No | ||
| doc_id | Yes | ||
| changed | Yes | ||
| summary | No | ||
| object_id | Yes | ||
| snapshot_id | Yes | ||
| operation_id | Yes | ||
| preview_after | No | ||
| preview_before | No |