changeset 124:6dae98ac9af4

Better way to draw borders.
author Mikhail Kryshen <mikhail@kryshen.net>
date Fri, 06 Apr 2012 20:49:21 +0400
parents 7b22c6d585f4
children 11f2030257f9
files src/net/kryshen/indyvon/layers.clj
diffstat 1 files changed, 16 insertions(+), 16 deletions(-) [+]
line diff
     1.1 --- a/src/net/kryshen/indyvon/layers.clj	Fri Apr 06 20:48:30 2012 +0400
     1.2 +++ b/src/net/kryshen/indyvon/layers.clj	Fri Apr 06 20:49:21 2012 +0400
     1.3 @@ -25,7 +25,8 @@
     1.4     (java.lang.ref SoftReference)
     1.5     (java.awt Font Cursor Image Toolkit Point)
     1.6     java.awt.image.ImageObserver
     1.7 -   (java.awt.geom AffineTransform Point2D$Double)
     1.8 +   (java.awt.geom AffineTransform Rectangle2D$Double Point2D$Double
     1.9 +                  Path2D Path2D$Double)
    1.10     (java.awt.font FontRenderContext TextLayout)
    1.11     java.util.concurrent.TimeUnit
    1.12     (com.google.common.cache Cache CacheBuilder CacheLoader)))
    1.13 @@ -83,22 +84,21 @@
    1.14    "Decorate layer with a border."
    1.15    ([content]
    1.16       (border content 1))
    1.17 -  ([content width]
    1.18 -     (border content width 0))
    1.19 -  ([content width gap]
    1.20 -     (let [layer (padding content (+ width gap))]
    1.21 +  ([content thikness]
    1.22 +     (border content thikness 0))
    1.23 +  ([content thikness gap]
    1.24 +     (let [layer (padding content (+ thikness gap))
    1.25 +           t (double thikness)]
    1.26         (decorate-layer layer [_]
    1.27 -         (let [bw (int width)
    1.28 -               w (int *width*)
    1.29 -               h (int *height*)
    1.30 -               iw (- w bw)
    1.31 -               ih (- h bw)]
    1.32 -           (with-color :border-color
    1.33 -             (doto *graphics*
    1.34 -               (.fillRect 0 0 iw bw)
    1.35 -               (.fillRect iw 0 bw ih)
    1.36 -               (.fillRect bw ih iw bw)
    1.37 -               (.fillRect 0 bw bw ih))))
    1.38 +         (with-color :border-color
    1.39 +           (let [w (double *width*)
    1.40 +                 h (double *height*)
    1.41 +                 outer (Rectangle2D$Double. 0.0 0.0 w h)
    1.42 +                 inner (Rectangle2D$Double. t t (- w t t) (- h t t))]
    1.43 +             (.fill *graphics*
    1.44 +                    (doto (Path2D$Double. Path2D/WIND_EVEN_ODD)
    1.45 +                      (.append outer false)
    1.46 +                      (.append inner false)))))
    1.47           (render! layer)))))
    1.48  
    1.49  ;; TODO: opacity and blur.