graphite石墨
图例库Figure gallery

37 张手绘图例37 hand-drawn figures

32 张会动,滚到哪张就画哪张;其余 5 张按「看它怎么画」也能一笔一笔重画。每张都是几十行代码,拿去改比照着画快:换字、换颜色、换数据。手机上图框可以左右拖,图里的字不会缩到看不清。32 are animated and draw when you scroll to them; the other 5 redraw stroke by stroke on "Watch it drawn". Each is a few dozen lines of code: changing words, colours or data beats redrawing. On a phone, drag a figure sideways; its labels never shrink below readable.

角色与道具Cast and props

能反复出场的小角色和常用物件。拿去换姿势、换颜色,拼成自己的场景。Small characters and everyday objects to reuse. Change the pose or colour and build your own scene.

01 小机器人 · 六种姿势Little robot · six poses动图 5.6smotion 5.6s站、挥手、打字、思考、指向、欢呼。代表「替你干活的程序」,比画一个电脑图标好认。Stand, wave, type, think, point, cheer. Stands for "the program doing the work" — easier to read than a computer icon.下载 SVGSVG源码Code
02 人物 · 姿势和衣服可换People · poses and clothes动图 5.6smotion 5.6s圆脑袋、几笔头发、弯弯的眼睛。衣服颜色只用一支彩铅,让人物在场景里好找。Round head, a few strokes of hair, smiling eyes. One pencil for the clothes so the person is easy to find in a scene.下载 SVGSVG源码Code
03 常用物件 · 十六件Everyday objects · sixteen屏幕、灯泡、服务器、文件、齿轮……每件只用一两支彩铅。拼场景时从这里挑。Screen, bulb, server, file, gear… one or two pencils each. Pick from here when you build a scene.下载 SVGSVG源码Code

场景插画Scenes

一幅画讲一个比喻:谁在做什么。画面里不写字,字放在网页上叠上去。One picture, one metaphor: who is doing what. No words inside the drawing; the page lays text on top.

对了!got it!
04 想到了 · 灯泡亮起来An idea · the bulb lights up动图 6smotion 6s一个人在桌前想事情,先画桌子、人、电脑,最后灯泡一亮。讲「为什么要做这件事」的开场画面。Someone thinking at a desk: desk, person and laptop are drawn first, then the bulb lights. An opening shot for "why we are doing this".下载 SVGSVG源码Code
输入input处理process结果result
05 白板讲解 · 代码画的版本At the whiteboard · drawn with code动图 7.8smotion 7.8s和展示页首屏同一个题目,这张用代码画。对比看:大场景位图更好看,代码画的胜在每一笔都能动、能换主题、能改。The same brief as the showcase hero, drawn with code. Side by side: the bitmap looks richer; the code version can move every stroke, follow the theme and be edited.下载 SVGSVG源码Code

电影画风Cinematic

宽银幕、一个光源、镜头在动。同一支铅笔,换成讲故事的节奏。Widescreen, one light source, a moving camera. The same pencil, paced like a film.

1远景 · 3 秒 · 慢慢推近wide · 3 s · slow push in2中景 · 2 秒 · 跟着走medium · 2 s · follow3特写 · 2 秒 · 停住close-up · 2 s · hold0 s3 s5 s7 s时间线:一共 7 秒timeline: 7 s in all
06 分镜 · 远景、中景、特写Storyboard · wide, medium, close-up动图 5.4smotion 5.4s拍短片前先画分镜:三格各写清楚镜头怎么动、停几秒。做 HTML 动画时,这三格就是三段时间线。Before filming, a storyboard: each panel says how the camera moves and for how long. In an HTML animation the three panels are three stretches of the timeline.下载 SVGSVG源码Code
那天晚上,雨一直没停。That night the rain never stopped.
07 电影感 · 雨夜路灯(镜头慢推)Cinematic · a lamp in the rain (slow push)动图 12smotion 12s电影感的四个手法都在这一格:上下黑边、只有一个光源、镜头慢慢推近、雨一直在下。黑边里的字幕不跟着推。Four film devices in one frame: letterbox bars, a single light source, a slow push in, rain that keeps falling. The subtitle in the bar does not move with the camera.下载 SVGSVG源码Code

框图与架构Block and architecture

方框、分层、连线。手绘让结构图不像规范文档,读者更愿意看下去。Boxes, layers and wires. Drawn by hand, a structure diagram stops looking like a spec.

