PasteRack.org
Paste # 39584
2017-10-13 18:45:50

Forked from paste # 65553.

Fork as a new paste.

Paste viewed 123 times.


Embed:

  1. #lang racket
  2. (require pict racket/draw)
  3. (define (happy-eyes width height [boldness 0.1])
  4.   ;; More boldness = less height for the smaller ellipse.
  5.   (define height-percent (- 1 boldness))
  6.   (unless (< 0 boldness 1)
  7.           (error 'happy-eyes "Boldness must be between 0 and 1 exclusive"))
  8.  (dc (lambda (dc dx dy)
  9.       (define old-brush (send dc get-brush))
  10.       (send dc set-brush
  11.         (send the-brush-list find-or-create-brush
  12.                               "black"
  13.                           'solid))
  14.       (define eye-path (new dc-path%))
  15.         (send eye-path arc 0 0 width height 0 pi)
  16.       (send eye-path arc 0 (* height boldness)
  17.             width (* height height-percent) pi 0 #f)
  18.       (send eye-path close)
  19.       (send dc draw-path eye-path dx dy)
  20.       (send dc set-brush old-brush))
  21.      width height))
  22.  
  23. (for/list ([boldness (in-range 0.1 1 0.1)])
  24.           (cc-superimpose (rectangle 200 200) (happy-eyes 50 80 boldness)))

=>

'(image image image image image image image image image image)