Text icon fix - works better when trimmed

Recycle icon (text icon of string "\u267b")

Removed debug output from plt-logo

Slightly faster bitmap <-> flomap conversion (uses bitmap%'s premultiply-alpha)

Please merge into release
This commit is contained in:
Neil Toronto 2012-01-11 22:35:40 -07:00
parent 436a1dcb71
commit 5dcfd76927
4 changed files with 24 additions and 25 deletions

View File

@ -60,10 +60,13 @@
(define weight (send font get-weight))
(define underline? (send font get-underlined))
(define smoothing (send font get-smoothing))
(define size
(let* ([size (inexact->exact (ceiling height))])
(min 255 (if trim? (* 2 size) size))))
(make-cached-flomap
[height str family style weight underline? smoothing color trim? outline? material]
(let ([font (make-object font% (min 255 (inexact->exact (ceiling height)))
family style weight underline? smoothing #t)])
(let ([font (make-object font% size family style weight underline? smoothing #t)])
(define-values (w h) (get-text-size str font))
(define outline-amt (if outline? (/ height 32) 0))
(define ceiling-amt (inexact->exact (ceiling outline-amt)))
@ -80,6 +83,9 @@
fm))
(flomap-render-icon fm material))))
(define (recycle-flomap color [height (default-icon-height)] [material (default-icon-material)])
(text-flomap "" (make-object font% 64 'default) color #t #t height material))
(define (x-flomap color [height (default-icon-height)] [material (default-icon-material)])
(make-cached-flomap
[height color material]
@ -287,6 +293,7 @@
;; Bitmaps (icons)
(define text-icon (compose flomap->bitmap text-flomap))
(define recycle-icon (compose flomap->bitmap recycle-flomap))
(define regular-polygon-icon (compose flomap->bitmap regular-polygon-flomap))
(define octagon-icon (compose flomap->bitmap octagon-flomap))
(define x-icon (compose flomap->bitmap x-flomap))

View File

@ -127,16 +127,11 @@
(let* ([bulge-dfm (flomap->deep-flomap bulge-fm)]
[bulge-dfm (deep-flomap-bulge-spheroid bulge-dfm (* 112 scale))]
;[bulge-dfm (deep-flomap-raise bulge-dfm (* 8 scale))]
;[bulge-dfm (deep-flomap-smooth-z bulge-dfm (* 1/2 scale))]
#;[bulge-dfm (deep-flomap (deep-flomap-argb bulge-dfm)
(flomap-rough (deep-flomap-z bulge-dfm) 0.5))]
[lambda-dfm (flomap->deep-flomap (lambda-flomap "azure" 4))]
[lambda-dfm (deep-flomap-bulge-spheroid lambda-dfm (* 112 scale))]
[lambda-dfm (deep-flomap-smooth-z lambda-dfm (* 3 scale))]
[lambda-fm (time (printf "render lam:~n")
(deep-flomap-render-icon lambda-dfm metal-material))]
[fm (time (printf "render fm:~n") (deep-flomap-render-icon bulge-dfm glass-logo-material))]
[lambda-fm (deep-flomap-render-icon lambda-dfm metal-material)]
[fm (deep-flomap-render-icon bulge-dfm glass-logo-material)]
[fm (flomap-cc-superimpose
fm
(lambda-flomap lambda-outline-color 10)
@ -153,11 +148,6 @@
fm)])
fm)))
(define (plt-logo height)
(define fm (plt-flomap height))
(time (printf "flomap->bitmap:~n")
(flomap->bitmap fm)))
(define continents-path-commands
'((m 11.526653 18.937779)
(c 0.05278 0.724075 1.940414 1.202607 0.678885 2.296248
@ -293,4 +283,5 @@
earth-fm
land-fm)))
(define plt-logo (compose flomap->bitmap plt-flomap))
(define planet-logo (compose flomap->bitmap planet-flomap))

View File

@ -18,10 +18,8 @@
(define w (send bm get-width))
(define h (send bm get-height))
(define bs (make-bytes (* 4 w h)))
;; get bytes without premultiplying alpha because doing it in flonums maintains precision
;; (if RGB bytes are stored without premultiplying alpha)
(send bm get-argb-pixels 0 0 w h bs #t)
(send bm get-argb-pixels 0 0 w h bs #f)
(send bm get-argb-pixels 0 0 w h bs #t #t)
(send bm get-argb-pixels 0 0 w h bs #f #t)
(define argb-fm (make-flomap 4 w h))
(define argb-vs (flomap-values argb-fm))
@ -38,7 +36,7 @@
(unsafe-flvector-set! argb-vs i2 (unsafe-fl/ (unsafe-fx->fl g) 255.0))
(unsafe-flvector-set! argb-vs i3 (unsafe-fl/ (unsafe-fx->fl b) 255.0)))
(flomap-multiply-alpha argb-fm))
argb-fm)
(define (flomap->bitmap fm)
(match-define (flomap vs c w h) fm)
@ -52,9 +50,7 @@
[(4) fm]
[else (raise-type-error 'flomap->bitmap "flomap with 1, 2, 3 or 4 components" fm)])]
;; inset if zero (bitmaps can't have zero size)
[fm (flomap-inset fm 0 0 (if (= w 0) 1 0) (if (= h 0) 1 0))]
;; divide alphas before converting
[fm (flomap-divide-alpha fm)])
[fm (flomap-inset fm 0 0 (if (= w 0) 1 0) (if (= h 0) 1 0))])
;; guaranteed an ARGB flomap now
(match-define (flomap vs 4 w h) fm)
(define bs (make-bytes (* 4 w h)))
@ -72,8 +68,8 @@
(unsafe-bytes-set! bs i3 (unsafe-fl->byte (unsafe-fl* 255.0 b))))
(define bm (make-bitmap w h))
(send bm set-argb-pixels 0 0 w h bs #t)
(send bm set-argb-pixels 0 0 w h bs #f)
(send bm set-argb-pixels 0 0 w h bs #t #t)
(send bm set-argb-pixels 0 0 w h bs #f #t)
bm))
(define (draw-flomap w h draw-proc)

View File

@ -6,6 +6,9 @@
(provide (all-defined-out))
;; ===================================================================================================
;; Caching flomaps with a hash table of weak box values
(define num-callbacks 0)
(define (get-num-callbacks) num-callbacks)
@ -74,7 +77,9 @@
(with-syntax ([(name) (generate-temporaries #'(make-cached-flomap))])
(syntax/loc stx
(make-cached-flomap* 'name (λ (size args ...) expr0 expr ...) size args ...)))]))
;; ===================================================================================================
;; Drawing
(define (draw-ellipse/smoothed dc x y w h)
(define pen (send dc get-pen))