ガイド · 8 話中 4
線と曲線
要素を線で結ぶ、点を通る線を引く、式から曲線を描く。
2 つの要素を結ぶ
[line from=#a to=#b arrow=end:] は #a と #b の向き合う辺どうしを結び、要素がどこに描かれてもついていきます。辺は from-side・to-side で選び、route=elbow で直角に折れます。頭の形はクラスで選びます(.open-head、.dot-head など)。
[title: 拍手の音の行き先]
[subtitle: 音、反響、カーテンが吸う分]
[box #clap .card x=6% y=48% w=20%:
拍手
]
[box #wall .card x=40% y=32% w=20%:
壁
]
[box #ear .card x=74% y=48% w=20%:
聞き手
]
[box #curtain .tint x=40% y=74% w=20%:
カーテン
]
[line .stealth-head from=#clap to=#wall arrow=end style="--head-size: lg":]
[box x=28% y=36% w=12% style="text-align: center":
音
]
[line .open-head from=#wall to=#ear arrow=end:]
[box x=61% y=36% w=12% style="text-align: center":
反響
]
[line .dot-head from=#clap from-side=bottom to=#curtain to-side=left route=elbow arrow=end:]
[box x=20% y=72% w=16% style="text-align: center":
吸われる
]点を通る線
points=((430, 500), (760, 300), (1160, 300)) は線が通る点を並べます。各点は論理ピクセルの (x, y) で、最初と最後の点が端になります。点から点へまっすぐ進み、クラス .smooth を付けると、すべての点を通る 1 本のなめらかな曲線になります。
[title: 聞き手への 2 つの道]
[subtitle: 柱の上で反射するか、回り込むか]
[box #clap .card x=5% y=44% w=16%:
拍手
]
[box #pillar .tint x=44% y=40% w=12% h=22%:
柱
]
[box #ear .card x=79% y=44% w=16%:
聞き手
]
[line .stealth-head points=((430, 500), (760, 300), (1160, 300), (1490, 500)) arrow=end:]
[box x=42% y=21% w=16% style="text-align: center":
反射して
]
[line .smooth points=((430, 590), (700, 800), (1220, 800), (1490, 590)) arrow=end:]
[box x=42% y=75% w=16% style="text-align: center":
回り込んで
]式から描く
[curve f="x -> sin(x)" domain=(-pi, pi):] は、横の範囲を −π から π として式を描きます。描く場所は x・y・w・h の箱で、縦は range= がなければ箱の下端が −1、上端が 1 です。よく使う式は、資料の設定の functions: に名前を付けて置けます。
===
functions:
rc(t): 0.5*(1-cos(2*pi*t))
drive(t): rc(t)*sin(2*pi*8*t)
===
[title: 量子ビットの駆動パルス]
[subtitle: 二乗余弦の包絡線、8 周期]
[curve .muted x=8% y=28% w=84% h=44% f="rc(t)" style="stroke-dasharray: 12px 8px":]
[curve .muted x=8% y=28% w=84% h=44% f="-rc(t)" style="stroke-dasharray: 12px 8px":]
[curve .primary x=8% y=28% w=84% h=44% f="drive(t)" arrow=end:]
[box x=8% y=78% w=84%:
正弦波に二乗余弦の包絡線 $\tfrac{1}{2}(1-\cos 2\pi t)$(破線)を掛けたもの。
]