color names for crayons

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
3 messages Options
Reply | Threaded
Open this post in threaded view
|

color names for crayons

Ralph Boland
I am using Squeak 5.1.  Sorry if this has already been fixed.

It's nice to have the additional named colors (the crayon color names)
but unfortunately if you do for example:

   "Color banana name"

you don't get #banana but instead get the unnamed color specifics.
I wrote the following code to fix this.
Feel free to use it or even add it to the next version of squeak under
the squeak license.

Ralph Boland


initializeCrayonNames
"Name crayon colors. The following colors were removed as they are duplicates:
    maraschino (red)
    lemon (yellow)
    snow (white)
    licorice (black)
    cantaloupe (lightOrange)"

"Color initializeCrayonNames"
"example: Color blueberry name"

    | crayonColors |

    crayonColors := #(aluminum aqua asparagus banana blueberry
bubblegum cantaloupe carnation cayenne clover eggplant fern flora
grape honeydew ice iron lavender lead licorice lime magnesium maroon
mercury midnight mocha moss nickel ocean orchid plum salmon seaFoam
silver sky snow spindrift spring steel strawberry tangerine teal tin
tungsten turquoise).

    crayonColors do: [:color |
        self named: color put: (Color perform: color)].

Reply | Threaded
Open this post in threaded view
|

Re: color names for crayons

marcel.taeumel
Hi Ralph,

thanks for your suggestion. Since the names are already encoded in the messages and some order is already defined in Color >> #orderedCrayonColors, you could just do this:

Color orderedCrayonColors keyAtValue: Color banana.

Anyway, you pointed out an issue with color naming and the new crayon colors. I will fix this in the Trunk. Thanks again. :)

Best,
Marcel
Reply | Threaded
Open this post in threaded view
|

Re: color names for crayons

marcel.taeumel
Anyhow, makes sense to have a cache:

[Color r: 0 g: 0 b: 0] bench '3,410,000 per second. 293 nanoseconds per run.'
[Color black] bench '128,000,000 per second. 7.8 nanoseconds per run.'

:-)

Best,
Marcel