Tymless Tutorial: Data



   
  < aliases

Locations

 
shapes >
 

Drawing

Control

Data

Reference

 

A location is a place on the drawing board. It need not be 'drawn on' to be a valid location.

Locations can be created and assigned to variables using the by operator, which returns the location given by the x and y coordinates.

locA = 2 by 3.5

There is also a system variable $here which tells the turtle where it is. You can store its value in a user-defined variable, or alter its value to move the turtle 'by hand'. E.g.

$here = 3 by 4

moves the turtle to location (3,4)

Locations have two system properties, .$x and .$y which can be manipulated independently.

All locations are treated by Tymless as complex numbers. For those not familiar with these they not as complex as their name suggests! Each number consists of two parts, the x-coordinate and the y-coordinate (usually called the 'real' and 'imaginary' part). The wonderful feature of these numbers is that you can do arithmetic with them as if they were any other number, and the result is always another complex number. For example you can add two locations together to produce a third location. The ordinary numbers are also a subset of the complex numbers (they are the complex numbers lying along the x-axis) so you can include them in your location arithmetic too.

A = 3 by 4
B = $here
locPlus = A + B
locMinus = A - B
locTimes = A * B
locSquared = A ** 2
locPower = A ** B

As well as +, -, * and /, you can use **, and the trigonometric functions sin, cos and tan. Locations also have some functions of their own, such as rotate and flip.

Changing a location arithmetically like this is called a 'transformation'.

 

   
  < aliases
 
shapes >