{
  "$schema": "https://json-schema.org/draft/2020-12/schema",
  "$id": "https://enunun.github.io/math-study/schema/scene.schema.json",
  "title": "図のシーン",
  "description": "えぬちゃんらんどの図が読み書きする，シーンのJSONの形式．図の作成ページ(/math-study/tools/figure-editor/)の「JSON」タブで編集するものと同じである．",
  "type": "object",
  "required": ["version", "description", "view", "objects"],
  "additionalProperties": false,
  "properties": {
    "version": {
      "type": "string",
      "pattern": "^\\d+\\.\\d+\\.\\d+(-[0-9A-Za-z.-]+)?(\\+[0-9A-Za-z.-]+)?$",
      "description": "このシーンを書いたエンジンの版(semver)．読み込むエンジンの版と，主版が同じで(主版が0の間は副版も同じ)，エンジンより新しくない版だけを読める．"
    },
    "description": {
      "$ref": "#/$defs/nonBlankString",
      "description": "図の説明．SVGの代替テキスト(alt)になるので，空白だけの文字列は書けない．"
    },
    "view": { "$ref": "#/$defs/view" },
    "objects": {
      "type": "array",
      "description": "図を作るオブジェクトの並び．並びは，描く順であり，参照の順でもある(点は，その点を使うベクトルより前に置く必要はないが，`<id>_x`などの名前は，あとに置いたオブジェクトからしか使えない)．",
      "items": { "$ref": "#/$defs/object" }
    }
  },
  "$defs": {
    "identifier": {
      "type": "string",
      "pattern": "^[A-Za-z][A-Za-z0-9_]*$",
      "description": "英字で始まり，英数字と`_`だけでできた名前．オブジェクトの`id`と，`var`(媒介変数の名前)，曲面の`vars`に使う．シーンの中で重ならないこと，`e`・`pi`・関数の名前(`sin`など)と重ならないことが必要である．"
    },
    "nonBlankString": {
      "type": "string",
      "pattern": "\\S",
      "description": "空文字列や，空白だけの文字列を除いた，文字列．"
    },
    "bound": {
      "description": "数か，式(文字列)．式の構文が正しいか，式が指す名前(媒介変数，先に置いたパラメータや点の座標)が存在するかは，スキーマでは表せず，エンジンが式を読むときに確かめる．",
      "oneOf": [{ "type": "number" }, { "$ref": "#/$defs/nonBlankString" }]
    },
    "positiveNumberOrExpression": {
      "description": "格子の刻み(`x_step`，`y_step`)，接平面の半径(`size`)，曲面のワイヤーフレームの刻み(`wireframe_step`)に使う．数で書くときは，正の数でなければならない．式で書くときの正負は，エンジンが式を評価するときに確かめる．",
      "oneOf": [{ "type": "number", "exclusiveMinimum": 0 }, { "$ref": "#/$defs/nonBlankString" }]
    },
    "numberPair": { "type": "array", "items": { "type": "number" }, "minItems": 2, "maxItems": 2 },
    "boundPair": {
      "type": "array",
      "items": { "$ref": "#/$defs/bound" },
      "minItems": 2,
      "maxItems": 2
    },
    "length": {
      "type": "string",
      "pattern": "^(\\d+\\.\\d+|\\d+|\\.\\d+)(cm|mm|pt)$",
      "description": "単位つきの長さ(`\"1.2pt\"`のような文字列)．数値は正でなければならない．線の太さ(`style.width`)は，さらに0より大きく10pt以下でなければならない．"
    },
    "anchor": {
      "type": "string",
      "enum": [
        "center",
        "north",
        "south",
        "east",
        "west",
        "north east",
        "north west",
        "south east",
        "south west"
      ],
      "description": "ラベルの箱の，位置に合わせる部分．TikZのanchorと同じ名前である．"
    },
    "color": {
      "type": "string",
      "enum": ["gray", "red", "blue", "green", "orange", "purple"],
      "description": "決まった名前から選ぶ，線の色．省くと，文字の色になる．"
    },
    "line": { "type": "string", "enum": ["solid", "dotted", "dashed"] },
    "hidden": {
      "type": "string",
      "enum": ["dotted", "dashed", "none", "visible"],
      "description": "空間の図で，不透明な面に隠れた部分の線の描き方．既定は`dotted`(点線)．`none`は描かない．`visible`は陰線処理をせず，隠れた部分も見える部分と同じ線で描く(点の印も隠さない)．"
    },
    "arrow": { "type": "string", "enum": ["stealth", "none"] },
    "direction": {
      "type": "string",
      "enum": ["x", "y", "z"],
      "description": "`z`は，空間の図でだけ使える．"
    },
    "style": {
      "type": "object",
      "additionalProperties": false,
      "description": "線のスタイル．省いた項目は，オブジェクトの種類ごとの既定になる(既定の線の種類は，格子だけ点線，ほかは実線)．",
      "properties": {
        "line": {
          "$ref": "#/$defs/line",
          "description": "線の種類．省くと，種類ごとの既定(格子とワイヤーフレームは点線，ほかは実線)になる．"
        },
        "hidden": { "$ref": "#/$defs/hidden" },
        "color": { "$ref": "#/$defs/color" },
        "width": { "$ref": "#/$defs/length" },
        "crossing_gap": {
          "$ref": "#/$defs/length",
          "description": "空間の図で，この線がほかの線の奥を通る所に入れる切れ目の長さ．交点を中心に，線に沿ってこの長さだけ描かないので，線どうしが交わらずにすれ違っていることがわかる．手前の線は，どのオブジェクトの線でもよく，同じ線の別の部分でもよい．省くと切らない．平面の図では使わない．"
        }
      }
    },
    "tick": {
      "type": "object",
      "required": ["at"],
      "additionalProperties": false,
      "properties": {
        "at": {
          "$ref": "#/$defs/bound",
          "description": "軸の上の位置．軸の範囲の中でなければならない．"
        },
        "label": { "type": "string", "description": "目盛の名前の式(TeX)．省くと，線だけを引く．" },
        "anchor": { "$ref": "#/$defs/anchor" }
      }
    },
    "fill": {
      "type": "object",
      "additionalProperties": false,
      "properties": {
        "color": { "$ref": "#/$defs/color" },
        "opacity": {
          "type": "number",
          "exclusiveMinimum": 0,
          "maximum": 1,
          "description": "既定は0.25．"
        }
      }
    },
    "position": {
      "description": "オブジェクトの位置．座標の並び(平面の図では2個，空間の図では3個)か，点の式(`\"B + C - A\"`のような文字列)で書く．点の式は，先に置いた点の`id`を位置ベクトルとして，和と差，数の倍と数での割り算でつなぎ，内積`dot(A, B)`，外積`cross(A, B)`(平面では数)，長さ`norm(A)`も使える．値は点(ベクトル)になる．点の式は，点と，平面の図のラベルで使える(空間の図のラベルでは使えない)．座標の数は，`view`によって決まる．",
      "oneOf": [
        { "$ref": "#/$defs/nonBlankString" },
        { "type": "array", "items": { "$ref": "#/$defs/bound" }, "minItems": 2, "maxItems": 3 }
      ]
    },
    "planeView": {
      "type": "object",
      "required": ["x", "y", "unit"],
      "additionalProperties": false,
      "properties": {
        "x": { "$ref": "#/$defs/numberPair", "description": "x方向の，見える範囲．小さい方が先．" },
        "y": { "$ref": "#/$defs/numberPair", "description": "y方向の，見える範囲．小さい方が先．" },
        "unit": {
          "type": "object",
          "required": ["x", "y"],
          "additionalProperties": false,
          "properties": { "x": { "$ref": "#/$defs/length" }, "y": { "$ref": "#/$defs/length" } },
          "description": "x方向とy方向それぞれの，1単位の実寸．"
        }
      }
    },
    "spaceView": {
      "type": "object",
      "required": ["azimuth", "elevation", "unit"],
      "additionalProperties": false,
      "properties": {
        "azimuth": {
          "type": "number",
          "description": "方位角(度)．z軸のまわりに，x軸からy軸の向きに測る．"
        },
        "elevation": {
          "type": "number",
          "minimum": -90,
          "maximum": 90,
          "description": "仰角(度)．xy平面から上向きに測る．"
        },
        "unit": { "$ref": "#/$defs/length", "description": "3方向共通の，1単位の実寸．" }
      }
    },
    "view": {
      "description": "図の見え方．平面の図は`x`，`y`，`unit`を持ち，空間の図は`azimuth`，`elevation`，`unit`を持つ．どちらの形になるかで，平面の図か空間の図かが決まり，使えるオブジェクトの種類も変わる．",
      "oneOf": [{ "$ref": "#/$defs/planeView" }, { "$ref": "#/$defs/spaceView" }]
    },
    "axis": {
      "type": "object",
      "required": ["id", "type", "direction"],
      "additionalProperties": false,
      "description": "座標軸．平面の図はx軸とy軸，空間の図はx軸・y軸・z軸を使える．空間の図の軸には，`range`が必要である．",
      "properties": {
        "id": { "$ref": "#/$defs/identifier" },
        "type": { "const": "axis" },
        "direction": { "$ref": "#/$defs/direction" },
        "arrow": { "$ref": "#/$defs/arrow", "description": "軸の先の矢じり．既定は`stealth`．" },
        "label": { "type": "string", "description": "軸の名前の式(TeX)．`\"x\"`は$x$と組まれる．" },
        "range": {
          "$ref": "#/$defs/numberPair",
          "description": "軸を引く範囲．平面の図では省くと見える範囲になる．空間の図では必要である．小さい方が先．"
        },
        "style": { "$ref": "#/$defs/style" },
        "ticks": {
          "type": "array",
          "items": { "$ref": "#/$defs/tick" },
          "description": "目盛．空間の図の軸には，まだ付けられない．"
        }
      }
    },
    "label": {
      "type": "object",
      "required": ["id", "type", "at", "tex"],
      "additionalProperties": false,
      "description": "数式を置くラベル．原点の`O`も，ラベルで書く．変換(`transform`)は位置だけを動かし，文字の向きや大きさは変えない．",
      "properties": {
        "id": { "$ref": "#/$defs/identifier" },
        "type": { "const": "label" },
        "transform": { "$ref": "#/$defs/transform" },
        "at": { "$ref": "#/$defs/position" },
        "anchor": { "$ref": "#/$defs/anchor" },
        "tex": {
          "$ref": "#/$defs/nonBlankString",
          "description": "TeXの文字列．`$…$`が数式になる．"
        }
      }
    },
    "parameter": {
      "type": "object",
      "required": ["id", "type", "value"],
      "additionalProperties": false,
      "description": "式から名前で参照する数．",
      "properties": {
        "id": {
          "$ref": "#/$defs/identifier",
          "description": "識別子．式の中で，この名前で値を参照する．"
        },
        "type": { "const": "parameter" },
        "value": { "type": "number", "description": "値．" },
        "range": {
          "$ref": "#/$defs/numberPair",
          "description": "値を動かせる範囲．図の編集画面は，範囲のある媒介変数にスライダーを出す．描画には使わない．値は範囲の中(端を含む)にする(スキーマでは表せない)．"
        },
        "step": {
          "type": "number",
          "exclusiveMinimum": 0,
          "description": "スライダーの刻み．スライダーは，範囲の下端から刻みの倍数の値だけを取る(整数の指数なら1にする)．描画には使わない．範囲(`range`)と一緒に書く(スキーマでは表せない)．"
        }
      }
    },
    "graph": {
      "type": "object",
      "required": ["id", "type", "var", "expr", "domain"],
      "additionalProperties": false,
      "description": "関数のグラフ(y = f(x))．平面の図でだけ使える．",
      "properties": {
        "id": { "$ref": "#/$defs/identifier" },
        "type": { "const": "graph" },
        "var": { "$ref": "#/$defs/identifier" },
        "expr": { "$ref": "#/$defs/nonBlankString" },
        "domain": {
          "$ref": "#/$defs/boundPair",
          "description": "定義域．数どうしなら，小さい方が先でなければならない．"
        },
        "style": { "$ref": "#/$defs/style" },
        "transform": { "$ref": "#/$defs/transform" }
      }
    },
    "curve": {
      "type": "object",
      "required": ["id", "type"],
      "additionalProperties": false,
      "description": "媒介変数表示の曲線．式(`var`，`expr`，`domain`)か，Bézier曲線の制御点(`bezier`)か，スプライン曲線が通る点(`spline`)の，どれか1つで書く．2つ以上は書けない．",
      "oneOf": [
        {
          "required": ["var", "expr", "domain"],
          "not": { "anyOf": [{ "required": ["bezier"] }, { "required": ["spline"] }] }
        },
        {
          "required": ["bezier"],
          "not": {
            "anyOf": [
              { "required": ["var"] },
              { "required": ["expr"] },
              { "required": ["domain"] },
              { "required": ["spline"] }
            ]
          }
        },
        {
          "required": ["spline"],
          "not": {
            "anyOf": [
              { "required": ["var"] },
              { "required": ["expr"] },
              { "required": ["domain"] },
              { "required": ["bezier"] }
            ]
          }
        }
      ],
      "properties": {
        "id": { "$ref": "#/$defs/identifier" },
        "type": { "const": "curve" },
        "var": { "$ref": "#/$defs/identifier" },
        "expr": {
          "description": "曲線の式．各座標の数か式の並び(平面の図では2個，空間の図では3個．数は`view`で決まる)か，点の式と同じベクトルの式(文字列)で書く．ベクトルの式では，媒介変数は数，先に置いた点はベクトルとして使え，内積`dot`，外積`cross`，長さ`norm`も使える．例：中心C，直交する単位ベクトルU，Vの円は`\"C + cos(t)*U + sin(t)*V\"`．",
          "oneOf": [
            { "$ref": "#/$defs/nonBlankString" },
            { "type": "array", "items": { "$ref": "#/$defs/bound" }, "minItems": 2, "maxItems": 3 }
          ]
        },
        "domain": {
          "$ref": "#/$defs/boundPair",
          "description": "変数の範囲．数どうしなら，小さい方が先でなければならない．"
        },
        "bezier": {
          "type": "array",
          "items": {
            "type": "array",
            "items": { "$ref": "#/$defs/bound" },
            "minItems": 2,
            "maxItems": 3
          },
          "minItems": 2,
          "maxItems": 12,
          "description": "Bézier曲線の制御点．各点は，平面の図では2個，空間の図では3個の，数か式で書く座標である．2点以上12点以下を並べる．媒介変数の範囲は，0から1である．"
        },
        "spline": {
          "type": "array",
          "items": {
            "type": "array",
            "items": { "$ref": "#/$defs/bound" },
            "minItems": 2,
            "maxItems": 3
          },
          "minItems": 2,
          "maxItems": 12,
          "description": "スプライン曲線が，順に通る点．各点は，平面の図では2個，空間の図では3個の，数か式で書く座標である．2点以上12点以下を並べる．媒介変数の範囲は，0から1である．Catmull-Romの方法で，与えた点をすべて通る滑らかな曲線になる．"
        },
        "style": { "$ref": "#/$defs/style" },
        "transform": { "$ref": "#/$defs/transform" }
      }
    },
    "tangent_line": {
      "type": "object",
      "required": ["id", "type", "of", "at"],
      "additionalProperties": false,
      "description": "グラフか曲線の接線．平面の図でだけ使える．接する点での向きは，数値微分(中心差分)で求める．",
      "properties": {
        "id": { "$ref": "#/$defs/identifier" },
        "type": { "const": "tangent_line" },
        "transform": { "$ref": "#/$defs/transform" },
        "of": {
          "$ref": "#/$defs/identifier",
          "description": "接する対象の`id`．`graph`か`curve`オブジェクトのものでなければならない．"
        },
        "at": {
          "$ref": "#/$defs/bound",
          "description": "接する点．`of`がグラフなら変数の値，曲線なら媒介変数の値．"
        },
        "style": { "$ref": "#/$defs/style" }
      }
    },
    "grid": {
      "type": "object",
      "required": ["id", "type"],
      "additionalProperties": false,
      "description": "格子．範囲を，原点から数えた刻みの倍数の位置の線で区切る．刻みは，少なくとも1つが必要である．空間の図では範囲(`x_range`，`y_range`)が要り，`z_range`がなければxy平面(z = 0)の上に引く．ほかの平面には，変換で動かす．`z_range`があれば直方体の中の3次元の格子になり，各方向の線を，ほかの2つの方向の刻みの倍数の位置すべてに引く．そのため，刻みが2つ以上要る(スキーマでは表せない)．",
      "anyOf": [{ "required": ["x_step"] }, { "required": ["y_step"] }, { "required": ["z_step"] }],
      "properties": {
        "id": { "$ref": "#/$defs/identifier" },
        "type": { "const": "grid" },
        "x_step": {
          "$ref": "#/$defs/positiveNumberOrExpression",
          "description": "x方向の刻み．なければ，x一定の線(平面の図の縦の線)を引かない．"
        },
        "y_step": {
          "$ref": "#/$defs/positiveNumberOrExpression",
          "description": "y方向の刻み．なければ，y一定の線(平面の図の横の線)を引かない．"
        },
        "z_step": {
          "$ref": "#/$defs/positiveNumberOrExpression",
          "description": "z方向の刻み．空間の図で，`z_range`があるときだけ使える(スキーマでは表せない)．"
        },
        "style": { "$ref": "#/$defs/style" },
        "transform": { "$ref": "#/$defs/transform" },
        "x_range": {
          "$ref": "#/$defs/numberPair",
          "description": "線を引くxの範囲．平面の図では，なければ見える範囲．"
        },
        "y_range": {
          "$ref": "#/$defs/numberPair",
          "description": "線を引くyの範囲．平面の図では，なければ見える範囲．"
        },
        "z_range": {
          "$ref": "#/$defs/numberPair",
          "description": "線を引くzの範囲．空間の図でだけ使える(スキーマでは表せない)．あれば3次元の格子になる．"
        }
      }
    },
    "point": {
      "type": "object",
      "required": ["id", "type", "at"],
      "additionalProperties": false,
      "description": "点．座標は，あとに置いたオブジェクトの式から，`<id>_x`のような名前で参照できる．",
      "properties": {
        "id": { "$ref": "#/$defs/identifier" },
        "type": { "const": "point" },
        "at": { "$ref": "#/$defs/position" },
        "label": { "type": "string", "description": "点の名前の式(TeX)．省くと，名前を置かない．" },
        "anchor": { "$ref": "#/$defs/anchor" },
        "dot": { "type": "boolean", "description": "点の印(塗った丸)を描くか．既定は描かない．" },
        "style": { "$ref": "#/$defs/style" },
        "transform": { "$ref": "#/$defs/transform" }
      }
    },
    "vector": {
      "type": "object",
      "required": ["id", "type", "from", "to"],
      "additionalProperties": false,
      "description": "向きのある線分．`from`と`to`は，`point`オブジェクトの`id`でなければならない．",
      "properties": {
        "id": { "$ref": "#/$defs/identifier" },
        "type": { "const": "vector" },
        "from": { "$ref": "#/$defs/identifier" },
        "to": { "$ref": "#/$defs/identifier" },
        "arrow": { "$ref": "#/$defs/arrow", "description": "終点の矢じり．既定は`stealth`．" },
        "style": { "$ref": "#/$defs/style" },
        "transform": { "$ref": "#/$defs/transform" }
      }
    },
    "segment": {
      "type": "object",
      "required": ["id", "type", "from", "to"],
      "additionalProperties": false,
      "description": "線分(矢じりのない，向きのない線)．`from`と`to`は，`point`オブジェクトの`id`でなければならない．",
      "properties": {
        "id": { "$ref": "#/$defs/identifier" },
        "type": { "const": "segment" },
        "from": { "$ref": "#/$defs/identifier" },
        "to": { "$ref": "#/$defs/identifier" },
        "style": { "$ref": "#/$defs/style" },
        "transform": { "$ref": "#/$defs/transform" }
      }
    },
    "region": {
      "type": "object",
      "required": ["id", "type", "between", "domain"],
      "additionalProperties": false,
      "description": "2つのグラフ(かグラフとx軸)の間の領域．斜線で埋める．平面の図でだけ使える．",
      "properties": {
        "id": { "$ref": "#/$defs/identifier" },
        "type": { "const": "region" },
        "transform": { "$ref": "#/$defs/transform" },
        "between": {
          "type": "array",
          "items": { "$ref": "#/$defs/identifier" },
          "minItems": 1,
          "maxItems": 2,
          "description": "領域を挟む，`graph`オブジェクトの`id`．1つならグラフとx軸の間，2つなら2つのグラフの間になる．"
        },
        "domain": {
          "$ref": "#/$defs/boundPair",
          "description": "領域のxの範囲．グラフの定義域の中でなければならない．"
        },
        "hatch": { "type": "boolean", "description": "斜線を引くか．既定は引く．" },
        "fill": { "$ref": "#/$defs/fill", "description": "塗り．省くと，斜線で埋める．" },
        "angle": {
          "type": "number",
          "description": "斜線の角度(度)．x軸から反時計回りに測る．既定は45．"
        },
        "gap": { "$ref": "#/$defs/length", "description": "斜線の間隔．既定は3mm．" },
        "style": { "$ref": "#/$defs/style" }
      }
    },
    "fractal": {
      "type": "object",
      "required": ["id", "type", "base", "transforms", "depth"],
      "additionalProperties": false,
      "description": "フラクタル図形．平面の図でだけ使える．反復関数系(IFS)：基本図形(`base`)を，`transforms`で`depth`回，再帰的に写す．深さ0は`base`をそのまま描き，深さnは，深さn-1の図形全体に，それぞれの変換を施したものをすべて集めたものになる．",
      "properties": {
        "id": { "$ref": "#/$defs/identifier" },
        "type": { "const": "fractal" },
        "base": {
          "type": "array",
          "items": { "$ref": "#/$defs/boundPair" },
          "minItems": 2,
          "maxItems": 12,
          "description": "基本図形が通る点(x，y)の列．2点以上12点以下．"
        },
        "closed": {
          "type": "boolean",
          "description": "基本図形を閉じるか(最後の点から最初の点へも線を引く)．既定は閉じない．"
        },
        "transforms": {
          "type": "array",
          "items": { "type": "array", "items": { "$ref": "#/$defs/transformStep" }, "minItems": 1 },
          "minItems": 1,
          "maxItems": 12,
          "description": "反復関数系の変換の並び．各要素は，1つの変換を表す，手順(`transformStep`)の並びである．1つ以上12個以下．写像(`map`)は使えない(スキーマでは表せない)．"
        },
        "depth": {
          "type": "integer",
          "minimum": 0,
          "maximum": 10,
          "description": "再帰の深さ．変換の数のこの乗が，図形の数になるので，大きすぎる組み合わせは断られる．"
        },
        "style": { "$ref": "#/$defs/style" },
        "transform": { "$ref": "#/$defs/transform" },
        "all_depths": {
          "type": "boolean",
          "description": "深さ0から`depth`までの図形を，すべて重ねて描くか．既定は，深さ`depth`の図形だけを描く．"
        }
      }
    },
    "sphere": {
      "type": "object",
      "required": ["id", "type", "center", "radius"],
      "additionalProperties": false,
      "description": "球．空間の図でだけ使える．変換(`transform`)があれば，同じ形の曲面(`surface`)として描く(拡大縮小で楕円面にもなる)．",
      "properties": {
        "id": { "$ref": "#/$defs/identifier" },
        "type": { "const": "sphere" },
        "transform": { "$ref": "#/$defs/transform" },
        "center": {
          "type": "array",
          "items": { "type": "number" },
          "minItems": 3,
          "maxItems": 3,
          "description": "中心の座標．"
        },
        "radius": { "type": "number", "exclusiveMinimum": 0, "description": "半径．正の数．" },
        "style": { "$ref": "#/$defs/style" },
        "wireframe": {
          "$ref": "#/$defs/style",
          "description": "球のワイヤーフレーム(経線と緯線)．この項目があれば描き，スタイルとして使う(`{}`でもよい)．省くと描かない．"
        }
      }
    },
    "surface": {
      "type": "object",
      "required": ["id", "type"],
      "additionalProperties": false,
      "description": "曲面．空間の図でだけ使える．式(`vars`，`expr`，`domain`)か，Bézier曲面の制御点の網(`bezier`)のどちらかで書き，両方は書けない．`control_net`は，`bezier`があるときだけ使える．",
      "oneOf": [
        {
          "required": ["vars", "expr", "domain"],
          "not": { "anyOf": [{ "required": ["bezier"] }, { "required": ["control_net"] }] }
        },
        {
          "required": ["bezier"],
          "not": {
            "anyOf": [
              { "required": ["vars"] },
              { "required": ["expr"] },
              { "required": ["domain"] }
            ]
          }
        }
      ],
      "properties": {
        "id": { "$ref": "#/$defs/identifier" },
        "type": { "const": "surface" },
        "vars": {
          "type": "array",
          "items": { "$ref": "#/$defs/identifier" },
          "minItems": 2,
          "maxItems": 2,
          "description": "2つの変数の名前．重ならないこと，`e`や`pi`と重ならないことが必要である．"
        },
        "expr": {
          "type": "array",
          "items": { "$ref": "#/$defs/nonBlankString" },
          "minItems": 3,
          "maxItems": 3,
          "description": "x，y，z座標の式．"
        },
        "domain": {
          "type": "array",
          "items": { "$ref": "#/$defs/boundPair" },
          "minItems": 2,
          "maxItems": 2,
          "description": "各変数の範囲．数どうしなら，小さい方が先でなければならない．"
        },
        "bezier": {
          "type": "array",
          "items": {
            "type": "array",
            "items": {
              "type": "array",
              "items": { "$ref": "#/$defs/bound" },
              "minItems": 3,
              "maxItems": 3
            },
            "minItems": 2,
            "maxItems": 12
          },
          "minItems": 2,
          "maxItems": 12,
          "description": "制御点の網．`bezier[i][j]`は，1つ目の変数の方向にi番目，2つ目の変数の方向にj番目の点で，x，y，zの3つの座標を持つ．各方向に2点以上12点以下を，行の長さを揃えて並べる．"
        },
        "mesh": {
          "type": "array",
          "items": { "type": "integer", "minimum": 4, "maximum": 200 },
          "minItems": 2,
          "maxItems": 2,
          "description": "網の細かさ(各変数の方向の分割数)．既定は48と48．"
        },
        "boundary": { "type": "boolean", "description": "定義域の縁を描くか．既定は描かない．" },
        "style": { "$ref": "#/$defs/style" },
        "wireframe": {
          "$ref": "#/$defs/style",
          "description": "曲面のワイヤーフレーム(u一定・v一定の断面)．式で書いた曲面でも，Bézier曲面でも，同じように，曲面の上の線として描く．この項目があれば描き，スタイルとして使う(`{}`でもよい)．省くと描かない．"
        },
        "wireframe_step": {
          "type": "array",
          "items": { "$ref": "#/$defs/positiveNumberOrExpression" },
          "minItems": 2,
          "maxItems": 2,
          "description": "ワイヤーフレームの刻み(u方向，v方向)．断面は，各変数が刻みの整数倍になる所のうち，定義域の内側(両端を除く)に引く．数か式で書く．省くと，どちらも定義域の幅の4分の1．Bézier曲面の変数の範囲は0から1．`wireframe`があるときだけ使う．各方向の断面が50本を超える刻みは断られる(スキーマでは表せない)．"
        },
        "control_net": {
          "$ref": "#/$defs/style",
          "description": "Bézier曲面の，制御点の網(行と列を結ぶ折れ線)．`bezier`があるときだけ使える．この項目があれば描き，スタイルとして使う(`{}`でもよい)．省くと描かない．"
        },
        "transform": { "$ref": "#/$defs/transform" }
      }
    },
    "cut": {
      "type": "object",
      "required": ["id", "type", "surface", "normal", "offset"],
      "additionalProperties": false,
      "description": "曲面の，平面による切り口．平面は，法線と定数で`normal・p = offset`と書く．空間の図でだけ使える．",
      "properties": {
        "id": { "$ref": "#/$defs/identifier" },
        "type": { "const": "cut" },
        "transform": { "$ref": "#/$defs/transform" },
        "surface": {
          "$ref": "#/$defs/identifier",
          "description": "切る曲面の`id`．`surface`オブジェクトのものでなければならない．"
        },
        "normal": {
          "type": "array",
          "items": { "$ref": "#/$defs/bound" },
          "minItems": 3,
          "maxItems": 3,
          "description": "平面の法線．0でない有限のベクトルでなければならない．"
        },
        "offset": { "$ref": "#/$defs/bound" },
        "style": { "$ref": "#/$defs/style" }
      }
    },
    "implicit_curve": {
      "type": "object",
      "required": ["id", "type", "vars", "expr", "domain", "level", "values"],
      "additionalProperties": false,
      "description": "陰関数の曲線．2つの変数の関数`level`が，`values`の各値になる所を，写像`expr`で図の平面か空間へ移した曲線．写像が作る面は描かず，ほかの線も隠さない．平面の図で`expr`を`[\"x\", \"y\"]`にすれば陰関数の曲線に，斜交座標の式にすれば格子面の族のような直線の族になる．空間の図で`expr`を曲面の式にすれば曲面の等高線に，4次元の曲面のx，y，z座標にして`level`を4つ目の座標にすれば，超平面による切り口になる．",
      "properties": {
        "id": { "$ref": "#/$defs/identifier" },
        "type": { "const": "implicit_curve" },
        "vars": {
          "type": "array",
          "items": { "$ref": "#/$defs/identifier" },
          "minItems": 2,
          "maxItems": 2,
          "description": "2つの変数の名前．重ならないこと，`e`や`pi`と重ならないことが必要である．"
        },
        "expr": {
          "type": "array",
          "items": { "$ref": "#/$defs/nonBlankString" },
          "minItems": 2,
          "maxItems": 3,
          "description": "写像の各座標の式．平面の図では2個，空間の図では3個でなければならない．どちらの数にするかは`view`で決まる．"
        },
        "domain": {
          "type": "array",
          "items": { "$ref": "#/$defs/boundPair" },
          "minItems": 2,
          "maxItems": 2,
          "description": "各変数の範囲．数どうしなら，小さい方が先でなければならない．"
        },
        "level": {
          "$ref": "#/$defs/nonBlankString",
          "description": "値を比べる関数の式．2つの変数と媒介変数を使う．"
        },
        "values": {
          "type": "array",
          "items": { "$ref": "#/$defs/bound" },
          "minItems": 1,
          "maxItems": 64,
          "description": "線を引く値．数か式を並べ，値ごとに線を引く．"
        },
        "mesh": {
          "type": "array",
          "items": { "type": "integer", "minimum": 4, "maximum": 200 },
          "minItems": 2,
          "maxItems": 2,
          "description": "網の細かさ(各変数の方向の分割数)．既定は48．細かいほど，小さな輪を取りこぼさず，重い．"
        },
        "style": { "$ref": "#/$defs/style" },
        "transform": { "$ref": "#/$defs/transform" }
      }
    },
    "intersection": {
      "type": "object",
      "required": ["id", "type", "surfaces"],
      "additionalProperties": false,
      "description": "2つの曲面の交線．空間の図でだけ使える．",
      "properties": {
        "id": { "$ref": "#/$defs/identifier" },
        "type": { "const": "intersection" },
        "transform": { "$ref": "#/$defs/transform" },
        "surfaces": {
          "type": "array",
          "items": { "$ref": "#/$defs/identifier" },
          "minItems": 2,
          "maxItems": 2,
          "uniqueItems": true,
          "description": "交わる，違う2つの`surface`オブジェクトの`id`．`surface`オブジェクトのものでなければならない．"
        },
        "style": { "$ref": "#/$defs/style" }
      }
    },
    "tangent_plane": {
      "type": "object",
      "required": ["id", "type", "of", "at", "size"],
      "additionalProperties": false,
      "description": "曲面の接平面．空間の図でだけ使える．接する点での，2つの偏微分(中心差分)の向きに張る平行四辺形として描く．",
      "properties": {
        "id": { "$ref": "#/$defs/identifier" },
        "type": { "const": "tangent_plane" },
        "transform": { "$ref": "#/$defs/transform" },
        "of": {
          "$ref": "#/$defs/identifier",
          "description": "接する曲面の`id`．`surface`オブジェクトのものでなければならない．"
        },
        "at": {
          "type": "array",
          "items": { "$ref": "#/$defs/bound" },
          "minItems": 2,
          "maxItems": 2,
          "description": "接する点の，曲面の2つの変数の値．"
        },
        "size": {
          "$ref": "#/$defs/positiveNumberOrExpression",
          "description": "接平面の半径(cm)．中心から各辺への距離．"
        },
        "style": { "$ref": "#/$defs/style" }
      }
    },
    "complex": {
      "type": "object",
      "required": ["id", "type", "vertices", "faces"],
      "additionalProperties": false,
      "description": "複体(頂点と面でできた図形，正多面体など)．空間の図でだけ使える．稜(辺)は，どの2つの面にも属さない稜がないよう，`faces`から自動的に決まる(スキーマでは表せない)．`faces`は，外から見て頂点が反時計回りになるように書く：稜を隠すかどうかは，その稜に隣接する2つの面の法線の向きで決まるので，向きが逆だと隠れ方が逆になる(スキーマでは表せない)．",
      "properties": {
        "id": { "$ref": "#/$defs/identifier" },
        "type": { "const": "complex" },
        "vertices": {
          "type": "array",
          "description": "頂点の座標．3個ずつ(x，y，z)．3個以上64個以下．",
          "items": { "type": "array", "items": { "type": "number" }, "minItems": 3, "maxItems": 3 },
          "minItems": 3,
          "maxItems": 64
        },
        "faces": {
          "type": "array",
          "description": "面．頂点の番号(0始まり，`vertices`の添字)を，周に沿って並べる．1個以上64個以下の面，1つの面は3個以上32個以下の頂点．",
          "items": {
            "type": "array",
            "items": { "type": "integer", "minimum": 0 },
            "minItems": 3,
            "maxItems": 32
          },
          "minItems": 1,
          "maxItems": 64
        },
        "style": { "$ref": "#/$defs/style" },
        "transform": { "$ref": "#/$defs/transform" }
      }
    },
    "polyhedron": {
      "type": "object",
      "required": ["id", "type", "solid", "center", "radius"],
      "additionalProperties": false,
      "description": "正多面体．種類と，中心と，半径(中心から頂点までの距離)だけで書き，頂点と面はエンジンが決める．空間の図でだけ使える．同じ頂点と面の複体(`complex`)と同じように描き，隠す．基準の向きは種類ごとに決まっていて(立方体は，面が座標軸に垂直)，ほかの向きは変換(`transform`)の回転で作る．",
      "properties": {
        "id": { "$ref": "#/$defs/identifier" },
        "type": { "const": "polyhedron" },
        "solid": {
          "enum": ["tetrahedron", "cube", "octahedron", "dodecahedron", "icosahedron"],
          "description": "種類．正四面体，正六面体(立方体)，正八面体，正十二面体，正二十面体．"
        },
        "center": {
          "type": "array",
          "items": { "type": "number" },
          "minItems": 3,
          "maxItems": 3,
          "description": "中心の座標．"
        },
        "radius": {
          "type": "number",
          "exclusiveMinimum": 0,
          "description": "中心から頂点までの距離(外接球の半径)．"
        },
        "style": { "$ref": "#/$defs/style" },
        "transform": { "$ref": "#/$defs/transform" }
      }
    },
    "transformStep": {
      "type": "object",
      "additionalProperties": false,
      "description": "変換の手順の1つ．操作(`translate`，`rotate`，`scale`，`reflect`，`shear`，`map`)をちょうど1つ書く．数は，数か，媒介変数と定数を使う式で書く．座標は，平面の図では2個，空間の図では3個書く．`axis`は空間の図の回転にだけ，`center`は回転・拡大縮小・対称移動・せん断にだけ書ける(スキーマでは表せない)．",
      "oneOf": [
        { "required": ["translate"] },
        { "required": ["rotate"] },
        { "required": ["scale"] },
        { "required": ["reflect"] },
        { "required": ["shear"] },
        { "required": ["map"] }
      ],
      "dependentRequired": { "axis": ["rotate"] },
      "properties": {
        "translate": {
          "type": "array",
          "items": { "$ref": "#/$defs/bound" },
          "minItems": 2,
          "maxItems": 3,
          "description": "平行移動の量．"
        },
        "rotate": {
          "$ref": "#/$defs/bound",
          "description": "回転の角度(度)．平面の図では反時計回り，空間の図では`axis`の向きに右ねじの向き．"
        },
        "axis": {
          "type": "array",
          "items": { "$ref": "#/$defs/bound" },
          "minItems": 3,
          "maxItems": 3,
          "description": "回転の軸の向き．空間の図の回転に要る．0でないベクトルにする．"
        },
        "scale": {
          "description": "拡大縮小の倍率．1つの数なら全方向に同じ倍率，並びなら方向ごとの倍率．負の数で反転する．",
          "oneOf": [
            { "$ref": "#/$defs/bound" },
            { "type": "array", "items": { "$ref": "#/$defs/bound" }, "minItems": 2, "maxItems": 3 }
          ]
        },
        "reflect": {
          "type": "array",
          "items": { "$ref": "#/$defs/bound" },
          "minItems": 2,
          "maxItems": 3,
          "description": "対称移動の鏡．平面の図では鏡にする直線の向き(`[1, 0]`でx軸，`[1, 1]`で直線y = x)，空間の図では鏡にする平面の法線(`[0, 0, 1]`でxy平面)．0でないベクトルにする．"
        },
        "shear": {
          "$ref": "#/$defs/boundPair",
          "description": "せん断の量(xがyに，yがxに，それぞれ比例して動く量)．平面の図でだけ使える．"
        },
        "map": {
          "$ref": "#/$defs/identifier",
          "description": "写像(`map`オブジェクト)の`id`．線分・ベクトル・複体・正多面体とフラクタルの`transforms`には使えない(スキーマでは表せない)．"
        },
        "center": {
          "type": "array",
          "items": { "$ref": "#/$defs/bound" },
          "minItems": 2,
          "maxItems": 3,
          "description": "回転・拡大縮小・対称移動・せん断で動かない点．なければ原点．"
        }
      }
    },
    "transform": {
      "type": "array",
      "items": { "$ref": "#/$defs/transformStep" },
      "maxItems": 16,
      "description": "変換．手順を，書いた順に施す(最初の手順が，点に最初にかかる)．"
    },
    "polygon": {
      "type": "object",
      "required": ["id", "type"],
      "additionalProperties": false,
      "description": "多角形．辺(閉じた折れ線)と，塗った面(`fill`)でできる．平面の図でだけ使える．正多角形は辺の数(`sides`)と中心(`center`)と半径(`radius`，中心から頂点まで)で書き，底辺が水平になる向きに置く．ほかの多角形は，頂点(`vertices`)を周に沿って並べる．どちらか一方で書く．",
      "oneOf": [
        { "required": ["sides", "center", "radius"], "not": { "required": ["vertices"] } },
        {
          "required": ["vertices"],
          "not": {
            "anyOf": [
              { "required": ["sides"] },
              { "required": ["center"] },
              { "required": ["radius"] }
            ]
          }
        }
      ],
      "properties": {
        "id": { "$ref": "#/$defs/identifier" },
        "type": { "const": "polygon" },
        "sides": {
          "type": "integer",
          "minimum": 3,
          "maximum": 64,
          "description": "正多角形の辺の数．"
        },
        "center": { "$ref": "#/$defs/boundPair", "description": "正多角形の中心．" },
        "radius": {
          "$ref": "#/$defs/positiveNumberOrExpression",
          "description": "正多角形の，中心から頂点までの距離．"
        },
        "vertices": {
          "type": "array",
          "items": { "$ref": "#/$defs/position" },
          "minItems": 3,
          "maxItems": 64,
          "description": "頂点．座標か，点の式(`\"A\"`など)で，周に沿って並べる．"
        },
        "fill": {
          "$ref": "#/$defs/fill",
          "description": "面を塗る色と不透明度．なければ塗らない．"
        },
        "style": { "$ref": "#/$defs/style" },
        "transform": { "$ref": "#/$defs/transform" }
      }
    },
    "function": {
      "type": "object",
      "required": ["id", "type", "vars", "expr"],
      "additionalProperties": false,
      "description": "式から呼べる関数．描かない．`id`が関数の名前になり，どのオブジェクトの式からも`f(x)`の形で呼べる．本体は，媒介変数と，先に置いた関数を使える(合成`f(g(x))`もできる)．",
      "properties": {
        "id": { "$ref": "#/$defs/identifier" },
        "type": { "const": "function" },
        "vars": {
          "type": "array",
          "items": { "$ref": "#/$defs/identifier" },
          "minItems": 1,
          "maxItems": 3,
          "description": "引数の名前．"
        },
        "expr": { "$ref": "#/$defs/nonBlankString", "description": "本体の式．" }
      }
    },
    "map": {
      "type": "object",
      "required": ["id", "type", "vars", "expr"],
      "additionalProperties": false,
      "description": "写像．点の座標を，同じ数の座標に写す．描かない．変換の手順`{\"map\": \"<id>\"}`で使う．変数と式の数は，平面の図では2個，空間の図では3個にする(スキーマでは表せない)．",
      "properties": {
        "id": { "$ref": "#/$defs/identifier" },
        "type": { "const": "map" },
        "vars": {
          "type": "array",
          "items": { "$ref": "#/$defs/identifier" },
          "minItems": 2,
          "maxItems": 3,
          "description": "座標の変数の名前．"
        },
        "expr": {
          "type": "array",
          "items": { "$ref": "#/$defs/nonBlankString" },
          "minItems": 2,
          "maxItems": 3,
          "description": "写した先の座標の式．"
        }
      }
    },
    "image": {
      "type": "object",
      "required": ["id", "type", "of", "transform"],
      "additionalProperties": false,
      "description": "別のオブジェクトを変換した像．元のオブジェクトはそのまま残る．元にできるのは，先に置いた，座標軸・媒介変数・関数・写像を除くオブジェクト(像も含む)である(スキーマでは表せない)．",
      "properties": {
        "id": { "$ref": "#/$defs/identifier" },
        "type": { "const": "image" },
        "of": { "$ref": "#/$defs/identifier", "description": "元のオブジェクトの`id`．" },
        "transform": { "$ref": "#/$defs/transform" },
        "label": { "type": "string", "description": "点の像の名前の式(TeX)．点の像にだけ書ける．" },
        "style": {
          "$ref": "#/$defs/style",
          "description": "書けば元のスタイルの代わりに使い，書かなければ元のスタイルを使う．"
        }
      }
    },
    "vector_field": {
      "type": "object",
      "required": ["id", "type", "field", "x_step", "y_step"],
      "additionalProperties": false,
      "description": "ベクトル場．格子点ごとに場の式を評価し，その値の矢印を置く．平面の図でも空間の図でも使える．場は，ベクトルの式(点の式と同じ形で，格子点の位置ベクトル`r`と先に置いた点を使う．例：`\"(r - Q) / norm(r - Q)^3\"`)か，成分の式の並び(例：`[\"-r_y\", \"r_x\"]`)で書く．値が有限でない格子点(点電荷の位置など)は描かない．平面の図では，見える範囲からはみ出す矢印も描かない．空間の図では，格子点を置く3つの範囲とz方向の刻みが要り(スキーマでは表せない)，矢印の曲面に隠れる部分は隠れた線で描く．",
      "properties": {
        "id": { "$ref": "#/$defs/identifier" },
        "type": { "const": "vector_field" },
        "var": {
          "$ref": "#/$defs/identifier",
          "description": "格子点の位置ベクトルの名前．既定は`r`で，成分は`r_x`，`r_y`(空間の図では`r_z`も)の名前で使える．媒介変数や点の名前と重ならないこと(スキーマでは表せない)．"
        },
        "field": {
          "description": "場の式．ベクトルの式(文字列．値がベクトルになる．内積`dot`，外積`cross`，長さ`norm`も使える)か，成分の数か式の並び(平面の図では2個，空間の図では3個)．",
          "oneOf": [
            { "$ref": "#/$defs/nonBlankString" },
            { "type": "array", "items": { "$ref": "#/$defs/bound" }, "minItems": 2, "maxItems": 3 }
          ]
        },
        "x_step": { "$ref": "#/$defs/bound", "description": "格子点のx方向の刻み．正の数か式．" },
        "y_step": {
          "$ref": "#/$defs/bound",
          "description": "格子点のy方向の刻み．正の数か式．格子点は5000個まで(スキーマでは表せない)．"
        },
        "z_step": {
          "$ref": "#/$defs/bound",
          "description": "格子点のz方向の刻み．正の数か式．空間の図でだけ書き，空間の図では必要である(スキーマでは表せない)．"
        },
        "x_range": {
          "$ref": "#/$defs/numberPair",
          "description": "格子点を置くxの範囲．下端から刻みごとに置く．平面の図で省くと，見える範囲から刻みの半分だけ内側にある，刻みの倍数に置く(矢印が縁で切れない)．空間の図では必要である(スキーマでは表せない)．"
        },
        "y_range": {
          "$ref": "#/$defs/numberPair",
          "description": "格子点を置くyの範囲．省いたときの置き方は`x_range`と同じである．"
        },
        "z_range": {
          "$ref": "#/$defs/numberPair",
          "description": "格子点を置くzの範囲．空間の図でだけ書き，空間の図では必要である(スキーマでは表せない)．"
        },
        "length": {
          "enum": ["scaled", "normalized", "clamped"],
          "description": "矢印の長さの決め方．`scaled`(既定)は場の値に倍率`scale`を掛けた長さ，`normalized`は長さをそろえて向きだけを示し(長さは`scale`)，`clamped`は倍率を掛けて`max_length`より長ければそこで切る．"
        },
        "scale": {
          "$ref": "#/$defs/bound",
          "description": "倍率．`normalized`では矢印の長さ．既定は，`scaled`と`clamped`では1，`normalized`では刻みの小さい方の0.8倍．"
        },
        "max_length": {
          "$ref": "#/$defs/bound",
          "description": "矢印の長さの上限．`clamped`でだけ使う(スキーマでは表せない)．既定は刻みの小さい方の0.8倍．"
        },
        "pivot": {
          "enum": ["middle", "tail"],
          "description": "矢印を格子点のどこに置くか．`middle`(既定)は中点，`tail`は根元．"
        },
        "style": { "$ref": "#/$defs/style" },
        "transform": { "$ref": "#/$defs/transform" }
      }
    },
    "field_line": {
      "type": "object",
      "required": ["id", "type", "field", "seeds"],
      "additionalProperties": false,
      "description": "流線．起点(`seeds`)から，場の向き(単位ベクトル)に沿って，4次のRunge-Kutta法で積分した曲線．電気力線などに使う．場は，ベクトル場(`vector_field`)と同じく，ベクトルの式か成分の式の並びで書く．場が有限でない所，0の所，向きが急に反転した所(点電荷を飛び越えたとき)と，平面の図では見える範囲の外で止まる．平面の図では見える範囲で切り取り，空間の図では曲面に隠れる部分を隠れた線で描く．",
      "properties": {
        "id": { "$ref": "#/$defs/identifier" },
        "type": { "const": "field_line" },
        "var": {
          "$ref": "#/$defs/identifier",
          "description": "位置ベクトルの名前．既定は`r`で，成分は`r_x`，`r_y`(空間の図では`r_z`も)の名前で使える．"
        },
        "field": {
          "description": "場の式．ベクトルの式(文字列)か，成分の数か式の並び(平面の図では2個，空間の図では3個)．",
          "oneOf": [
            { "$ref": "#/$defs/nonBlankString" },
            { "type": "array", "items": { "$ref": "#/$defs/bound" }, "minItems": 2, "maxItems": 3 }
          ]
        },
        "seeds": {
          "type": "array",
          "items": {
            "type": "array",
            "items": { "$ref": "#/$defs/bound" },
            "minItems": 2,
            "maxItems": 3
          },
          "minItems": 1,
          "maxItems": 200,
          "description": "起点の並び．各起点は座標の数か式の並びで，平面の図では2個，空間の図では3個にする(スキーマでは表せない)．式には，媒介変数や点の座標の名前(`Q_x`など)を使える．起点ごとに1本の流線を引く．"
        },
        "length": {
          "$ref": "#/$defs/bound",
          "description": "起点から片側に伸ばす，曲線に沿った長さ．正の数か式．既定は10．"
        },
        "step": {
          "$ref": "#/$defs/bound",
          "description": "積分の刻み(曲線に沿った長さ)．正の数か式．既定は長さの400分の1．片側の点は20000個まで(スキーマでは表せない)．"
        },
        "direction": {
          "enum": ["both", "forward", "backward"],
          "description": "伸ばす向き．`both`(既定)は場の向きと逆向きの両方，`forward`は場の向きだけ，`backward`は逆向きだけ．"
        },
        "style": { "$ref": "#/$defs/style" },
        "transform": { "$ref": "#/$defs/transform" }
      }
    },
    "wigner_seitz": {
      "type": "object",
      "required": ["id", "type", "basis"],
      "additionalProperties": false,
      "description": "Wigner-Seitz胞．2つの基本ベクトルで張る格子の，中心の格子点にいちばん近い点の集まりで，中心と近くの格子点を結ぶ線分の垂直二等分線で囲まれた凸多角形である．逆格子の基本ベクトルを渡せば，第1Brillouinゾーンになる．辺と塗りは，多角形(`polygon`)と同じに描く．平面の図でだけ使える．",
      "properties": {
        "id": { "$ref": "#/$defs/identifier" },
        "type": { "const": "wigner_seitz" },
        "basis": {
          "type": "array",
          "items": { "$ref": "#/$defs/boundPair" },
          "minItems": 2,
          "maxItems": 2,
          "description": "2つの基本ベクトル．各ベクトルは2個の数か式である．平行であってはならない(スキーマでは表せない)．"
        },
        "center": {
          "$ref": "#/$defs/boundPair",
          "description": "中心の格子点．省くと原点である．"
        },
        "fill": {
          "$ref": "#/$defs/fill",
          "description": "面を塗る色と不透明度．なければ塗らない．"
        },
        "style": { "$ref": "#/$defs/style" },
        "transform": { "$ref": "#/$defs/transform" }
      }
    },
    "taylor": {
      "type": "object",
      "required": ["id", "type", "of", "at", "order"],
      "additionalProperties": false,
      "description": "グラフのTaylor展開を，`order`次で打ち切った多項式のグラフ．平面の図でだけ使える．展開するグラフの式は，特殊関数を含まず，中心で微分できなければならない(スキーマでは表せない)．",
      "properties": {
        "id": { "$ref": "#/$defs/identifier" },
        "type": { "const": "taylor" },
        "transform": { "$ref": "#/$defs/transform" },
        "of": {
          "$ref": "#/$defs/identifier",
          "description": "展開するグラフ(`graph`)の`id`．変換したグラフは使えない．"
        },
        "at": { "$ref": "#/$defs/bound", "description": "展開の中心．" },
        "order": {
          "type": "integer",
          "minimum": 0,
          "maximum": 30,
          "description": "打ち切る次数．"
        },
        "domain": {
          "$ref": "#/$defs/boundPair",
          "description": "描く範囲．なければ，グラフの定義域．"
        },
        "style": { "$ref": "#/$defs/style" }
      }
    },
    "elliptic_curve": {
      "type": "object",
      "required": ["id", "type", "a", "b"],
      "additionalProperties": false,
      "description": "楕円曲線．Weierstrassの標準形y^2 = x^3 + a x + bの実の点を描く．点`p`(と`q`)のx座標を与えると，群の演算の作図を描く：`q`があれば，PとQを通る直線，3つ目の交点-(P+Q)，それをx軸について折り返したP+Q．`q`がなければ，Pでの接線による2P．平面の図でだけ使える．",
      "properties": {
        "id": {
          "$ref": "#/$defs/identifier"
        },
        "type": {
          "const": "elliptic_curve"
        },
        "a": {
          "$ref": "#/$defs/bound",
          "description": "係数a．"
        },
        "b": {
          "$ref": "#/$defs/bound",
          "description": "係数b．"
        },
        "p": {
          "$ref": "#/$defs/bound",
          "description": "点Pのx座標．省くと，曲線だけを描く．x^3 + a x + bが負になるx座標では，曲線の上に点がないので誤りになる(スキーマでは表せない)．"
        },
        "p_lower": {
          "type": "boolean",
          "description": "点Pを下の枝(y < 0)にとるか．既定は上の枝(y >= 0)．"
        },
        "q": {
          "$ref": "#/$defs/bound",
          "description": "点Qのx座標．省くと，Pの2倍を作図する．`p`と一緒に書く(スキーマでは表せない)．"
        },
        "q_lower": {
          "type": "boolean",
          "description": "点Qを下の枝にとるか．"
        },
        "construction": {
          "type": "boolean",
          "description": "和(か2倍)の作図を描くか．既定は描く．"
        },
        "multiples": {
          "type": "integer",
          "minimum": 2,
          "maximum": 64,
          "description": "Pの倍数P，2P，…，nPの点を並べるときのn．`p`と一緒に書く(スキーマでは表せない)．"
        },
        "labels": {
          "type": "boolean",
          "description": "点の名前(P，Q，P+Qなど)を置くか．既定は置く．"
        },
        "style": {
          "$ref": "#/$defs/style"
        },
        "transform": {
          "$ref": "#/$defs/transform"
        }
      }
    },
    "heatmap": {
      "type": "object",
      "required": ["id", "type", "expr"],
      "additionalProperties": false,
      "description": "値を色で表す図．2つの変数の式の値を，点ごとに色へ対応させた画像にする．式は複素数の式として読み(iは虚数単位)，値の虚部が0でない点と，値が有限でない点は透明にする．SVGではPNGの画像を埋め込み，TikZでは粗い升目の塗りつぶしにする．平面の図でだけ使える．",
      "properties": {
        "id": {
          "$ref": "#/$defs/identifier"
        },
        "type": {
          "const": "heatmap"
        },
        "vars": {
          "type": "array",
          "items": {
            "$ref": "#/$defs/identifier"
          },
          "minItems": 2,
          "maxItems": 2,
          "description": "2つの変数の名前．省くと`[\"x\", \"y\"]`．"
        },
        "expr": {
          "$ref": "#/$defs/nonBlankString",
          "description": "値の式．"
        },
        "domain": {
          "type": "array",
          "items": {
            "$ref": "#/$defs/boundPair"
          },
          "minItems": 2,
          "maxItems": 2,
          "description": "画像を置く範囲[[xの下端, 上端], [yの下端, 上端]]．省くと見える範囲．見える範囲の外は切り取る．"
        },
        "range": {
          "$ref": "#/$defs/boundPair",
          "description": "色の両端に対応させる値．省くと，値の最小と最大(`coolwarm`では0を中心にした範囲，対数の目盛では最大から6桁下まで)．外の値は端の色になる．"
        },
        "colormap": {
          "enum": ["viridis", "gray", "gray_inverse", "coolwarm"],
          "description": "値と色の対応．`viridis`(既定，暗い紫から黄へ)，`gray`(黒から白)，`gray_inverse`(白から黒)，`coolwarm`(青から白を経て赤)．"
        },
        "scale": {
          "enum": ["linear", "log"],
          "description": "値の目盛．`log`では常用対数をとってから色に対応させ，正でない値は透明にする．"
        },
        "resolution": {
          "type": "integer",
          "minimum": 1,
          "maximum": 1000,
          "description": "SVGの画像の，長い辺の画素の数．省くと200．"
        },
        "tikz_resolution": {
          "type": "integer",
          "minimum": 1,
          "maximum": 200,
          "description": "TikZの出力の，長い辺の升目の数．省くと40．"
        }
      }
    },
    "domain_coloring": {
      "type": "object",
      "required": ["id", "type", "expr"],
      "additionalProperties": false,
      "description": "複素関数の色塗り．複素数zの関数の値の偏角を色相(正の実数が赤，負の実数が青緑)で表した画像にする．零点のまわりでは色相が一周し，極では値がなく透明になる．平面の図でだけ使える．",
      "properties": {
        "id": {
          "$ref": "#/$defs/identifier"
        },
        "type": {
          "const": "domain_coloring"
        },
        "var": {
          "$ref": "#/$defs/identifier",
          "description": "複素数の変数の名前．省くと`z`で，点(x, y)ではx + iyの値になる．"
        },
        "expr": {
          "$ref": "#/$defs/nonBlankString",
          "description": "関数の式．複素数の式として読み，iは虚数単位である．"
        },
        "domain": {
          "type": "array",
          "items": {
            "$ref": "#/$defs/boundPair"
          },
          "minItems": 2,
          "maxItems": 2,
          "description": "画像を置く範囲[[xの下端, 上端], [yの下端, 上端]]．省くと見える範囲．"
        },
        "shading": {
          "enum": ["modulus", "none"],
          "description": "明るさの陰影．`modulus`(既定)は，絶対値が2倍になるごとに明るさの縞を1本入れる．`none`は色相だけ．"
        },
        "resolution": {
          "type": "integer",
          "minimum": 1,
          "maximum": 1000,
          "description": "SVGの画像の，長い辺の画素の数．省くと200．"
        },
        "tikz_resolution": {
          "type": "integer",
          "minimum": 1,
          "maximum": 200,
          "description": "TikZの出力の，長い辺の升目の数．省くと40．"
        }
      }
    },
    "fourier_series": {
      "type": "object",
      "required": ["id", "type", "expr", "period", "terms"],
      "additionalProperties": false,
      "description": "フーリエ級数の部分和．1周期の区間`period`の上の関数のフーリエ係数を求め，`terms`次までの部分和のグラフか，振幅のスペクトルを描く．係数は1周期の中点則(8192点以上)で求め，値が有限でない点は0とみなす．平面の図でだけ使える．",
      "properties": {
        "id": {
          "$ref": "#/$defs/identifier"
        },
        "type": {
          "const": "fourier_series"
        },
        "var": {
          "$ref": "#/$defs/identifier",
          "description": "変数の名前．省くと`x`．"
        },
        "expr": {
          "$ref": "#/$defs/nonBlankString",
          "description": "関数の式．"
        },
        "period": {
          "$ref": "#/$defs/boundPair",
          "description": "1周期の区間[下端, 上端]．下端は上端より小さい(スキーマでは表せない)．"
        },
        "terms": {
          "$ref": "#/$defs/bound",
          "description": "部分和の最高次数N．0以上500以下で，式の値は整数に丸める(スキーマでは表せない)．媒介変数にすれば，スライダーで次数を変えられる．"
        },
        "mode": {
          "enum": ["sum", "amplitude"],
          "description": "描くもの．`sum`(既定)は部分和のグラフ，`amplitude`は，n次の振幅sqrt(a_n^2 + b_n^2)(0次は|a_0|/2)を，x = nの縦の線と点で描く．"
        },
        "domain": {
          "$ref": "#/$defs/boundPair",
          "description": "部分和を描くxの範囲．省くと見える範囲．"
        },
        "style": {
          "$ref": "#/$defs/style"
        },
        "transform": {
          "$ref": "#/$defs/transform"
        }
      }
    },
    "fourier_transform": {
      "type": "object",
      "required": ["id", "type", "expr", "support"],
      "additionalProperties": false,
      "description": "1次元のフーリエ変換F(k) = ∫ f(x) e^{-ikx} dxのグラフ．横軸がkである．fは区間`support`の外で0とし，積分は区間を分けた4点のGauss-Legendre則で求める．平面の図でだけ使える．",
      "properties": {
        "id": {
          "$ref": "#/$defs/identifier"
        },
        "type": {
          "const": "fourier_transform"
        },
        "var": {
          "$ref": "#/$defs/identifier",
          "description": "変数の名前．省くと`x`．"
        },
        "expr": {
          "$ref": "#/$defs/nonBlankString",
          "description": "関数の式．複素数の式として読み，iは虚数単位である．"
        },
        "support": {
          "$ref": "#/$defs/boundPair",
          "description": "関数が0でない区間[下端, 上端]．"
        },
        "part": {
          "enum": ["abs", "re", "im", "power"],
          "description": "描く部分．`abs`(既定)は|F(k)|，`re`は実部，`im`は虚部，`power`は|F(k)|^2．"
        },
        "domain": {
          "$ref": "#/$defs/boundPair",
          "description": "描くkの範囲．省くと見える範囲．"
        },
        "style": {
          "$ref": "#/$defs/style"
        },
        "transform": {
          "$ref": "#/$defs/transform"
        }
      }
    },
    "fourier_intensity": {
      "type": "object",
      "required": ["id", "type", "expr", "support"],
      "additionalProperties": false,
      "description": "2次元のフーリエ変換の強さ．開口の関数f(x, y)(`support`の外で0)のフーリエ変換F(kx, ky)の強さ|F|^2(か振幅|F|)を，図の座標を(kx, ky)として，画像の中の最大を1にそろえて色で表す．Fraunhofer回折の図形である．SVGではPNGの画像，TikZでは粗い升目の塗りつぶしになる．平面の図でだけ使える．",
      "properties": {
        "id": {
          "$ref": "#/$defs/identifier"
        },
        "type": {
          "const": "fourier_intensity"
        },
        "vars": {
          "type": "array",
          "items": {
            "$ref": "#/$defs/identifier"
          },
          "minItems": 2,
          "maxItems": 2,
          "description": "2つの変数の名前．省くと`[\"x\", \"y\"]`．"
        },
        "expr": {
          "$ref": "#/$defs/nonBlankString",
          "description": "開口の関数の式．複素数の式として読む．値が有限でない点は0とみなす．"
        },
        "support": {
          "type": "array",
          "items": {
            "$ref": "#/$defs/boundPair"
          },
          "minItems": 2,
          "maxItems": 2,
          "description": "関数が0でない範囲[[xの下端, 上端], [yの下端, 上端]]．"
        },
        "samples": {
          "type": "integer",
          "minimum": 2,
          "maximum": 512,
          "description": "開口の関数を標本化する，各方向の点の数．省くと128．"
        },
        "quantity": {
          "enum": ["intensity", "amplitude"],
          "description": "表す量．`intensity`(既定)は強さ|F|^2，`amplitude`は振幅|F|．"
        },
        "domain": {
          "type": "array",
          "items": {
            "$ref": "#/$defs/boundPair"
          },
          "minItems": 2,
          "maxItems": 2,
          "description": "画像を置く(kx, ky)の範囲．省くと見える範囲．"
        },
        "range": {
          "$ref": "#/$defs/boundPair",
          "description": "色の両端の値(最大を1にそろえた値)．省くと値の最小と最大(対数の目盛では最大から6桁下まで)．"
        },
        "colormap": {
          "enum": ["viridis", "gray", "gray_inverse", "coolwarm"],
          "description": "値と色の対応．省くと`gray`(黒い背景に明るい点)．"
        },
        "scale": {
          "enum": ["linear", "log"],
          "description": "値の目盛．`log`では常用対数をとる．弱い環や副極大を見るのに使う．"
        },
        "resolution": {
          "type": "integer",
          "minimum": 1,
          "maximum": 1000,
          "description": "SVGの画像の，長い辺の画素の数．省くと200．"
        },
        "tikz_resolution": {
          "type": "integer",
          "minimum": 1,
          "maximum": 200,
          "description": "TikZの出力の，長い辺の升目の数．省くと40．"
        }
      }
    },
    "diffraction": {
      "type": "object",
      "required": ["id", "type", "basis"],
      "additionalProperties": false,
      "description": "結晶の回折図形．基本ベクトルで張る格子と，単位胞の中の原子から，逆格子点G = h b1 + k b2 (+ l b3)(a_i・b_j = δ_ij)ごとの構造因子F = Σ f_j exp(-2πi(h x_j + k y_j + l z_j))を求め，|F|に比例する半径(強さ|F|^2に比例する面積)の点を置く．強さが最大の10^-10倍より弱い点(消滅則で消える点)は描かない．3次元の結晶は，晶帯軸`zone`に垂直な逆格子の断面(ゼロ次のLaueゾーン)を描く．`cells`を書くと，有限の結晶の強さを画像にする．平面の図でだけ使える．",
      "properties": {
        "id": {
          "$ref": "#/$defs/identifier"
        },
        "type": {
          "const": "diffraction"
        },
        "basis": {
          "type": "array",
          "items": {
            "type": "array",
            "items": {
              "$ref": "#/$defs/bound"
            },
            "minItems": 2,
            "maxItems": 3
          },
          "minItems": 2,
          "maxItems": 3,
          "description": "実格子の基本ベクトル．2個の座標のベクトルを2つ(平面の格子)か，3個の座標のベクトルを3つ(結晶)並べる．平行であってはならない(スキーマでは表せない)．"
        },
        "atoms": {
          "type": "array",
          "maxItems": 64,
          "items": {
            "type": "object",
            "required": ["position"],
            "additionalProperties": false,
            "properties": {
              "position": {
                "type": "array",
                "items": {
                  "$ref": "#/$defs/bound"
                },
                "minItems": 2,
                "maxItems": 3,
                "description": "分率座標(基本ベクトルを単位にした座標)．基本ベクトルの数だけ並べる(スキーマでは表せない)．"
              },
              "factor": {
                "$ref": "#/$defs/bound",
                "description": "散乱因子．数か，逆格子ベクトルの長さqの式．省くと1．"
              }
            }
          },
          "description": "単位胞の中の原子．省くと，原点に散乱因子1の原子が1つある．"
        },
        "zone": {
          "type": "array",
          "items": {
            "type": "integer"
          },
          "minItems": 3,
          "maxItems": 3,
          "description": "晶帯軸[u, v, w](実格子の向きu a1 + v a2 + w a3)．3次元の結晶でだけ書く．省くと[0, 0, 1]．"
        },
        "radius": {
          "$ref": "#/$defs/bound",
          "description": "描く逆格子点の|G|の上限．省くと見える範囲を覆う．"
        },
        "spot": {
          "$ref": "#/$defs/length",
          "description": "最も強い点の半径．省くと3pt．"
        },
        "labels": {
          "type": "boolean",
          "description": "点に指数の名前((1\\bar{1}0)など)を置くか．"
        },
        "cells": {
          "type": "array",
          "items": { "$ref": "#/$defs/bound" },
          "minItems": 2,
          "maxItems": 3,
          "description": "有限の結晶の，各基本ベクトルの向きの単位胞の数．数か式で，式の値は整数に丸め，1以上1000以下にする．基本ベクトルの数だけ並べる(スキーマでは表せない)．書くと，点ではなく強さの画像にする．"
        },
        "range": {
          "$ref": "#/$defs/boundPair",
          "description": "画像の色の両端の値(最大を1にそろえた値)．`cells`があるときに使う．"
        },
        "colormap": {
          "enum": ["viridis", "gray", "gray_inverse", "coolwarm"],
          "description": "画像の値と色の対応．省くと`gray`．"
        },
        "scale": {
          "enum": ["linear", "log"],
          "description": "画像の値の目盛．"
        },
        "resolution": {
          "type": "integer",
          "minimum": 1,
          "maximum": 1000,
          "description": "SVGの画像の，長い辺の画素の数．省くと200．"
        },
        "tikz_resolution": {
          "type": "integer",
          "minimum": 1,
          "maximum": 200,
          "description": "TikZの出力の，長い辺の升目の数．省くと40．"
        },
        "style": {
          "$ref": "#/$defs/style"
        }
      }
    },
    "object": {
      "description": "図を作るオブジェクト．`type`で種類を選ぶ．`graph`，`region`，`tangent_line`，`fractal`，`polygon`，`taylor`，`wigner_seitz`，`elliptic_curve`，`heatmap`，`domain_coloring`，`fourier_series`，`fourier_transform`，`fourier_intensity`，`diffraction`は平面の図でだけ，`sphere`，`surface`，`cut`，`intersection`，`tangent_plane`，`complex`，`polyhedron`は空間の図でだけ使える．",
      "oneOf": [
        { "$ref": "#/$defs/axis" },
        { "$ref": "#/$defs/label" },
        { "$ref": "#/$defs/parameter" },
        { "$ref": "#/$defs/graph" },
        { "$ref": "#/$defs/curve" },
        { "$ref": "#/$defs/tangent_line" },
        { "$ref": "#/$defs/grid" },
        { "$ref": "#/$defs/point" },
        { "$ref": "#/$defs/vector" },
        { "$ref": "#/$defs/segment" },
        { "$ref": "#/$defs/region" },
        { "$ref": "#/$defs/fractal" },
        { "$ref": "#/$defs/sphere" },
        { "$ref": "#/$defs/surface" },
        { "$ref": "#/$defs/cut" },
        { "$ref": "#/$defs/implicit_curve" },
        { "$ref": "#/$defs/intersection" },
        { "$ref": "#/$defs/tangent_plane" },
        { "$ref": "#/$defs/complex" },
        { "$ref": "#/$defs/polyhedron" },
        { "$ref": "#/$defs/polygon" },
        { "$ref": "#/$defs/function" },
        { "$ref": "#/$defs/map" },
        { "$ref": "#/$defs/image" },
        { "$ref": "#/$defs/taylor" },
        { "$ref": "#/$defs/vector_field" },
        { "$ref": "#/$defs/field_line" },
        { "$ref": "#/$defs/wigner_seitz" },
        { "$ref": "#/$defs/elliptic_curve" },
        { "$ref": "#/$defs/heatmap" },
        { "$ref": "#/$defs/domain_coloring" },
        { "$ref": "#/$defs/fourier_series" },
        { "$ref": "#/$defs/fourier_transform" },
        { "$ref": "#/$defs/fourier_intensity" },
        { "$ref": "#/$defs/diffraction" }
      ]
    }
  }
}
