> For the complete documentation index, see [llms.txt](https://docs.pydraw.graphics/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://docs.pydraw.graphics/quick-reference/location.md).

# Location

## Initialization

Locations can be initialized with two coordinates, a tuple, another location, or by specifying only one coordinate (such as x or y), defaulting the other coordinate's value to zero.

```python
location = Location(0, 0)  # Two arguments
location = Location((200, 100))  # A single tuple
location = Location(another_location)  # Copy constructor

location = Location(x=100)  # Create a location at (100, 0)
```

## Values

There is a variety of ways to retrieve the values from a Location instance:

```python
location.x()  # Get the x-coordinate
location.y()  # Get the y-coordinate
```

Locations are also readable as tuples:

```python
location[0]  # Get the x-coordinate
location[1]  # Get the y-coordinate
```

## Changing Locations

The methods above can also be used to modify coordinates:

```python
location.x(new_x)  # Set a new x-coordinate value
location.y(new_y)  # Set a new y-coordinate value
```

You can also call the handy `.move()` and `.moveto()` methods:

```python
location.move(dx, dy)  # Move the location by passed values
location.move((dx, dy))  # You can also pass in tuples!
location.move(location)  # Not sure why you'd need this :P
location.move(dx=100)  # Only move the x-coordinate by +100

location.moveto(x, y)  # Move to a new position
location.moveto((x, y))  # Pass in tuple
location.moveto(location)  # Move to the same position as another Location instance
location.moveto(y=100)  # Change the y-coordinate to 100
```

## Advanced

{% hint style="info" %}
It is possible to convert to turtle-based coordinates by calling:

```python
turtle_location = screen.create_location(location)
```

Or to convert to Tkinter:

```python
tkinter_location = screen.canvas_location(location)
```

{% endhint %}


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

## Querying This Documentation
If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter, and the optional `goal` query parameter:

```
GET https://docs.pydraw.graphics/quick-reference/location.md?ask=<question>&goal=<endgoal>
```

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is optional and describes the broader end goal you are ultimately trying to accomplish on behalf of the user. GitBook uses it to tailor the answer towards what is most useful for that goal.

The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
