scale.scm 869 B

12345678910111213141516171819202122232425
  1. (add-to-load-path (dirname (dirname (current-filename))))
  2. (use-modules (basket)
  3. (srfi srfi-1))
  4. (define (random-triangle center radius)
  5. (map (lambda (x)
  6. (vec-add center
  7. (vec-rotate (make-vec radius 0)
  8. (+ (* x (/ tau 3))
  9. (* (random:uniform) (/ tau 3))))))
  10. (iota 3)))
  11. (define (draw-around center radius)
  12. (let ((triangle (random-triangle center radius))
  13. (rect (list (vec-sub center (make-vec radius radius))
  14. (vec-add center (make-vec radius radius)))))
  15. (map (lambda (x) (poly->path (poly-scale triangle x))) (iota 9 0 1/8))))
  16. (define image
  17. `(stroke
  18. ,(map (lambda (v) (draw-around v 1/8))
  19. (concatenate (rect->vecss '((1/8 . 1/8) (7/8 . 7/8)) 4)))))
  20. (render-cairo-png image 1024 (cadr (program-arguments)))