Skip to content

Instantly share code, notes, and snippets.

@apeace
Created May 25, 2014 01:17
Show Gist options
  • Save apeace/b458c7e3e0cc3205622a to your computer and use it in GitHub Desktop.
Save apeace/b458c7e3e0cc3205622a to your computer and use it in GitHub Desktop.
#lang racket
(require 2htdp/universe)
(require 2htdp/image)
;; diagonal overlayed circles
(overlay/offset
(overlay/offset (circle 30 'solid (color 185 26 217 175))
82 82
(circle 30 'solid (color 242 84 247 175)))
0 0
(circle 30 'solid (color 0 0 230 175)))
;; straight line of overlayed circles
(overlay/offset
(overlay/offset (circle 30 'solid (color 185 26 217 175))
90 0
(circle 30 'solid (color 242 84 247 175)))
0 0
(circle 30 'solid (color 0 0 230 175)))
;; a rotated hexagon
(define my-hexagon (regular-polygon 60 6 'solid (color 185 26 217 175)))
(rotate 45 my-hexagon)
(rotate 50 my-hexagon)
;; plain stars
(define (make-star rotation color) (rotate rotation (star-polygon 100 5 2 'solid color)))
(define red-star (make-star 0 'red))
(define blue-star (make-star 36 'blue))
(define black-star (make-star 18 'black))
(define black-star2 (make-star -18 'black))
red-star
blue-star
;; star overlay pattern
(define star-pattern (overlay red-star blue-star black-star black-star2))
star-pattern
;; eye
(define width 100)
(define height 100)
(define bg (rectangle width width 'solid 'black))
(define baseline 40)
(define x1 (/ width 10))
(define y1 (- (- height baseline) (/ height 10)))
(define x2 (- width (/ width 10)))
(define y2 (- (- height baseline) (/ height 10)))
(define (place-curve img rotation)
(add-curve (rotate rotation img)
x1 y1 45 .5
x2 y2 -45 .5
'white))
(add-line (place-curve bg 0) x1 y1 x2 y2 'white)
;; animated star pattern
(define animation-bg (rectangle 300 300 'solid 'white))
(define (create-scene-img tick)
(overlay/align 'middle
'middle
(rotate (+ 1 (remainder tick 359)) star-pattern)
animation-bg))
(animate create-scene-img)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment