sierpinski.scm 490 B

1234567891011121314151617
  1. (add-to-load-path (dirname (dirname (current-filename))))
  2. (use-modules (basket))
  3. (define (sierpinski x y z n)
  4. (if (= n 0)
  5. `((,x ,y ,z))
  6. (append
  7. (sierpinski x (vec-midpoint x y) (vec-midpoint x z) (1- n))
  8. (sierpinski y (vec-midpoint y x) (vec-midpoint y z) (1- n))
  9. (sierpinski z (vec-midpoint z x) (vec-midpoint z y) (1- n)))))
  10. (define image
  11. `(fill
  12. ,(sierpinski '(0.5 . 0) '(0 . 1) '(1 . 1) 8)))
  13. (render-cairo-png image 1024 (cadr (program-arguments)))