Index / 2018-09-14-dotted-tiles.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
27
28
29
30
#lang racket
(require 2htdp/image)

(define (dot s)
  (lambda (a)
    (underlay
     (circle (/ s 4) 'solid 'gray)
     (square s (truncate a) 'black))))

(define (sq2x2 i)
  (lambda (s)
    (lambda (a)
      (let ((ii (i (/ s 2))))
        (above (beside (ii        a)  (ii (* 0.9 a)))
               (beside (ii (* 0.7 a)) (ii (* 0.8 a))))))))

(define (step i)
  (lambda (s)
    (lambda (a)
      (let* ([i2 (sq2x2 i)]
             [i4 (sq2x2 i2)]
             [i8 (sq2x2 i4)])
        (above (beside ((i  s) a) ((i2 s) a))
               (beside ((i8 s) a) ((i4 s) a)))))))

(provide main)
(define (main . args)
  (save-image
   (((step (step dot)) 200) 255)
   (car args)))