> 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/grafik.md).

# Grundläggande grafik

## Mått och koordinatsystem

Observera att koordinatsystemet i Raylib har **origo i övre vänstra hörnet**, och att **Y-axeln är omvänd** så att positiva värden går nedåt.

Måtten är i **pixlar**.

## SetTargetFps()

Används normalt utanför spel-loopen, för att begränsa antalet bildrutor per sekund. Är ett av de sätt som finns att få t.ex. förflyttningar att ske lika snabbt på alla datorer.

```csharp
Raylib.SetTargetFps(60); // Begränsar till 60fps
```

## BeginDrawing(), EndDrawing()

Används för att påbörja, respektive avsluta, den delen av spelloopen som ritar ut saker till fönstret.

```csharp
while (!Raylib.WindowShouldClose())
{
  // Spelets logik
  
  Raylib.BeginDrawing();
  
  // Kod för att rita ut saker till fönstret
  
  Raylib.EndDrawing();
}
```

## ClearBackground()

Rensar fönstret. Görs normalt kort efter BeginDrawing.

```csharp
while (!Raylib.WindowShouldClose())
{
  Raylib.BeginDrawing();

  Raylib.ClearBackground(Color.WHITE);
  
  Raylib.EndDrawing();
}
```

## Färger

Det finns en hel del färdiga färger i Raylib, till exempel Color.MAGENTA eller Color.ORANGE.

Om man vill skapa en egen ny färg så kan man göra det:

```csharp
Color hotPink = new Color(255, 105, 180, 255);
```

Parametrarna är helt enkelt siffror från 0–255 för rött, grönt, blått och alpha (genomskinlighet). 0 alpha är helt genomskinlig, 255 är helt ogenomskinlig.


---

# 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/grafik.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.
