chapter.4.scm 883 B

123456789101112131415161718192021222324252627282930313233343536373839
  1. (import (scheme base)
  2. (turtle simple))
  3. (define (scissor dist phase)
  4. (right phase)
  5. (forward dist)
  6. (left (* 2 phase))
  7. (forward dist)
  8. (right phase))
  9. (define (scissor-poly d a phase)
  10. (let loop ((total-turning 0))
  11. (unless (and (positive? total-turning)
  12. (zero? (modulo total-turning 360)))
  13. (scissor d phase)
  14. (left a)
  15. (loop (+ total-turning a)))))
  16. (define (deform-scissor-poly d a phasechange)
  17. (let loop ((phase 0))
  18. (clear-screen)
  19. (scissor-poly d a phase)
  20. (loop (+ phase phasechange))))
  21. (define (crazy-scissor-poly d a local-phasechange)
  22. (define local-phase 0)
  23. (repeat (10)
  24. (scissor d (modulo local-phase 360))
  25. (left a)
  26. (set! local-phase (+ local-phase local-phasechange))))
  27. (define (main)
  28. ;(deform-scissor-poly 100 144 20)
  29. (set-pos 0 0)
  30. (clear-screen)
  31. (crazy-scissor-poly 100 150 50))