automated snapshot

This commit is contained in:
sumi
2025-12-22 01:43:35 -06:00
parent 922c8bb2f6
commit 2f10e026a0
3 changed files with 73 additions and 20 deletions

View File

@@ -85,18 +85,29 @@ func initSchema(db *sql.DB) error {
return tx.Commit()
}
func (s *Storage) Save() (string, error) {
func (s *Storage) Save(capture *SketchCapture) (string, error) {
id, _ := s.gen.Next()
kid := ids.Base62Encode(id)
path := filepath.Join(s.snapshotsDir, kid)
os.MkdirAll(path, 0755)
// wysiwyg at screen res
img := rl.LoadImageFromScreen()
defer rl.UnloadImage(img)
snapshotPng := filepath.Join(path, fmt.Sprintf("%s.png", kid))
rl.ExportImage(*img, snapshotPng)
// capture full res compsite
compositePng := filepath.Join(path, fmt.Sprintf("%s-composite.png", kid))
rl.ExportImage(*capture.compositeImage, compositePng)
// capture full res layer
for i, layerImage := range capture.layerImages {
layerPng := filepath.Join(path, fmt.Sprintf("%s-%3d.png", kid, i))
rl.ExportImage(*layerImage, layerPng)
}
s.log.Printf("Checking git status...\n")
hash, branch, committed, err := CommitAllIfDirty(s.repoRoot, "automated snapshot", s.log)