界面层Interface网页 · Appweb · app接口层API鉴权 · 限流auth · rate limit业务层Services下单 · 支付 · 通知orders · payments · mail数据层Data数据库 · 缓存database · cache请求request结果answer
08 分层架构 · 一个请求往下走Layers · one request going down动图 8.6smotion 8.6s四层自上而下画出来,然后一个请求沿着层往下走、带着结果回来。分层图最该讲的是「谁调谁」。Four layers drawn top down, then one request walks down and comes back with the answer. A layer diagram is about who calls whom.下载 SVGSVG源码Code
用户users负载均衡loadbalancer服务器 1server 1服务器 2server 2服务器 3server 3缓存cacheRedis数据库database
09 一个网站的样子 · 流量从哪来到哪去A web service · where the traffic goes动图 6.4smotion 6.4s用户 → 负载均衡 → 三台服务器 → 缓存和数据库。连线上的虚线一直在走,表示这条路一直有流量。Users → load balancer → three servers → cache and database. The moving dashes mean the path always carries traffic.下载 SVGSVG源码Code
SoC 芯片SoCCPU 大核 ×4CPU 4 big小核 ×44 littleGPUGPU图形graphicsNPUNPU神经网络neural nets片上总线on-chip bus内存控制器memory controllerUSB · 显示 · 摄像头 · 网络USB · display · camera · networkDRAM 内存(片外)DRAM (off chip)
10 芯片里有什么 · SoC 框图Inside a chip · an SoC block diagramCPU、GPU、NPU 挂在同一条总线上,一起抢内存。手绘不改结构,只是让这种图没那么吓人。CPU, GPU and NPU share one bus and compete for memory. Drawing it by hand keeps the structure and loses the intimidation.下载 SVGSVG源码Code
提交commit编译build测试test审查review上线ship五关都过,才能上线。All five green, then it ships.
11 流水线 · 一关一关过Pipeline · one gate at a time动图 8smotion 8s提交 → 编译 → 测试 → 审查 → 上线。打勾一个一个出现;卡在哪一关,那一格就画红叉。Commit → build → test → review → ship. Ticks appear one by one; where it stops, that box gets a red cross.下载 SVGSVG源码Code
用户程序user program系统调用syscallVFSVFSext4ext4页缓存page cache块层block layerread(fd, buf, n)你的程序your programSYSCALL_DEFINE3(read)read_write.c:724ksys_readread_write.c:706vfs_readread_write.c:554new_sync_readread_write.c:483ext4_file_read_iterext4/file.c:130f_op->read_itergeneric_file_read_iterfilemap.c:2956filemap_readfilemap.c:2768filemap_get_pagesfilemap.c:2667copy_folio_to_iteruio.h:201① 先查页缓存① look in the cache② 拷给程序② copy outpage_cache_sync_ra→ … → read_pagesreadahead.c:557ext4_readahead→ ext4_mpage_readpagesext4/readpage.c:415submit_bioblk-core.c:916没有 → 读盘not there → diskaops->readahead磁盘disk读完放进页缓存 ↑data goes up to the cache ↑第一次:页缓存里有 → 直接拷给程序,不碰磁盘first read: in the cache → copied straight out, no disk第二次:页缓存里没有 → 页缓存回头调 ext4,往下读盘second read: not cached → the cache calls ext4, down to the disk等磁盘……(最慢的一段)waiting for the disk… (the slow part)数据进了页缓存,再拷给程序;下次读就走第一条路data is cached, then copied; the next read takes the short path命中:到页缓存就回头 · 未命中:回头调 ext4,一路到块层和磁盘hit: turn back at the page cache · miss: back into ext4, down to the disk函数和行号核对自内核树 v7.0-9887-ga43fac2b5813functions and lines checked at v7.0-9887-ga43fac2b5813
12 调用关系 · 程序读一个 ext4 文件Who calls whom · reading an ext4 file动图 24.73smotion 24.73sread() 从系统调用一路往下:VFS → ext4 → 页缓存。页缓存里有,直接拷给程序,不碰磁盘;没有,页缓存回头调 ext4 的 readahead 去读盘,读完放进页缓存再拷。框里是函数名和定义它的文件:行号(核对的内核树 v7.0-9887-ga43fac2b5813);圆点的快慢是示意,没有实测。read() goes down from the system call: VFS → ext4 → page cache. If the page cache has the data, it is copied to the program and the disk is not touched; if not, the page cache calls back into ext4's readahead to read the disk, keeps the data, then copies it. Boxes show the function and the file:line that defines it (checked at v7.0-9887-ga43fac2b5813); the dots' speed is an illustration, not a measurement.下载 SVGSVG源码Code

越用越懂你Learns your taste

