Photo kit command

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)
Changes the document
yes
Acts on
layer (one id), which a run step’s on fills

Parameters

Parameters of shape.add
NameTypeRequiredDescription
addToanynolayerId|{"layer":layerId,"op":…}? (append to an existing shape layer instead of making one); append to an existing shape layer instead of making one
atnumber[]noInstead 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).
backgroundColorstringnoThe background color the command uses, "#rrggbb", for this call only; the current background color by default.
coalescestringnoMerges consecutive edits with the same key into one undo step, as a slider drag or a typing session is one.
fillobjectno"#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
foregroundColorstringnoThe foreground color the command uses, "#rrggbb", for this call only; the current foreground color by default.
fromnumber[]no
kind"rect" | "roundedRect" | "ellipse" | "polygon" | "star" | "line" | "path"no
layerinteger | stringnoThe 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.
namestringno
op"combine" | "subtract" | "intersect" | "exclude"nowith addTo
pathobjectnokind path
radiinumber[]no[tl,tr,br,bl]|r (roundedRect=10); roundedRect=10
rectnumber[]norect/roundedRect/ellipse/polygon/star
sidesintegerno3 to 100
starRationumberno0 to 1; star=0.5
strokeobjectno{"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
tonumber[]no
weightnumbernopixels; 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/[email protected] and the kit itself (photo_commands through @kition/[email protected], built from KitionAI/kition-photo@abe3f30). As data: commands.jsonl.