# Line

{% hint style="info" %}
Line contains some methods also found in [Renderable](/quick-reference/renderable.md), but is not a Renderable, as it does not possess a width and height.
{% endhint %}

## Initialization

You can initialize a Line in a few different ways:

```python
line = Line(screen, x1, y1, x2, y2)  # Pass two points
line = Line(screen, (x1, y1), (x2, y2))  # Two points as tuples
line = Line(screen, location1, location2)  # Two points as Locations
```

## Movement

You can move the Line using slightly modified methods from Object:

We can translate by a specified amount with:

```python
line.move(dx, dy)  # Move both points by dx, dy
line.move(dx, dy, point=1)  # Move only the first point by dx, dy
```

We can move both positions to new locations with:

```python
line.moveto(x1, y1, x2, y2)
line.moveto((x1, y1), (x2, y2))
line.moveto(location1, location2)
```

We can change only one of the positions with either:

```python
line.pos1(location)
```

```python
line.pos2(location)
```

{% hint style="info" %}
Most methods in Line are able to take numbers, tuples, or Locations because Lines deal with more coordinates than Renderables.
{% endhint %}

## Location

Retrieve both positions in a tuple using the familiar:

```python
line.location()  # Returns both endpoints positions as a tuple (pos1, pos2)
```

## Rotation

You can rotate lines just as you would expect:

```python
line.rotation()  # Get the current rotation
line.rotation(rotation)  # Set a new angle
```

```python
line.rotate(angle_change)  # Change angle by angle_change
```

Or we can pass a location in for the line to look at:

```python
line.lookat(location)  # Look at the passed location (moves second endpoint)
line.lookat(location, point=1)  # Move the first point instead
```

## Color

You can change the Color of a Line just like a Renderable:

```python
line.color()  # Retrieve the current Color
line.color(color)  # Set a new Color
```

## Thickness

You can modify the thickness of the line in pixels with:

```python
line.thickness(thickness)
```

## Dashes

You may decide to change the line to a dotted line with:

```python
line.dashes(3)  # Add dashes 3px in length with 3px between them
line.dashes((3, 2))  # Specify dash length and distance separately.
```

## Length

You can get the length of the line by calling:

```python
line.length()
```

## Visibility

Visibility is accessed exactly as it is in Renderable:

```python
line.visible(False)
```

## Transform and Cloning

Transforms and cloning work as in Renderable:

```python
line.transform()  # (pos1, pos2, angle)
```

{% hint style="warning" %}
Line's transform is a tuple with both positions and current angle.
{% endhint %}

Cloning works as expected:

```python
line2 = line.clone()  # new line that's the same!
```

## Intersects (Overlaps)

The Line's version of [Renderable](/quick-reference/renderable.md#contains-and-overlaps)'s `overlaps()` is `intersects()`. It can take any Renderable or Line and will check if the line intersects with any of their lines.

```python
line.intersects(line2)
line.intersects(rectangle)
```


---

# Agent Instructions: 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:

```
GET https://docs.pydraw.graphics/quick-reference/line.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
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.
