Please enable JavaScript to view this site.

ESL Documentation

The graphics cursor is initially positioned at the object's origin - the point on the screen described by the at position specification in the object definition. Each time a drawing statement is executed, the position of the graphics cursor is updated.

 

The cursor position after the execution of a drawing statement depends on the statement executed. The cursor might be in a different place or in the same place. Some drawing statements, such as box and circle, begin and end at the same place, so the position of the graphics cursor is the same before and after the statement is executed. Other drawing statements, such as draw and move, change the position of the graphics cursor.

 

Suppose you define a key as follows:

 

key Arrow at position 100 200

    draw to 200 300

    draw to 400 0

 

ESL displays the image shown below:

 

_img271

 

(The coordinates shown in this picture are Arrow's own coordinates. Arrow's origin is 100 200 in the screen coordinate system.)  Before the drawing statements are executed, the initial position of the graphics cursor is at this origin.

 

When ESL executes the first drawing statement:

 

draw to 200 300

 

a line is drawn, as shown below:

 

_img272

 

The graphics cursor is now positioned at 200 300 in Arrow's coordinate system. When ESL executes the second drawing statement:

 

draw to 400 0

 

a second line is drawn, starting at the current position of Arrow's graphics cursor (200 300):

_img273

The graphics cursor is now positioned at 400 0 in Arrow's coordinate system. ESL retains the position of an object's graphics cursor, and any later additions to the contents of the object will begin at this point. For example, if the following response definition, which adds new drawing statements to Arrow's contents, is executed, the statements start at the current position of Arrow's graphics cursor (400 0), and draw a vertical line to the tip of the arrow:

 

response to MakeBigArrow

    add to Arrow

    move to 200 0        # Moves the graphics cursor.

    draw to 200 300      # Draws the line.

 

The final appearance of the object is shown below:

 

_img274

 

Arrow's graphics cursor remains at position 200 300, and any further changes to the contents of Arrow will begin at that point.

 

Some drawing statements allow you to specify relative or absolute

points in the coordinate system.

 

Relative positions, which are points relative to the current position, are specified with the by keyword.

 

Absolute positions are specified with the to keyword.

 

For example, a drawing statement of the form:

 

draw by 100 100

 

draws a line whose endpoint is 100 positions to the right of the current position and 100 positions up from this starting position. Because this line is drawn relative to the current position, this statement is considered to be a relative drawing statement.

 

On the other hand, a drawing statement of the form:

 

draw to 100 100

 

draws a line whose endpoint is at coordinate position 100 100 in the object's coordinate space, regardless of the starting position of the line. Because ESL draws to this absolute position, this statement is considered to be an absolute drawing statement.