> For the complete documentation index, see [llms.txt](https://csharp.progdocs.se/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://csharp.progdocs.se/annat/raylib/rectangle.md).

# Rectangle

Rectangle är en datatyp som beskriver rektanglar. De kan användas både för att rita ut rektanglar på skärmen och för att [kolla kollisioner](/annat/raylib/kollisioner.md).

```csharp
// Skapar två rektanglar
Rectangle r1 = new Rectangle(10,10,50,20);
Rectangle r1 = new Rectangle(5,5,50,20);

// Ritar ut en rektangel
Raylib.DrawRectangleRec(r1, Color.SKYBLUE);

// Kollar ifall två rektanglar överlappar varandra
bool isColliding = Raylib.CheckCollisionRecs(r1, r2);
```

Man kan ändra på en rektangels egenskaper i efterhand.

```csharp
r1.X += 3;
r1.Y = 90;
r1.Width = 50;
r1.Height = 30;
```

## Rectangle och List

Rectangles är inte [klasser](/klasser-och-objektorientering/klasser-och-instanser.md) – de är Structs. Det betyder att om man lagrar rectangles i en lista, så kan man inte ändra rektanglarna direkt i listan.

```csharp
List<Rectangle> rects = new List<Rectangle>();

rects.Add(new Rectangle());
rects.Add(new Rectangle());
rects.Add(new Rectangle());
rects.Add(new Rectangle());

// SÅHÄR KAN MAN INTE GÖRA
rects[1].X = 5;

// GÖR SÅHÄR ISTÄLLET
Rectangle tmp = rects[1];
tmp.X = 5;
rects[1] = tmp;
```


---

# 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://csharp.progdocs.se/annat/raylib/rectangle.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.
