Fixed error in flomap gradient calculation (borders were always getting 0.0, causing erroneous lighting)

Inset rendered deep-flomaps by 1px to harden against future border issues

Adjusted scatter-simulating blur (finally rid of edge sparklies!)

Added portable hash-quote-icon, stopwatch-icon

Vertical toolbar macro stepper icon now discernable

Updated Performance Report toolbar icon

Updated FrTime loading icon

Closes PR 12422

Please merge into release
This commit is contained in:
Neil Toronto 2012-01-19 21:31:00 -07:00
parent 484803a896
commit b8e3e8a04b
13 changed files with 273 additions and 176 deletions

Binary file not shown.

Before

Width:  |  Height:  |  Size: 2.6 KiB

After

Width:  |  Height:  |  Size: 2.5 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 2.6 KiB

After

Width:  |  Height:  |  Size: 2.5 KiB

View File

@ -18,7 +18,8 @@
left-magnifying-glass-icon left-magnifying-glass-flomap left-magnifying-glass-icon left-magnifying-glass-flomap
bomb-icon bomb-flomap bomb-icon bomb-flomap
left-bomb-icon left-bomb-flomap left-bomb-icon left-bomb-flomap
clock-icon clock-flomap) clock-icon clock-flomap
stopwatch-icon stopwatch-flomap)
(only-doc-out (all-defined-out))) (only-doc-out (all-defined-out)))
(define (flat-regular-polygon-flomap sides start color size) (define (flat-regular-polygon-flomap sides start color size)
@ -266,63 +267,110 @@
[face-color (or/c string? (is-a?/c color%)) light-metal-icon-color] [face-color (or/c string? (is-a?/c color%)) light-metal-icon-color]
[hand-color (or/c string? (is-a?/c color%)) "firebrick"] [hand-color (or/c string? (is-a?/c color%)) "firebrick"]
[hours (integer-in 0 11) 1] [hours (integer-in 0 11) 1]
[minutes (real-in 0 60) 33]) flomap? [minutes (real-in 0 60) 47]) flomap?
(make-cached-flomap (make-cached-flomap
[height face-color hand-color hours minutes] [height face-color hand-color hours minutes]
(define R 12) (define R 13)
(define hour-θ (* (+ (- hours 3) (/ minutes 60)) (/ (* 2 pi) 12))) (define hour-θ (* (+ (- hours 3) (/ minutes 60)) (/ (* 2 pi) 12)))
(define minute-θ (* (- minutes 15) (/ (* 2 pi) 60))) (define minute-θ (* (- minutes 15) (/ (* 2 pi) 60)))
(define 60-degrees (* 60 (/ (* 2 pi) 180))) (define scale (/ height 32))
(define scale (/ height 32)) (define face-fm
(flomap-cc-superimpose
;; face and ticks
(draw-icon-flomap
32 32 (λ (dc)
(set-icon-pen dc (icon-color->outline-color (icon-color->outline-color face-color))
1 'solid)
(send dc set-brush face-color 'solid)
(draw-ellipse/smoothed dc 0 0 32 32)
(set-icon-pen dc "black" 1 'solid)
(for ([θ (in-range 0 (* 2 pi) (* 1/30 pi))]
[r (in-cycle (list 1.5 .5 .5 .5 .5
1.0 .5 .5 .5 .5
1.0 .5 .5 .5 .5))]
[t (in-cycle (list 1.0 .25 .25 .25 .25
.75 .25 .25 .25 .25
.75 .25 .25 .25 .25))])
(set-icon-pen dc "black" t 'solid)
(send dc draw-line
(+ 15.5 (* (- R r) (cos θ)))
(+ 15.5 (* (- R r) (sin θ)))
(+ 15.5 (* R (cos θ)))
(+ 15.5 (* R (sin θ))))))
scale)
(fm* 0.25 (lambda-flomap face-color (* 1/2 height) glass-icon-material))
(draw-rendered-icon-flomap
32 32 (λ (dc)
(set-icon-pen dc (icon-color->outline-color hand-color) 1/2 'solid)
(send dc set-brush hand-color 'solid)
;; minute hand
(send dc draw-polygon
(list (cons (+ 15.5 (* R (cos minute-θ)))
(+ 15.5 (* R (sin minute-θ))))
(cons (+ 15.5 (* 1 (cos (+ minute-θ (* 1/2 pi)))))
(+ 15.5 (* 1 (sin (+ minute-θ (* 1/2 pi))))))
(cons (+ 15.5 (* 1 (cos (+ minute-θ pi))))
(+ 15.5 (* 1 (sin (+ minute-θ pi)))))
(cons (+ 15.5 (* 1 (cos (+ minute-θ (* 3/2 pi)))))
(+ 15.5 (* 1 (sin (+ minute-θ (* 3/2 pi)))))))))
scale
metal-icon-material)
;; hands
(draw-rendered-icon-flomap
32 32 (λ (dc)
(set-icon-pen dc (icon-color->outline-color hand-color) 1/2 'solid)
(send dc set-brush hand-color 'solid)
;; hour hand
(send dc draw-polygon
(list (cons (+ 15.5 (* (- R 5) (cos hour-θ)))
(+ 15.5 (* (- R 5) (sin hour-θ))))
(cons (+ 15.5 (* 1.25 (cos (+ hour-θ (* 1/2 pi)))))
(+ 15.5 (* 1.25 (sin (+ hour-θ (* 1/2 pi))))))
(cons (+ 15.5 (* 1.25 (cos (+ hour-θ pi))))
(+ 15.5 (* 1.25 (sin (+ hour-θ pi)))))
(cons (+ 15.5 (* 1.25 (cos (+ hour-θ (* 3/2 pi)))))
(+ 15.5 (* 1.25 (sin (+ hour-θ (* 3/2 pi)))))))))
scale
metal-icon-material)))
(define face-fm (define shell-fm
(draw-icon-flomap (draw-icon-flomap
32 32 (λ (dc) 32 32 (λ (dc)
;; face (set-icon-pen dc "white" 1 'solid)
(set-icon-pen dc (icon-color->outline-color face-color) 1 'solid) (send dc set-brush "white" 'solid)
(send dc set-brush face-color 'solid) (draw-ellipse/smoothed dc 1 1 30 30))
(draw-ellipse/smoothed dc 0 0 32 32) scale))
;; ticks
(let* ([dfm (flomap->deep-flomap shell-fm)]
[dfm (deep-flomap-bulge-spheroid dfm (* 6 scale))]
[dfm (deep-flomap-raise dfm (* -2 scale))]
[dfm (deep-flomap-smooth-z dfm (* 1/3 scale))])
(flomap-cc-superimpose
face-fm
(deep-flomap-render-icon dfm clock-shell-material face-fm)))))
(defproc (stopwatch-flomap [height (and/c rational? (>=/c 0)) (default-icon-height)]
[face-color (or/c string? (is-a?/c color%)) light-metal-icon-color]
[hand-color (or/c string? (is-a?/c color%)) "firebrick"]
[hours (integer-in 0 11) 0]
[minutes (real-in 0 60) 47]) flomap?
(make-cached-flomap
[height face-color hand-color hours minutes]
(define clock-fm (clock-flomap (* 30/32 height) face-color hand-color hours minutes))
(define buttons-fm
(draw-rendered-icon-flomap
32 8 (λ (dc)
(set-icon-pen dc (make-object color% 128 0 0) 1 'solid)
(send dc set-brush (make-object color% 144 0 0) 'solid)
(send dc draw-polygon '((2 . 4) (4 . 2) (15.5 . 15.5)))
(send dc draw-polygon '((0 . 5) (5 . 0) (6 . 1) (1 . 6)))
(set-icon-pen dc "black" 1 'solid) (set-icon-pen dc "black" 1 'solid)
(for ([θ (in-range 0 (* 2 pi) (* 1/6 pi))] (send dc set-brush (make-object color% 16 16 16) 'solid)
[i (in-cycle (in-range 0 3))]) (send dc draw-polygon '((28 . 5) (26 . 3) (15.5 . 15.5)))
(define r (if (= i 0) 2 1)) (send dc draw-polygon '((31 . 5) (26 . 0) (24.5 . 1.5) (29.5 . 6.5))))
(send dc draw-line (/ height 32)
(+ 15.5 (* (- R r) (cos θ))) metal-icon-material))
(+ 15.5 (* (- R r) (sin θ))) (flomap-pin* 1/2 0 1/2 -2/32 buttons-fm clock-fm)))
(+ 15.5 (* R (cos θ)))
(+ 15.5 (* R (sin θ)))))
(set-icon-pen dc (icon-color->outline-color hand-color) 1/2 'solid)
(send dc set-brush hand-color 'solid)
;; minute hand
(send dc draw-polygon
(list (cons (+ 15.5 (* R (cos minute-θ)))
(+ 15.5 (* R (sin minute-θ))))
(cons (+ 15.5 (* 1.5 (cos (+ minute-θ 60-degrees))))
(+ 15.5 (* 1.5 (sin (+ minute-θ 60-degrees)))))
(cons (+ 15.5 (* 1.5 (cos (- minute-θ 60-degrees))))
(+ 15.5 (* 1.5 (sin (- minute-θ 60-degrees)))))))
;; hour hand
(send dc draw-polygon
(list (cons (+ 15.5 (* (- R 4) (cos hour-θ)))
(+ 15.5 (* (- R 4) (sin hour-θ))))
(cons (+ 15.5 (* 1.5 (cos (+ hour-θ 60-degrees))))
(+ 15.5 (* 1.5 (sin (+ hour-θ 60-degrees)))))
(cons (+ 15.5 (* 1.5 (cos (- hour-θ 60-degrees))))
(+ 15.5 (* 1.5 (sin (- hour-θ 60-degrees))))))))
scale))
(define shell-fm
(draw-icon-flomap
32 32 (λ (dc)
(set-icon-pen dc (icon-color->outline-color "white") 1 'solid)
(send dc set-brush "white" 'solid)
(draw-ellipse/smoothed dc 0 0 32 32))
scale))
(let* ([dfm (flomap->deep-flomap shell-fm)]
[dfm (deep-flomap-bulge-spheroid dfm (* 8 scale))])
(deep-flomap-render-icon dfm clock-shell-material face-fm))))
;; =================================================================================================== ;; ===================================================================================================
;; Bitmaps (icons) ;; Bitmaps (icons)
@ -335,12 +383,14 @@
) (is-a?/c bitmap%) ) (is-a?/c bitmap%)
(flomap->bitmap (regular-polygon-flomap sides start color height material))) (flomap->bitmap (regular-polygon-flomap sides start color height material)))
(defproc (clock-icon [height (and/c rational? (>=/c 0)) (default-icon-height)] (define-icon-wrappers
[face-color (or/c string? (is-a?/c color%)) light-metal-icon-color] ([height (and/c rational? (>=/c 0)) (default-icon-height)]
[hand-color (or/c string? (is-a?/c color%)) "firebrick"] [face-color (or/c string? (is-a?/c color%)) light-metal-icon-color]
[hours (integer-in 0 11) 1] [hand-color (or/c string? (is-a?/c color%)) "firebrick"]
[minutes (real-in 0 60) 33]) (is-a?/c bitmap%) [hours (integer-in 0 11) 0]
(flomap->bitmap (clock-flomap height face-color hand-color hours minutes))) [minutes (real-in 0 60) 47])
[clock-icon clock-flomap]
[stopwatch-icon stopwatch-flomap])
(define-icon-wrappers (define-icon-wrappers
([color (or/c string? (is-a?/c color%))] ([color (or/c string? (is-a?/c color%))]

View File

@ -72,8 +72,9 @@
) (is-a?/c bitmap%) ) (is-a?/c bitmap%)
(let* ([fm (bitmap->flomap bitmap)] (let* ([fm (bitmap->flomap bitmap)]
[dfm (flomap->deep-flomap fm)] [dfm (flomap->deep-flomap fm)]
[dfm (deep-flomap-icon-style dfm (* 32 z-ratio))]) [dfm (deep-flomap-icon-style dfm (* 32 z-ratio))]
(flomap->bitmap (deep-flomap-render-icon dfm material)))) [fm (deep-flomap-render-icon dfm material)])
(flomap->bitmap fm)))
(defproc (icon-color->outline-color [color (or/c string? (is-a?/c color%))]) (is-a?/c color%) (defproc (icon-color->outline-color [color (or/c string? (is-a?/c color%))]) (is-a?/c color%)
(cond [(string? color) (icon-color->outline-color (send the-color-database find-color color))] (cond [(string? color) (icon-color->outline-color (send the-color-database find-color color))]
@ -120,7 +121,8 @@
(define s (/ (deep-flomap-height dfm) 32)) (define s (/ (deep-flomap-height dfm) 32))
(let* ([dfm (deep-flomap-emboss dfm (* s 2) (* s 2))] (let* ([dfm (deep-flomap-emboss dfm (* s 2) (* s 2))]
[dfm (deep-flomap-bulge-round dfm (* s 6))] [dfm (deep-flomap-bulge-round dfm (* s 6))]
[dfm (deep-flomap-raise dfm (* s height))]) [dfm (deep-flomap-raise dfm (* s height))]
[dfm (deep-flomap-smooth-z dfm 1/3)])
dfm)) dfm))
(define (draw-icon-flomap w h draw-proc scale) (define (draw-icon-flomap w h draw-proc scale)

View File

@ -13,7 +13,8 @@
recycle-icon recycle-flomap recycle-icon recycle-flomap
x-icon x-flomap x-icon x-flomap
check-icon check-flomap check-icon check-flomap
lambda-icon lambda-flomap) lambda-icon lambda-flomap
hash-quote-icon hash-quote-flomap)
(only-doc-out (all-defined-out))) (only-doc-out (all-defined-out)))
(define (flat-x-flomap color height) (define (flat-x-flomap color height)
@ -238,6 +239,35 @@
(/ height 32) (/ height 32)
material))) material)))
(defproc (hash-quote-flomap [color (or/c string? (is-a?/c color%))]
[height (and/c rational? (>=/c 0)) (default-icon-height)]
[material deep-flomap-material-value? (default-icon-material)]) flomap?
(make-cached-flomap
[height color material]
(define (draw-hash-quote dc)
;; vertical lines
(send dc draw-polygon '((6 . 0) (11 . 0) (9 . 30) (4 . 30)))
(send dc draw-polygon '((17 . 0) (22 . 0) (20 . 30) (15 . 30)))
;; horizontal lines
(send dc draw-polygon '((1 . 6.5) (26 . 6.5) (26 . 11.5) (1 . 11.5)))
(send dc draw-polygon '((0 . 18.5) (25 . 18.5) (25 . 23.5) (0 . 23.5)))
;; quote
(send dc draw-polygon '((30 . 0) (34 . 0) (33 . 9) (30 . 9))))
(define outline-color (icon-color->outline-color color))
(draw-rendered-icon-flomap
36 32 (λ (dc)
(send dc translate 0.5 0.5)
(set-icon-pen dc outline-color 2 'solid)
(send dc set-brush outline-color 'solid)
(draw-hash-quote dc)
(send dc set-pen "black" 1 'transparent)
(send dc set-brush color 'solid)
(draw-hash-quote dc))
(/ height 32)
material)))
;; =================================================================================================== ;; ===================================================================================================
;; Bitmaps (icons) ;; Bitmaps (icons)
@ -257,4 +287,5 @@
[recycle-icon recycle-flomap] [recycle-icon recycle-flomap]
[x-icon x-flomap] [x-icon x-flomap]
[check-icon check-flomap] [check-icon check-flomap]
[lambda-icon lambda-flomap]) [lambda-icon lambda-flomap]
[hash-quote-icon hash-quote-flomap])

View File

@ -24,10 +24,12 @@
(defthing debugger-bomb-color (or/c string? (is-a?/c color%)) #:document-value (defthing debugger-bomb-color (or/c string? (is-a?/c color%)) #:document-value
(make-object color% 128 32 32)) (make-object color% 128 32 32))
;; Actual color is too dark after rendering ;; Actual color is too dark after rendering
;(define macro-stepper-hash-color (make-object color% 30 96 30))
(defthing macro-stepper-hash-color (or/c string? (is-a?/c color%)) #:document-value (defthing macro-stepper-hash-color (or/c string? (is-a?/c color%)) #:document-value
(make-object color% 90 192 90)) (make-object color% 60 192 60))
(defthing small-macro-stepper-hash-color (or/c string? (is-a?/c color%)) #:document-value
(make-object color% 128 255 128))
(defproc (check-syntax-flomap [height (and/c rational? (>=/c 0)) (toolbar-icon-height)] (defproc (check-syntax-flomap [height (and/c rational? (>=/c 0)) (toolbar-icon-height)]
[material deep-flomap-material-value? (default-icon-material)] [material deep-flomap-material-value? (default-icon-material)]
@ -49,8 +51,7 @@
[material deep-flomap-material-value? (default-icon-material)] [material deep-flomap-material-value? (default-icon-material)]
) flomap? ) flomap?
(flomap-ht-append (flomap-ht-append
(text-flomap "#'" (make-object font% (max 1 (min 1024 height)) 'system) (hash-quote-flomap macro-stepper-hash-color height material)
macro-stepper-hash-color #t 'auto height material)
(make-flomap 4 (max 1 (inexact->exact (round (* 1/32 height)))) 0) (make-flomap 4 (max 1 (inexact->exact (round (* 1/32 height)))) 0)
(step-flomap syntax-icon-color height material))) (step-flomap syntax-icon-color height material)))
@ -60,8 +61,7 @@
(flomap-pin* (flomap-pin*
0 0 7/16 0 0 0 7/16 0
(step-flomap syntax-icon-color height material) (step-flomap syntax-icon-color height material)
(text-flomap "#'" (make-object font% (max 1 (min 1024 height)) 'system) (hash-quote-flomap small-macro-stepper-hash-color (* 3/4 height) material)))
macro-stepper-hash-color #t 'auto (* 3/4 height) material)))
(defproc (debugger-flomap [height (and/c rational? (>=/c 0)) (toolbar-icon-height)] (defproc (debugger-flomap [height (and/c rational? (>=/c 0)) (toolbar-icon-height)]
[material deep-flomap-material-value? (default-icon-material)] [material deep-flomap-material-value? (default-icon-material)]

View File

@ -298,33 +298,10 @@
(lambda-flomap light-metal-icon-color (* 5/8 height) metal-icon-material))) (lambda-flomap light-metal-icon-color (* 5/8 height) metal-icon-material)))
(defproc (macro-stepper-logo-flomap [height (and/c rational? (>=/c 0)) 96]) flomap? (defproc (macro-stepper-logo-flomap [height (and/c rational? (>=/c 0)) 96]) flomap?
(define outline-color (icon-color->outline-color light-metal-icon-color))
(define (draw-hash-quote dc)
;; vertical lines
(send dc draw-polygon '((5 . 0) (8 . 0) (6 . 19) (3 . 19)))
(send dc draw-polygon '((12 . 0) (15 . 0) (13 . 19) (10 . 19)))
;; horizontal lines
(send dc draw-polygon '((1 . 4) (1 . 7) (18 . 7) (18 . 4)))
(send dc draw-polygon '((0 . 12) (0 . 15) (17 . 15) (17 . 12)))
;; quote
(send dc draw-polygon '((20 . 0) (23 . 0) (22.75 . 6) (20.25 . 6)))
)
(flomap-pin* (flomap-pin*
1/2 20/32 1/2 1/2 1/2 20/32 15/36 1/2
(foot-flomap (make-object color% 34 42 160) height glass-icon-material) (foot-flomap (make-object color% 34 42 160) height glass-icon-material)
(draw-rendered-icon-flomap (hash-quote-flomap light-metal-icon-color (* 1/2 height) metal-icon-material)))
32 32 (λ (dc)
(send dc translate 5 6)
(set-icon-pen dc outline-color 2 'solid)
(send dc set-brush outline-color 'solid)
(draw-hash-quote dc)
(send dc set-pen "black" 1 'transparent)
(send dc set-brush light-metal-icon-color 'solid)
(draw-hash-quote dc))
(/ (* 3/4 height) 32)
metal-icon-material)))
(define-icon-wrappers (define-icon-wrappers
([height (and/c rational? (>=/c 0)) 256]) ([height (and/c rational? (>=/c 0)) 256])

View File

@ -69,11 +69,13 @@
;; =================================================================================================== ;; ===================================================================================================
;; Pass 1: tracing from a directional light source ;; Pass 1: tracing from a directional light source
(: trace-directional-light (flomap flomap flomap flomap Integer Integer Integer Integer (: trace-directional-light (flomap flomap flomap flomap
-> (values flomap flomap))) Integer Integer Integer Integer -> (values flomap flomap)))
(define (trace-directional-light alpha-fm rgb-fm z-fm normal-fm x-min x-max y-min y-max) (define (trace-directional-light alpha-fm rgb-fm z-fm normal-fm
x-min x-max y-min y-max)
(match-define (flomap alpha-vs 1 w h) alpha-fm) (match-define (flomap alpha-vs 1 w h) alpha-fm)
(match-define (list rgb-vs z-vs normal-vs) (map flomap-values (list rgb-fm z-fm normal-fm))) (match-define (list rgb-vs z-vs normal-vs)
(map flomap-values (list rgb-fm z-fm normal-fm)))
(define z-max (flomap-max-value z-fm)) (define z-max (flomap-max-value z-fm))
(define opacity-z (/ z-max (transmission-density))) (define opacity-z (/ z-max (transmission-density)))
@ -111,8 +113,12 @@
(define diffuse-fm (make-flomap 3 w h lz)) (define diffuse-fm (make-flomap 3 w h lz))
(define diffuse-vs (flomap-values diffuse-fm)) (define diffuse-vs (flomap-values diffuse-fm))
(define sx-vs (make-flvector (* w h) +nan.0)) ;(define sx-vs (make-flvector (* w h) +nan.0))
(define sy-vs (make-flvector (* w h) +nan.0)) ;(define sy-vs (make-flvector (* w h) +nan.0))
(define sx-fm (inline-build-flomap 1 w h (λ (k x y i) (+ (fx->fl x) 0.5))))
(define sy-fm (inline-build-flomap 1 w h (λ (k x y i) (+ (fx->fl y) 0.5))))
(define sx-vs (flomap-values sx-fm))
(define sy-vs (flomap-values sy-fm))
(define Irgb-vs (make-flvector (* 3 w h))) (define Irgb-vs (make-flvector (* 3 w h)))
(for*: ([int-y : Integer (in-range y-min y-max)] (for*: ([int-y : Integer (in-range y-min y-max)]
@ -330,9 +336,10 @@
;; =================================================================================================== ;; ===================================================================================================
;; Pass 2: tracing from a directional viewer ;; Pass 2: tracing from a directional viewer
(: trace-directional-view (flomap flomap flomap flomap flomap Integer Integer Integer Integer (: trace-directional-view (flomap flomap flomap flomap flomap
-> (values flomap flomap))) Integer Integer Integer Integer -> (values flomap flomap)))
(define (trace-directional-view alpha-fm rgb-fm z-fm normal-fm shadow-fm x-min x-max y-min y-max) (define (trace-directional-view alpha-fm rgb-fm z-fm normal-fm shadow-fm
x-min x-max y-min y-max)
(define-values (w h) (flomap-size alpha-fm)) (define-values (w h) (flomap-size alpha-fm))
(match-define (list alpha-vs rgb-vs z-vs normal-vs shadow-vs) (match-define (list alpha-vs rgb-vs z-vs normal-vs shadow-vs)
(map flomap-values (list alpha-fm rgb-fm z-fm normal-fm shadow-fm))) (map flomap-values (list alpha-fm rgb-fm z-fm normal-fm shadow-fm)))
@ -407,7 +414,10 @@
(unsafe-flvector-set! reflected-vs (fx+ j 2) b)))) (unsafe-flvector-set! reflected-vs (fx+ j 2) b))))
;; transmission (refraction) ;; transmission (refraction)
(when (Ti . > . 0.0) (when (Ti . > . 0.0)
(define-values (tx ty tz) (transmitted-vector nx ny nz 0.0 0.0 -1.0 1.0 η2)) (define snx (unsafe-flvector-ref normal-vs j))
(define sny (unsafe-flvector-ref normal-vs (fx+ j 1)))
(define snz (unsafe-flvector-ref normal-vs (fx+ j 2)))
(define-values (tx ty tz) (transmitted-vector snx sny snz 0.0 0.0 -1.0 1.0 η2))
;; sz = z + dist * tz, so dist = (sz - z) / tz ;; sz = z + dist * tz, so dist = (sz - z) / tz
(define dist (/ (- 0.0 z) tz)) (define dist (/ (- 0.0 z) tz))
(when (and (dist . >= . 0.0) (dist . < . +inf.0)) (when (and (dist . >= . 0.0) (dist . < . +inf.0))
@ -456,38 +466,43 @@
(case-lambda (case-lambda
[(dfm) (deep-flomap-render dfm #f)] [(dfm) (deep-flomap-render dfm #f)]
[(dfm background-fm) [(dfm background-fm)
(define-values (w h) (deep-flomap-size dfm)) (let ([dfm (deep-flomap-inset dfm 1)])
(define argb-fm (flomap-divide-alpha (deep-flomap-argb dfm))) (define-values (w h) (deep-flomap-size dfm))
(define alpha-fm (flomap-ref-component argb-fm 0)) (define argb-fm (flomap-divide-alpha (deep-flomap-argb dfm)))
(define rgb-fm (flomap-drop-components argb-fm 1)) (define alpha-fm (flomap-ref-component argb-fm 0))
(define z-fm (fmmax 0.0 (deep-flomap-z dfm))) (define rgb-fm (flomap-drop-components argb-fm 1))
(define normal-fm (flomap-gradient-normal z-fm)) (define z-fm (fmmax 0.0 (deep-flomap-z dfm)))
(define bg-fm (if background-fm (prep-background background-fm w h) #f)) (define normal-fm (flomap-gradient-normal z-fm))
(define-values (_1 x-min y-min _2 x-max y-max) (flomap-nonzero-rect alpha-fm)) (define bg-fm (if background-fm (prep-background background-fm w h) #f))
(define-values (x-min y-min x-max y-max)
(let-values ([(_1 x-min y-min _2 x-max y-max) (flomap-nonzero-rect alpha-fm)])
(values (max 0 (- x-min 1)) (max 0 (- y-min 1))
(min w (+ x-max 1)) (min h (+ y-max 1)))))
;; pass 1: trace from the light source ;; pass 1: trace from the light source
(define-values (diffracted-fm raw-shadow-fm) (define-values (diffracted-fm raw-shadow-fm)
(trace-directional-light alpha-fm rgb-fm z-fm normal-fm x-min x-max y-min y-max)) (trace-directional-light alpha-fm rgb-fm z-fm normal-fm x-min x-max y-min y-max))
;; blur the shadow to simulate internal scatter ;; two Gaussian blurs by half of σ^2 is equivalent to one Gaussian blur by σ^2
(define σ (* (min w h) (shadow-blur))) (define σ^2 (sqr (* (min w h) (shadow-blur))))
(define shadow-fm
(cond [bg-fm
;; two Gaussian blurs by half-σ is equivalent to one Gaussian blur by σ
(define half-σ (* (/ 1 (sqrt 2)) σ))
(let* ([fm (flomap-blur raw-shadow-fm half-σ)]
[fm (fm* fm bg-fm)]
[fm (flomap-blur fm half-σ)])
fm)]
[else
(flomap-blur raw-shadow-fm σ)]))
;; pass 2: trace from the viewer ;; blur the shadow to simulate internal scatter
(define-values (reflected-fm transmitted-fm) (define shadow-fm
(trace-directional-view alpha-fm rgb-fm z-fm normal-fm shadow-fm x-min x-max y-min y-max)) (cond [bg-fm
(let* ([fm (flomap-blur raw-shadow-fm (sqrt (* 1/3 σ^2)))]
[fm (fm* fm bg-fm)]
[fm (flomap-blur fm (sqrt (* 1/3 σ^2)))])
fm)]
[else
(flomap-blur raw-shadow-fm (sqrt (* 2/3 σ^2)))]))
;; add all the light together, convert to premultiplied-alpha flomap ;; pass 2: trace from the viewer
(let* ([fm (fm+ (fm+ diffracted-fm transmitted-fm) reflected-fm)] (define-values (reflected-fm raw-transmitted-fm)
[fm (flomap-append-components alpha-fm fm)] (trace-directional-view alpha-fm rgb-fm z-fm normal-fm shadow-fm x-min x-max y-min y-max))
[fm (flomap-multiply-alpha fm)]) ;; simulate scatter some more
fm)])) (define transmitted-fm (flomap-blur raw-transmitted-fm (sqrt (* 1/3 σ^2))))
;; add all the light together, convert to premultiplied-alpha flomap
(let* ([fm (fm+ (fm+ diffracted-fm transmitted-fm) reflected-fm)]
[fm (flomap-append-components alpha-fm fm)]
[fm (flomap-multiply-alpha fm)])
(flomap-inset fm -1)))]))

View File

@ -14,44 +14,56 @@
(: flomap-gradient-x (flomap -> flomap)) (: flomap-gradient-x (flomap -> flomap))
(define (flomap-gradient-x fm) (define (flomap-gradient-x fm)
(match-define (flomap vs c w h) fm) (match-define (flomap vs c w h) fm)
(define cw (fx* c w)) (define +x (fx* c 1))
(define d20 (fx- 1 cw)) (define -x+y (fx* c (fx- w 1)))
(define d22 (fx+ cw 1)) (define +x+y (fx* c (fx+ w 1)))
(define w-1 (fx- w 1)) (define w-1 (fx- w 1))
(define h-1 (fx- h 1)) (define h-1 (fx- h 1))
(inline-build-flomap (inline-build-flomap
c w h c w h
(λ (_k x y i) (λ (k x y i)
(cond [(and (x . fx> . 0) (x . fx< . w-1) (cond [(and (x . fx> . 0) (x . fx< . w-1)
(y . fx> . 0) (y . fx< . h-1)) (y . fx> . 0) (y . fx< . h-1))
(+ (- (* 0.1875 (unsafe-flvector-ref vs (fx+ i d20))) (+ (- (* 0.1875 (unsafe-flvector-ref vs (fx- i -x+y)))
(* 0.1875 (unsafe-flvector-ref vs (fx- i d22)))) (* 0.1875 (unsafe-flvector-ref vs (fx- i +x+y))))
(- (* 0.6250 (unsafe-flvector-ref vs (fx+ i 1))) (- (* 0.6250 (unsafe-flvector-ref vs (fx+ i +x)))
(* 0.6250 (unsafe-flvector-ref vs (fx- i 1)))) (* 0.6250 (unsafe-flvector-ref vs (fx- i +x))))
(- (* 0.1875 (unsafe-flvector-ref vs (fx+ i d22))) (- (* 0.1875 (unsafe-flvector-ref vs (fx+ i +x+y)))
(* 0.1875 (unsafe-flvector-ref vs (fx- i d20)))))] (* 0.1875 (unsafe-flvector-ref vs (fx+ i -x+y)))))]
[else 0.0])))) [else
(+ (- (* 0.1875 (flomap-ref fm k (+ x 1) (- y 1)))
(* 0.1875 (flomap-ref fm k (- x 1) (- y 1))))
(- (* 0.6250 (flomap-ref fm k (+ x 1) y))
(* 0.6250 (flomap-ref fm k (- x 1) y)))
(- (* 0.1875 (flomap-ref fm k (+ x 1) (+ y 1)))
(* 0.1875 (flomap-ref fm k (- x 1) (+ y 1)))))]))))
(: flomap-gradient-y (flomap -> flomap)) (: flomap-gradient-y (flomap -> flomap))
(define (flomap-gradient-y fm) (define (flomap-gradient-y fm)
(match-define (flomap vs c w h) fm) (match-define (flomap vs c w h) fm)
(define cw (fx* c w)) (define +y (fx* c w))
(define d02 (fx- cw 1)) (define -x+y (fx* c (fx- w 1)))
(define d22 (fx+ cw 1)) (define +x+y (fx* c (fx+ w 1)))
(define w-1 (fx- w 1)) (define w-1 (fx- w 1))
(define h-1 (fx- h 1)) (define h-1 (fx- h 1))
(inline-build-flomap (inline-build-flomap
c w h c w h
(λ (_k x y i) (λ (k x y i)
(cond [(and (x . fx> . 0) (x . fx< . w-1) (cond [(and (x . fx> . 0) (x . fx< . w-1)
(y . fx> . 0) (y . fx< . h-1)) (y . fx> . 0) (y . fx< . h-1))
(+ (- (* 0.1875 (unsafe-flvector-ref vs (fx+ i d02))) (+ (- (* 0.1875 (unsafe-flvector-ref vs (fx+ i -x+y)))
(* 0.1875 (unsafe-flvector-ref vs (fx- i d22)))) (* 0.1875 (unsafe-flvector-ref vs (fx- i +x+y))))
(- (* 0.6250 (unsafe-flvector-ref vs (fx+ i cw))) (- (* 0.6250 (unsafe-flvector-ref vs (fx+ i +y)))
(* 0.6250 (unsafe-flvector-ref vs (fx- i cw)))) (* 0.6250 (unsafe-flvector-ref vs (fx- i +y))))
(- (* 0.1875 (unsafe-flvector-ref vs (fx+ i d22))) (- (* 0.1875 (unsafe-flvector-ref vs (fx+ i +x+y)))
(* 0.1875 (unsafe-flvector-ref vs (fx- i d02)))))] (* 0.1875 (unsafe-flvector-ref vs (fx- i -x+y)))))]
[else 0.0])))) [else
(+ (- (* 0.1875 (flomap-ref fm k (- x 1) (+ y 1)))
(* 0.1875 (flomap-ref fm k (- x 1) (- y 1))))
(- (* 0.6250 (flomap-ref fm k x (+ y 1)))
(* 0.6250 (flomap-ref fm k x (- y 1))))
(- (* 0.1875 (flomap-ref fm k (+ x 1) (+ y 1)))
(* 0.1875 (flomap-ref fm k (+ x 1) (- y 1)))))]))))
(: flomap-gradient (flomap -> (values flomap flomap))) (: flomap-gradient (flomap -> (values flomap flomap)))
(define (flomap-gradient fm) (define (flomap-gradient fm)

View File

@ -45,8 +45,7 @@ Its shape and color are a visual metaphor for an action or a message.
Icons should be @bold{easily recognizable}, @bold{distinguishable}, @bold{visually consistent}, and @bold{metaphorically appropriate} for the actions and messages they are used with. Icons should be @bold{easily recognizable}, @bold{distinguishable}, @bold{visually consistent}, and @bold{metaphorically appropriate} for the actions and messages they are used with.
It can be difficult to meet all four requirements at once (``distinguishable'' and ``visually consistent' are often at odds), but good examples, good abstractions, and an existing icon library help considerably. It can be difficult to meet all four requirements at once (``distinguishable'' and ``visually consistent' are often at odds), but good examples, good abstractions, and an existing icon library help considerably.
@(define (hash-quote) (text-icon "#'" (make-object font% 32 'system) @(define (hash-quote) (hash-quote-icon macro-stepper-hash-color 16))
macro-stepper-hash-color #t 'auto 16))
@(define (step) (step-icon syntax-icon-color 16)) @(define (step) (step-icon syntax-icon-color 16))
@(define (play) (play-icon syntax-icon-color 16)) @(define (play) (play-icon syntax-icon-color 16))
@(define (bar) (bar-icon syntax-icon-color 16)) @(define (bar) (bar-icon syntax-icon-color 16))
@ -283,7 +282,7 @@ Renders a text string as an icon. For example,
@interaction[#:eval icons-eval @interaction[#:eval icons-eval
(text-icon "An Important Point!" (text-icon "An Important Point!"
(make-object font% 48 'decorative 'normal 'bold #t) (make-object font% 48 'decorative 'normal 'bold #t)
"lightskyblue" #t 2 48)] "lightskyblue" #t 'auto 48)]
Before rendering, the drawn text is scaled so that it is exactly @racket[height] pixels tall. Before rendering, the drawn text is scaled so that it is exactly @racket[height] pixels tall.
Make sure the font is large enough that scaling does not create blurry and jagged edge artifacts, as in the following example: Make sure the font is large enough that scaling does not create blurry and jagged edge artifacts, as in the following example:
@ -329,6 +328,12 @@ Returns an ``x'' icon that is guaranteed to look the same on all platforms.
(lambda-icon light-metal-icon-color 32 metal-icon-material)] (lambda-icon light-metal-icon-color 32 metal-icon-material)]
} }
@doc-apply[hash-quote-icon]{
@examples[#:eval icons-eval
(require (only-in images/icons/tool macro-stepper-hash-color))
(hash-quote-icon macro-stepper-hash-color 32)]
}
@;==================================================================================================== @;====================================================================================================
@section[#:tag "misc"]{Miscellaneous Icons} @section[#:tag "misc"]{Miscellaneous Icons}
@ -388,10 +393,14 @@ Equivalent to @racket[(regular-polygon-icon 8 (/ (* 2 pi) 16) color height mater
@doc-apply[clock-icon]{ @doc-apply[clock-icon]{
@examples[#:eval icons-eval @examples[#:eval icons-eval
(clock-icon 48) (clock-icon 96)
(clock-icon 48 "lightblue" "darkblue" 3 21)] (clock-icon 48 "lightblue" "darkblue" 3 21)]
} }
@doc-apply[stopwatch-icon]{
@examples[#:eval icons-eval (stopwatch-icon 96)]
}
@;==================================================================================================== @;====================================================================================================
@section[#:tag "stickman"]{Stickman Icons} @section[#:tag "stickman"]{Stickman Icons}

View File

@ -30,11 +30,11 @@ Returns an unofficial PLaneT logo. This is used as the PLaneT icon when DrRacket
} }
@doc-apply[stepper-logo]{ @doc-apply[stepper-logo]{
An algebraic stepper logo. Returns the algebraic stepper logo.
@examples[#:eval logos-eval (stepper-logo)] @examples[#:eval logos-eval (stepper-logo)]
} }
@doc-apply[macro-stepper-logo]{ @doc-apply[macro-stepper-logo]{
A macro stepper logo. Returns the macro stepper logo.
@examples[#:eval logos-eval (macro-stepper-logo)] @examples[#:eval logos-eval (macro-stepper-logo)]
} }

View File

@ -48,12 +48,13 @@
(λ (color) (load-icon syntax-icon-color color)) (λ (color) (load-icon syntax-icon-color color))
(λ (color) (small-save-icon syntax-icon-color color)) (λ (color) (small-save-icon syntax-icon-color color))
(λ (color) (small-load-icon syntax-icon-color color))) (λ (color) (small-load-icon syntax-icon-color color)))
(list x-icon check-icon recycle-icon lambda-icon) (list x-icon check-icon recycle-icon lambda-icon hash-quote-icon)
(list octagon-icon stop-sign-icon stop-signs-icon foot-icon (list octagon-icon stop-sign-icon stop-signs-icon foot-icon
(λ (color) (magnifying-glass-icon metal-icon-color color)) (λ (color) (magnifying-glass-icon metal-icon-color color))
(λ (color) (left-magnifying-glass-icon metal-icon-color color)) (λ (color) (left-magnifying-glass-icon metal-icon-color color))
(λ (color) (bomb-icon metal-icon-color color)) (λ (color) (bomb-icon metal-icon-color color))
(λ (color) (left-bomb-icon metal-icon-color color))))) (λ (color) (left-bomb-icon metal-icon-color color))
(λ (color) (stopwatch-icon (default-icon-height) color)))))
(define tool-icon-procs (define tool-icon-procs
(list check-syntax-icon small-check-syntax-icon (list check-syntax-icon small-check-syntax-icon

View File

@ -1,7 +1,9 @@
#lang racket/base #lang racket/base
(require racket/class racket/port racket/list racket/match (require racket/class racket/port racket/list racket/match
racket/gui/base racket/unit drracket/tool) racket/gui/base racket/unit drracket/tool
images/compile-time
(for-syntax racket/base images/icons/misc images/icons/style))
(require "report.rkt" "display.rkt") (require "report.rkt" "display.rkt")
@ -11,9 +13,7 @@
;; DrRacket tool for reporting missed optimizations in the editor. ;; DrRacket tool for reporting missed optimizations in the editor.
(define performance-report-bitmap (define performance-report-bitmap
(make-object (compiled-bitmap (stopwatch-icon (toolbar-icon-height))))
bitmap%
(collection-file-path "performance-report.png" "icons") 'png/mask))
;; performance-report-callback : drracket:unit:frame<%> -> void ;; performance-report-callback : drracket:unit:frame<%> -> void
(define (performance-report-callback drr-frame) (define (performance-report-callback drr-frame)