{
  "openapi": "3.1.1",
  "info": {
    "title": "Pressure Brush Stroke Renderer API",
    "version": "1.0.0",
    "summary": "Render textured pressure strokes as SVG and editable Flipline drawings.",
    "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://fliplinebrushstroke.usefulweb.site"
    }
  ],
  "paths": {
    "/api/v1/calculate": {
      "post": {
        "operationId": "calculate",
        "summary": "Render textured pressure strokes as SVG and editable Flipline drawings.",
        "description": "Turn normalized points and pressure samples into graphite, ink, marker, pigment-wash or airbrush strokes. Download a deterministic SVG, reusable brush recipe and editable Flipline project.\n\nMethodology:\n- Accept 1–256 points with normalized x/y and optional pressure in 0–1. Missing pressure is 1. Canvas dimensions are 32–1600 px and at most 2 MP.\n- Resample by pixel arc length using brush spacing, at most 1024 centers per stroke. Linear interpolation carries pressure between samples. Brush width and pigment respond to pressure when enabled.\n- Five authored stamp styles use a seeded linear-congruential generator for texture. At most four ellipse dabs per center. Opacity and flow multiply per dab; overlap accumulates pigment.\n- The SVG and browser use the same ellipse geometry. Pigment wash is a layered stamp approximation, not wet-paint physics. sRGB canvas compositing can vary slightly across renderers.",
        "tags": [
          "apps"
        ],
        "x-mcp-tool": "flipline_brush_stroke",
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/FliplineBrushStrokeInput"
              },
              "examples": {
                "example1": {
                  "summary": "A textured pencil stroke",
                  "value": {
                    "points": "0.1 0.65 0.2\n0.3 0.3 0.6\n0.6 0.7 1\n0.9 0.35 0.15"
                  }
                },
                "example2": {
                  "summary": "A broad chisel marker",
                  "value": {
                    "kind": "marker",
                    "size": 55,
                    "opacity": 60,
                    "flow": 20,
                    "texture": 10,
                    "points": "0.1 0.5 0.3\n0.5 0.3 1\n0.9 0.5 0.3"
                  }
                }
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Calculation result envelope.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/FliplineBrushStrokeResult"
                }
              }
            }
          },
          "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"
                }
              }
            }
          }
        }
      },
      "FliplineBrushStrokeInput": {
        "type": "object",
        "additionalProperties": false,
        "properties": {
          "points": {
            "title": "Stroke points: x y pressure (0–1, one point per line)",
            "type": "string",
            "maxLength": 32000,
            "default": "0.1 0.65 0.2\n0.3 0.3 0.6\n0.6 0.7 1\n0.9 0.35 0.15"
          },
          "width": {
            "title": "Canvas width (px)",
            "type": "integer",
            "minimum": 32,
            "maximum": 1600,
            "default": 800
          },
          "height": {
            "title": "Canvas height (px)",
            "type": "integer",
            "minimum": 32,
            "maximum": 1600,
            "default": 320
          },
          "size": {
            "title": "Brush width (px)",
            "type": "number",
            "minimum": 1,
            "maximum": 100,
            "default": 28
          },
          "kind": {
            "title": "Brush style",
            "type": "string",
            "enum": [
              "ink",
              "pencil",
              "marker",
              "wash",
              "airbrush"
            ],
            "default": "pencil"
          },
          "color": {
            "title": "Ink HEX color",
            "type": "string",
            "maxLength": 7,
            "default": "#30585D"
          },
          "background": {
            "title": "Paper HEX color",
            "type": "string",
            "maxLength": 7,
            "default": "#FFF9EE"
          },
          "opacity": {
            "title": "Pigment opacity (%)",
            "type": "number",
            "minimum": 0,
            "maximum": 100,
            "default": 85
          },
          "flow": {
            "title": "Pigment flow (%)",
            "type": "number",
            "minimum": 0,
            "maximum": 100,
            "default": 55
          },
          "texture": {
            "title": "Brush texture (%)",
            "type": "number",
            "minimum": 0,
            "maximum": 100,
            "default": 75
          },
          "pressure": {
            "title": "Use pressure samples",
            "type": "boolean",
            "default": true
          },
          "seed": {
            "title": "Texture seed",
            "type": "integer",
            "minimum": 0,
            "maximum": 4294967295,
            "default": 17
          }
        },
        "required": []
      },
      "FliplineBrushStrokeResult": {
        "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": [
              "project",
              "svg",
              "dabs"
            ],
            "properties": {
              "project": {
                "type": "object",
                "additionalProperties": false,
                "required": [
                  "format",
                  "version",
                  "name",
                  "width",
                  "height",
                  "fps",
                  "background",
                  "transparent",
                  "frames",
                  "layers"
                ],
                "properties": {
                  "format": {
                    "const": "flipline"
                  },
                  "version": {
                    "const": 1
                  },
                  "name": {
                    "type": "string",
                    "maxLength": 120
                  },
                  "width": {
                    "type": "integer",
                    "minimum": 32,
                    "maximum": 1600
                  },
                  "height": {
                    "type": "integer",
                    "minimum": 32,
                    "maximum": 1600
                  },
                  "fps": {
                    "type": "integer",
                    "minimum": 1,
                    "maximum": 30
                  },
                  "background": {
                    "type": "string",
                    "pattern": "^#[a-fA-F0-9]{6}$"
                  },
                  "transparent": {
                    "type": "boolean"
                  },
                  "paper": {
                    "enum": [
                      "plain",
                      "grain",
                      "linen"
                    ]
                  },
                  "frames": {
                    "type": "array",
                    "minItems": 1,
                    "maxItems": 24,
                    "items": {
                      "type": "object",
                      "additionalProperties": false,
                      "required": [
                        "id",
                        "hold",
                        "label"
                      ],
                      "properties": {
                        "id": {
                          "type": "string",
                          "minLength": 1,
                          "maxLength": 80
                        },
                        "hold": {
                          "type": "integer",
                          "minimum": 1,
                          "maximum": 10
                        },
                        "label": {
                          "type": "string",
                          "maxLength": 80
                        }
                      }
                    }
                  },
                  "layers": {
                    "type": "array",
                    "minItems": 1,
                    "maxItems": 4,
                    "items": {
                      "type": "object",
                      "additionalProperties": false,
                      "required": [
                        "id",
                        "name",
                        "visible",
                        "locked",
                        "opacity",
                        "cels"
                      ],
                      "properties": {
                        "id": {
                          "type": "string",
                          "minLength": 1,
                          "maxLength": 80
                        },
                        "name": {
                          "type": "string",
                          "maxLength": 80
                        },
                        "visible": {
                          "type": "boolean"
                        },
                        "locked": {
                          "type": "boolean"
                        },
                        "opacity": {
                          "type": "number",
                          "minimum": 0,
                          "maximum": 1
                        },
                        "cels": {
                          "type": "array",
                          "minItems": 1,
                          "maxItems": 24,
                          "items": {
                            "type": "array",
                            "maxItems": 500,
                            "items": {
                              "type": "object",
                              "additionalProperties": false,
                              "required": [
                                "id",
                                "kind",
                                "points",
                                "color",
                                "size",
                                "fill"
                              ],
                              "properties": {
                                "brush": {
                                  "type": "object",
                                  "additionalProperties": false,
                                  "required": [
                                    "kind",
                                    "opacity",
                                    "flow",
                                    "spacing",
                                    "texture",
                                    "pressure",
                                    "seed"
                                  ],
                                  "properties": {
                                    "kind": {
                                      "enum": [
                                        "ink",
                                        "pencil",
                                        "marker",
                                        "wash",
                                        "airbrush"
                                      ]
                                    },
                                    "opacity": {
                                      "type": "number",
                                      "minimum": 0,
                                      "maximum": 1
                                    },
                                    "flow": {
                                      "type": "number",
                                      "minimum": 0,
                                      "maximum": 1
                                    },
                                    "spacing": {
                                      "type": "number",
                                      "minimum": 0.08,
                                      "maximum": 1
                                    },
                                    "texture": {
                                      "type": "number",
                                      "minimum": 0,
                                      "maximum": 1
                                    },
                                    "pressure": {
                                      "type": "boolean"
                                    },
                                    "seed": {
                                      "type": "integer",
                                      "minimum": 0,
                                      "maximum": 4294967295
                                    }
                                  }
                                },
                                "pressures": {
                                  "type": "array",
                                  "minItems": 1,
                                  "maxItems": 4096,
                                  "items": {
                                    "type": "number",
                                    "minimum": 0,
                                    "maximum": 1
                                  }
                                },
                                "id": {
                                  "type": "string",
                                  "minLength": 1,
                                  "maxLength": 80
                                },
                                "kind": {
                                  "enum": [
                                    "pen",
                                    "eraser",
                                    "line",
                                    "rect",
                                    "ellipse",
                                    "image"
                                  ]
                                },
                                "points": {
                                  "type": "array",
                                  "minItems": 1,
                                  "maxItems": 4096,
                                  "items": {
                                    "type": "array",
                                    "minItems": 2,
                                    "maxItems": 2,
                                    "items": {
                                      "type": "number",
                                      "minimum": 0,
                                      "maximum": 1
                                    }
                                  }
                                },
                                "color": {
                                  "type": "string",
                                  "pattern": "^#[a-fA-F0-9]{6}$"
                                },
                                "size": {
                                  "type": "number",
                                  "minimum": 1,
                                  "maximum": 100
                                },
                                "fill": {
                                  "type": "boolean"
                                },
                                "source": {
                                  "type": "string",
                                  "pattern": "^data:image/(png|jpeg|webp);base64,[A-Za-z0-9+/=]+$"
                                },
                                "angle": {
                                  "type": "number",
                                  "minimum": -360,
                                  "maximum": 360,
                                  "description": "Clockwise rotation in degrees around the center of the mark bounds (normalized to -180…180)."
                                },
                                "flipX": {
                                  "type": "boolean",
                                  "description": "Mirror horizontally around the mark center."
                                },
                                "flipY": {
                                  "type": "boolean",
                                  "description": "Mirror vertically around the mark center."
                                }
                              }
                            }
                          }
                        }
                      }
                    }
                  }
                },
                "description": "Normalized drawing coordinates. Each layer has one cel per frame. At most 2 MP canvas, 50000 points, 2000 marks and 8 million embedded source characters in total. Image/shape marks require two points; IDs are unique within their collection. Optional angle/flipX/flipY transform a mark around the center of its point bounds."
              },
              "svg": {
                "type": "string"
              },
              "dabs": {
                "type": "integer"
              }
            }
          },
          "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"
              }
            }
          }
        }
      }
    }
  }
}