Skip to content

Shenrui-Ma/video-regen-recipes / templates/drawing-process/svg-redraw-comparison

svg-redraw-comparison

Unverified

用参考图制作高精度 SVG 临摹绘制过程视频,交付纯 SVG 网页、独立 SVG 和原图对照 MP4。禁止 Canvas、位图嵌入与外链,按构图、线稿、固有色、阴影、高光、细节重放;横图上下、竖图左右合成。

FileKindSize
LICENSEother1.1 KB
LICENSES.mdmarkdown998 B
README.mdmarkdown2.5 KB
SKILL.mdskill md3.8 KB
assets/manifest.jsonconfig320 B
assets/reference.pngbinary2.7 MB
examples/demo.htmlother30.1 KB
examples/foundations.svgother597.0 KB
examples/preview.mp4binary3.2 MB
examples/redraw.svgother15.6 MB
examples/regions.jsonconfig6.7 KB
examples/validation.jsonconfig2.1 KB
profile.jsonconfig2.2 KB
prompts/author-original.prompt.txtmarkdown1.2 KB
prompts/redraw.prompt.txtmarkdown1.2 KB
references/validation.mdmarkdown1.2 KB
references/workflow.mdmarkdown5.0 KB
scripts/_contours.pyscript1.3 KB
scripts/_regions.pyscript1.2 KB
scripts/_validate_svg.pyscript1.5 KB
scripts/build_demo.pyscript5.9 KB
scripts/clean_png.pyscript2.1 KB
scripts/export_video.cjsscript6.1 KB
scripts/package_demo.pyscript3.4 KB
scripts/trace_reference.pyscript5.0 KB
sources.mdmarkdown1.7 KB
tests/check_player.cjsscript3.9 KB
tests/test_pipeline.pyscript4.2 KB
web/load-art.jsscript3.2 KB
web/player.cssother738 B
web/player.jsscript2.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))
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: 198kUpdated Claude CodeCodexVerifiedInstall
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: 194kUpdated Claude CodeCodexVerifiedInstall
ponytail-debtDietrichGebert/ponytailHarvest every shortcut: comment into one debt ledger, so deferrals get tracked instead of forgotten. One-shot report.Stars: 194kUpdated Claude CodeCodexVerifiedInstall
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: 194kUpdated Claude CodeCodexVerifiedInstall