分步画布与图形写法
这一页是 docs/CONTENT_SPEC.md「visual 类型」的实时示例。下面的题目演示了分步画布:先看整体思路, 再按 → 或“下一步”逐步揭示;题图会随步骤出现交点、阴影和高亮。
曲线 与 所围成的平面图形的面积为( )
−0.20.20.40.60.811.21.4−0.20.20.40.60.811.21.4xyO
可以先点选一个选项试试。
整体思路
先画图,再积分:求交点定出积分区间,看清谁在上、谁在下,面积 。
求交点,定区间
联立 ,得 或 ,交点 、。
判断上下,写出积分
计算
选 C。
0.20.40.60.810.10.2xyO被积函数 的图像:曲边梯形面积就是
图形示例
函数曲线 + 切线 + 标注点
−1.5−1−0.50.511.522.5−11234xyO切线
type: plot
x: [-2, 3]
y: [-1.5, 5]
items:
- fn: x^2
label: $y=x^2$
- tangent: x^2
at: 1
color: red
label: 切线 $y=2x-1$
- point: [1, 1]
label: $(1,1)$
- vline: 1阴影面积 + 自定义刻度
−11xyO
type: plot
x: [-0.5, 7]
y: [-1.4, 1.4]
xticks: [{ at: pi/2, label: '$\frac{\pi}{2}$' }, { at: pi, label: '$\pi$' }, { at: 2pi, label: '$2\pi$' }]
yticks: [-1, 1]
items:
- area: sin(x)
domain: [0, pi]
color: blue
label: $+$
- area: sin(x)
domain: [pi, 2pi]
color: red
label: $-$
- fn: sin(x)
label: $y=\sin x$间断点与渐近线
函数在无定义或跳跃处自动断开;空心点表示去掉的点。
−3−2−1123−4−3−2−1123xyO
type: plot
x: [-4, 4]
y: [-5, 4]
grid: true
items:
- fn: 1/(x-1) + 1
label: $y=\frac{1}{x-1}+1$
- vline: 1
- hline: 1
- fn: (x^2-4)/(x+2)
color: green
label: $y=\frac{x^2-4}{x+2}$
- point: [-2, -4]
hollow: true
color: green参数方程与极坐标
−0.50.511.52−1.2−1−0.8−0.6−0.4−0.20.20.40.60.811.2xyO星形线
type: plot
x: [-1, 2.4]
y: [-1.4, 1.4]
equal: true
items:
- polar: 1 + cos(t)
color: purple
label: $r=1+\cos\theta$
- param: [cos(t)^3, sin(t)^3]
color: orange
label: 星形线几何 / 向量(关闭坐标轴,等比例)
type: plot
x: [-0.5, 4.5]
y: [-0.5, 3.2]
equal: true
axes: false
items:
- polygon: [[0, 0], [4, 0], [1, 3]]
color: blue
- vector: [[0, 0], [4, 0]]
color: red
label: $\boldsymbol a$
- vector: [[0, 0], [1, 3]]
color: green
label: $\boldsymbol b$
- circle: [1.67, 1, 1]
color: gray
dash: true
- text: $S=\frac12|\boldsymbol a\times\boldsymbol b|$
at: [3, 2.4]维恩图 + 参数用于数字字段
参数可用于坐标、半径、domain 等任意数字字段;拖动 改变两圆距离。
type: plot
x: [-2.2, 3.2]
y: [-1.6, 1.6]
equal: true
axes: false
params:
d: { min: 0, max: 2.4, value: 1.2, label: "$d$" }
items:
- polygon: [[-2.1, -1.5], [3.1, -1.5], [3.1, 1.5], [-2.1, 1.5]]
color: gray
fill: false
label: $\Omega$
labelAt: [-1.9, 1.3]
- circle: [0, 0, 1]
fill: true
label: $A$
labelAt: [-0.6, 0.9]
- circle: [d, 0, 1]
fill: true
color: red
label: $B$
labelAt: [d + 0.6, 0.9]参数滑块动画
拖动滑块或点 ▶ 播放:极限 。
−4−224−1123xyO
type: plot
x: [-6, 6]
y: [-1.5, 3.5]
params:
a: { min: 0.5, max: 3, value: 1, step: 0.01, play: true }
items:
- fn: sin(a x)/x
label: $y=\frac{\sin ax}{x}$
- hline: a
color: red
label: $y=a$
- point: [0, a]
hollow: true手绘 SVG(data-step / data-focus 在分步画布中生效)
元素加 data-step="2" 即在第 2 步出现
type: svg
caption: 元素加 data-step="2" 即在第 2 步出现
svg: |
<svg viewBox="0 0 240 120" xmlns="http://www.w3.org/2000/svg">
<path d="M20 100 C80 100 100 20 220 20" fill="none" stroke="currentColor" stroke-width="2"/>
<line data-step="2" x1="20" y1="60" x2="220" y2="60" stroke="#dc2626" stroke-dasharray="5 4"/>
<circle data-focus="1" cx="120" cy="60" r="4" fill="#2563eb"/>
</svg>