你挑的每一张、说的每一句「太密了」、审查器的每条意见,都记进口味日志,下一张图照它画。这几张图是学习算法自己画的:数字都是 taste.js 真算出来的。Every pick, every "too dense", every reviewer note goes into a taste log, and the next drawing follows it. These figures are drawn by the learner itself: every number is computed by taste.js.

「还是太密了」"still too dense"你you你的反应what you do二选一pick A or B×1说一句say a sentence×1留下 / 删掉keep / delete×0.5审查器的意见a reviewer's note×0.3口味日志taste log只追加,不改写append onlygraphite-taste.jsonl每个旋钮算一个值one value per knobm ← (m·W + x·w) / (W + w)起点算 2 份 · 越旧越轻starts at 2 · older = lighter(半衰期 90 天)(half-life 90 days)审查器reviewers×0.3硬下限(不算口味)hard floor (not taste)手机上字太小 → 字号至少 +2labels too small on phone → +2客观问题objectiveAB下一次:挑一张(只差最没把握的那个旋钮)next: pick one (they differ in the least certain knob)
13 越用越懂你 · 一圈是怎么转的Learns your taste · how the loop turns动图 17.4smotion 17.4s你的每个反应记一行日志:二选一和说一句各算 1 份,留下或删掉算 0.5 份,审查器的意见算 0.3 份。每个旋钮从日志里算一个加权平均,越旧的记录越轻(半衰期 90 天)。审查器查出的客观问题不算口味,是硬下限,永远不会被淡忘。下一次,它挑自己最没把握的那个旋钮,拿两张只差这一处的图问你。Every reaction is one line in a log: a pick or a sentence weighs 1, keep or delete 0.5, a reviewer's note 0.3. Each knob is a weighted mean over the log, older lines weigh less (half-life 90 days). An objective problem found by a checker is not taste: it is a hard floor and never fades. Next time it asks about the knob it is least sure of, with two drawings that differ only there.下载 SVGSVG源码Code
3456100 天没用100 days unused每一格 = 一次反应one step = one reaction密dense疏sparse彩铅间距(hatchGap)pencil spacing (hatchGap)出厂默认 3.7house default 3.7读者心里想要的 5.5(程序看不到)what the reader wants, 5.5 (hidden)给你看的两张the two shown你挑中的your pick学到的值learned说了「还是太密了」said "还是太密了"审查器:「too busy」×0.3reviewer: "too busy" ×0.3旧答案慢慢变轻old answers fade口味变了:想要 4.2taste changed: wants 4.2学到 4.29learned 4.29最后的答案开始一上一下:学到位了answers start to alternate: it has arrived
14 一个旋钮怎么学到位How one knob learns动图 17.64smotion 17.64s读者想要疏一点的彩铅(间距 5.5)。出厂是 3.7;答了 10 次之后学到 5.25。100 天没用,旧答案按半衰期变轻,值往出厂回落到 4.92;读者这时改成想要 4.2,又答 7 次,学到 4.29。曲线上每个点都是 taste.js 在那一天真算出来的。The reader wants sparser colouring (spacing 5.5). House value 3.7; after 10 answers it has learned 5.25. 100 days unused: old answers fade and the value drifts back to 4.92. The reader now wants 4.2; 7 more answers and it is at 4.29. Every point is what taste.js computes on that day.下载 SVGSVG源码Code
读者甲 · 喜欢干净Reader A · likes it clean「太乱了」 「太密了」"too messy" "too dense"线条抖动wobble0.60彩铅间距spacing5.17彩铅浓淡strength0.39线条粗细line weight1.61出厂默认House default(还没用过)(not used yet)线条抖动wobble1.00彩铅间距spacing3.70彩铅浓淡strength0.52线条粗细line weight2.10读者乙 · 喜欢手感重Reader B · likes it heavy「太死板了,像打印的」 「太淡了」"too stiff, looks printed" "too faint"线条抖动wobble1.41彩铅间距spacing2.86彩铅浓淡strength0.70线条粗细line weight2.70
15 同一张图,三个人用出三种样子One drawing, three readers, three looks动图 6.6smotion 6.6s中间是出厂样子。左右两位各说了两句话,再各答了 60 个二选一(每次问哪个旋钮,由程序挑它最没把握的那个)。画的内容和随机种子一模一样,不同的只有学到的口味:线条抖动、彩铅疏密、浓淡、线宽。The middle is the house look. The readers on either side each said two things, then answered 60 A-or-B questions (the learner chose which knob to ask each time). Same drawing, same random seed; only the learned taste differs: wobble, pencil spacing, strength, line weight.下载 SVGSVG源码Code

流程图Flowcharts

判断、分支、回路。会动的那一笔沿着流程走,告诉读者现在走到哪。Decisions, branches and loops. The moving mark walks the flow and shows where we are.

