Skip to content

Commit

Permalink
Docs
Browse files Browse the repository at this point in the history
  • Loading branch information
klutometis committed Dec 30, 2012
1 parent d04909d commit f870e99
Showing 1 changed file with 16 additions and 10 deletions.
26 changes: 16 additions & 10 deletions animation.wiki
Expand Up @@ -3,20 +3,24 @@
Utility for creating animations from a series of images
[[toc:]]
=== {{make-animator}}
<procedure>(make-animator #!key (magnitude 10000) (frames-per-second 4) (type png)) → Two values: next-frame and finalize</procedure>
<procedure>(make-animator #!key (magnitude 10000) (frames-per-second 4) (type png) (width 1600) (height 900)) → Two values: next-frame and finalize</procedure>
Create an animator, which consists of two values: a frame-creator and a finalizer.

{{Next-frame}} is a niladic function which returns the filename
of the next frame; {{finalize}} is a monadic function taking the
basename of the animation (e.g. {{graph}} → {{graph.avi}}).
name of the resultant animation (e.g. {{graph.avi}}).
; magnitude : Roughly the number of animations one anticipates
; frames-per-second : Frames per second
; type : The frame type; one of e.g. "png", "jpg"
; width : The width of the frame in pixels (#f for no scaling)
; height : The height of the frame (#f for no scaling)
<enscript highlight="scheme">(define (make-animator
#!key
(magnitude 10000)
(frames-per-second 4)
(type "png"))
(type "png")
(width 1600)
(height 900))
(let ((directory (create-temporary-directory))
(current-frame 0)
(digits (inexact->exact (ceiling (/ (log magnitude) (log 10))))))
Expand All @@ -28,20 +32,22 @@ basename of the animation (e.g. {{graph}} → {{graph.avi}}).
(inc! current-frame)
frame))
(define (finalize animation)
(run (cd ,directory
&&
mencoder
(let ((options
(option-string
(append
`((type unquote type) (fps unquote frames-per-second))
(if width `((w unquote width)) '())
(if height `((h unquote height)) '())))))
(run (mencoder
,(format
"mf://~a"
(make-pathname directory (format "*.~a" type)))
-mf
,(format "type=~a:fps=~a" type frames-per-second)
,options
-ovc
lavc
-o
,(if (absolute-pathname? animation)
animation
(make-pathname (current-directory) animation ".avi")))))
,animation))))
(values next-frame finalize)))
</enscript>
==== Examples
Expand Down

0 comments on commit f870e99

Please sign in to comment.