File size: 7,308 Bytes
d513eb2
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
"""Code-native mechanism illustrations; never presented as measured simulations."""
def diagram(title, shapes, left, right):
 return f'''<svg viewBox="0 0 640 360" role="img" aria-label="{title}机制示意"><defs><marker id="arrow-{title}" markerWidth="8" markerHeight="8" refX="7" refY="3" orient="auto"><path d="M0 0 L7 3 L0 6" fill="none" stroke="#b0451e" stroke-width="1.5"/></marker></defs><rect width="640" height="360" fill="#f1ede4"/><path d="M45 292 H595" stroke="#d3cab9" stroke-width="2"/>{shapes}<rect x="28" y="312" width="284" height="30" rx="7" fill="#e0eeea"/><rect x="328" y="312" width="284" height="30" rx="7" fill="#f5e5dc"/><text x="44" y="333" font-size="16" fill="#14706a">观察:{left}</text><text x="344" y="333" font-size="16" fill="#b0451e">调整:{right}</text></svg>'''

DRAWINGS={
 '插接件':diagram('插接件','''<path d="M150 208 L394 208 L474 250 L230 250 Z" fill="#cdc6b7" stroke="#938b7a" stroke-width="3"/><path d="M230 250 L230 283 L474 283 L474 250" fill="#b5ae9d" stroke="#938b7a" stroke-width="3"/><ellipse cx="308" cy="229" rx="43" ry="16" fill="#464f49"/><g transform="rotate(12 308 140)"><path d="M285 75 L329 75 L329 203 Q308 220 285 203 Z" fill="#a7bcb2" stroke="#557a69" stroke-width="3"/><ellipse cx="307" cy="75" rx="22" ry="8" fill="#dde8df"/><path d="M258 73 V119 H277 M355 73 V119 H338" fill="none" stroke="#8b9186" stroke-width="12"/></g><path d="M306 39 V61 M410 138 Q376 137 350 165" stroke="#b0451e" stroke-width="3" fill="none" marker-end="url(#arrow-插接件)"/><circle cx="329" cy="213" r="8" fill="none" stroke="#b0451e" stroke-width="3"/><text x="407" y="118" fill="#b0451e" font-size="20">偏载 → 回退校正</text><path d="M308 182 V241" stroke="#14706a" stroke-width="2" stroke-dasharray="6 5"/>''','偏载、卡滞与进给','对齐姿态,再逐步插入'),
 '带闭门器的门':diagram('闭门器','''<path d="M190 54 H428 V281 H190 Z" fill="#e4dfd3" stroke="#9f9685" stroke-width="5"/><path d="M190 57 L353 103 L353 278 L190 280 Z" fill="#c8d4cb" stroke="#64816f" stroke-width="4"/><circle cx="327" cy="195" r="6" fill="#617362"/><rect x="235" y="48" width="91" height="24" rx="4" fill="#899185"/><path d="M280 61 L345 79 L307 114" stroke="#515d52" stroke-width="6" fill="none"/><path d="M402 199 Q395 247 366 269" stroke="#b0451e" stroke-width="4" fill="none" marker-end="url(#arrow-闭门器)"/><path d="M471 200 L396 201 L356 199" stroke="#9ba699" stroke-width="17" fill="none" stroke-linecap="round"/><text x="65" y="113" fill="#14706a" font-size="19">储能回拉</text><path d="M147 108 L239 64" stroke="#14706a" stroke-width="2" stroke-dasharray="5 5"/><text x="413" y="165" fill="#b0451e" font-size="19">跟随推扶</text>''','门角度、回拉与角速度','末段缓释,避免甩门'),
 '折叠柔性物':diagram('折叠柔性物','''<path d="M120 217 L330 184 L505 231 L294 273 Z" fill="#e1d6be" stroke="#9a8e72" stroke-width="3"/><path d="M120 217 Q162 137 216 100 Q256 76 295 108 L408 192 L330 184 Z" fill="#b4c9bb" stroke="#5f816d" stroke-width="3"/><path d="M136 208 Q191 147 235 155 Q282 183 324 181" fill="none" stroke="#789983" stroke-width="3"/><path d="M157 208 Q210 162 254 170" fill="none" stroke="#789983" stroke-width="2"/><path d="M195 63 V93 H214 M263 61 V92 H246" stroke="#8b9486" stroke-width="10" fill="none"/><path d="M259 83 Q320 61 378 129" stroke="#b0451e" stroke-width="3" fill="none" marker-end="url(#arrow-折叠柔性物)"/><path d="M330 187 L294 271" stroke="#14706a" stroke-width="2" stroke-dasharray="7 5"/><text x="411" y="116" fill="#14706a" font-size="19">目标折线</text><path d="M431 128 L333 203" stroke="#14706a" stroke-width="2" stroke-dasharray="5 5"/>''','拉伸、曲率与褶皱','换抓点,补松弛与支撑'),
 '挤压软包装':diagram('软包装','''<path d="M246 70 Q215 115 230 162 Q192 208 224 267 L408 267 Q444 220 407 160 Q425 108 394 70 Z" fill="#d7ddd1" stroke="#7d907c" stroke-width="3"/><path d="M247 70 L255 50 H386 L394 70 Z" fill="#91ac97" stroke="#7d907c" stroke-width="3"/><path d="M229 169 Q309 181 408 160 L417 237 Q321 267 218 242 Z" fill="#b9cbb4" opacity=".8"/><path d="M120 146 H222 M420 146 H522" stroke="#979b8b" stroke-width="20" stroke-linecap="round"/><path d="M174 113 H230 M474 113 H408" stroke="#b0451e" stroke-width="3" fill="none" marker-end="url(#arrow-软包装)"/><ellipse cx="317" cy="235" rx="89" ry="31" fill="none" stroke="#b0451e" stroke-width="2" stroke-dasharray="7 5"/><text x="413" y="84" fill="#14706a" font-size="19">按形变限压</text><text x="54" y="240" fill="#b0451e" font-size="18">局部鼓胀</text><path d="M143 235 H223" stroke="#b0451e" stroke-width="2" stroke-dasharray="5 5"/>''','压缩量、鼓胀与应变','移动挤压区、分散载荷'),
 '压合密封圈':diagram('密封圈','''<path d="M132 234 L436 234 L505 272 L201 272 Z" fill="#c8c8bb" stroke="#969788" stroke-width="3"/><ellipse cx="316" cy="227" rx="116" ry="34" fill="#e6be95" stroke="#a17e58" stroke-width="4"/><ellipse cx="316" cy="227" rx="75" ry="18" fill="#c8c8bb" stroke="#a17e58" stroke-width="3"/><path d="M132 140 L436 140 L505 178 L201 178 Z" fill="#c1cdc2" stroke="#7e9582" stroke-width="3"/><path d="M201 178 V196 H505 V178" fill="#95ab96" stroke="#7e9582" stroke-width="3"/><path d="M220 72 V134 M332 64 V134 M430 78 V134" stroke="#b0451e" stroke-width="3" fill="none" marker-end="url(#arrow-密封圈)"/><path d="M216 201 V217 M415 201 V217" stroke="#14706a" stroke-width="3" stroke-dasharray="3 3"/><text x="62" y="105" fill="#14706a" font-size="18">均衡压合</text><text x="421" y="223" fill="#b0451e" font-size="18">避免挤出</text>''','局部压缩与偏载','均衡载荷,及时止压'),
 '弯曲软管':diagram('软管','''<path d="M102 255 L102 161 Q102 80 223 80 Q355 80 356 197 L356 255" fill="none" stroke="#668d7c" stroke-width="34" stroke-linecap="round"/><path d="M102 255 L102 161 Q102 80 223 80 Q355 80 356 197 L356 255" fill="none" stroke="#b4d1c0" stroke-width="22" stroke-linecap="round"/><path d="M122 169 H179 V211 H122" fill="#e3d9c9" stroke="#a1937f" stroke-width="3"/><path d="M372 187 H421 V224 H372" fill="#e3d9c9" stroke="#a1937f" stroke-width="3"/><path d="M398 73 Q455 52 489 92" fill="none" stroke="#b0451e" stroke-width="3" marker-end="url(#arrow-软管)"/><ellipse cx="488" cy="152" rx="35" ry="34" fill="none" stroke="#14706a" stroke-width="9"/><ellipse cx="488" cy="235" rx="35" ry="10" fill="none" stroke="#b0451e" stroke-width="9"/><path d="M539 220 L568 249 M568 220 L539 249" stroke="#b0451e" stroke-width="3"/><text x="176" y="40" fill="#14706a" font-size="19">控制弯曲半径</text><text x="432" y="107" fill="#14706a" font-size="17">保持截面</text>''','局部曲率与截面扁化','补支撑,放大弯曲半径'),
}

def task_art(name,demo,vis):
 if demo:
  return f'<img src="assets/{demo}.jpg" alt="{name}已有仿真回放截图">','已有仿真回放',demo
 if name=='弹开式容器':
  return '<img src="assets/basket.jpg" alt="收纳篮旧机构诊断回放">','机构诊断回放 · 非完整任务','basket'
 old={'刮水':'squeegee','沥水':'drain','漏斗转装':'funnel','旋瓶盖':'cap','拉拉链':'zipper','揭膜':'peel','软食装盘':'scoop'}
 return (vis(old[name]) if name in old else DRAWINGS[name]),'概念示意 · 待实现验证',None