{
  "$schema": "https://json-schema.org/draft/2020-12/schema",
  "$id": "drawing_ink_check.schema.json",
  "title": "drawing_ink_check",
  "description": "Measure the fraction of non-paper (ink) pixels in named horizontal bands of a finished drawing, so a band that should carry a title, a notes block or a disclaimer can be proved not to be blank. Implements the 'region-of-ink check' asked for by docs/rendering.md.",
  "type": "object",
  "properties": {
    "image": {
      "type": "string",
      "description": "Path to the rendered PNG to check."
    },
    "bands": {
      "type": "array",
      "description": "The horizontal bands that must carry something. Either pixel rows (y0/y1, y measured from the top, y1 exclusive) or page fractions (top/bottom, 0..1).",
      "minItems": 1,
      "items": {
        "type": "object",
        "properties": {
          "name": {"type": "string", "description": "What this band is meant to contain, e.g. TITLE."},
          "y0": {"type": "integer", "minimum": 0, "description": "Top row, in page pixels."},
          "y1": {"type": "integer", "minimum": 1, "description": "Bottom row, exclusive, in page pixels."},
          "top": {"type": "number", "minimum": 0, "maximum": 1, "description": "Alternative to y0: top of the band as a fraction of page height."},
          "bottom": {"type": "number", "minimum": 0, "maximum": 1, "description": "Alternative to y1: bottom of the band as a fraction of page height."}
        },
        "required": ["name"],
        "additionalProperties": false,
        "oneOf": [
          {"required": ["y0", "y1"]},
          {"required": ["top", "bottom"]}
        ]
      }
    },
    "paper": {
      "description": "The RGB value that counts as blank paper, or the string \"auto\" to use the single most common colour on the page.",
      "oneOf": [
        {"type": "string", "enum": ["auto"]},
        {"type": "array", "items": {"type": "integer", "minimum": 0, "maximum": 255}, "minItems": 3, "maxItems": 3}
      ],
      "default": "auto"
    },
    "tolerance": {
      "type": "integer",
      "minimum": 0,
      "maximum": 255,
      "description": "Per-pixel difference from paper that counts as ink. Keeps anti-aliasing and near-paper fills from reading as content.",
      "default": 24
    },
    "min_ink": {
      "type": "number",
      "minimum": 0,
      "maximum": 1,
      "description": "A band whose ink fraction is below this is reported BLANK.",
      "default": 0.002
    }
  },
  "required": ["image", "bands"],
  "additionalProperties": false
}
