Compare commits
No commits in common. "da71b1bd85eef8978ef58c5ab17808b0c6481552" and "bc61ef7d8f1b4caa562734bb129728f2b2372c39" have entirely different histories.
da71b1bd85
...
bc61ef7d8f
36
demo.scm
36
demo.scm
@ -23,20 +23,17 @@
|
|||||||
|
|
||||||
(define (idx->edges i w)
|
(define (idx->edges i w)
|
||||||
(filter-map
|
(filter-map
|
||||||
(lambda (offset)
|
(lambda (x y)
|
||||||
(let* ([x (idx->x i w)]
|
(if (or (negative? (+ (idx->x i w) x))
|
||||||
[y (idx->y i w)]
|
(negative? (+ (idx->y i w) y))
|
||||||
[ox (+ x (car offset))]
|
(>= (+ (idx->x i w) x) w))
|
||||||
[oy (+ y (cdr offset))])
|
#f
|
||||||
(and
|
(xy->idx
|
||||||
(not (negative? ox))
|
(+ (idx->x i w) x)
|
||||||
(not (negative? oy))
|
(+ (idx->y i w) y)
|
||||||
(< ox w)
|
w)))
|
||||||
(xy->idx ox oy w))))
|
'(+0 -1 -1 +1)
|
||||||
'(( 0 . -1)
|
'(-1 +0 -1 -1)))
|
||||||
(-1 . 0)
|
|
||||||
(-1 . -1)
|
|
||||||
(+1 . -1))))
|
|
||||||
|
|
||||||
(define (generate-web w h)
|
(define (generate-web w h)
|
||||||
(define (make-node i)
|
(define (make-node i)
|
||||||
@ -45,10 +42,11 @@
|
|||||||
(+ (* 30 (idx->y i w)) 10))
|
(+ (* 30 (idx->y i w)) 10))
|
||||||
(idx->edges i w)
|
(idx->edges i w)
|
||||||
white))
|
white))
|
||||||
(let loop ([i 0]
|
(reverse
|
||||||
[lst '()])
|
(let loop ([i 0]
|
||||||
(if (>= i (* w h))
|
[lst '()])
|
||||||
(reverse lst)
|
(if (>= i (* w h))
|
||||||
(loop (1+ i) (cons (make-node i) lst)))))
|
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 5 5) (cadr (command-line)))
|
||||||
|
Loading…
Reference in New Issue
Block a user