收到请求request in缓存里有吗?in the cache?直接读缓存read the cache有yes查数据库query the DB没有no写进缓存save to cache返回给用户reply没命中:约 20 ms(示意)miss: ~20 ms (illustrative)命中:约 1 ms(示意)hit: ~1 ms (illustrative)
16 流程图 · 缓存命中和没命中Flowchart · cache hit and miss动图 11.9smotion 11.9s同一个请求走两次:第一次缓存里没有,绕远路去数据库;第二次直接命中。小圆点走的快慢就是要讲的事。时间是示意。The same request twice: first a miss, the long way through the database; then a hit. How fast the dot moves is the point. Times are illustrative.下载 SVGSVG源码Code
改一点change跑一次run量分数measure变好了?better?记下来log it保留keep或者退回or undo第 1 轮round 1变好了,保留better: keep第 2 轮round 2没变好,退回worse: undo第 3 轮round 3变好了,保留better: keep
17 循环图 · 改一点,试一下,留下好的A loop · change, try, keep what helps动图 18.3smotion 18.3s五步围成一圈,高亮的圈在转,中间记着第几轮。适合讲任何「反复试」的过程:训练、调参、A/B 测试。Five steps in a ring, a highlight going round, the round number in the middle. Fits any try-again process: training, tuning, A/B tests.下载 SVGSVG源码Code

代码大白话Code in plain words

左边是代码,右边是它在做的事:LRU 缓存怎么淘汰、调用栈怎么一层层摞起来。当前那一行和画面同步高亮。Code on one side, what it does on the other: how an LRU cache evicts, how the call stack piles up. The current line and the picture move together.

