PasteRack.org
Paste # 93557
2017-05-22 18:17:39

Fork as a new paste.

Paste viewed 118 times.


Embed:

winny: rounded rectangles

  1. #lang racket
  2.  
  3. (define (thick-filled-rounded-rectangle w h [corner-radius -0.25]
  4.                                         #:color [color "black"]
  5.                                         #:style [style 'solid]
  6.                                         #:angle [angle 0]
  7.                                         #:border-width [border-width 1]
  8.                                         #:border-color [border-color #f]
  9.                                         #:border-style [border-style 'solid])
  10.     (let ([dc-path (new dc-path%)])
  11.       (send dc-path rounded-rectangle 0 0 w h corner-radius)
  12.       (send dc-path rotate angle)
  13.       (let-values ([(x y w h) (send dc-path get-bounding-box)])
  14.         (dc (λ (dc dx dy)
  15.               (with-save* dc ([get-brush set-brush
  16.                                          (send the-brush-list find-or-create-brush color style)]
  17.                               [get-pen set-pen #:when border-color
  18.                                        (send the-pen-list find-or-create-pen
  19.                                              border-color
  20.                                              border-width border-style)])
  21.                 (send dc draw-path dc-path (- dx x) (- dy y))))
  22.             w h))))

=>