racket/draw: clean up object name hacks
The only observable impact of this change is that `the-color-database` will now print as `(object:color-database% ...)` instead of `(object:color-database<%> ...)`. The former makes more sense anyway, given that you can't have an instance of an interface. If we really want the latter though, we can add `object-rename` for this purpose.
This commit is contained in:
parent
839f971912
commit
80ca36e6ab
|
@ -8,7 +8,7 @@
|
||||||
color-green
|
color-green
|
||||||
color-blue
|
color-blue
|
||||||
color-alpha
|
color-alpha
|
||||||
(rename-out [color-database-intf color-database<%>])
|
color-database<%>
|
||||||
the-color-database
|
the-color-database
|
||||||
color->immutable-color)
|
color->immutable-color)
|
||||||
|
|
||||||
|
@ -98,13 +98,10 @@
|
||||||
|
|
||||||
(define color-objects (make-hash))
|
(define color-objects (make-hash))
|
||||||
|
|
||||||
(define color-database-intf
|
(define color-database<%>
|
||||||
(let ([color-database<%> (interface ()
|
(interface () find-color get-names))
|
||||||
find-color
|
|
||||||
get-names)])
|
|
||||||
color-database<%>))
|
|
||||||
|
|
||||||
(defclass* color-database<%> object% (color-database-intf)
|
(defclass* color-database% object% (color-database<%>)
|
||||||
(super-new)
|
(super-new)
|
||||||
(def/public (find-color [string? name])
|
(def/public (find-color [string? name])
|
||||||
(let ([name (string-downcase name)])
|
(let ([name (string-downcase name)])
|
||||||
|
@ -120,7 +117,7 @@
|
||||||
(def/public (get-names)
|
(def/public (get-names)
|
||||||
(sort (hash-map colors (lambda (k v) k)) string<?)))
|
(sort (hash-map colors (lambda (k v) k)) string<?)))
|
||||||
|
|
||||||
(define the-color-database (new color-database<%>))
|
(define the-color-database (new color-database%))
|
||||||
|
|
||||||
(define colors
|
(define colors
|
||||||
#hash(("aliceblue" . #(240 248 255))
|
#hash(("aliceblue" . #(240 248 255))
|
||||||
|
|
Loading…
Reference in New Issue
Block a user