Please enable JavaScript to view this site.

ESL Documentation

You can change the color of a key or the background color of a graphical, image, or textual region by specifying a make COLOR statement. You can also specify a make COLOR statement to change the color of all of the objects in a class; for example:

 

response to Logo

    make Screen1 blue

 

Here, Screen1 is changed to blue.

 

You can use a string variable for the color; for example:

 

make Lobster in Seafood color ColorChoice

 

Here, ColorChoice is a variable that can contain a string value representing one of the color keywords, or an integer value representing one of the color numbers. (See Color for more information on the use of ESL color keywords and values.)

 

The make COLOR statement changes the default color of the object's drawing statements, but does not override the explicit colors specified within the drawing statements; for example:

 

blue key BigKey at position 100 200

    solid box 50 50

    move to 10 20

    black text align "BIG"

 

response to MakeRed

    make BigKey red

 

This changes the color of the solid box, but does not change the color of the text. If you want to change the color of the object's drawing statements (such as the text in BigKey), you need to specify a change or change graphics action statement.

 

You can change the color of an object, or all the objects in a class, by adding a color value to the make statement; for example:

 

response to BigPicture

    make object blue

 

You can include ancestry in the statement, and you can use a string or integer variable to hold the color value; for example:

 

make Graph in BigPicture color ColorChoice

 

Here, Graph and its contents are drawn in the color specified in the variable ColorChoice.

 

You can change the color of a colored textual region. (See Textual Regions for detailed information on colored textual regions.) For example:

 

make Speedometer in Dashboard foreground blue

 

To change both the background and foreground color, you need to write separate statements; for example:

 

make Notebook foreground aqua 

make Notebook background red

 

Note that when you change the foreground or background of a textual region, all previous color specifications - including those used to color individual characters in a colored textual region - are cleared and replaced with the newly specified color.

 

You can use the following built-in functions to find out the current color of an object during runtime.

 

Function

Value Returned

foreground of

Returns the foreground color of the specified object.

background of

Returns the background color of the specified graphical or textual region.

border of

Returns the color of the border of a specified graphical or textual region.

foreground at

Returns the foreground color of a specified position in a textual region.

background at

Returns the background color of a specified position in a textual region.