{
  "openapi": "3.1.1",
  "info": {
    "title": "Layer Transform & Bounds Planner API",
    "version": "1.0.0",
    "summary": "Calculate a layer transform, rotated corners and canvas bounds.",
    "description": "Every endpoint performs the same calculation as the human page and returns inputs, result, units, assumptions, sources, warnings and computedAt. MCP endpoint: /mcp."
  },
  "servers": [
    {
      "url": "https://luminalayertransform.usefulweb.app"
    }
  ],
  "paths": {
    "/api/v1/calculate": {
      "post": {
        "operationId": "calculate",
        "summary": "Calculate a layer transform, rotated corners and canvas bounds.",
        "description": "Enter canvas and layer dimensions, center position, rotation and flips. Get the affine matrix for normalized layer coordinates plus exact corner and bounding-box coordinates.\n\nMethodology:\n- For layer-local coordinates u/v from 0 to 1, canvas x = a*u + c*v + e and y = b*u + d*v + f.\n- The layer rotates around its center. Flips apply in local space before rotation. Coordinates outside the canvas are retained.\n- The same affine transform is used by Design Layers for selection, dragging and mask coordinates.",
        "tags": [
          "apps"
        ],
        "x-mcp-tool": "lumina_layer_transform",
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/LuminaLayerTransformInput"
              },
              "examples": {
                "example1": {
                  "summary": "A rotated photo on a cover",
                  "value": {
                    "canvasWidth": 1000,
                    "canvasHeight": 700,
                    "width": 600,
                    "height": 400,
                    "x": 500,
                    "y": 350,
                    "rotation": 20
                  }
                }
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Calculation result envelope.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/LuminaLayerTransformResult"
                }
              }
            }
          },
          "400": {
            "description": "Malformed JSON body.",
            "content": {
              "application/problem+json": {
                "schema": {
                  "$ref": "#/components/schemas/Problem"
                }
              }
            }
          },
          "422": {
            "description": "Invalid input (see errors[]).",
            "content": {
              "application/problem+json": {
                "schema": {
                  "$ref": "#/components/schemas/Problem"
                }
              }
            }
          },
          "429": {
            "description": "Rate limit exceeded (see Retry-After).",
            "content": {
              "application/problem+json": {
                "schema": {
                  "$ref": "#/components/schemas/Problem"
                }
              }
            }
          }
        }
      }
    },
    "/api/v1/tool": {
      "get": {
        "operationId": "getToolDefinition",
        "summary": "Inputs, output schema and examples for this tool",
        "responses": {
          "200": {
            "description": "Tool definition.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object"
                }
              }
            }
          }
        }
      }
    }
  },
  "components": {
    "schemas": {
      "Problem": {
        "type": "object",
        "description": "RFC 9457 problem details. 422 responses include per-field `errors`.",
        "required": [
          "type",
          "title",
          "status",
          "detail"
        ],
        "properties": {
          "type": {
            "type": "string"
          },
          "title": {
            "type": "string"
          },
          "status": {
            "type": "integer"
          },
          "detail": {
            "type": "string"
          },
          "code": {
            "type": "string"
          },
          "errors": {
            "type": "array",
            "items": {
              "type": "object",
              "required": [
                "field",
                "message"
              ],
              "properties": {
                "field": {
                  "type": "string"
                },
                "message": {
                  "type": "string"
                }
              }
            }
          }
        }
      },
      "LuminaLayerTransformInput": {
        "type": "object",
        "additionalProperties": false,
        "properties": {
          "canvasWidth": {
            "title": "Canvas width (px)",
            "type": "integer",
            "minimum": 1,
            "maximum": 4000,
            "default": 1000
          },
          "canvasHeight": {
            "title": "Canvas height (px)",
            "type": "integer",
            "minimum": 1,
            "maximum": 4000,
            "default": 700
          },
          "width": {
            "title": "Layer width (px)",
            "type": "integer",
            "minimum": 1,
            "maximum": 4000,
            "default": 600
          },
          "height": {
            "title": "Layer height (px)",
            "type": "integer",
            "minimum": 1,
            "maximum": 4000,
            "default": 400
          },
          "x": {
            "title": "Layer center X (px)",
            "type": "number",
            "minimum": -8000,
            "maximum": 8000,
            "default": 500
          },
          "y": {
            "title": "Layer center Y (px)",
            "type": "number",
            "minimum": -8000,
            "maximum": 8000,
            "default": 350
          },
          "rotation": {
            "title": "Rotation (degrees)",
            "type": "number",
            "minimum": -180,
            "maximum": 180,
            "default": 20
          },
          "flipX": {
            "title": "Flip horizontally",
            "type": "boolean",
            "default": false
          },
          "flipY": {
            "title": "Flip vertically",
            "type": "boolean",
            "default": false
          }
        },
        "required": []
      },
      "LuminaLayerTransformResult": {
        "type": "object",
        "additionalProperties": false,
        "required": [
          "schemaVersion",
          "tool",
          "computedAt",
          "inputs",
          "summary",
          "result",
          "units",
          "assumptions",
          "sources",
          "warnings",
          "presentation",
          "links"
        ],
        "properties": {
          "schemaVersion": {
            "type": "string",
            "const": "1.0"
          },
          "tool": {
            "type": "object",
            "additionalProperties": false,
            "required": [
              "id",
              "name",
              "version"
            ],
            "properties": {
              "id": {
                "type": "string"
              },
              "name": {
                "type": "string"
              },
              "version": {
                "type": "string"
              }
            }
          },
          "computedAt": {
            "type": "string",
            "format": "date-time"
          },
          "inputs": {
            "type": "object",
            "description": "Normalised inputs actually used, including applied defaults."
          },
          "summary": {
            "type": "string"
          },
          "result": {
            "type": "object",
            "additionalProperties": false,
            "required": [
              "matrix",
              "corners",
              "bounds"
            ],
            "properties": {
              "matrix": {
                "type": "array",
                "minItems": 6,
                "maxItems": 6,
                "items": {
                  "type": "number"
                }
              },
              "corners": {
                "type": "array",
                "minItems": 4,
                "maxItems": 4,
                "items": {
                  "type": "object",
                  "additionalProperties": false,
                  "required": [
                    "x",
                    "y"
                  ],
                  "properties": {
                    "x": {
                      "type": "number"
                    },
                    "y": {
                      "type": "number"
                    }
                  }
                }
              },
              "bounds": {
                "type": "object",
                "additionalProperties": false,
                "required": [
                  "left",
                  "top",
                  "right",
                  "bottom",
                  "width",
                  "height"
                ],
                "properties": {
                  "left": {
                    "type": "number"
                  },
                  "top": {
                    "type": "number"
                  },
                  "right": {
                    "type": "number"
                  },
                  "bottom": {
                    "type": "number"
                  },
                  "width": {
                    "type": "number"
                  },
                  "height": {
                    "type": "number"
                  }
                }
              }
            }
          },
          "units": {
            "type": "object",
            "additionalProperties": {
              "type": "string"
            }
          },
          "assumptions": {
            "type": "array",
            "items": {
              "type": "string"
            }
          },
          "sources": {
            "type": "array",
            "items": {
              "type": "object",
              "additionalProperties": false,
              "required": [
                "title"
              ],
              "properties": {
                "title": {
                  "type": "string"
                },
                "url": {
                  "type": "string"
                },
                "publisher": {
                  "type": "string"
                },
                "retrievedAt": {
                  "type": "string"
                },
                "note": {
                  "type": "string"
                }
              }
            }
          },
          "warnings": {
            "type": "array",
            "items": {
              "type": "string"
            }
          },
          "presentation": {
            "type": "array",
            "items": {
              "type": "object"
            },
            "description": "Display blocks used by the human page (same data)."
          },
          "links": {
            "type": "object",
            "additionalProperties": false,
            "required": [
              "human",
              "api",
              "openapi",
              "methodology"
            ],
            "properties": {
              "human": {
                "type": "string",
                "format": "uri"
              },
              "api": {
                "type": "string",
                "format": "uri"
              },
              "openapi": {
                "type": "string",
                "format": "uri"
              },
              "methodology": {
                "type": "string",
                "format": "uri"
              }
            }
          }
        }
      }
    }
  }
}