pre-gif re-write

This commit is contained in:
2024-10-16 13:48:22 -05:00
parent da71b1bd85
commit 87c65bc84e
6 changed files with 102 additions and 12 deletions

View File

@@ -1,16 +1,18 @@
(use-modules (graphgif)
(srfi srfi-1))
(define red (create-color 1 0 0))
(define my-graph
`(((10 . 10) (1) ,white)
((30 . 20) () ,red)))
`(((10 . 10) (1))
((30 . 20) () ,red)))
(define more-complex-graph
`(((10 . 10) () ,white)
((40 . 10) (0) ,white)
((25 . 25) (0 1) ,white)
((10 . 40) (0 2 4) ,white)
((40 . 40) (1 2 3) ,white)))
`(((10 . 10) ())
((40 . 10) (0))
((25 . 25) (0 1))
((10 . 40) (0 2 4))
((40 . 40) (1 2 3))))
(define (idx->x i w)
(modulo i w))
@@ -33,6 +35,7 @@
(not (negative? oy))
(< ox w)
(xy->idx ox oy w))))
;; Auto-connect these directions if legal indices
'(( 0 . -1)
(-1 . 0)
(-1 . -1)
@@ -43,12 +46,11 @@
(list
(cons (+ (* 30 (idx->x i w)) 10)
(+ (* 30 (idx->y i w)) 10))
(idx->edges i w)
white))
(idx->edges i w)))
(let loop ([i 0]
[lst '()])
(if (>= i (* w h))
(reverse lst)
(loop (1+ i) (cons (make-node i) lst)))))
(write-graph-to-file (generate-web 5 5) (cadr (command-line)))
(write-graph-to-file (generate-web 10 10) (cadr (command-line)))