Skip to content

Instantly share code, notes, and snippets.

@msafadieh
Last active March 14, 2019 22:53
Show Gist options
  • Save msafadieh/1308d4c41957e00b82a83224396152a7 to your computer and use it in GitHub Desktop.
Save msafadieh/1308d4c41957e00b82a83224396152a7 to your computer and use it in GitHub Desktop.
cool racket graphics
#lang racket
(require 2htdp/image)
(require 2htdp/universe)
(define (polygons n)
(let* ([random-color (lambda () (color (random 255) (random 255) (random 255)))]
[random-polygon (lambda (x) (star-polygon (* (add1 x) 30) (random 12 16) 11 'solid (random-color)))]
[polygons-list (build-list n random-polygon)]
[background (square (* 150 n) 'solid (random-color))])
(foldr overlay background polygons-list)))
(big-bang 5
[name "Stars"]
[to-draw polygons]
[on-tick identity 0.5])
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment