Operators (Transformations)

A really creative part of SeeLogo is the ability to create new shapes by transforming old ones, but be warned. You will have so much fun that it can be addicting. Essentially, there are two types of transformations: 1) Those that transform a shape just once or twice (SIZE, FLIP, TRANS, GLIDERF, MIRROR) and 2) those who transform a shape a specified number of times: SPIN, SPINR ,SPINL, GROWBY GROWGBY and REPEAT.

When we see a picture on the screen, there is some hidden information that is not so obvious. The turtle state is actually part of the picture and it is going to affect the way the picture is transformed. We already met this concept when we drew shapes. For example, the command JT 80 50 RT 45 BOX 70 20 draws a tilted rectangle at the coordinate (80,50). The same principle applies when we use operators.

Let us start by examining the REPEAT command. This command takes two inputs: a number and a picture. For example, typing REPEAT 3 [CIRCLE 30] will redraw the same circle 3 times since the turtle did not move. However, the command REPEAT 3 [CIRCLE 30 JT 30 0] will draw 3 circles side by side.




Here is another way to accomplish this task. Note that pictures can use other pictures as building blocks.

START A NEW SEELOGO

TYPE NEW A

CIRCLE 30

JT 30 0

NEW B

REPEAT 3 A

If, on the other hand, you define a new procedure named A1 as "CIRCLE 30 JT 0 30" (instead of 30 0) and apply the repeat operator to it, the circles will be stacked on top of each other.


Using this example, we also showed how the syntax of the REPEAT command works. In a succinct form we can say that the grammar for the "Repeat command" is REPEAT number [NAME]. Instead of the predefined name, we can actually also use any list of commands enclosed in square brackets. The program B will be the same as REPEAT 3 [CIRCLE 30 JT 30 0] and one could type it directly into the editor.


The syntax of the other operators is similar:

TILE [name]

MIRROR [name]

DOUBLE [name]


SIZE number [name]

REPEAT number [name]

Note: There is another command called LOOP that works very similarly to REPEAT but is used in programming. This will be introduced later.

SPIN number [name]

SPINR number [name]

SPINL number [name]

ROT number [name]

COLOR number [name]

SOLID number [name]


GROWBY number1 number2 [name]

GROWGBY number1 number2 [name]

GLIDEREF number1 number2 [name]

TRANS number1 number2 [name]


Here are some using the important operators.

NEW p1

MIRROR [ CURVER 120 50]




new p2

SPIN 8 [ARCR 180 40 JT 0 0]





new p3

GROWBY 10% 24 [FD 20 RT 90]




new p4

GROWGBY 10% 12 [ARCR 180 40]





new p5

SPINR 3 [ARCR 120 40 ARCL 120 40]




Once an operator is applied to a picture, other operators, including the original one, can be re-applied. Beautiful pictures will emerge! For example:

SPIN 5 [p1 JT 0 0]

MIRROR [p2]

MIRROR [p4]

SPIN 6 [p5]

If you are reading it in the SeeLogo Help Screen, you will be able to link to the following problems: (the links work through seelogo)

REPEAT I

REPEAT II

SPIN

SPINR L

MIRROR

GROWBY (without Computations)

GROWBY (with Computations)

GROWGBY

Mixed Exercises I

Mixed Exercises II

Mixed (Level II - applying operators twice)