Logo icon indicating copy to clipboard operation
Logo copied to clipboard

Berkeley Logo Conformity

Open TheTastefulToastie opened this issue 7 years ago • 2 comments

In the Berkeley Logo User Manual the commands are implemented as full words and then aliased with shorter two-letter abbreviations and all commands are specified in screaming-case (all uppercase).

  • We currently only implement the abbreviated commands.
  • The abbreviation for BACK appears to be incorrect (currently bd).
  • Uppercase commands are not currently accepted by the interpretor. (Should be case-insensitive?)
  • It seems we should also be able to specify colors using the numbers 0-15 (see below).
Excerpt from the Berkeley Logo User Manual

GRAPHICS

Berkeley Logo provides traditional Logo turtle graphics with one turtle. Multiple turtles, dynamic turtles, and collision detection are not supported. This is the most hardware-dependent part of Logo; some features may exist on some machines but not others. Nevertheless, the goal has been to make Logo programs as portable as possible, rather than to take fullest advantage of the capabilities of each machine. In particular, Logo attempts to scale the screen so that turtle coordinates [-100 -100] and [100 100] fit on the graphics window, and so that the aspect ratio is 1:1.

The center of the graphics window (which may or may not be the entire screen, depending on the machine used) is turtle location [0 0]. Positive X is to the right; positive Y is up. Headings (angles) are measured in degrees clockwise from the positive Y axis. (This differs from the common mathematical convention of measuring angles counterclockwise from the positive X axis.) The turtle is represented as an isoceles triangle; the actual turtle position is at the midpoint of the base (the short side). However, the turtle is drawn one step behind its actual position, so that the display of the base of the turtle's triangle does not obscure a line drawn perpendicular to it (as would happen after drawing a square).

Colors are, of course, hardware-dependent. However, Logo provides partial hardware independence by interpreting color numbers 0 through 7 uniformly on all computers:

0  black	1  blue		2  green	3  cyan
4  red		5  magenta	6  yellow	7 white

Where possible, Logo provides additional user-settable colors; how many are available depends on the hardware and operating system environment. If at least 16 colors are available, Logo tries to provide uniform initial settings for the colors 8-15:

 8  brown	 9  tan		10  forest	11  aqua
12  salmon	13  purple	14  orange	15  grey

Logo begins with a black background and white pen.

TURTLE MOTION

FORWARD dist FD dist

moves the turtle forward, in the direction that it's facing, by
the specified distance (measured in turtle steps).

BACK dist BK dist

moves the turtle backward, i.e., exactly opposite to the direction
that it's facing, by the specified distance.  (The heading of the
turtle does not change.)

LEFT degrees LT degrees

turns the turtle counterclockwise by the specified angle, measured
in degrees (1/360 of a circle).

RIGHT degrees RT degrees

turns the turtle clockwise by the specified angle, measured in
degrees (1/360 of a circle).

SETPOS pos

moves the turtle to an absolute position in the graphics window.  The
input is a list of two numbers, the X and Y coordinates.

SETXY xcor ycor

moves the turtle to an absolute position in the graphics window.  The
two inputs are numbers, the X and Y coordinates.

SETX xcor

moves the turtle horizontally from its old position to a new
absolute horizontal coordinate.  The input is the new X
coordinate.

SETY ycor

moves the turtle vertically from its old position to a new
absolute vertical coordinate.  The input is the new Y
coordinate.

SETHEADING degrees SETH degrees

turns the turtle to a new absolute heading.  The input is
a number, the heading in degrees clockwise from the positive
Y axis.

HOME

moves the turtle to the center of the screen.  Equivalent to
SETPOS [0 0] SETHEADING 0.

ARC angle radius

draws an arc of a circle, with the turtle at the center, with the
specified radius, starting at the turtle's heading and extending
clockwise through the specified angle.  The turtle does not move.

TheTastefulToastie avatar Nov 27 '18 14:11 TheTastefulToastie

The color part is easy we can check if the param is Int and set the correct hex from a map

Sent from my iPhone

On Nov 27, 2018, at 6:43 AM, TheTastefulToastie <[email protected]mailto:[email protected]> wrote:

In the Berkeley Logo User Manualhttps://people.eecs.berkeley.edu/~bh/usermanual the commands are implemented as full words and then aliased with shorter two-letter abbreviations and all commands are specified in screaming-case (all uppercase).

  • We currently only implement the abbreviated commands.
  • The abbreviation for BACK appears to be incorrect (currently bd).
  • Uppercase commands are not currently accepted by the interpretor. (Should be case-insensitive?)
  • It seems we should also be able to specify colors using the numbers 0-15 (see below).

