seveibar/pd-dual-stepper-controller
Bottom-side PCB silkscreen artwork consisting of embedded mirrored TS Circuit SVG logos, with via-clearance-aware lower-board placement.
- Version
- 0.1.0
- License
- unset
- Stars
- 0
scripts/snapshot-clock.ts
import { readFileSync, writeFileSync } from 'node:fs'
import sharp from 'sharp'
const svg = readFileSync('dist/schematic/controller.svg', 'utf8')
await sharp(Buffer.from(svg)).flatten({background:'#f5f1ed'}).png().toFile('../controller-auto-layout.png')
const matrix = svg.match(/data-real-to-screen-transform="matrix\(([^)]+)\)"/)![1]!.split(',').map(Number)
const [a,b,c,d,e,f] = matrix as [number,number,number,number,number,number]
const xMin=8.3, xMax=14.5, yMin=2.4, yMax=8.7
const x=a*xMin+e, y=d*yMax+f, width=a*(xMax-xMin), height=-d*(yMax-yMin)
const cropped=svg.replace(/width="1600" height="1100"/,`width="1100" height="${Math.round(1100*height/width)}" viewBox="${x} ${y} ${width} ${height}"`)
writeFileSync('../clock-auto-layout.svg',cropped)
await sharp(Buffer.from(cropped)).flatten({background:'#f5f1ed'}).png().toFile('../clock-auto-layout.png')
console.log('Saved full controller and clock close-up snapshots')