put Aput Bput Cget Aput Dget Bget Cput Emap(哈希表)map (hash table)headtail双向链表doubly linked list← 最近用过← most recent最久没用 →least recent →lru.jsget(k) { const n = map.get(k) if (!n) return MISS list.moveToHead(n) return n.val}put(k, v) { if (map.size === CAP) { const old = list.popTail() map.delete(old.key) } const n = list.addHead(k, v) map.set(k, n)}示意:put 已有的键(改值、挪到最前)这里省略sketch: put on an existing key (update, move to front) left outAA BA B CA CA C DC DC D EABCDEput A:还有空位,A 放到最前面put A: room left, A goes to the front放入input B:还有空位,B 放到最前面put B: room left, B goes to the front放入input C:还有空位,C 放到最前面put C: room left, C goes to the front放入inget A:命中,map 一步找到,挪到最前面get A: hit — found via the map, moved to the front命中hitput D:满了,先淘汰最后面的 B,再把 D 放最前put D: full — drop B at the back, D goes in front淘汰 Bout B没有 B → MISSno B → MISSget B:未命中(B 刚才被淘汰了)get B: miss (B was evicted)未命中missget C:命中,map 一步找到,挪到最前面get C: hit — found via the map, moved to the front命中hitput E:满了,先淘汰最后面的 A,再把 E 放最前put E: full — drop A at the back, E goes in front淘汰 Aout A8 次请求:命中 2 · 未命中 1 · 淘汰 28 requests: 2 hits · 1 miss · 2 evicted两样东西各管一件事:map 管「在不在、在哪」,链表管「谁最久没用」map: is it here, and where · list: who is oldest
18 LRU 缓存 · 哈希表找得快,双向链表记先后An LRU cache · the map finds it, the linked list keeps the order动图 19smotion 19s容量 3,跑 8 次请求。map 一步跳到节点;用过的节点挪到链表最前,满了就从最后面淘汰。这一轮:命中 2 次、未命中 1 次、淘汰 2 个。Capacity 3, 8 requests. The map jumps straight to a node; a used node moves to the front, and when full the one at the back goes. This run: 2 hits, 1 miss, 2 evicted.下载 SVGSVG源码Code
fib.jsfunction fib(n) { if (n <= 1) return n return fib(n - 1) + fib(n - 2)}调用栈(从下往上摞)call stack (piles upward)调用树:每个圈是一次 fib(n),圈里是 ncall tree: each circle is one fib(n); the number is n栈里的帧 = 树上橙色那条路frames on the stack = the orange path5=5fib(5)= 54=3fib(4)= 33=2fib(3)= 22=1fib(2)= 11=1fib(1)= 10=0fib(0)= 01=1fib(1)= 12=1fib(2)= 11=1fib(1)= 10=0fib(0)= 03=2fib(3)= 22=1fib(2)= 11=1fib(1)= 10=0fib(0)= 01=1fib(1)= 1一共 15 次调用,栈最深 5 层15 calls, at most 5 deepfib(2) 算了 3 遍,fib(3) 算了 2 遍fib(2) 3×, fib(3) 2×→ 记下算过的结果(记忆化),→ remember each answer (memoise):只需算 6 个不同的 nonly 6 different n to work out
19 调用栈就是调用树上的一条路 · fib(5)The call stack is one path in the call tree · fib(5)动图 16.5smotion 16.5s右边每个圈是一次 fib(n) 调用,按调用顺序长出来;左边的栈只装着「从根走到当前这一次」的那条路(橙色)。fib(5) 一共调用 15 次,栈最深 5 层;fib(2) 被算了 3 遍。Each circle on the right is one call of fib(n), growing in call order; the stack on the left holds only the path from the root to the current call (orange). fib(5) makes 15 calls, 5 deep at most; fib(2) is worked out 3 times.下载 SVGSVG源码Code
count.jslet count = 0for (const box of boxes) { if (box.hasApple) count++}count = 0count = 1count = 2count = 3五个箱子都看过了:3 个苹果。All five boxes checked: 3 apples.机器人和箱子是比喻robot and boxes: a metaphor
20 for 循环 = 一个一个看过去A for loop = look at each one in turn动图 12.1smotion 12.1s小机器人从左到右看每个箱子,有苹果就把计数加一。左边高亮的那一行,就是它此刻在做的事。The robot checks each box from left to right and adds one when it finds an apple. The highlighted line is what it is doing right now.下载 SVGSVG源码Code
fact.jsfunction fact(n) { if (n === 1) return 1 return n * fact(n - 1)}调用栈(从下往上摞)call stack (piles upward)fact(4)= 4 × 6 = 24fact(3)= 3 × 2 = 6fact(2)= 2 × 1 = 2fact(1)= 14! = 24往上摞:还算不出来piling up: cannot answer yet往下拿:一层层算回来unwinding: each layer answers
21 递归 = 一摞盘子,先摞上去再一个个拿下来Recursion = a stack of plates, piled up then taken off动图 10.7smotion 10.7sfact(4) 要等 fact(3),fact(3) 要等 fact(2)……一直摞到 fact(1) 直接给出 1,再从上往下一层层算回去。fact(4) waits for fact(3), which waits for fact(2)… down to fact(1), which answers 1 at once; then each layer finishes on the way back.下载 SVGSVG源码Code
"alice"hash( )01234567八个格子,编号 0 到 7eight hooks, numbered 0 to 7→ 3第一次:算出 3,衣服挂进 3 号first time: 3, the coat goes on hook 3→ 3再报 "alice":还是 3,直接去拿ask for "alice": 3 again, go straight there
22 哈希表 = 衣帽间的号码牌A hash map = a coat check动图 9.8smotion 9.8s名字进机器,出来一个号码,衣服就挂在那个格子里。下次报同一个名字,算出同一个号码,不用一格格翻。A name goes into the machine, a number comes out, the coat goes on that hook. Same name next time, same number: no searching.下载 SVGSVG源码Code

数学与算法Maths and algorithms

把公式和算法的每一步画出来:方波由一圈圈正弦叠出来、拉格朗日插值和乘数、内核调度器挑下一个任务、球往山下滚。数都由代码当场算。Each step of a formula or algorithm, drawn: a square wave built from circling sines, Lagrange interpolation and multipliers, the kernel scheduler picking the next task, a ball rolling downhill. Every number is computed by the code.

