use vectors
This commit is contained in:
parent
31f4707fbf
commit
2da23e143c
2
demo.scm
2
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")
|
||||
|
17
graphgif.scm
17
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
|
||||
|
Loading…
Reference in New Issue
Block a user