Removed accidental dependence of images/icons/stickman on racket/gui

Began scribble docs

Added `compiled-bitmap' and `compiled-bitmap-list', which embed bitmaps
computed at expansion time into compiled files (safe 3D values)

Please merge into release
This commit is contained in:
Neil Toronto 2012-01-12 21:48:41 -07:00
parent 5dcfd76927
commit 4d1cedc913
16 changed files with 638 additions and 96 deletions

View File

@ -26,7 +26,8 @@ profile todo:
net/url
racket/match
mrlib/include-bitmap
images/icons/misc images/icons/style images/icons/control images/logos
images/compile-time
(for-syntax images/icons/misc images/icons/style images/icons/control images/logos)
(for-syntax racket/base))
(define orig (current-output-port))
@ -187,11 +188,11 @@ profile todo:
(super-make-object bitmap))])
note%)))
(define file-note% (make-note% "stop-22x22.png" (stop-sign-icon halt-icon-color)))
(define bug-note% (make-note% "stop-multi.png" (stop-signs-icon halt-icon-color)))
(define file-note% (make-note% "stop-22x22.png" (compiled-bitmap (stop-sign-icon halt-icon-color))))
(define bug-note% (make-note% "stop-multi.png" (compiled-bitmap (stop-signs-icon halt-icon-color))))
(define mf-note% (make-note% "mf.gif" (include-bitmap (lib "icons/mf.gif") 'gif)))
(define small-planet-bitmap (planet-logo (default-icon-height)))
(define small-planet-bitmap (compiled-bitmap (planet-logo (default-icon-height))))
(define planet-note% (make-note% "small-planet.png" small-planet-bitmap))
;; display-stats : (syntax -> syntax)

View File

@ -38,9 +38,7 @@ module browser threading seems wrong.
"local-member-names.rkt"
"eval-helpers.rkt"
(prefix-in drracket:arrow: "../arrow.rkt")
(prefix-in icons: (combine-in images/icons/file images/icons/control images/icons/style
images/icons/stickman images/logos))
(prefix-in icons: images/compile-time)
mred
(prefix-in mred: mred)
@ -69,6 +67,46 @@ module browser threading seems wrong.
(let ([fw (collection-path "framework")])
(directory-exists? (build-path fw 'up 'up ".git"))))))
;; ===================================================================================================
;; Compiled bitmaps
(require (for-syntax
racket/base
(prefix-in icons: (combine-in images/icons/file images/icons/control images/icons/style
images/icons/stickman images/logos))))
(define execute-bitmap
(icons:compiled-bitmap (icons:play-icon icons:run-icon-color (icons:toolbar-icon-height))))
(define break-bitmap
(icons:compiled-bitmap (icons:stop-icon icons:halt-icon-color (icons:toolbar-icon-height))))
(define small-save-bitmap
(icons:compiled-bitmap (icons:small-save-icon icons:syntax-icon-color "gold"
(icons:toolbar-icon-height))))
(define save-bitmap
(icons:compiled-bitmap (icons:save-icon icons:syntax-icon-color "gold"
(icons:toolbar-icon-height))))
(begin-for-syntax
(define stickman-height 18)
(define num-running-frames 12))
(define running-frame-list
(icons:compiled-bitmap-list
(for/list ([t (in-range 0 1 (/ 1 num-running-frames))])
(icons:running-stickman-icon t icons:run-icon-color "white" icons:run-icon-color
stickman-height))))
(define running-frames (list->vector running-frame-list))
(define standing-frame
(icons:compiled-bitmap
(icons:standing-stickman-icon icons:run-icon-color "white" icons:run-icon-color
stickman-height)))
(define very-small-planet-bitmap
(icons:compiled-bitmap (icons:planet-logo (icons:toolbar-icon-height))))
;; ===================================================================================================
(define-unit unit@
(import [prefix help-desk: drracket:help-desk^]
[prefix drracket:app: drracket:app^]
@ -386,13 +424,6 @@ module browser threading seems wrong.
frame
program-filename)))])))
(define execute-bitmap (icons:play-icon icons:run-icon-color (icons:toolbar-icon-height)))
(define break-bitmap (icons:stop-icon icons:halt-icon-color (icons:toolbar-icon-height)))
(define small-save-bitmap (icons:small-save-icon icons:syntax-icon-color "gold"
(icons:toolbar-icon-height)))
(define save-bitmap (icons:save-icon icons:syntax-icon-color "gold"
(icons:toolbar-icon-height)))
(define-values (get-program-editor-mixin add-to-program-editor-mixin)
(let* ([program-editor-mixin
(mixin (editor:basic<%> (class->interface text%)) ()
@ -4399,27 +4430,15 @@ module browser threading seems wrong.
(class canvas%
(inherit get-dc refresh get-client-size)
(define stickman-height 18)
(define num-running-frames 12)
(define frame-delay 200) ; 5 FPS at the most (when the user program is blocked or waiting)
(define running-frames
(for/vector ([t (in-range 0 1 (/ 1 num-running-frames))])
(icons:running-stickman-icon t icons:run-icon-color "white" icons:run-icon-color
stickman-height)))
(define standing-frame
(icons:standing-stickman-icon icons:run-icon-color "white" icons:run-icon-color
stickman-height))
(define all-running-frames
(cons standing-frame (vector->list running-frames)))
(define running-frame-delay 200) ; 5 FPS at the most (if user program is blocked or waiting)
(define num-running-frames (vector-length running-frames))
(define is-running? #f)
(define frame 0)
(define timer (make-object timer% (λ () (refresh) (yield)) #f))
(define/public (set-running r?)
(cond [r? (unless is-running? (set! frame 4))
(send timer start frame-delay #f)]
(send timer start running-frame-delay #f)]
[else (send timer stop)
(refresh)])
(set! is-running? r?))
@ -4438,7 +4457,10 @@ module browser threading seems wrong.
(super-new [stretchable-width #f]
[stretchable-height #f]
[style '(transparent no-focus)])
(inherit min-width min-height)
(define all-running-frames (cons standing-frame running-frame-list))
(min-width (apply max (map (λ (x) (send x get-width)) all-running-frames)))
(min-height (apply max (map (λ (x) (send x get-height)) all-running-frames)))))
@ -4683,8 +4705,6 @@ module browser threading seems wrong.
[(null? l) '()]
[else (cons (car l) (loop (cdr l) (- n 1)))])))
(define very-small-planet-bitmap (icons:planet-logo (icons:toolbar-icon-height)))
(define saved-bug-reports-window #f)
(define saved-bug-reports-panel #f)
(define (init-saved-bug-reports-window)

View File

@ -2,7 +2,8 @@
(require racket/class
racket/gui/base
string-constants/string-constant
images/icons/tool images/icons/style)
images/compile-time
(for-syntax racket/base images/icons/tool images/icons/style))
(provide syncheck-drracket-button
syncheck-bitmap
syncheck-small-bitmap
@ -10,8 +11,10 @@
(define-local-member-name syncheck:button-callback)
(define syncheck-bitmap (check-syntax-icon (toolbar-icon-height)))
(define syncheck-small-bitmap (small-check-syntax-icon (toolbar-icon-height)))
(define syncheck-bitmap
(compiled-bitmap (check-syntax-icon (toolbar-icon-height))))
(define syncheck-small-bitmap
(compiled-bitmap (small-check-syntax-icon (toolbar-icon-height))))
(define syncheck-drracket-button
(list

View File

@ -15,7 +15,8 @@
framework
string-constants
lang/debugger-language-interface
images/icons/tool)
images/compile-time
(for-syntax images/icons/tool))
(provide tool@)
@ -1082,8 +1083,8 @@
(super-new)))
(define debug-bitmap (debugger-icon))
(define small-debug-bitmap (small-debugger-icon))
(define debug-bitmap (compiled-bitmap (debugger-icon)))
(define small-debug-bitmap (compiled-bitmap (small-debugger-icon)))
(define make-pause-label
(bitmap-label-maker

View File

@ -0,0 +1,29 @@
#lang racket/base
(require (for-syntax racket/base racket/class racket/draw)
racket/class racket/draw)
(provide compiled-bitmap compiled-bitmap-list)
(define-for-syntax (make-3d-bitmap ctxt bm)
(define p (open-output-bytes))
(send bm save-file p 'png)
(with-syntax ([bs (datum->syntax ctxt (get-output-bytes p))])
(syntax/loc ctxt
(make-object bitmap% (open-input-bytes bs) 'png/alpha))))
(define-syntax (compiled-bitmap stx)
(syntax-case stx ()
[(_ expr) (syntax/loc stx
(let-syntax ([maker (λ (inner-stx) (make-3d-bitmap inner-stx expr))])
(maker)))]))
(define-syntax (compiled-bitmap-list stx)
(syntax-case stx ()
[(_ expr)
(syntax/loc stx
(let-syntax ([maker (λ (inner-stx)
(with-syntax ([(bm (... ...))
(map (λ (e) (make-3d-bitmap inner-stx e)) expr)])
#'(list bm (... ...))))])
(maker)))]))

View File

@ -1,23 +1,39 @@
#lang racket/base
(require racket/class
(require racket/class racket/draw
racket/contract unstable/latent-contract unstable/latent-contract/defthing
"../private/flomap.rkt"
"../private/deep-flomap.rkt"
"../private/utils.rkt"
"style.rkt")
(provide (all-defined-out))
(provide
(activate-contract-out
flat-right-arrow-flomap
flat-right-over-arrow-flomap
right-arrow-flomap left-arrow-flomap up-arrow-flomap down-arrow-flomap
right-over-arrow-flomap left-over-arrow-flomap
right-under-arrow-flomap left-under-arrow-flomap
right-arrow-icon left-arrow-icon up-arrow-icon down-arrow-icon
right-over-arrow-icon left-over-arrow-icon
right-under-arrow-icon left-under-arrow-icon)
(only-doc-out (all-defined-out)))
(define (flat-right-arrow-flomap color height)
(draw-icon-flomap
32 32 (λ (dc)
(send dc set-brush color 'solid)
(send dc draw-polygon (list '(0 . 9) '(15 . 9) '(14 . 0)
'(31 . 15.5)
'(14 . 31) '(15 . 22) '(0 . 22))))
(/ height 32)))
(defproc (flat-right-arrow-flomap [color (or/c string? (is-a?/c color%))]
[height (and/c rational? (>=/c 0))]
) flomap?
(let ([color (->color% color)])
(draw-icon-flomap
32 32 (λ (dc)
(send dc set-brush color 'solid)
(send dc draw-polygon (list '(0 . 9) '(15 . 9) '(14 . 0)
'(31 . 15.5)
'(14 . 31) '(15 . 22) '(0 . 22))))
(/ height 32))))
(define (flat-right-over-arrow-flomap color height)
(defproc (flat-right-over-arrow-flomap [color (or/c string? (is-a?/c color%))]
[height (and/c rational? (>=/c 0))]
) flomap?
(draw-icon-flomap
32 32 (λ (dc)
(send dc set-brush color 'solid)
@ -29,55 +45,72 @@
(l -4 -4))))
(/ height 32)))
(define (flomap-render-short-icon fm material)
(define scale (/ (flomap-height fm) 32))
(define dfm
(let* ([dfm (flomap->deep-flomap fm)]
[dfm (deep-flomap-icon-style dfm)]
[dfm (deep-flomap-raise dfm (* -12 scale))])
dfm))
(deep-flomap-render-icon dfm material))
(define (right-arrow-flomap color [height (default-icon-height)] [material (default-icon-material)])
(defproc (right-arrow-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]
(flomap-render-short-icon (flat-right-arrow-flomap color height) material)))
(flomap-render-thin-icon (flat-right-arrow-flomap color height) material)))
(define (up-arrow-flomap color [height (default-icon-height)] [material (default-icon-material)])
(defproc (up-arrow-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]
(flomap-render-icon (flomap-cw-rotate (flat-right-arrow-flomap color height)) material)))
(define (down-arrow-flomap color [height (default-icon-height)] [material (default-icon-material)])
(defproc (down-arrow-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]
(flomap-render-icon (flomap-ccw-rotate (flat-right-arrow-flomap color height)) material)))
(define (right-over-arrow-flomap color
[height (default-icon-height)]
[material (default-icon-material)])
(defproc (right-over-arrow-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]
(flomap-render-short-icon (flat-right-over-arrow-flomap color height) material)))
(flomap-render-thin-icon (flat-right-over-arrow-flomap color height) material)))
(define (right-under-arrow-flomap color
[height (default-icon-height)]
[material (default-icon-material)])
(defproc (right-under-arrow-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]
(flomap-render-short-icon
(flomap-render-thin-icon
(flomap-flip-vertical (flat-right-over-arrow-flomap color height)) material)))
(define left-arrow-flomap (compose flomap-flip-horizontal right-arrow-flomap))
(define left-over-arrow-flomap (compose flomap-flip-horizontal right-over-arrow-flomap))
(define left-under-arrow-flomap (compose flomap-flip-horizontal right-under-arrow-flomap))
(defproc (left-arrow-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?
(flomap-flip-horizontal (right-arrow-flomap color height material)))
(define right-arrow-icon (compose flomap->bitmap right-arrow-flomap))
(define left-arrow-icon (compose flomap->bitmap left-arrow-flomap))
(define up-arrow-icon (compose flomap->bitmap up-arrow-flomap))
(define down-arrow-icon (compose flomap->bitmap down-arrow-flomap))
(define right-over-arrow-icon (compose flomap->bitmap right-over-arrow-flomap))
(define left-over-arrow-icon (compose flomap->bitmap left-over-arrow-flomap))
(define right-under-arrow-icon (compose flomap->bitmap right-under-arrow-flomap))
(define left-under-arrow-icon (compose flomap->bitmap left-under-arrow-flomap))
(defproc (left-over-arrow-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?
(flomap-flip-horizontal (right-over-arrow-flomap color height material)))
(defproc (left-under-arrow-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?
(flomap-flip-horizontal (right-under-arrow-flomap color height material)))
(define-simple-icon-wrapper left-arrow-icon left-arrow-flomap)
(define-simple-icon-wrapper right-arrow-icon right-arrow-flomap)
(define-simple-icon-wrapper up-arrow-icon up-arrow-flomap)
(define-simple-icon-wrapper down-arrow-icon down-arrow-flomap)
(define-simple-icon-wrapper right-over-arrow-icon right-over-arrow-flomap)
(define-simple-icon-wrapper left-over-arrow-icon left-over-arrow-flomap)
(define-simple-icon-wrapper right-under-arrow-icon right-under-arrow-flomap)
(define-simple-icon-wrapper left-under-arrow-icon left-under-arrow-flomap)

View File

@ -1,6 +1,6 @@
#lang racket/gui
#lang racket/base
(require racket/class racket/snip racket/vector
(require racket/class racket/vector racket/match racket/math
"../private/flomap.rkt"
"../private/deep-flomap.rkt"
"../private/utils.rkt"
@ -100,13 +100,6 @@
(polar->cartesian (+ standing-right-elbow-angle standing-torso-angle standing-right-hand-angle)
lower-arm-length)))
(define (draw-short-rendered-icon-flomap w h proc scale material)
(let* ([fm (draw-icon-flomap w h proc scale)]
[dfm (flomap->deep-flomap fm)]
[dfm (deep-flomap-icon-style dfm)]
[dfm (deep-flomap-raise dfm (* -18 (/ (flomap-height fm) 32)))])
(deep-flomap-render-icon dfm material)))
(define (standing-stickman-flomap color arm-color head-color
[height (default-icon-height)]
[material (default-icon-material)])
@ -298,9 +291,9 @@
(define standing-stickman-icon (compose flomap->bitmap standing-stickman-flomap))
(define running-stickman-icon (compose flomap->bitmap running-stickman-flomap))
#;
#;; FOR TESTING ONLY: Do not let this find its way into the repo uncommented!
(begin
(require (planet "animated-canvas.rkt" ("williams" "animated-canvas.plt" 2 4)))
(require racket/gui (planet "animated-canvas.rkt" ("williams" "animated-canvas.plt" 2 4)))
(define size 20)

View File

@ -1,6 +1,7 @@
#lang racket
(require racket/draw unstable/parameter-group
racket/contract unstable/latent-contract/defthing
"../private/flomap.rkt"
"../private/deep-flomap.rkt")
@ -70,3 +71,31 @@
(let* ([fm (draw-icon-flomap w h draw-proc scale)]
[fm (flomap-render-icon fm material)])
fm))
;; TODO: make one of the following functions unnecessary
(define (flomap-render-thin-icon fm material)
(define scale (/ (flomap-height fm) 32))
(define dfm
(let* ([dfm (flomap->deep-flomap fm)]
[dfm (deep-flomap-icon-style dfm)]
[dfm (deep-flomap-raise dfm (* -12 scale))])
dfm))
(deep-flomap-render-icon dfm material))
(define (draw-short-rendered-icon-flomap w h proc scale material)
(let* ([fm (draw-icon-flomap w h proc scale)]
[dfm (flomap->deep-flomap fm)]
[dfm (deep-flomap-icon-style dfm)]
[dfm (deep-flomap-raise dfm (* -12 (/ (flomap-height fm) 32)))])
(deep-flomap-render-icon dfm material)))
;; ===================================================================================================
;; Syntax for writing icon functions
(define-syntax-rule (define-simple-icon-wrapper icon-fun flomap-fun)
(defproc (icon-fun [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)]
) (is-a?/c bitmap%)
(flomap->bitmap (flomap-fun color height material))))

6
collects/images/info.rkt Normal file
View File

@ -0,0 +1,6 @@
#lang setup/infotab
(define scribblings '(["scribblings/images.scrbl" (multi-page) (gui-library)]))
(define compile-omit-paths '("tests"))

View File

@ -81,6 +81,13 @@
;; ===================================================================================================
;; Drawing
(define (->color% c)
(match c
[(list r g b) (make-object color% r g b)]
[(? (is-a?/c color%)) c]
[(? string?) (send the-color-database find-color c)]
[else (raise-type-error '->color% "list, color% or string" c)]))
(define (draw-ellipse/smoothed dc x y w h)
(define pen (send dc get-pen))
(define brush (send dc get-brush))

View File

@ -0,0 +1,11 @@
#lang scribble/manual
@(require scribble/eval
(for-label images/compile-time
racket)
images/compile-time)
@(define (author-email) "neil.toronto@gmail.com")
@title{Embedding Computed Bitmaps in Source Files}
@author{@(author+email "Neil Toronto" (author-email))}

View File

@ -0,0 +1,366 @@
#lang scribble/manual
@(require scribble/eval
unstable/latent-contract/defthing
(for-label images/icons/arrow
mrlib/switchable-button
racket
racket/draw)
images/icons/arrow)
@(define (author-email) "neil.toronto@gmail.com")
@title{Icons}
@author{@(author+email "Neil Toronto" (author-email))}
@(define icons-eval (make-base-eval))
@interaction-eval[#:eval icons-eval (require racket/math racket/list images/icons/style)]
@;{
@section{Introduction (What is an icon, really?)}
@margin-note*{This introduction describes an ideal, not necessarily the current state of things.}
As a first approximation, an icon is just a small bitmap with an alpha channel.
But the icons in this collection are not simply loaded from disk.
They are generated programmatically by drawing on a @racket[dc<%>],
Icons can also be rendered , resized, generated programmatically by drawing on a , or composed using @racket[pict] functions.
The @racketmodname[icons] module is intended to make it possible to do all of these things, and to make it easy to get common icons in different colors, heights and styles.
An icon communicates. Its shape and color are a visual metaphor for an action or a message. Icons should be easily recognizable, distinguishable, visually consistent, and metaphorically appropriate for the actions and messages they are used with. This is difficult to do well, but good examples, good abstractions, and an existing icon library help considerably.
@(define (hash-quote) (hash-quote-flomap (solid-icon-color '(41 128 38)) 16))
@(define (step) (step-flomap (solid-icon-color "blue") 16 'diffuse))
@(define (macro-stepper) (ht-append (hash-quote) (step)))
Example: The Macro Stepper tool composes a new icon @(hash-quote) and an existing icon @(step), resulting in @(macro-stepper) for its toolbar icon.
The @(hash-quote) icon connotes syntax, and is the color of a syntax-quote as rendered by DrRacket by default.
The @(step) icon is colored like DrRacket colors identifier syntax by default, and is shaped using metaphors used in debugger toolbars, TV remotes, and music players around the world.
It is composed of @(go-icon (solid-icon-color "blue") 16 'diffuse) to connote starting and @(bar-icon (solid-icon-color "blue") 16 'diffuse) to connote immediately stopping---a ``step.''
The author of this collection is available to adapt or create SVG icons for DrRacket tools, and charges no more than your immortal soul.
@section{Icon Parameters}
@doc-apply[toolbar-icon-height]{
The height of DrRacket toolbar icons.
Use @racket[(toolbar-icon-height)] as the @racket[height] argument when loading common icons that will be used in DrRacket toolbars and buttons, or in the toolbars and buttons of DrRacket tools.
(When making an icon for DrRacket's main toolbar, try to keep it nearly square so that it will not take up too much horizontal space when the toolbar is docked vertically.
If you cannot, as with the Macro Stepper, send a thinner icon as the @racket[alternate-bitmap] argument to a @racket[switchable-button%].)
}
@doc-apply[default-icon-height]{
The height of standard (e.g. not toolbar) DrRacket icons, used as a default argument through the @racketmodname[icons] module.
}
@doc-apply[default-icon-style]{
The style of DrRacket icons, used as a default argument throughout the @racketmodname[icons] module.
}
}
@section[#:tag "arrows"]{Arrow Icons}
@defmodule[images/icons/arrow]
@interaction-eval[#:eval icons-eval (require images/icons/arrow)]
@doc-apply[right-arrow-icon]
@doc-apply[left-arrow-icon]
@doc-apply[up-arrow-icon]
@doc-apply[down-arrow-icon]{
Cardinal direction arrows.
@interaction[#:eval icons-eval
(list (right-arrow-icon syntax-icon-color (toolbar-icon-height))
(left-arrow-icon run-icon-color)
(up-arrow-icon halt-icon-color 37)
(down-arrow-icon "lightblue" 44 glass-icon-material))]
}
@doc-apply[right-over-arrow-icon]
@doc-apply[left-over-arrow-icon]
@doc-apply[right-under-arrow-icon]
@doc-apply[left-under-arrow-icon]{
@interaction[#:eval icons-eval
(list (right-over-arrow-icon metal-icon-color (toolbar-icon-height))
(left-over-arrow-icon dark-metal-icon-color)
(right-under-arrow-icon run-icon-color 37)
(left-under-arrow-icon "lightgreen" 44 glass-icon-material))]
}
@section[#:tag "control"]{Control Icons}
@section[#:tag "file"]{File Icons}
@section[#:tag "tool"]{Tool Icons}
@section[#:tag "stickman"]{Stickman Icons}
@section[#:tag "misc"]{Miscellaneous Icons}
@;{
@subsection{Control Icons}
@doc-apply[go-icon]
@doc-apply[bar-icon]
@doc-apply[back-icon]
@doc-apply[stop-icon]
@doc-apply[record-icon]
@doc-apply[step-icon]
@doc-apply[step-back-icon]
@doc-apply[continue-icon]
@doc-apply[continue-back-icon]
@doc-apply[fast-forward-icon]
@doc-apply[rewind-icon]
@doc-apply[pause-icon]{
These return typical ``playback'' icons.
@interaction[#:eval icons-eval
(for/list ([make-icon (list rewind-icon continue-back-icon
step-back-icon back-icon
pause-icon stop-icon
go-icon step-icon
continue-icon fast-forward-icon
record-icon)]
[style (in-cycle icon-styles)])
(make-icon (solid-icon-color "darkseagreen") 32 style))]
The remaining icon @(bar-icon #f 16), returned by @racket[bar-icon], is used to build the others.
}
@subsection{Arrow Icons}
@doc-apply[up-arrow-icon]
@doc-apply[down-arrow-icon]
@doc-apply[left-arrow-icon]
@doc-apply[right-arrow-icon]{
@examples[#:eval icons-eval
(for/list ([make-icon (list up-arrow-icon down-arrow-icon
left-arrow-icon right-arrow-icon)])
(for/list ([style (in-list icon-styles)])
(make-icon (solid-icon-color "brown") (default-icon-height) style)))]
}
@subsection{Sign Icons}
@doc-apply[stop-sign-icon]{
@examples[#:eval icons-eval (list (stop-sign-icon (default-icon-height) 'diffuse)
(stop-sign-icon (default-icon-height) 'shiny))]
}
@subsection{Check Icons}
@doc-apply[check-icon]{
@examples[#:eval icons-eval
(list (check-icon (solid-icon-color "green") 29 'diffuse)
(check-icon (solid-icon-color "green") 29 'shiny))]
}
@doc-apply[x-icon]{
@examples[#:eval icons-eval
(for/list ([color icon-colors]
[style (in-cycle icon-styles)])
(x-icon color 29 style))]
}
@subsection{Miscellaneous Icons}
@doc-apply[magnifying-glass-icon]{
@examples[#:eval icons-eval (list (magnifying-glass-icon 31 'diffuse)
(magnifying-glass-icon 31 'shiny))]
Note that the uncolorized magnifying glass has a brown handle.
}
@doc-apply[magnifying-glass-left-icon]{
@examples[#:eval icons-eval (list (magnifying-glass-left-icon 31 'diffuse)
(magnifying-glass-left-icon 31 'shiny))]
}
@doc-apply[disk-icon]{
@examples[#:eval icons-eval
(for/list ([color icon-colors]
[style (in-cycle icon-styles)])
(disk-icon color 33 style))]
}
@doc-apply[earth-icon]{
@examples[#:eval icons-eval (list (earth-icon 48 'diffuse)
(earth-icon 48 'shiny))]
}
@doc-apply[moon-icon]{
@examples[#:eval icons-eval (list (moon-icon 48 'diffuse)
(moon-icon 48 'shiny))]
}
@subsection{Symbols}
@doc-apply[hash-quote-icon]{
@examples[#:eval icons-eval (list (hash-quote-icon (toolbar-icon-height) 'diffuse)
(hash-quote-icon (toolbar-icon-height) 'shiny))]
}
@doc-apply[plus-icon]{
@examples[#:eval icons-eval
(for/list ([color icon-colors]
[style (in-cycle icon-styles)])
(plus-icon color 24 style))]
}
@doc-apply[times-icon]{
@examples[#:eval icons-eval
(for/list ([color icon-colors]
[style (in-cycle icon-styles)])
(times-icon color 24 style))]
}
@subsection{Logos}
@doc-apply[plt-logo]{
@examples[#:eval icons-eval
(list (plt-logo 128 'diffuse) (plt-logo 128 'shiny))]
}
@doc-apply[planet-logo]{
@examples[#:eval icons-eval (list (planet-logo 128 'diffuse)
(planet-logo 128 'shiny))]
}
@section{Icon Constants and Contracts}
@;{
@doc-apply[icon-colors]{
A list containing the names of allowed icon colors.
When an SVG icon source file is rendered, it is rendered once directly. Then, for each color corresponding to a symbol in @racket[icon-colors], it is colorized by replacing gradients, and then rendered.
When loading an icon, a @racket[#f] color name loads an uncolorized rendering.
Every icon can be loaded with a @racket[#f] color name.
An icon can be loaded using any name in @racket[icon-colors] only if its SVG source has gradients that can be colorized.
See @secref["new-icons"] for details.
The actual hues associated with the color names are the hues of the first seven @racketmodname[plot] color numbers.
The following example illustrates the correspondence:
@interaction[#:eval icons-eval
(require plot)
(for/list ([color (rest icon-colors)])
(stop-flomap color 48))
(parameterize ([plot-width 48]
[plot-height 48]
[plot-decorations? #f]
[plot-background-alpha 0])
(for/list ([n (in-range 7)])
(plot3d-pict (surface3d (λ (x y) (- (sqr x) (sqr y))) -1 1 -1 1
#:color n #:line-color n
#:samples 11 #:line-width 1))))]
This example also shows how to use @racketmodname[plot] to create icon @racket[pict]s from mathematical functions.
}}
@doc-apply[icon-color/c]{
A contract that identifies color names.
}
@doc-apply[icon-styles]{
Typical icon styles.
It is not necessary to have a version of each icon in each style.
But if an icon has different styles, it should have these.
}
@doc-apply[icon-style/c]{
A contract that identifies icon styles.
}
@section{Icon @racket[pict]s}
@interaction-eval[#:eval icons-eval (require slideshow/pict)]
It is more flexible, but a little more complicated, to load icons as @racket[pict]s.
As picts, icons can easily be appended, inset, superimposed, blurred, and more.
For example, it is easy to make modern-looking media player controls using @racket[cc-superimpose] and the @racket['shiny] style:
@interaction[#:eval icons-eval
(define media-icon-background (record-flomap 'blue 64 'shiny))
(list (cc-superimpose media-icon-background
(step-back-flomap 'white 32 'shiny))
(cc-superimpose media-icon-background
(pause-flomap 'white 32 'shiny))
(cc-superimpose media-icon-background
(step-flomap 'white 32 'shiny)))]
Almost all of the functions in preceeding sections are defined in terms of the @racket[pict]-producing functions documented in this section.
To use these functions effectively, you should require @racketmodname[icons] and @racketmodname[slideshow/pict] together.
Use @racket[bitmap] to convert a @racket[bitmap%] (e.g. an icon) to a @racket[pict], and @racket[pict->bitmap] to convert back.
Converting from @racket[pict]s to bitmaps can be lossy. For example, converting text can look especially horrible:
@interaction[#:eval icons-eval
(scale (text "Hello" null 10) 5)
(scale (bitmap (pict->bitmap (text "Hello" null 10))) 5)]
Therefore, when composing icons from parts, try to work only with @racket[pict]s, and convert to an icon using @racket[pict->bitmap] as the last step.
When composing icons from parts, it is fine to use @racket[pict]s converted from @racket[bitmap%]s.
Without scaling or rotating, the conversion is lossless:
@interaction[#:eval icons-eval
(define not-blurry (magnifying-glass-icon 64 'shiny))
not-blurry
(for/fold ([icon not-blurry]) ([i (in-range 30)])
(pict->bitmap (bitmap icon)))]
Avoid converting between @racket[pict]s and @racket[bitmap%]s more than once if bitmap-backed @racket[pict]s are scaled, rotated by angles that are not multiples of 90 degrees, or superimposed or appended at non-integer coordinates.
Avoid scaling up in general.
@doc-apply[load-flomap]{
Corresponds to @racket[load-icon]. In fact, @racket[load-icon] uses @racket[load-flomap] to load the icon as a @racket[pict], and passes it to @racket[pict->bitmap].
}
@doc-apply[go-flomap]
@doc-apply[bar-flomap]
@doc-apply[back-flomap]
@doc-apply[stop-flomap]
@doc-apply[record-flomap]
@doc-apply[step-flomap]
@doc-apply[step-back-flomap]
@doc-apply[continue-flomap]
@doc-apply[continue-back-flomap]
@doc-apply[fast-forward-flomap]
@doc-apply[rewind-flomap]
@doc-apply[pause-flomap]{
These return typical ``playback'' icons, as @racket[pict]s.
@interaction[#:eval icons-eval
(for/fold ([icon (blank)])
([make-flomap (list rewind-flomap continue-back-flomap
step-back-flomap back-flomap
pause-flomap stop-flomap
go-flomap step-flomap
continue-flomap fast-forward-flomap
record-flomap)])
(hc-append icon (make-flomap 'black 32 'shiny) (blank 12)))]
}
@doc-apply[up-arrow-flomap]{ Corresponds to @racket[up-arrow-icon]. }
@doc-apply[down-arrow-flomap]{ Corresponds to @racket[down-arrow-icon]. }
@doc-apply[left-arrow-flomap]{ Corresponds to @racket[left-arrow-icon]. }
@doc-apply[right-arrow-flomap]{ Corresponds to @racket[right-arrow-icon]. }
@doc-apply[stop-sign-flomap]{ Corresponds to @racket[stop-sign-icon]. }
@doc-apply[check-flomap]{ Corresponds to @racket[check-icon]. }
@doc-apply[x-flomap]{ Corresponds to @racket[x-icon]. }
@doc-apply[magnifying-glass-flomap]{ Corresponds to @racket[magnifying-glass-icon]. }
@doc-apply[magnifying-glass-left-flomap]{ Corresponds to @racket[magnifying-glass-left-icon]. }
@doc-apply[disk-flomap]{ Corresponds to @racket[disk-icon]. }
@doc-apply[earth-flomap]{ Corresponds to @racket[earth-icon]. }
@doc-apply[moon-flomap]{ Corresponds to @racket[moon-icon]. }
@doc-apply[hash-quote-flomap]{ Corresponds to @racket[hash-quote-icon]. }
@doc-apply[plus-flomap]{ Corresponds to @racket[plus-icon]. }
@doc-apply[times-flomap]{ Corresponds to @racket[times-icon]. }
@doc-apply[plt-logo-pict]{ Corresponds to @racket[plt-logo]. }
@doc-apply[planet-logo-pict]{ Corresponds to @racket[planet-logo]. }
}

View File

@ -0,0 +1,14 @@
#lang scribble/manual
@(define (author-email) "neil.toronto@gmail.com")
@title{Images}
@author{@(author+email "Neil Toronto" (author-email))}
@table-of-contents[]
@include-section["icons.scrbl"]
@include-section["logos.scrbl"]
@include-section["compile-time.scrbl"]

View File

@ -0,0 +1,11 @@
#lang scribble/manual
@(require scribble/eval
(for-label images/logos
racket)
images/logos)
@(define (author-email) "neil.toronto@gmail.com")
@title{Logos}
@author{@(author+email "Neil Toronto" (author-email))}

View File

@ -8,7 +8,10 @@
images/icons/tool
images/icons/style
images/private/deep-flomap-render
images/private/utils)
images/private/utils
images/compile-time
(for-syntax images/icons/stickman
images/icons/style))
(default-icon-height 16)
;(default-icon-material glass-icon-material)
@ -19,6 +22,20 @@
0.0))
;(default-icon-material diamond-material)
;; ===================================================================================================
;; Compiled stickman test
(begin-for-syntax
(define stickman-height 32)
(define num-running-frames 12))
(compiled-bitmap-list
(for/list ([t (in-range 0 1 (/ 1 num-running-frames))])
(running-stickman-icon t run-icon-color "white" run-icon-color stickman-height)))
;; ===================================================================================================
;; Other icons, various colors
(define icon-procss
(list (list reverse-icon continue-back-icon step-back-icon back-icon pause-icon
stop-icon record-icon play-icon step-icon continue-icon fast-forward-icon)

View File

@ -10,7 +10,8 @@
(only-in "view/view.rkt" macro-stepper-director%)
"view/stepper.rkt"
"view/prefs.rkt"
images/icons/tool
images/compile-time
(for-syntax racket/base images/icons/tool)
;; FIXME:
drracket/private/syncheck/local-member-names)
@ -83,6 +84,9 @@
(define macro-stepper-button-label "Macro Stepper")
(define macro-debugger-bitmap (compiled-bitmap (macro-stepper-icon)))
(define small-macro-debugger-bitmap (compiled-bitmap (small-macro-stepper-icon)))
(define tool@
(unit
(import drracket:tool^)
@ -109,9 +113,6 @@
(define-local-member-name check-language)
(define macro-debugger-bitmap (macro-stepper-icon))
(define small-macro-debugger-bitmap (small-macro-stepper-icon))
(define (macro-debugger-unit-frame-mixin %)
(class* % (frame/supports-macro-stepper<%>)
(super-new)