# turn proc

Source: https://ref.dm-lang.org/proc/turn/

### Format
> `turn(Dir, Angle)`

### Args
- `Dir`: One of NORTH, SOUTH, EAST, WEST, NORTHEAST, NORTHWEST, SOUTHEAST, SOUTHWEST.
- `Angle`: An angle in degrees (counterclockwise rotation).


### Returns
> The rotated direction.

This proc can also be applied to an [icon](https://ref.dm-lang.org/proc/turn/icon.md), a [matrix](https://ref.dm-lang.org/proc/turn/matrix.md), or a [vector](https://ref.dm-lang.org/proc/turn/vector.md).

```dm /turn/
var/dir
dir = turn(NORTH, 90)  // dir = west
dir = turn(dir, -90)   // dir = north
dir = turn(dir, 45)    // dir = northwest
```

Only multiples of 45 are allowed for angles. If an invalid angle is used, it will be treated as the closest multiple of 45 to 0.

If the supplied Dir is invalid, such as 0, or something like UP or DOWN, the result is a random direction unless the angle is also 0.

### See also
- [Turn proc (icon)](https://ref.dm-lang.org/icon/proc/Turn.md)
- [dir var (atom)](https://ref.dm-lang.org/atom/var/dir.md)
- [Turn proc (vector)](https://ref.dm-lang.org/vector/proc/Turn.md)

## Pages

- [turn proc (applied to an icon)](https://ref.dm-lang.org/proc/turn/icon.md)
- [turn proc (applied to a matrix)](https://ref.dm-lang.org/proc/turn/matrix.md)
- [turn proc (applied to a vector)](https://ref.dm-lang.org/proc/turn/vector.md)
