diff --git a/demo.scm b/demo.scm index e49b0e5..6d3a48e 100644 --- a/demo.scm +++ b/demo.scm @@ -7,4 +7,4 @@ (define graph1 (generate-web 10 10)) (define graph2 (remove-rect (copy-tree graph1) 10 3 3 4 5)) (assq-set! graph2 0 (set-node-color (assq-ref graph2 0) red)) -(write-graphs-to-file (list graph1 graph2) "graph.gif") +(write-graphs-to-file (vector graph1 graph2) "graph.gif") diff --git a/graphgif.scm b/graphgif.scm index f69b7e8..bee75f5 100644 --- a/graphgif.scm +++ b/graphgif.scm @@ -2,7 +2,8 @@ (use-modules (cairo) (srfi srfi-1) - (srfi srfi-9 gnu)) + (srfi srfi-9 gnu) + (srfi srfi-43)) (re-export (cairo-pattern-create-rgb . create-color)) @@ -141,16 +142,16 @@ (define (output-to-file surfaces filename) (define pngdir (mkdtemp "/tmp/graphgif_XXXXXX")) - (do ([i 1 (1+ i)] - [surfaces surfaces (cdr surfaces)]) - ((null? surfaces)) - (cairo-surface-write-to-png - (car surfaces) - (string-append pngdir "/img-" (number->string i) ".png"))) + (vector-for-each + (lambda (i surface) + (cairo-surface-write-to-png + surface + (string-append pngdir "/img-" (number->string i) ".png"))) + surfaces) (system* "ffmpeg" "-i" (string-append pngdir "/img-%d.png") "-r" "1" filename)) (define-public (write-graphs-to-file graphs filename) - (output-to-file (map draw-abstract-graph graphs) filename)) + (output-to-file (vector-map (lambda (_ graph) (draw-abstract-graph graph)) graphs) filename)) ;; Local Variables: ;; geiser-scheme-implementation: guile