diff --git a/demo.scm b/demo.scm index b1801c5..0762a6e 100644 --- a/demo.scm +++ b/demo.scm @@ -1,11 +1,6 @@ (use-modules (graphgif) - (srfi srfi-1) - (srfi srfi-43) - (ice-9 copy-tree) (d-)) -(define red (create-color 1 0 0)) - (define graph (~> (generate-web 10 10) (remove-rect 10 1 3 6 3) @@ -20,12 +15,12 @@ graph)) (define (make-graph-generator f) (generator - (f graph 90 9 (lambda (visited heap) - (yield (color-graph graph visited heap)))) + (f graph 90 9 + (lambda (visited heap) + (yield (color-graph graph visited heap)))) #f)) (define djikstra-generator (make-graph-generator djikstra)) (define a*-generator (make-graph-generator a*)) (write-graphs-to-file "djikstra.webp" djikstra-generator) (write-graphs-to-file "astar.webp" a*-generator) - diff --git a/graphgif.scm b/graphgif.scm index 8f540c6..61d115b 100644 --- a/graphgif.scm +++ b/graphgif.scm @@ -5,17 +5,17 @@ (srfi srfi-9 gnu) (srfi srfi-11) (srfi srfi-43)) -(re-export (cairo-pattern-create-rgb . create-color)) ;;;;;;;;;;;;;;;;;;; ;; Basic Drawing ;; ;;;;;;;;;;;;;;;;;;; -(define-public pi 3.14159) ;; Good enough +(define-public pi 3.14159) ;; Good enough (define-public tau (* 2 pi)) (define-public black (cairo-pattern-create-rgb 0 0 0)) (define-public white (cairo-pattern-create-rgb 1 1 1)) +(define-public red (cairo-pattern-create-rgb 1 0 0)) (define-immutable-record-type (node coords edges color) @@ -198,7 +198,8 @@ (when (< i-priority parent-priority) (vector-swap! heap i parent)) (fix-up! parent heap)))) - (fix-up! (vector-length heap) (vector-append heap (vector (cons priority item))))) + (fix-up! (vector-length heap) + (vector-append heap (vector (cons priority item))))) (define-public (heap-peek heap) (if (vector-empty? heap) #f (vector-ref heap 0))) @@ -267,7 +268,7 @@ (when update (update visited heap)) (iter (fold (lambda (edge heap) - (heap-insert (+ dist (chebychev edge) 1) edge heap)) +p (heap-insert (+ dist (chebychev edge) 1) edge heap)) (heap-pop heap) (node-edges (assv-ref graph idx))) (cons idx visited))])))