Index / 2018-10-02-cluster.rkt

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
#lang racket
(require 2htdp/image)

(define (step i n s)
  (if (< s 20)
      (i n s)
      (let* ([s3 (/ s 3)]
             [ii (i n s3)]
             [si (step i (+ n 1) s3)]
             [bi (rotate 180 (step i (+ n 1) (* s3 2)))])
        (above (beside (above ii si) bi)
               (beside si ii si)))))

(define (item n s)
  (overlay
   (circle (/ s 20) (if (zero? (modulo n 2)) 200 0) 'Cyan)
   (circle (/ s 3) 'solid 'black)
   (square s (max 0 (- 220 (* n 20))) 'SkyBlue)))

(provide main)
(define (main . args)
  (save-image
   (overlay
    (step item 0 600)
    (square 600 'solid 'black))
   (car args)))