;;; Scheme Recursive Art Contest Entry ;;; ;;; Please do not include your name or personal info in this file. ;;; ;;; Title: Fluttering Flowers Flowing on Fuschia Fringes ;;; ;;; Description: ;;; sad about finals? ;;; keep staring at this artwork. ;;; I doubt much will change ; Main constants (define scale 310) ; Universal helper functions / computed constants (define left_bound (- scale)) (define (square x) (* x x)) (define (s256 x) (/ x 256)) ; Computes pseudo-colorization of Julia fractal at given point (define (color-to-draw x y sc) (define mycolor (computejulia x y sc)) (define g (quotient (car (cdr mycolor)) 256)) (if (> g 200) (define g (quotient g 2)) ) (if (< g 120) (define g (+ g (quotient g 2)))) (list (modulo (car mycolor) 256) g (modulo (car (cdr mycolor)) 256)) ) ; Draw (colorize) a given (x, y) point (define (draw-point x y sc) (define col (color-to-draw x y sc)) (pixel (+ x 360) (+ y 340) (rgb (s256 (car col)) (s256 (car (cdr col))) (s256 (car (cdr (cdr col)))) ) ) ) ; Tail-recursive function to draw entire y-column for fixed x (define (draw-column f x y) ; Use a "squircle" boundary (equation: x^4 + y^2 = scale^4) to get the nice rounded edges (if (or (and (> x 0) (< (abs y) (expt (- (expt scale 4) (expt x 4)) 0.25))) (and (not (> x 0)) (< (abs y) (expt (- (expt scale 4) (expt x 4)) 0.25))) ) (f x y scale) ) ; Tail-recurse if necessary (if (> y left_bound) (draw-column f x (- y 1)) ) ) ; Helper to compute Julia fractal recursively to hardcoded fractal depth (define (julia-helper x y depth) (if (> (+ (square x) (square y)) 6) depth (begin (julia-helper (+ (- (square x) (square y)) 0.15) (+ (* 2 (* x y)) -0.69) (+ depth 1) ) ) ) ) ; Main Julia fractal computation driver using parameters: ; k = 899191, mod = 2^16 a = 0.15, b = -0.69 (define (computejulia x y sc) (define ret (* 899191 (julia-helper (/ y sc) (/ (- x) sc) 0))) (list (quotient ret 65536) (modulo ret 65536)) ; 2^16 = 65536 ) ; Tail-recursive drawing helper for each column (define (main-drawer width height) (draw-column draw-point width height) (if (> width left_bound) (main-drawer (- width 1) height))) ; Entry drawing function (define (draw) (speed 0) (ht) (main-drawer scale scale) (exitonclick)) ; Please leave this last line alone. You may add additional procedures above ; this line. (draw)