Shenrui-Ma/video-regen-recipes / templates/drawing-process/svg-redraw-comparison
svg-redraw-comparison
Unverified用参考图制作高精度 SVG 临摹绘制过程视频,交付纯 SVG 网页、独立 SVG 和原图对照 MP4。禁止 Canvas、位图嵌入与外链,按构图、线稿、固有色、阴影、高光、细节重放;横图上下、竖图左右合成。
| File | Kind | Size |
|---|---|---|
| LICENSE | other | 1.1 KB |
| LICENSES.md | markdown | 998 B |
| README.md | markdown | 2.5 KB |
| SKILL.md | skill md | 3.8 KB |
| assets/manifest.json | config | 320 B |
| assets/reference.png | binary | 2.7 MB |
| examples/demo.html | other | 30.1 KB |
| examples/foundations.svg | other | 597.0 KB |
| examples/preview.mp4 | binary | 3.2 MB |
| examples/redraw.svg | other | 15.6 MB |
| examples/regions.json | config | 6.7 KB |
| examples/validation.json | config | 2.1 KB |
| profile.json | config | 2.2 KB |
| prompts/author-original.prompt.txt | markdown | 1.2 KB |
| prompts/redraw.prompt.txt | markdown | 1.2 KB |
| references/validation.md | markdown | 1.2 KB |
| references/workflow.md | markdown | 5.0 KB |
| scripts/_contours.py | script | 1.3 KB |
| scripts/_regions.py | script | 1.2 KB |
| scripts/_validate_svg.py | script | 1.5 KB |
| scripts/build_demo.py | script | 5.9 KB |
| scripts/clean_png.py | script | 2.1 KB |
| scripts/export_video.cjs | script | 6.1 KB |
| scripts/package_demo.py | script | 3.4 KB |
| scripts/trace_reference.py | script | 5.0 KB |
| sources.md | markdown | 1.7 KB |
| tests/check_player.cjs | script | 3.9 KB |
| tests/test_pipeline.py | script | 4.2 KB |
| web/load-art.js | script | 3.2 KB |
| web/player.css | other | 738 B |
| web/player.js | script | 2.3 KB |
scripts/package_demo.py
View on GitHub"""Separate replay geometry from HTML without simplifying or retracing any path."""
import argparse
import hashlib
import json
from pathlib import Path
import re
import xml.etree.ElementTree as ET
NS='http://www.w3.org/2000/svg'
ET.register_namespace('',NS)
WEB=Path(__file__).resolve().parents[1]/'web'
def package_page(page,svg_path,output):
output=Path(output);svg_path=Path(svg_path)
match=re.search(r'<svg\b[\s\S]*?</svg>',page)
if not match:raise ValueError('Expected the original inline replay SVG')
art=ET.fromstring(match.group())
final=art.find(f'{{{NS}}}g[@id="final-contours"]')
if final is None:raise ValueError('Missing semantic painting groups')
source=ET.fromstring(svg_path.read_text())
source_paths={p.attrib['id']:p.attrib for p in source.iter(f'{{{NS}}}path')}
replay_paths={p.attrib['id']:p.attrib for p in final.iter(f'{{{NS}}}path')}
if source_paths!=replay_paths:raise ValueError('Static SVG and replay paths differ')
stages={p.attrib['id']:g.attrib['data-stage'][0] for g in final for p in g}
regions=source.find(f'{{{NS}}}g[@id="complete-vector-art"]')
if regions is None:raise ValueError('Missing source regions')
stage_index={g.attrib['data-region']:''.join(stages[p.attrib['id']] for p in g) for g in regions}
art.remove(final)
foundations=ET.tostring(art,encoding='utf-8')
payloads={'redraw.svg':svg_path.read_bytes(),'foundations.svg':foundations}
manifest={name:hashlib.sha256(data).hexdigest() for name,data in payloads.items()}
manifest['stages']=stage_index
controls='<p id="load-status" role="status">正在加载本地 SVG…</p><input id="svg-files" type="file" accept=".svg" multiple hidden aria-label="选择 redraw.svg 和 foundations.svg">'
page=page[:match.start()]+page[match.end():]
page=page.replace('<div class="frame">',controls+'<div class="frame">',1)
page=page.replace('单文件离线播放','轻量 HTML · 本地 SVG 数据')
loader=(WEB/'load-art.js').read_text()
player=(WEB/'player.js').read_text()
script='<script type="application/json" id="art-manifest">'+json.dumps(manifest)+'</script><script>'+loader+'\nloadArt().then(()=>{\n'+player+'\n}).catch(error=>{document.getElementById("load-status").textContent=error.message;document.body.dataset.error="true";});</script>'
page=re.sub(r'<script>[\s\S]*?</script>',lambda _:script,page,count=1)
if len(page.encode())>=200000:raise ValueError('HTML exceeds 200 kB')
output.parent.mkdir(parents=True,exist_ok=True)
for name,data in payloads.items():
dest=output.parent/name
if dest.exists():
if dest.read_bytes()!=data:raise ValueError('Existing vector asset differs: '+name)
else:
with dest.open('xb') as f:f.write(data)
with output.open('x',encoding='utf-8') as f:f.write(page)
return {'html_bytes':len(page.encode()),'vector_files':{name:{'bytes':len(data),'sha256':manifest[name]} for name,data in payloads.items()},'path_count':len(source_paths),'simplified':False,'requires_local_svg_files':True}
if __name__=='__main__':
parser=argparse.ArgumentParser(description=__doc__)
parser.add_argument('--html',type=Path,required=True);parser.add_argument('--svg',type=Path,required=True);parser.add_argument('--output',type=Path,required=True)
args=parser.parse_args()
print(json.dumps(package_page(args.html.read_text(),args.svg,args.output),indent=2))
Related skills
| Skill | Stars | Updated | Works with | Status | Install |
|---|---|---|---|---|---|
| slack-gif-creatoranthropics/skillsKnowledge and utilities for creating animated GIFs optimized for Slack. Provides constraints, validation tools, and animation concepts. Use when users request animated GIFs for Slack like "make me a GIF of X doing Y for Slack." | Stars: 198k | Updated | Claude CodeCodex | Verified | Install |
| ponytailDietrichGebert/ponytailLazy senior dev mode for any coding task: the smallest change that fully solves it, and a reply a busy human understands in one read. | Stars: 194k | Updated | Claude CodeCodex | Verified | Install |
| ponytail-debtDietrichGebert/ponytailHarvest every shortcut: comment into one debt ledger, so deferrals get tracked instead of forgotten. One-shot report. | Stars: 194k | Updated | Claude CodeCodex | Verified | Install |
| ponytail-debtDietrichGebert/ponytailList every `shortcut:` comment (and older `ponytail:` ones) as a debt ledger. One-shot report, changes nothing. Use for "ponytail debt", "what did ponytail defer", "list the shortcuts", /ponytail-debt. | Stars: 194k | Updated | Claude CodeCodex | Verified | Install |