vruntime += Δt × 1024 / weightΔt 实际跑了多久 · 1024 是 nice 0 的权重 · weight 是这个任务的权重Δt real time run · 1024 is the weight of nice 0 · weight is this task's weightkernel/sched/fair.cA · nice 0 · 权重 1024A · nice 0 · weight 1024每跑 3 ms,vruntime +3per 3 ms run: vruntime +3B · nice 3 · 权重 526B · nice 3 · weight 526每跑 3 ms,vruntime +5.84per 3 ms run: vruntime +5.84C · nice -3 · 权重 1991C · nice -3 · weight 1991每跑 3 ms,vruntime +1.54per 3 ms run: vruntime +1.54CPU 上:正在跑的任务(这时它不在树里)on the CPU: the running task (it is out of the tree meanwhile)036912vruntime(ms)· 越往左越该跑vruntime (ms) · further left = due soonerCPU 实际时间:每格 3 ms(示意,真内核按权重算时间片)real CPU time: 3 ms per cell (illustration; the kernel computes slices)ABCABCCACCBACCACC圈出来的是最左边那个 → 它上 CPUthe ringed one is leftmost → it gets the CPU最左节点另外记着leftmost cached内核里这条数轴是一棵红黑树:In the kernel this line is a red-black tree:按 vruntime 从小到大排,最左节点sorted by vruntime; the leftmost node is单独缓存(rb_leftmost),取它不用往下找。cached (rb_leftmost): no search to pick.14 轮:实际 · 按权重14 turns: got · weight shareC 57% · 56%A 29% · 29%B 14% · 15%2.6.24–6.5 的选法;6.6 起由 EEVDF 选,vruntime 照旧按权重涨the pick of 2.6.24–6.5; EEVDF picks since 6.6, vruntime still grows by weight
23 CFS 调度器 · 谁的 vruntime 最小谁先跑The CFS scheduler · smallest vruntime runs next动图 17.7smotion 17.7s三个任务排在一条 vruntime 数轴上,最左边(vruntime 最小)的那个上 CPU。跑的时候 vruntime 按 1024 / 权重 的倍数涨:权重大的涨得慢,很快又排回最左边。模拟 14 轮(每轮固定 3 ms,示意):C 8 次(57%,按权重该分 56%),A 4 次(29%,按权重该分 29%),B 2 次(14%,按权重该分 15%)。这是 2.6.24–6.5 的 CFS 选法;6.6 起改用 EEVDF 选任务,6.8 起树改按虚拟截止时间排序,vruntime 按权重增长这条沿用至今(v7.0-9887-ga43fac2b5813 的 fair.c:1398)。Three tasks sit on a vruntime number line; the leftmost (smallest vruntime) gets the CPU. While it runs, its vruntime grows by 1024 / weight per ms: heavy tasks grow slowly and are soon leftmost again. 14 simulated turns (a fixed 3 ms each, for illustration): C 8 turns (57%; its weight share is 56%), A 4 turns (29%; its weight share is 29%), B 2 turns (14%; its weight share is 15%). This is how CFS picked from 2.6.24 to 6.5; since 6.6 EEVDF does the picking and since 6.8 the tree is sorted by virtual deadline, while vruntime still grows by weight (fair.c:1398 at v7.0-9887-ga43fac2b5813).下载 SVGSVG源码Code
t虚线:要拼出的方波dashed: the square wave we wantf(t) = 4/π · ( sin t + sin 3t/3 + sin 5t/5 + sin 7t/7 + … )方波 = 一串正弦波叠起来:频率 1、3、5、7 倍,频率越高越小a square wave = sines stacked up: 1, 3, 5, 7 times the frequency, each smaller1 项:只是一条正弦1 term: just a sine12 项:肩膀开始变平2 terms: the shoulders flatten1/33 项:边更陡了3 terms: steeper edges1/54 项:已经很像方波;边角冲高 18%4 terms: nearly square; 18% overshoot at the corners1/71×2×3×4×5×6×7×8×傅立叶变换算的就是右边这张表:A Fourier transform computes this table:有哪些频率,各占多少(偶数倍是 0)which frequencies, and how much (even ones: 0)红点转一圈 = 方波走完一个周期one turn = one period of the wave
24 傅立叶级数 · 方波是一串转圈的正弦叠出来的Fourier series · a square wave from circles turning on circles动图 17smotion 17s四个圆一个套一个地转:频率 1、3、5、7 倍,半径是 1、1/3、1/5、1/7。最外面那个点的高度画到右边,就是四个正弦波的和,已经很像方波。右下角的柱子就是傅立叶变换算出来的东西:每个频率占多少。4 项时边角冲到方波高度的 1.184 倍;加到 400 项还是 1.179 倍——跳变处这一截冲高不会消失(吉布斯现象)。Four circles turn on each other at 1, 3, 5 and 7 times the speed, radii 1, 1/3, 1/5, 1/7. The height of the outermost point, traced to the right, is the sum of four sines — already close to a square wave. The bars are what a Fourier transform computes: how much of each frequency. With 4 terms the corner overshoots to 1.184× the wave's height; with 400 terms it is still 1.179× — the overshoot at a jump never goes away (Gibbs phenomenon).下载 SVGSVG源码Code
10x0x1x2x3① 给每个点造一个开关① a switch for each point② 乘上那点的高度,再加起来② times the point's height, then add(0, 1)(1, 3)(2.5, 2)(4, 3.5)L(x) = y0ℓ0 + y1ℓ1 + y2ℓ2 + y3ℓ3ℓi(x) = Π (x − xj) / (xi − xj) j ≠ iℓ0第 1 个开关:在自己那点是 1,另外三点是 0switch 1: 1 at its own point, 0 at the other threeℓ1第 2 个开关:在自己那点是 1,另外三点是 0switch 2: 1 at its own point, 0 at the other threeℓ2第 3 个开关:在自己那点是 1,另外三点是 0switch 3: 1 at its own point, 0 at the other threeℓ3第 4 个开关:在自己那点是 1,另外三点是 0switch 4: 1 at its own point, 0 at the other three在每个点上,只有它自己的开关是 1,At each point only its own switch is on,所以加起来正好是那个点的高度so the sum is exactly that point's heightL(x) = 1.00 + 4.08x − 2.49x² + 0.41x³展开就是一个普通的三次多项式expanded: an ordinary cubic
25 拉格朗日插值 · 先造「开关」,再加权加起来Lagrange interpolation · build switches, then add them up动图 15smotion 15s四个点,找一条穿过它们的曲线。先给每个点造一个「开关」曲线:在自己那点等于 1,在其余三点等于 0。再各自乘上那点的高度加起来——在任何一个点上,只有它自己的开关是 1,所以和正好是那点的高度。展开就是一个三次多项式 L(x) = 1.00 + 4.08x − 2.49x² + 0.41x³,系数由代码展开算出;把四个点代回展开式,最大误差 1e-14(浮点舍入)。Four points; find a curve through all of them. First build a "switch" curve for each point: 1 at its own point, 0 at the other three. Multiply each by its point's height and add. At any point only its own switch is on, so the sum is exactly that height. Expanded, it is the cubic L(x) = 1.00 + 4.08x − 2.49x² + 0.41x³; the coefficients are expanded in code; put back into it, the four points are off by at most 1e-14 (floating-point rounding).下载 SVGSVG源码Code
山顶top路:g(x, y) = 0road: g(x, y) = 0只能走在路上,路上哪一点最高?You may only walk on the road. Where is it highest?等高线一圈套一圈,越往里越高contours ring the hill; inner rings are higher∇f:往山上最陡的方向∇f: straight uphill∇g:垂直于路∇g: perpendicular to the road∇f 顺着路的那一截the part of ∇f along the road夹角 48°angle 48°夹角 36°angle 36°夹角 20°angle 20°夹角 0°angle 0°∇f = λ · ∇g相切:两支箭头在一条线上tangent: the arrows line up顺着路的那一截 = 0the part along the road = 0
26 拉格朗日乘数 · 路上的最高点,是路和等高线相切的地方Lagrange multipliers · the highest point on a road touches a contour动图 16.7smotion 16.7s你只能走在路上(约束 g = 0),想走到路上最高的地方(目标 f)。每停一次画三支箭头:橙色 ∇f 指向山上最陡的方向,蓝色 ∇g 垂直于路,绿色是 ∇f 顺着路的那一截——只要绿色不为 0,沿路还能往上走。四次停下时两支箭头的夹角依次是 48°、36°、20°、0°;最后一点是代码在路上找到的最高点,夹角 0°,等高线正好和路相切:∇f = λ∇g。You may only walk on the road (constraint g = 0) and want its highest point (objective f). At each stop three arrows: orange ∇f points straight uphill, blue ∇g is perpendicular to the road, green is the part of ∇f along the road — while green is not zero you can still climb by walking on. The angle between the two arrows at the four stops: 48°, 36°, 20°, 0°. The last stop is the highest point the code finds on the road: 0°, the contour just touches the road, ∇f = λ∇g.下载 SVGSVG源码Code
x←x−η·f′(x)位置position步长step size脚下有多陡how steep谷底:导数为 0,不再移动bottom: slope 0, no more steps
27 梯度下降 = 蒙着眼往山下走Gradient descent = walking downhill blindfolded动图 12smotion 12s每一步只看脚下有多陡,就往下坡走一步;越接近谷底越平,步子自然越小。公式里的每一项和图里同色。Each step looks only at how steep the ground is and steps downhill; near the bottom it is flatter, so steps shrink. Each term of the formula has the colour of its part in the picture.下载 SVGSVG源码Code
θsin θ半径 = 1radius = 1
29 正弦波是转圈画出来的A sine wave is a circle, unrolled动图 2.6smotion 2.6s左边的点匀速转圈,它的高度一路画到右边,就是 sin 曲线。两边用同一个时钟,所以永远对得上。The point goes round at a steady speed; its height, traced to the right, is the sine curve. Both sides run on one clock, so they always agree.下载 SVGSVG源码Code
3² = 94² = 165² = 259+16=25
30 勾股定理 · 数格子就能看出来Pythagoras · count the squares动图 9smotion 9s直角边 3 和 4,各自画一个正方形:9 格加 16 格,正好等于斜边 5 上那个正方形的 25 格。Legs 3 and 4, a square on each: 9 cells plus 16 cells is exactly the 25 cells of the square on the long side, 5.下载 SVGSVG源码Code
5273614排好了:比较 21 次,交换 12 次sorted: 21 comparisons, 12 swaps
31 冒泡排序 · 两两比较,大的往后换Bubble sort · compare neighbours, swap the bigger back动图 13.75smotion 13.75s圈住的两根在比较;左边比右边高就交换。每一轮最高的那根「冒」到最后。交换顺序是真跑一遍排序算出来的。The ringed pair is compared; if the left is taller they swap. Each pass bubbles the tallest to the end. The swaps come from running the sort.下载 SVGSVG源码Code

数据图Charts

手绘坐标轴,真实数据。点和线是铅笔画的,数字照样要对。Hand-drawn axes, real numbers. The dots are pencil; the values still have to be right.

分数(越低越好)score (lower is better)第几次实验run #1.0010.9970.994目前最好 0.9939best so far 0.993948 次实验 · 留下 12 次(含第一次基线,示意数据)48 runs · 12 kept incl. the baseline (illustrative)
32 实验进度 · 灰点丢掉,绿点留下Experiments · grey dropped, green kept动图 7smotion 7s每个点是一次实验。比当前最好还低就留下(绿),否则丢掉(灰);绿色台阶线是「目前最好」。数据是示意。Each dot is one run. Lower than the best so far: kept (green); otherwise dropped (grey). The green steps are the best so far. Illustrative data.下载 SVGSVG源码Code
耗时(分钟,示意)minutes (illustrative)9.63.1冷启动cold start4.21.6增量编译incremental6.85.9跑测试tests冷启动快了 3.1 倍cold start: 3.1× faster改之前before改之后after
33 柱状图 · 改之前和改之后Bar chart · before and after动图 5.2smotion 5.2s同一件事改前改后各量一次。柱子用彩铅涂,数值写在柱顶,差多少用一根手画箭头标出来。数据是示意。The same thing measured before and after a change. Coloured-pencil bars, the value on top, the difference marked with a hand-drawn arrow. Illustrative data.下载 SVGSVG源码Code

