7 color-database<%>

▼ |  | The Racket Drawing Toolkit

1 | Overview
2 | bitmap%
3 | bitmap-dc%
4 | brush%
5 | brush-list%
6 | color%
7 | color-database<%>
8 | dc<%>
9 | dc-path%
10 | font%
11 | font-list%
12 | font-name-directory<%>
13 | gl-config%
14 | gl-context<%>
15 | linear-gradient%
16 | pdf-dc%
17 | pen%
18 | pen-list%
19 | point%
20 | post-script-dc%
21 | ps-setup%
22 | radial-gradient%
23 | record-dc%
24 | region%
25 | svg-dc%
26 | Drawing Functions
27 | Drawing Contracts
28 | Signature and Unit
29 | Unsafe Libraries
30 | Drawing Conveniences
31 | Platform Dependencies
| Bibliography
| Index

On this page:

find-color
get-names

top contents ← prev up next →

interface color-database<%> : interface?

The global the-color-database object is an instance of color-database<%>. It maintains a database of standard RGB colors for a predefined set of named colors (such as “black” and “light gray”). See find-color for information on how color names are normalized.

The following colors are in the database:

Orange Red
Tomato
Dark Red
Red
Firebrick
Crimson
Deep Pink
Maroon
Indian Red
Medium Violet Red
Violet Red
Light Coral
Hot Pink
Pale Violet Red
Light Pink
Rosy Brown
Pink
Orchid
Lavender Blush
Snow
Chocolate
Saddle Brown
Brown
Dark Orange
Coral
Sienna
Orange
Salmon
Peru
Dark Goldenrod
Goldenrod
Sandy Brown
Light Salmon
Dark Salmon
Gold
Yellow
Olive
Burlywood
Tan
Navajo White
Peach Puff
Khaki
Dark Khaki
Moccasin
Wheat
Bisque
Pale Goldenrod
Blanched Almond
Medium Goldenrod
Papaya Whip
Misty Rose
Lemon Chiffon
Antique White
Cornsilk
Light Goldenrod Yellow
Old Lace
Linen
Light Yellow
Sea Shell
Beige
Floral White
Ivory
Green
Lawn Green
Chartreuse
Green Yellow
Yellow Green
Medium Forest Green
Olive Drab
Dark Olive Green
Dark Sea Green
Lime
Dark Green
Lime Green
Forest Green
Spring Green
Medium Spring Green
Sea Green
Medium Sea Green
Aquamarine
Light Green
Pale Green
Medium Aquamarine
Turquoise
Light Sea Green
Medium Turquoise
Honeydew
Mint Cream
Royal Blue
Dodger Blue
Deep Sky Blue
CornflowerBlue
Steel Blue
Light Sky Blue
Dark Turquoise
Cyan
Aqua
Dark Cyan
Teal
Sky Blue
Cadet Blue
CadetBlue
Dark Slate Gray
Light Slate Gray
Slate Gray
Light Steel Blue
Light Blue
Powder Blue
Pale Turquoise
Light Cyan
Alice Blue
Azure
Medium Blue
Cornflower Blue
Dark Blue
Midnight Blue
Navy
Blue
Indigo
Blue Violet
Medium Slate Blue
Slate Blue
Purple
Dark Slate Blue
Dark Violet
Dark Orchid
Medium Purple
Cornflower Blue
Medium Orchid
Magenta
Fuchsia
Dark Magenta
Violet
Plum
Lavender
Thistle
Ghost White
White
White Smoke
Gainsboro
Light Gray
Silver
Gray
Dark Gray
Dim Gray
Black

See also color%.

> method (send a-color-database find-color color-name)
> → (or/c (is-a?/c color%) #f)
> color-name : string?

Finds a color by name (character case is ignored). If no color is found for the name, #f is returned, otherwise the result is an immutable color object.

Color names are normalized by case and spaces are removed from colors before they are looked up in the database, with two exceptions: "cornflower blue" and "cadet blue". For those two colors, the names are compared in a case-insensitive way, but spaces are not removed, as the spaceless versions of those names are different colors than the ones with spaces in them.

Examples:

> > (define (show-colors-named . names)
> (apply
> hc-append
> 2
> (for/list ([name (in-list names)])
> (colorize
> (filled-rectangle 60 40)
> (send the-color-database find-color name)))))
> > (show-colors-named "blue"
> "BLUE"
> "B L U E")
> > (show-colors-named "cornflowerblue"
> "CORNFLOWERBLUE"
> "CORN flow ERB lue"
> "cornflower blue"
> "CORNFLOWER BLUE"
> "cornflower blue "
> " CORNFLOWER BLUE"
> "cornflower blue")

Changed in version 1.16 of package draw-lib: Changed normalization to more generally remove spaces.

> method (send a-color-database get-names) → (listof string?)

Returns an alphabetically sorted list of case-folded color names for which find-color returns a color% value.
top contents ← prev up next →