---
title: "object.gradient: Gradient — Layout kit command — Kition"
description: "Applies a linear or radial gradient with colour stops to objects' fill or stroke."
canonical: "https://developer.kition.ai/docs/kits/layout/commands/object.gradient"
---

> Canonical HTML: [https://developer.kition.ai/docs/kits/layout/commands/object.gradient](https://developer.kition.ai/docs/kits/layout/commands/object.gradient)

# object.gradient

**Gradient.** Applies a linear or radial gradient with colour stops to objects' fill or stroke.

- Kit: Layout 0.1.0 (.klayout); reference: [Layout kit commands](https://developer.kition.ai/docs/kits/layout.md)
- Changes the document: yes
- Acts on: `ids` (a list of ids), which a run step’s `on` fills

## Parameters

| Name | Type | Required | Description |
| --- | --- | --- | --- |
| `angle` | `number` | no | degrees |
| `from` | `number[]` | no |  |
| `ids` | `(integer \| string)[]` | no |  |
| `kind` | `"linear" \| "radial"` | no |  |
| `reverse` | `boolean` | no |  |
| `stops` | `object[]` | no | [{location: 0–100, color: "#rrggbb"\|{c,m,y,k}\|[r,g,b], opacity?: 0–100, midpoint?: 13–87}] |
| `to` | `number[]` | no | spread coords: the Gradient Swatch tool's drag |

## Call through layout_run

```text
layout_run {
  "path": "<file>.klayout",
  "steps": [{ "command": "object.gradient" }]
}
```

The required parameters, with placeholders for their types: not a tested example. Optional: `angle`, `from`, `ids`, `kind`, `reverse`, `stops`, `to`. layout_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": {
    "angle": {
      "description": "degrees",
      "type": "number"
    },
    "from": {
      "items": {
        "type": "number"
      },
      "type": "array"
    },
    "ids": {
      "items": {
        "description": "an id",
        "oneOf": [
          {
            "type": "integer"
          },
          {
            "type": "string"
          }
        ]
      },
      "type": "array",
      "x-khp-types": [
        "Item"
      ]
    },
    "kind": {
      "enum": [
        "linear",
        "radial"
      ],
      "type": "string"
    },
    "reverse": {
      "type": "boolean"
    },
    "stops": {
      "description": "[{location: 0–100, color: \"#rrggbb\"|{c,m,y,k}|[r,g,b], opacity?: 0–100, midpoint?: 13–87}]",
      "items": {
        "additionalProperties": true,
        "properties": {
          "color": {
            "description": "\"#rrggbb\"|{c,m,y,k}|[r,g,b]"
          },
          "location": {
            "description": "0–100"
          },
          "midpoint": {
            "description": "13–87"
          },
          "opacity": {
            "description": "0–100"
          }
        },
        "type": "object"
      },
      "type": "array"
    },
    "to": {
      "description": "spread coords: the Gradient Swatch tool's drag",
      "items": {
        "type": "number"
      },
      "type": "array"
    }
  },
  "returns": "{swatch, kind, stops} — edits the fill's gradient (an unnamed gradient unless it equals a gradient swatch)",
  "type": "object"
}
```

Generated from the command list of @kition/layout-darwin-arm64@0.1.0 and the kit itself (layout_commands through @kition/cli@0.1.1, built from KitionAI/kition-layout@8767a18).
