---
title: "gradient.fill.add: Gradient (Live) — Photo kit command — Kition"
description: "Adds a gradient fill layer from `from` to `to` px in `style` (linear, radial, angle, reflected, diamond), using a preset `gradient` or `stops`; stays editable."
canonical: "https://developer.kition.ai/docs/kits/photo/commands/gradient.fill.add"
---

> Canonical HTML: [https://developer.kition.ai/docs/kits/photo/commands/gradient.fill.add](https://developer.kition.ai/docs/kits/photo/commands/gradient.fill.add)

# gradient.fill.add

**Gradient (Live).** Adds a gradient fill layer from `from` to `to` px in `style` (linear, radial, angle, reflected, diamond), using a preset `gradient` or `stops`; stays editable.

- Kit: Photo 0.1.0 (PSD, PSB, or .kphoto); reference: [Photo kit commands](https://developer.kition.ai/docs/kits/photo.md)
- Changes the document: yes
- Acts on: `layer` (one id), which a run step’s `on` fills

## Parameters

| Name | Type | Required | Description |
| --- | --- | --- | --- |
| `at` | `number[]` | no | Instead of `layer`: a point [x, y] in image pixels; the command acts on the topmost visible layer, not fully locked, with a pixel there (the Move tool's Auto-Select). |
| `backgroundColor` | `string` | no | The background color the command uses, "#rrggbb", for this call only; the current background color by default. |
| `coalesce` | `string` | no | Merges consecutive edits with the same key into one undo step, as a slider drag or a typing session is one. |
| `dither` | `boolean` | no |  |
| `foregroundColor` | `string` | no | The foreground color the command uses, "#rrggbb", for this call only; the current foreground color by default. |
| `from` | `number[]` | no |  |
| `gradient` | `any` | no | preset name? |
| `layer` | `integer \| string` | no | The layer: its id as inspect lists it, "#n" (the n-th layer of the image's top level as inspect lists it, counted from the top: "#1" is the top one), or its whole name when no other layer has it; the active layer by default. |
| `mode` | `string` | no | for example normal, multiply |
| `opacity` | `integer` | no | 0 to 100 |
| `region` | `object` | no | Where the command acts, for this call only: {"rect": [x, y, width, height]}, {"ellipse": [x, y, width, height]}, {"polygon": [[x, y], …]} (3 points or more), {"layer": id} (that layer's pixels, by their opacity), {"channel": name or index} (a saved selection or alpha channel), or "all"; add "invert": true to take everything else. Without it, inside the current selection (made with select.* earlier in the run), or everywhere when there is none. |
| `reverse` | `boolean` | no |  |
| `stops` | `any[]` | no | [[t,"#rrggbb"\|"foreground"\|"background"],…]? |
| `style` | `"linear" \| "radial" \| "angle" \| "reflected" \| "diamond"` | no |  |
| `to` | `number[]` | no |  |
| `transparency` | `number[][]` | no | default: the current gradient |

## Call through photo_run

```text
photo_run {
  "path": "<file>.psd",
  "steps": [{ "command": "gradient.fill.add" }]
}
```

The required parameters, with placeholders for their types: not a tested example. Optional: `at`, `backgroundColor`, `coalesce`, `dither`, `foregroundColor`, `from`, `gradient`, `layer`, `mode`, `opacity`, `region`, `reverse`, `stops`, `style`, `to`, `transparency`. photo_run answers the step’s result in `completed[i].result`.

## Result

The kit gives no result schema for this command.

## Parameter schema

```json
{
  "additionalProperties": false,
  "properties": {
    "at": {
      "description": "Instead of `layer`: a point [x, y] in image pixels; the command acts on the topmost visible layer, not fully locked, with a pixel there (the Move tool's Auto-Select).",
      "items": {
        "type": "number"
      },
      "type": "array"
    },
    "backgroundColor": {
      "description": "The background color the command uses, \"#rrggbb\", for this call only; the current background color by default.",
      "type": "string"
    },
    "coalesce": {
      "description": "Merges consecutive edits with the same key into one undo step, as a slider drag or a typing session is one.",
      "type": "string"
    },
    "dither": {
      "default": true,
      "type": "boolean"
    },
    "foregroundColor": {
      "description": "The foreground color the command uses, \"#rrggbb\", for this call only; the current foreground color by default.",
      "type": "string"
    },
    "from": {
      "items": {
        "type": "number"
      },
      "type": "array"
    },
    "gradient": {
      "description": "preset name?"
    },
    "layer": {
      "description": "The layer: its id as inspect lists it, \"#n\" (the n-th layer of the image's top level as inspect lists it, counted from the top: \"#1\" is the top one), or its whole name when no other layer has it; the active layer by default.",
      "oneOf": [
        {
          "type": "integer"
        },
        {
          "type": "string"
        }
      ],
      "x-khp-index": "#",
      "x-khp-index-order": "reversed",
      "x-khp-name": "name",
      "x-khp-types": [
        "Layer"
      ]
    },
    "mode": {
      "default": "normal",
      "description": "for example normal, multiply",
      "type": "string"
    },
    "opacity": {
      "default": 100,
      "description": "0 to 100",
      "type": "integer"
    },
    "region": {
      "description": "Where the command acts, for this call only: {\"rect\": [x, y, width, height]}, {\"ellipse\": [x, y, width, height]}, {\"polygon\": [[x, y], …]} (3 points or more), {\"layer\": id} (that layer's pixels, by their opacity), {\"channel\": name or index} (a saved selection or alpha channel), or \"all\"; add \"invert\": true to take everything else. Without it, inside the current selection (made with select.* earlier in the run), or everywhere when there is none.",
      "properties": {
        "channel": {
          "x-khp-name": "name",
          "x-khp-role": "object",
          "x-khp-types": [
            "Channel"
          ]
        }
      }
    },
    "reverse": {
      "default": false,
      "type": "boolean"
    },
    "stops": {
      "description": "[[t,\"#rrggbb\"|\"foreground\"|\"background\"],…]?",
      "type": "array"
    },
    "style": {
      "default": "linear",
      "enum": [
        "linear",
        "radial",
        "angle",
        "reflected",
        "diamond"
      ],
      "type": "string"
    },
    "to": {
      "items": {
        "type": "number"
      },
      "type": "array"
    },
    "transparency": {
      "description": "default: the current gradient",
      "items": {
        "description": "[t, 0..100]",
        "items": {
          "type": "number"
        },
        "type": "array"
      },
      "type": "array"
    }
  },
  "returns": "{\"layer\":id}; a Gradient Fill layer above the active layer, masked by the selection",
  "type": "object"
}
```

Generated from the command list of @kition/photo-darwin-arm64@0.1.0 and the kit itself (photo_commands through @kition/cli@0.1.1, built from KitionAI/kition-photo@abe3f30).
