(define pi 3.1415927) (define (rec-draw-line x1 y1 x2 y2 current-depth max-depth) (cond ((< current-depth max-depth) (let ((mx1 (+ x1 (* (/ (- x2 x1) 4) 2))) (my1 (+ y1 (* (/ (- y2 y1) 4) 2))) (mx2 (+ x1 (* (/ (- x2 x1) 4) 3))) (my2 (+ y1 (* (/ (- y2 y1) 4) 3)))) (rec-draw-line x1 y1 mx1 my1 (1+ current-depth) max-depth) (rec-draw-line mx1 (- my1 5) mx2 (- my2 5) (1+ current-depth) max-depth) (rec-draw-line mx2 my2 x2 y2 (1+ current-depth) max-depth))) (else (draw-line (inexact->exact x1) (inexact->exact y1) (inexact->exact x2) (inexact->exact y2))))) (define (deg2rad angle) (* (/ angle 180) pi)) (define (draw-star-helper x1 y1 angle complete-length current-depth max-depth) (cond ((< current-depth max-depth) (let* ((length (/ complete-length 2)) (x2 (+ x1 (* (cos (deg2rad angle)) length))) (y2 (+ y1 (* (sin (deg2rad angle)) length)))) (draw-line (inexact->exact x1) (inexact->exact y1) (inexact->exact x2) (inexact->exact y2)) (draw-star-helper x2 y2 (- angle 15) (- complete-length length) (1+ current-depth) max-depth) )))) (define (draw-star x1 y1 angle length max-depth) (draw-star-helper x1 y1 angle length 0 max-depth)) (init-screen 640 480) (set-fg-color #x000000) (set-bg-color #xFFFFFF) (draw-line 0 0 640 480) (draw-line 640 0 0 480) (draw-star 20 400 0 500 100) (rec-draw-line 10 400 630 400 0 3) (while #t (next-event)) ;; EOF ;;