Excerpt from the Berkeley Logo User Manual

GRAPHICS

Berkeley Logo provides traditional Logo turtle graphics with one turtle. Multiple turtles, dynamic turtles, and collision detection are not supported. This is the most hardware-dependent part of Logo; some features may exist on some machines but not others. Nevertheless, the goal has been to make Logo programs as portable as possible, rather than to take fullest advantage of the capabilities of each machine. In particular, Logo attempts to scale the screen so that turtle coordinates [-100 -100] and [100 100] fit on the graphics window, and so that the aspect ratio is 1:1.

The center of the graphics window (which may or may not be the entire screen, depending on the machine used) is turtle location [0 0]. Positive X is to the right; positive Y is up. Headings (angles) are measured in degrees clockwise from the positive Y axis. (This differs from the common mathematical convention of measuring angles counterclockwise from the positive X axis.) The turtle is represented as an isoceles triangle; the actual turtle position is at the midpoint of the base (the short side). However, the turtle is drawn one step behind its actual position, so that the display of the base of the turtle's triangle does not obscure a line drawn perpendicular to it (as would happen after drawing a square).

Colors are, of course, hardware-dependent. However, Logo provides partial hardware independence by interpreting color numbers 0 through 7 uniformly on all computers:

0 black 1 blue 2 green 3 cyan 4 red 5 magenta 6 yellow 7 white

Where possible, Logo provides additional user-settable colors; how many are available depends on the hardware and operating system environment. If at least 16 colors are available, Logo tries to provide uniform initial settings for the colors 8-15:

8 brown 9 tan 10 forest 11 aqua 12 salmon 13 purple 14 orange 15 grey

Logo begins with a black background and white pen.

TURTLE MOTION

FORWARD dist FD dist

moves the turtle forward, in the direction that it's facing, by the specified distance (measured in turtle steps).

BACK dist BK dist

moves the turtle backward, i.e., exactly opposite to the direction that it's facing, by the specified distance. (The heading of the turtle does not change.)

LEFT degrees LT degrees

turns the turtle counterclockwise by the specified angle, measured in degrees (1/360 of a circle).

RIGHT degrees RT degrees

turns the turtle clockwise by the specified angle, measured in degrees (1/360 of a circle).

SETPOS pos

moves the turtle to an absolute position in the graphics window. The input is a list of two numbers, the X and Y coordinates.

SETXY xcor ycor

moves the turtle to an absolute position in the graphics window. The two inputs are numbers, the X and Y coordinates.

SETX xcor

moves the turtle horizontally from its old position to a new absolute horizontal coordinate. The input is the new X coordinate.

SETY ycor

moves the turtle vertically from its old position to a new absolute vertical coordinate. The input is the new Y coordinate.

SETHEADING degrees SETH degrees

turns the turtle to a new absolute heading. The input is a number, the heading in degrees clockwise from the positive Y axis.

HOME

moves the turtle to the center of the screen. Equivalent to SETPOS [0 0] SETHEADING 0.

ARC angle radius

draws an arc of a circle, with the turtle at the center, with the specified radius, starting at the turtle's heading and extending clockwise through the specified angle. The turtle does not move.

— You are receiving this because you are subscribed to this thread. Reply to this email directly, view it on GitHubhttps://github.com/CodingTrain/Logo/issues/74, or mute the threadhttps://github.com/notifications/unsubscribe-auth/ABZ1YMJhcrwC0-E9eCsKGvb3NPLcy4Sjks5uzU-hgaJpZM4Y1oq8.

Toyz avatar Nov 27 '18 17:11 Toyz

Yes, in addition to that it should probably only allow positive integers.

how many are available depends on the hardware and operating system environment

I see no reason to limit it, we can easily provide an unlimited number of user-definable colors.

We would also need to implemented the SETPALETTE command which would update the map with a new color (but not for colors 0-7).

SETPALETTE colornumber rgblist

	sets the actual color corresponding to a given number, if allowed by
	the hardware and operating system.  Colornumber must be an integer
	greater than or equal to 8.  (Logo tries to keep the first 8 colors
	constant.)  The second input is a list of three nonnegative numbers
	less than 100 specifying the percent saturation of red, green, and
	blue in the desired color.

TheTastefulToastie avatar Nov 27 '18 17:11 TheTastefulToastie