Created
September 17, 2018 19:19
-
-
Save astynax/dca68019f3fcedeab99c8ba8eafe39fb to your computer and use it in GitHub Desktop.
Carpet-like pattern
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#lang racket | |
(require 2htdp/image) | |
(define (->color c) | |
(cond [(= c 0) 'indigo] | |
[(= c 1) 'palevioletred] | |
[(= c 2) 'moccasin] | |
[else 'white])) | |
(define (next-c c) (modulo (+ 1 c) 4)) | |
(define (i c s) | |
(if (< s 5) | |
(square s 'solid (->color c)) | |
(overlay (rotate 45 (i (next-c c) (* 0.707 s))) | |
(square s 'solid (->color c))))) | |
(define (sq2x2 i1 i2) | |
(above (beside i1 i2) | |
(beside i2 i1))) | |
(define (step c s) | |
(if (< s 10) (i (next-c c) (* 1.2 s)) | |
(sq2x2 (step (next-c c) (/ s 2)) (i c (* 0.707 s))))) | |
(step 0 400) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment