{
  "openapi": "3.1.1",
  "info": {
    "title": "Screentone Pattern Maker API",
    "version": "1.0.0",
    "summary": "Make dot, line and crosshatch tones with explicit pitch, coverage and print scale.",
    "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://fliplinescreentone.usefulweb.site"
    }
  ],
  "paths": {
    "/api/v1/calculate": {
      "post": {
        "operationId": "calculate",
        "summary": "Make dot, line and crosshatch tones with explicit pitch, coverage and print scale.",
        "description": "Generate a repeating vector screentone, inspect its nominal ink coverage and lines per inch, and download an SVG or reusable tone recipe. Open it as a Comic Desk study or apply the recipe to an existing panel.\n\nMethodology:\n- Pitch is the repeating cell size in source pixels. Nominal lines per inch = DPI / pitch; physical size in mm = pixels / DPI × 25.4. No printer-specific dot gain or color conversion is modelled.\n- For dots, radius = pitch × sqrt(coverage / π). Parallel stripe width = pitch × coverage. For perpendicular crosshatch, stripe width = pitch × (1 − sqrt(1 − coverage)), accounting for overlap. Pattern rotation preserves this nominal coverage.\n- Coverage is 5–75%, pitch 4–80 px and angle −90° to 90°. SVG keeps vector patterns; the tone recipe imports into Comic Desk with pitch rescaled to preserve lines per inch at the page DPI. Avoid resampling a rasterized tone to reduce moiré.\n\nNominal geometric coverage, not a measured ink density. Raster resampling and printing can introduce moiré.",
        "tags": [
          "apps"
        ],
        "x-mcp-tool": "flipline_screentone",
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/FliplineScreentoneInput"
              },
              "examples": {
                "example1": {
                  "summary": "A 20% dot tone",
                  "value": {}
                },
                "example2": {
                  "summary": "A 35% crosshatch",
                  "value": {
                    "pattern": "crosshatch",
                    "coverage": 35,
                    "angle": 0,
                    "pitch": 20
                  }
                }
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Calculation result envelope.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/FliplineScreentoneResult"
                }
              }
            }
          },
          "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"
                }
              }
            }
          }
        }
      },
      "FliplineScreentoneInput": {
        "type": "object",
        "additionalProperties": false,
        "properties": {
          "pattern": {
            "title": "Tone pattern",
            "type": "string",
            "enum": [
              "dots",
              "lines",
              "crosshatch"
            ],
            "default": "dots"
          },
          "pitch": {
            "title": "Tone pitch (px)",
            "type": "integer",
            "minimum": 4,
            "maximum": 80,
            "default": 14
          },
          "coverage": {
            "title": "Tone coverage (%)",
            "type": "integer",
            "minimum": 5,
            "maximum": 75,
            "default": 20
          },
          "angle": {
            "title": "Tone angle (°)",
            "type": "integer",
            "minimum": -90,
            "maximum": 90,
            "default": 45
          },
          "dpi": {
            "title": "Tone resolution (DPI)",
            "type": "integer",
            "minimum": 72,
            "maximum": 600,
            "default": 150
          },
          "width": {
            "title": "Swatch width (px)",
            "type": "integer",
            "minimum": 64,
            "maximum": 1600,
            "default": 600
          },
          "height": {
            "title": "Swatch height (px)",
            "type": "integer",
            "minimum": 64,
            "maximum": 1600,
            "default": 400
          },
          "ink": {
            "title": "Tone ink (HEX)",
            "type": "string",
            "maxLength": 7,
            "default": "#253e45"
          }
        },
        "required": []
      },
      "FliplineScreentoneResult": {
        "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": [
              "recipe",
              "linesPerInch",
              "widthMm",
              "heightMm",
              "nominalCoverage",
              "swatch",
              "recipeFile",
              "openInApp"
            ],
            "properties": {
              "recipe": {
                "type": "object",
                "additionalProperties": false,
                "required": [
                  "format",
                  "version",
                  "tone",
                  "dpi",
                  "width",
                  "height"
                ],
                "properties": {
                  "format": {
                    "const": "flipline-tone"
                  },
                  "version": {
                    "const": 1
                  },
                  "tone": {
                    "type": "object",
                    "additionalProperties": false,
                    "required": [
                      "kind",
                      "pitch",
                      "coverage",
                      "angle",
                      "ink",
                      "over"
                    ],
                    "properties": {
                      "kind": {
                        "enum": [
                          "none",
                          "dots",
                          "lines",
                          "crosshatch"
                        ]
                      },
                      "pitch": {
                        "type": "number",
                        "minimum": 4,
                        "maximum": 80
                      },
                      "coverage": {
                        "type": "number",
                        "minimum": 0.05,
                        "maximum": 0.75
                      },
                      "angle": {
                        "type": "number",
                        "minimum": -90,
                        "maximum": 90
                      },
                      "ink": {
                        "type": "string",
                        "pattern": "^#[a-fA-F0-9]{6}$"
                      },
                      "over": {
                        "type": "boolean"
                      }
                    }
                  },
                  "dpi": {
                    "type": "integer",
                    "minimum": 72,
                    "maximum": 600
                  },
                  "width": {
                    "type": "integer",
                    "minimum": 64,
                    "maximum": 1600
                  },
                  "height": {
                    "type": "integer",
                    "minimum": 64,
                    "maximum": 1600
                  }
                }
              },
              "linesPerInch": {
                "type": "number"
              },
              "widthMm": {
                "type": "number"
              },
              "heightMm": {
                "type": "number"
              },
              "nominalCoverage": {
                "type": "number"
              },
              "swatch": {
                "type": "object",
                "additionalProperties": false,
                "required": [
                  "artifactId",
                  "filename",
                  "mime",
                  "bytes",
                  "sha256",
                  "path"
                ],
                "properties": {
                  "artifactId": {
                    "type": "string"
                  },
                  "filename": {
                    "type": "string"
                  },
                  "mime": {
                    "type": "string"
                  },
                  "bytes": {
                    "type": "integer"
                  },
                  "sha256": {
                    "type": "string"
                  },
                  "path": {
                    "type": "string",
                    "description": "Download path on the same site (valid for about 2 hours)."
                  }
                }
              },
              "recipeFile": {
                "type": "object",
                "additionalProperties": false,
                "required": [
                  "artifactId",
                  "filename",
                  "mime",
                  "bytes",
                  "sha256",
                  "path"
                ],
                "properties": {
                  "artifactId": {
                    "type": "string"
                  },
                  "filename": {
                    "type": "string"
                  },
                  "mime": {
                    "type": "string"
                  },
                  "bytes": {
                    "type": "integer"
                  },
                  "sha256": {
                    "type": "string"
                  },
                  "path": {
                    "type": "string",
                    "description": "Download path on the same site (valid for about 2 hours)."
                  }
                }
              },
              "openInApp": {
                "type": [
                  "string",
                  "null"
                ]
              }
            }
          },
          "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"
              }
            }
          }
        }
      }
    }
  }
}