{
  "openapi": "3.1.1",
  "info": {
    "title": "Equation Art Studio API",
    "version": "1.0.0",
    "summary": "Turn math into art: parametric, polar, Lissajous, rose and spirograph curves.",
    "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://equationartstudio.usefulweb.site"
    }
  ],
  "paths": {
    "/api/v1/calculate": {
      "post": {
        "operationId": "calculate",
        "summary": "Turn math into art: parametric, polar, Lissajous, rose and spirograph curves.",
        "description": "Type x(t) and y(t), or r(θ), or start from a preset (Lissajous, rose, spirograph, butterfly, heart), add rotational symmetry and a colour palette, and get a crisp SVG artwork plus a PNG download. Expressions are parsed safely (no code execution) and support + − × ÷ ^, sin, cos, tan, sqrt, abs, exp, log, pi and e.\n\nMethodology:\n- Expressions are tokenised and parsed by a small recursive-descent parser into a syntax tree, which is compiled into plain arithmetic closures — no eval or Function, and only the listed functions, constants and variables are accepted.\n- Polar curves are converted with x = r(θ)·cos θ, y = r(θ)·sin θ. Presets: Lissajous x = sin(a·t + d), y = sin(b·t); rose r = cos(a/b·θ); spirograph (hypotrochoid) x = (a−b)cos t + c·cos((a−b)/b·t), y = (a−b)sin t − c·sin((a−b)/b·t); Temple Fay’s butterfly; the classic 16 sin³t heart. Roses and spirographs with whole-number a, b run exactly one full period.\n- t is sampled evenly from start to end. Undefined samples (division by zero, sqrt of a negative number) leave gaps, and very large jumps (asymptotes) are not connected.\n- The drawing is fitted into a 600 × 600 square with equal x/y scale, optionally rotated into k symmetric copies, and coloured along t with a gradient from the palette. Points closer than 0.3 px are dropped to keep the SVG small.\n- The SVG uses only plain shapes (no scripts or styles). The PNG is rendered from the same SVG with ImageMagick when it is installed; both downloads stay available for about 2 hours.",
        "tags": [
          "fun"
        ],
        "x-mcp-tool": "equation_art_studio",
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/EquationArtStudioInput"
              },
              "examples": {
                "example1": {
                  "summary": "Spirograph, sunset palette",
                  "value": {
                    "curve": "spirograph",
                    "a": 7,
                    "b": 4,
                    "c": 3,
                    "samples": 2000,
                    "symmetry": 1,
                    "palette": "sunset",
                    "strokeWidth": 2
                  }
                },
                "example2": {
                  "summary": "Rose with 3-fold symmetry",
                  "value": {
                    "curve": "rose",
                    "a": 7,
                    "b": 3,
                    "samples": 1500,
                    "symmetry": 3,
                    "palette": "ocean",
                    "strokeWidth": 1.5,
                    "png": false
                  }
                },
                "example3": {
                  "summary": "Own parametric curve",
                  "value": {
                    "curve": "parametric",
                    "xExpr": "cos(t) + cos(6t)/2 + sin(14t)/3",
                    "yExpr": "sin(t) + sin(6t)/2 + cos(14t)/3",
                    "tMin": "0",
                    "tMax": "2*pi",
                    "samples": 2500,
                    "symmetry": 1,
                    "palette": "neon",
                    "strokeWidth": 2,
                    "png": false
                  }
                }
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Calculation result envelope.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/EquationArtStudioResult"
                }
              }
            }
          },
          "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"
                }
              }
            }
          }
        }
      },
      "EquationArtStudioInput": {
        "type": "object",
        "additionalProperties": false,
        "properties": {
          "curve": {
            "title": "Curve",
            "type": "string",
            "enum": [
              "parametric",
              "polar",
              "lissajous",
              "rose",
              "spirograph",
              "butterfly",
              "heart"
            ],
            "default": "spirograph"
          },
          "xExpr": {
            "title": "x(t)",
            "description": "Used for “my own parametric curve”. Variables: t, a, b, c, d. Implicit multiplication works: 2t, 3sin(t).",
            "type": "string",
            "maxLength": 400,
            "default": "cos(t) + cos(6t)/2 + sin(14t)/3"
          },
          "yExpr": {
            "title": "y(t)",
            "type": "string",
            "maxLength": 400,
            "default": "sin(t) + sin(6t)/2 + cos(14t)/3"
          },
          "rExpr": {
            "title": "r(θ)",
            "description": "Used for “my own polar curve”. Write θ as theta or t.",
            "type": "string",
            "maxLength": 400,
            "default": "1 + 0.5*cos(5theta)"
          },
          "tMin": {
            "title": "t from",
            "description": "A number or constant expression such as 0 or -pi. Empty = preset default (0).",
            "type": "string",
            "maxLength": 60
          },
          "tMax": {
            "title": "t to",
            "description": "E.g. 2*pi. Empty = preset default (2π, or a full period for roses and spirographs).",
            "type": "string",
            "maxLength": 60
          },
          "a": {
            "title": "a",
            "description": "Parameter for presets and your expressions. Empty = preset default.",
            "type": "number",
            "minimum": -1000,
            "maximum": 1000
          },
          "b": {
            "title": "b",
            "type": "number",
            "minimum": -1000,
            "maximum": 1000
          },
          "c": {
            "title": "c",
            "type": "number",
            "minimum": -1000,
            "maximum": 1000
          },
          "d": {
            "title": "d",
            "type": "number",
            "minimum": -1000,
            "maximum": 1000
          },
          "samples": {
            "title": "Samples",
            "description": "More samples = smoother curves. Samples × symmetry copies is limited to 24,000.",
            "type": "integer",
            "minimum": 50,
            "maximum": 10000,
            "default": 2000
          },
          "symmetry": {
            "title": "Rotational symmetry (copies)",
            "type": "integer",
            "minimum": 1,
            "maximum": 12,
            "default": 1
          },
          "palette": {
            "title": "Palette",
            "type": "string",
            "enum": [
              "sunset",
              "ocean",
              "forest",
              "neon",
              "rainbow",
              "mono"
            ],
            "default": "sunset"
          },
          "strokeWidth": {
            "title": "Line width",
            "type": "number",
            "minimum": 0.25,
            "maximum": 12,
            "default": 2,
            "x-unit": "px"
          },
          "png": {
            "title": "Also render a PNG download",
            "type": "boolean",
            "default": true
          }
        },
        "required": []
      },
      "EquationArtStudioResult": {
        "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": [
              "curve",
              "curveName",
              "kind",
              "x",
              "y",
              "r",
              "tMin",
              "tMax",
              "params",
              "samples",
              "symmetry",
              "palette",
              "invalidSamples",
              "drawnPoints",
              "closed",
              "arcLength",
              "bbox",
              "svgBytes",
              "svgArtifact",
              "pngArtifact"
            ],
            "properties": {
              "curve": {
                "type": "string"
              },
              "curveName": {
                "type": "string"
              },
              "kind": {
                "type": "string",
                "enum": [
                  "parametric",
                  "polar"
                ]
              },
              "x": {
                "type": [
                  "string",
                  "null"
                ]
              },
              "y": {
                "type": [
                  "string",
                  "null"
                ]
              },
              "r": {
                "type": [
                  "string",
                  "null"
                ]
              },
              "tMin": {
                "type": "number"
              },
              "tMax": {
                "type": "number"
              },
              "params": {
                "type": "object",
                "additionalProperties": false,
                "required": [
                  "a",
                  "b",
                  "c",
                  "d"
                ],
                "properties": {
                  "a": {
                    "type": "number"
                  },
                  "b": {
                    "type": "number"
                  },
                  "c": {
                    "type": "number"
                  },
                  "d": {
                    "type": "number"
                  }
                }
              },
              "samples": {
                "type": "integer"
              },
              "symmetry": {
                "type": "integer"
              },
              "palette": {
                "type": "string"
              },
              "invalidSamples": {
                "type": "integer"
              },
              "drawnPoints": {
                "type": "integer"
              },
              "closed": {
                "type": "boolean"
              },
              "arcLength": {
                "type": "number",
                "description": "Length of one copy of the curve in curve units."
              },
              "bbox": {
                "type": "array",
                "items": {
                  "type": "number"
                },
                "description": "[minX, minY, maxX, maxY] in curve units, including symmetry copies."
              },
              "svgBytes": {
                "type": "integer"
              },
              "svgArtifact": {
                "type": "object",
                "additionalProperties": false,
                "required": [
                  "artifactId",
                  "path",
                  "bytes",
                  "sha256"
                ],
                "properties": {
                  "artifactId": {
                    "type": "string"
                  },
                  "path": {
                    "type": "string"
                  },
                  "bytes": {
                    "type": "integer"
                  },
                  "sha256": {
                    "type": "string"
                  }
                }
              },
              "pngArtifact": {
                "type": [
                  "object",
                  "null"
                ],
                "additionalProperties": false,
                "required": [
                  "artifactId",
                  "path",
                  "bytes",
                  "sha256"
                ],
                "properties": {
                  "artifactId": {
                    "type": "string"
                  },
                  "path": {
                    "type": "string"
                  },
                  "bytes": {
                    "type": "integer"
                  },
                  "sha256": {
                    "type": "string"
                  }
                }
              }
            }
          },
          "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"
              }
            }
          }
        }
      }
    }
  }
}