Skip to content
Åpecranꓘ: The Tenebric Symplecticum
Go back

Circle Fractal in Racket

Edit page

Circle Fractal

(require 2htdp/image)  
  
  
;; =================  
;; Constants:  
  
(define STEP (/ 2 5))  
(define TRIVIAL-SIZE 5)  
  
;; Funtions  
  
;; Number -> Image  
;; produce the above fractal of the given size  
(check-expect (circle_frac TRIVIAL-SIZE) (circle 5 "solid" "darkgreen"))  
(check-expect (circle_frac (* (/ 5 2) TRIVIAL-SIZE))  
         (local [(define sub (circle 5 "solid" "darkgreen"))]  
          (above sub  
              (beside sub (circle (* (/ 5 2) TRIVIAL-SIZE) "solid" "darkgreen") sub)  
              sub)))  
  
  
;(define (circle_frac s)      ;stub  
; (square 0 "solid" "white"))  
  
(define (circle_frac s)  
 (if (<= s TRIVIAL-SIZE)  
   (circle s "solid" "darkgreen")  
   (local [(define sub (circle_frac (* STEP s)))]  
    (above sub  
        (beside sub (circle s "solid" "darkgreen") sub)  
        sub))))  

Edit page
Share this post:

Previous Post
Blackjack Game in Python (CodeSkulptor)
Next Post
Simple Command-Line Phonebook in Python