标注与叠层Marks and overlays

圈重点、画箭头、贴便签、深色终端卡:叠在插画或截图上用。Circles, arrows, sticky notes and a dark terminal card, laid over a drawing or a screenshot.

这里是重点the key part圈起来ring it这一句要读两遍read this one twice荧光笔划过的字highlighted words对right不对wrong123这一段this part便签:回头再看note: come back to this贴歪一点更像真的a little crooked looks real手画边框的提示框a hand-drawn callout box
34 批注工具 · 圈、箭头、划线、对错Annotation kit · rings, arrows, underlines, ticks老师改作业的那几样:圈重点、画箭头、划线、荧光笔、打勾打叉、编号。叠在任何截图上都像人改过。What a teacher marks a page with: rings, arrows, underlines, highlighter, ticks and crosses, numbers. On any screenshot they read as a person's notes.下载 SVGSVG源码Code
$ npm test ✓ parser 42 passed ✓ renderer 17 passed ✗ export 1 failed: frame 300 differs 59 passed · 1 failed · 3.1 s$
35 终端卡 · 一行一行打出来Terminal card · typed line by line动图 4.5smotion 4.5s深色终端在浅色和深色主题里都保持深色。命令一行一行出现,结果的颜色有意思:绿是通过,红是失败。The terminal stays dark in both themes. Lines appear one at a time; colours mean something: green passed, red failed.下载 SVGSVG源码Code
1左边是目录contents on the left2主画面the main view3只有这个按钮会动数据only this button changes data
36 给界面截图加讲解Explaining a screen with callouts一个手画的窗口(换成真实截图也行),旁边三个编号标注。编号和正文里的 1 2 3 对应,读者不用找。A hand-drawn window (or a real screenshot) with three numbered callouts that match 1 2 3 in the text, so nobody hunts.下载 SVGSVG源码Code
标题title主体subject字幕subtitles16:9 横屏 · 字幕离底边 ≥ 8%16:9 · subtitles ≥ 8% above the edge按钮UI平台文字platform text标题title主体subject字幕subtitles9:16 竖屏 · 避开右侧和底部9:16 · keep off the right and bottom
37 短视频画面 · 横屏和竖屏的安全区Video frames · safe areas, landscape and portrait做小视频时字和主体放哪:标题在上、字幕在下,右侧和底部留给平台按钮。比例按 16:9 和 9:16 画。Where words and subjects go in a short video: title on top, subtitles below, the right edge and bottom left for the platform's buttons. Drawn at 16:9 and 9:16.下载 SVGSVG源码Code