((section 2 "Outdated egg!" (p "This is an egg for CHICKEN 4, the unsupported old release.  You're almost certainly looking for " (int-link "/eggref/5/animation" "the CHICKEN 5 version of this egg") ", if it exists.") (p "If it does not exist, there may be equivalent functionality provided by another egg; have a look at the " (link "https://wiki.call-cc.org/chicken-projects/egg-index-5.html" "egg index") ". Otherwise, please consider porting this egg to the current version of CHICKEN.")) (section 2 "animation" (p "Utility for creating animations from a series of images") (toc) (section 3 (tt "make-animator") (def (sig (procedure "(make-animator #!key (magnitude 10000) (frames-per-second 4) (type png) (width 1600) (height 900)) → Two values: next-frame and finalize" (id make-animator))) (p "Create an animator, which consists of two values: a frame-creator and a finalizer.") (p (tt "Next-frame") " is a niladic function which returns the filename of the next frame; " (tt "finalize") " is a monadic function taking the name of the resultant animation (e.g. " (tt "\"graph.avi\"") ").") (dl (dt (tt "magnitude")) (dd "Roughly the number of animations one anticipates") (dt (tt "frames-per-second")) (dd "Frames per second") (dt (tt "type")) (dd "The frame type; one of e.g. \"png\", \"jpg\"") (dt (tt "width")) (dd "The width of the frame in pixels (#f for no scaling)") (dt (tt "height")) (dd "The height of the frame (#f for no scaling)")) (highlight scheme "(define (make-animator\n         #!key\n         (magnitude 10000)\n         (frames-per-second 4)\n         (type \"png\")\n         (width 1600)\n         (height 900))\n  (let ((directory (create-temporary-directory))\n        (current-frame 0)\n        (digits (inexact->exact (ceiling (/ (log magnitude) (log 10))))))\n    (define (next-frame)\n      (let ((frame (make-pathname\n                     directory\n                     (format (format \"~~~a,48d\" digits) current-frame)\n                     type)))\n        (inc! current-frame)\n        frame))\n    (define (finalize animation)\n      (let ((options\n              (option-string\n                (append\n                  `((type unquote type) (fps unquote frames-per-second))\n                  (if width `((w unquote width)) '())\n                  (if height `((h unquote height)) '())))))\n        (run (mencoder\n               ,(format\n                  \"mf://~a\"\n                  (make-pathname directory (format \"*.~a\" type)))\n               -mf\n               ,options\n               -ovc\n               lavc\n               -o\n               ,animation))))\n    (values next-frame finalize)))")) (section 4 "Examples" (p "In this hypothetical example, we're running a depth-first-search on a graph; outputting an animation frame every step.") (pre "(receive (next-frame finalize) (make-animator)\n  (let ((graph (make-random-graph)))\n    (call-for-each-frame (depth-first-search graph)\n                         (lambda (graph)\n                           (write-graph-as-png graph (next-frame))))\n    (finalize \"graph\")))"))) (section 3 "About this egg" (section 4 "Author" (p (int-link "/users/klutometis" "Peter Danenberg"))) (section 4 "Repository" (p (link "https://github.com/klutometis/animation"))) (section 4 "License" (p "BSD")) (section 4 "Dependencies" (ul (li (int-link "format")) (li (int-link "hahn")) (li (int-link "matchable")) (li (int-link "miscmacros")) (li (int-link "shell")) (li (int-link "setup-helper")))) (section 4 "Versions" (dl (dt (link "https://github.com/klutometis/animation/releases/tag/0.1" "0.1")) (dd "Initial release") (dt (link "https://github.com/klutometis/animation/releases/tag/0.2" "0.2")) (dd "Fix cock-invocation.") (dt (link "https://github.com/klutometis/animation/releases/tag/0.3" "0.3")) (dd "Add width and height.") (dt (link "https://github.com/klutometis/animation/releases/tag/0.3.1" "0.3.1")) (dd "Remove the dependency on setup-helper-cock.") (dt (link "https://github.com/klutometis/animation/releases/tag/0.3.2" "0.3.2")) (dd "Remove the dependency on debug.") (dt (link "https://github.com/klutometis/animation/releases/tag/0.3.3" "0.3.3")) (dd "Use hahn."))) (section 4 "Colophon" (p "Documented by " (int-link "/egg/hahn" "hahn") ".")))))