---
title: "shape.add: New Shape Layer — Photo kit command — Kition"
description: "Adds a shape layer (rectangle, rounded rectangle, ellipse, polygon, star, line or path) with fill and stroke; answers its id."
canonical: "https://developer.kition.ai/docs/kits/photo/commands/shape.add"
---

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

# shape.add

**New Shape Layer.** Adds a shape layer (rectangle, rounded rectangle, ellipse, polygon, star, line or path) with fill and stroke; answers its id.

- 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 |
| --- | --- | --- | --- |
| `addTo` | `any` | no | layerId\|{"layer":layerId,"op":…}? (append to an existing shape layer instead of making one); append to an existing shape layer instead of making one |
| `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. |
| `fill` | `object` | no | "#rrggbb"\|[r,g,b,a]\|{"gradient":{"stops":[[t,"#hex"]],"angle":deg,"scale":%,"style":"linear\|radial\|angle\|reflected\|diamond","reverse":bool}}\|{"pattern":name}\|null (no fill)=foreground; no fill; default foreground |
| `foregroundColor` | `string` | no | The foreground color the command uses, "#rrggbb", for this call only; the current foreground color by default. |
| `from` | `number[]` | no |  |
| `kind` | `"rect" \| "roundedRect" \| "ellipse" \| "polygon" \| "star" \| "line" \| "path"` | no |  |
| `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. |
| `name` | `string` | no |  |
| `op` | `"combine" \| "subtract" \| "intersect" \| "exclude"` | no | with addTo |
| `path` | `object` | no | kind path |
| `radii` | `number[]` | no | [tl,tr,br,bl]\|r (roundedRect=10); roundedRect=10 |
| `rect` | `number[]` | no | rect/roundedRect/ellipse/polygon/star |
| `sides` | `integer` | no | 3 to 100 |
| `starRatio` | `number` | no | 0 to 1; star=0.5 |
| `stroke` | `object` | no | {"width":px,"color":"#rrggbb"\|fill,"opacity":0..100,"align":"inside\|center\|outside","cap":"butt\|round\|square","join":"miter\|round\|bevel","miterLimit":n,"dashes":[multiples of width],"dashOffset":n}\|null=none; default none |
| `to` | `number[]` | no |  |
| `weight` | `number` | no | pixels; line |

## Call through photo_run

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

The required parameters, with placeholders for their types: not a tested example. Optional: `addTo`, `at`, `backgroundColor`, `coalesce`, `fill`, `foregroundColor`, `from`, `kind`, `layer`, `name`, `op`, `path`, `radii`, `rect`, `sides`, `starRatio`, `stroke`, `to`, `weight`. 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": {
    "addTo": {
      "description": "layerId|{\"layer\":layerId,\"op\":…}? (append to an existing shape layer instead of making one); append to an existing shape layer instead of making one"
    },
    "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"
    },
    "fill": {
      "description": "\"#rrggbb\"|[r,g,b,a]|{\"gradient\":{\"stops\":[[t,\"#hex\"]],\"angle\":deg,\"scale\":%,\"style\":\"linear|radial|angle|reflected|diamond\",\"reverse\":bool}}|{\"pattern\":name}|null (no fill)=foreground; no fill; default foreground",
      "properties": {
        "pattern": {
          "x-khp-name": "name",
          "x-khp-role": "object",
          "x-khp-types": []
        }
      }
    },
    "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"
    },
    "kind": {
      "default": "rect",
      "enum": [
        "rect",
        "roundedRect",
        "ellipse",
        "polygon",
        "star",
        "line",
        "path"
      ],
      "type": "string"
    },
    "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"
      ]
    },
    "name": {
      "type": "string"
    },
    "op": {
      "default": "combine",
      "description": "with addTo",
      "enum": [
        "combine",
        "subtract",
        "intersect",
        "exclude"
      ],
      "type": "string"
    },
    "path": {
      "additionalProperties": true,
      "description": "kind path",
      "type": "object"
    },
    "radii": {
      "description": "[tl,tr,br,bl]|r (roundedRect=10); roundedRect=10",
      "items": {
        "type": "number"
      },
      "type": "array"
    },
    "rect": {
      "description": "rect/roundedRect/ellipse/polygon/star",
      "items": {
        "type": "number"
      },
      "type": "array"
    },
    "sides": {
      "default": 5,
      "description": "3 to 100",
      "type": "integer"
    },
    "starRatio": {
      "description": "0 to 1; star=0.5",
      "type": "number"
    },
    "stroke": {
      "description": "{\"width\":px,\"color\":\"#rrggbb\"|fill,\"opacity\":0..100,\"align\":\"inside|center|outside\",\"cap\":\"butt|round|square\",\"join\":\"miter|round|bevel\",\"miterLimit\":n,\"dashes\":[multiples of width],\"dashOffset\":n}|null=none; default none",
      "properties": {
        "fill": {
          "properties": {
            "pattern": {
              "x-khp-name": "name",
              "x-khp-role": "object",
              "x-khp-types": []
            }
          }
        }
      }
    },
    "to": {
      "items": {
        "type": "number"
      },
      "type": "array"
    },
    "weight": {
      "default": 1,
      "description": "pixels; line",
      "type": "number"
    }
  },
  "returns": "shape.info. path: {\"subpaths\":[{\"closed\":bool=true,\"op\":\"combine|subtract|intersect|exclude\",\"knots\":[[x,y] | {\"anchor\":[x,y],\"in\":[x,y],\"out\":[x,y],\"smooth\":bool}]}],\"fillRule\":\"nonzero|evenodd\",\"inverted\":bool}",
  "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).
