{
  "schemaVersion": 1,
  "slug": "crochet-calculator",
  "category": "diy-craft",
  "kind": "implementation",
  "independentValidation": false,
  "implementationHash": "84223113ab7ee25c36771d352097f804bc7bb4275ba5ac39bc08545e8d8992a4",
  "provenance": "Generated from the calculation contract used by the published page. Publication is not external validation.",
  "sourceFiles": [
    "data/calculators/crochet-calculator.json",
    "src/engine.js"
  ],
  "runtimeSource": "/sources/engine.txt",
  "runtimeHash": "5c888d8898afbdee36267bb9977829e1e2ac568f6677c8ee87469c139864645c",
  "scope": "The compute function records implemented equations, constants, lookup tables and custom rules. Inputs record defaults and allowed values; outputs record precision and units. Defaults are examples, not recommendations. General background references are not evidence for this specific algorithm.",
  "publishedFormula": {
    "formula": "N = (round(W × s ÷ w) + e) × round(H × r ÷ w)",
    "vars": [
      [
        "s",
        "Swatch stitches"
      ],
      [
        "r",
        "Swatch rows"
      ],
      [
        "w",
        "Swatch size (in)"
      ],
      [
        "W",
        "Project width (in)"
      ],
      [
        "H",
        "Project height (in)"
      ],
      [
        "e",
        "Extra foundation chains"
      ]
    ],
    "note": "Stitches per inch = s ÷ w; rows per inch = r ÷ w. Total stitches are an approximate chains × rows count; yarn quantity is not estimated."
  },
  "externalEvidence": null,
  "contract": {
    "compute": "const spi = swatchSize > 0 ? swatchStitches/swatchSize : 0; const rpi = swatchSize > 0 ? swatchRows/swatchSize : 0; const chains = Math.round(projectWidth*spi) + foundationExtra; const rows = Math.round(projectHeight*rpi); const total = chains*rows; return { stitchesPerInch: spi, rowsPerInch: rpi, chainsToStart: chains, totalRows: rows, totalStitches: total };",
    "inputs": [
      {
        "name": "swatchStitches",
        "type": "number",
        "default": 16,
        "min": 1,
        "max": 200,
        "step": 1,
        "slider": true
      },
      {
        "name": "swatchRows",
        "type": "number",
        "default": 18,
        "min": 1,
        "max": 200,
        "step": 1,
        "slider": true
      },
      {
        "name": "swatchSize",
        "type": "number",
        "default": 4,
        "min": 1,
        "max": 24,
        "step": 0.5,
        "slider": true
      },
      {
        "name": "projectWidth",
        "type": "number",
        "default": 40,
        "min": 1,
        "max": 300,
        "step": 0.5,
        "slider": true
      },
      {
        "name": "projectHeight",
        "type": "number",
        "default": 30,
        "min": 1,
        "max": 300,
        "step": 0.5,
        "slider": true
      },
      {
        "name": "foundationExtra",
        "type": "number",
        "default": 2,
        "min": 0,
        "max": 20,
        "step": 1,
        "slider": true
      }
    ],
    "outputs": [
      {
        "name": "stitchesPerInch",
        "precision": 2,
        "unit": ""
      },
      {
        "name": "rowsPerInch",
        "precision": 2,
        "unit": ""
      },
      {
        "name": "chainsToStart",
        "precision": 0,
        "unit": ""
      },
      {
        "name": "totalRows",
        "precision": 0,
        "unit": ""
      },
      {
        "name": "totalStitches",
        "precision": 0,
        "unit": ""
      }
    ],
    "interpret": null
  }
}
