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

tests/test_pipeline.py

View on GitHub
import hashlib,importlib.util,json
from pathlib import Path
import struct,sys,tempfile,unittest,zlib
ROOT=Path(__file__).resolve().parents[1]
sys.path.insert(0,str(ROOT/'scripts'))
from clean_png import clean,parse,chunk,SIGNATURE
from _contours import contours
from _regions import read_regions
from _validate_svg import read_contours
from package_demo import package_page

class PipelineTests(unittest.TestCase):
 def test_lossless_png_cleanup(self):
  raw=b'\0'+bytes([10,20,30])*2
  original=SIGNATURE+chunk(b'IHDR',struct.pack('>IIBBBBB',2,1,8,2,0,0,0))+chunk(b'tEXt',b'note\0fixture')+chunk(b'IDAT',zlib.compress(raw))+chunk(b'IEND',b'')
  output=clean(original)
  self.assertEqual([k for k,_ in parse(output)],[b'IHDR',b'IDAT',b'IEND'])
  self.assertEqual(zlib.decompress(b''.join(v for k,v in parse(output) if k==b'IDAT')),raw)
 def test_boundary_is_closed(self):
  path,count=contours({0:1,1:3,3:2,2:0},1)
  self.assertEqual(count,1);self.assertEqual(path,'M0 0h1v1h-1v-1z')
 def test_reference_bound_regions(self):
  with tempfile.TemporaryDirectory() as tmp:
   p=Path(tmp)/'regions.json';p.write_text(json.dumps({'width':2,'height':1,'reference_sha256':hashlib.sha256(b'fixture').hexdigest(),'regions':[{'id':'background','polygon':[]}]}))
   self.assertEqual(read_regions(p,2,1,b'fixture'),[('background',[])])
   with self.assertRaises(ValueError):read_regions(p,2,1,b'other')
 def test_bad_region_geometry_rejected(self):
  with tempfile.TemporaryDirectory() as tmp:
   p=Path(tmp)/'r.json';p.write_text(json.dumps({'width':2,'height':1,'reference_sha256':hashlib.sha256(b'f').hexdigest(),'regions':[{'id':'background','polygon':[]},{'id':'subject','polygon':[[0,0],[3,0],[1,1]]}]}))
   with self.assertRaises(ValueError):read_regions(p,2,1,b'f')
 def valid(self):
  return '<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 2 1"><g id="complete-vector-art"><g data-region="background"><path fill="#aabbcc" d="M0 0h2v1h-2z"/></g></g></svg>'
 def test_vector_validation(self):
  read_contours(self.valid(),2,1,['background'])
  with self.assertRaises(ValueError):read_contours(self.valid(),2,1,['another'])
 def test_raster_and_active_content_rejected(self):
  for node in ['<image href="data:image/png;base64,AAAA"/>','<script/>','<foreignObject/>']:
   with self.assertRaises(ValueError):read_contours(self.valid().replace('</svg>',node+'</svg>'),2,1,['background'])
  with self.assertRaises(ValueError):read_contours(self.valid().replace('fill="#aabbcc"','onload="alert(1)" fill="#aabbcc"'),2,1,['background'])
 def test_published_demo_is_lightweight_with_verified_local_vectors(self):
  text=(ROOT/'examples/demo.html').read_text()
  self.assertLess(len(text.encode()),200000)
  for marker in ['<canvas','<img','<image','<foreignObject','data:image','<script src=','http://','https://']:
   if marker=='http://':
    self.assertNotIn(marker,text.replace('http://www.w3.org/2000/svg',''))
   else:self.assertNotIn(marker,text)
  self.assertIn('window.replay=',text)
  import re
  manifest=json.loads(re.search(r'<script type="application/json" id="art-manifest">(.*?)</script>',text).group(1))
  for name in ['redraw.svg','foundations.svg']:
   self.assertEqual(hashlib.sha256((ROOT/'examples'/name).read_bytes()).hexdigest(),manifest[name])
 def test_packaging_keeps_paths_and_rejects_mismatch(self):
  with tempfile.TemporaryDirectory() as tmp:
   root=Path(tmp);source=root/'source.svg';source.write_text(self.valid().replace('<path fill=','<path id="tone-1" fill='))
   path='<path id="tone-1" fill="#aabbcc" d="M0 0h2v1h-2z"/>'
   art='<svg id="art" xmlns="http://www.w3.org/2000/svg" viewBox="0 0 2 1"><g id="construction"/><g id="flat-colors"/><g id="ink"/><g id="final-contours"><g data-stage="shadow">'+path+'</g></g></svg>'
   page='<html><div class="frame">'+art+'</div><script>oldPlayer()</script></html>'
   out=root/'new/demo.html';info=package_page(page,source,out)
   self.assertLess(info['html_bytes'],200000);self.assertFalse(info['simplified'])
   self.assertEqual((out.parent/'redraw.svg').read_bytes(),source.read_bytes())
   self.assertNotIn('M0 0h2v1h-2z',out.read_text())
   with self.assertRaisesRegex(ValueError,'paths differ'):package_page(page.replace('#aabbcc','#ffffff'),source,root/'bad/demo.html')
if __name__=='__main__':unittest.main()
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