# surface.DrawTexturedRectUV

- **Ortam:** İstemci, Menü
- **İngilizce aslı:** https://wiki.facepunch.com/gmod/surface.DrawTexturedRectUV
- **Çeviri tarihi:** 2025-09-08

```lua
surface.DrawTexturedRectUV( number x, number y, number width, number height, number startU, number startV, number endU, number endV )
```

## Açıklama

Tekrarlanan veya kısmi bir dokuya sahip dokulu bir dikdörtgen çizer.

`u` ve `v`, doku koordinatlarını ifade eder.

- (u, v) = (0, 0) sol üsttür
- (u, v) = (1, 0) sağ üsttür
- (u, v) = (1, 1) sağ alttır
- (u, v) = (0, 1) sol alttır

(1, 0) başlangıç ve (0, 1) bitiş noktalarını kullanarak bir resmi yatay olarak çevrilmiş şekilde çizebilirsiniz, aynısı diğer yönler için de geçerlidir. 1'in üzerine çıkmak dokuyu döşeyecektir. Negatif değerlere de izin verilir.

İşte yardımcı bir resim:

![image.png](https://gmod.tr/api/uploads/wiki/7c6f2f7dbefb01a547f2.png)

Ayrıca bakınız: [surface.DrawTexturedRect](https://gmod.tr/wiki/surface.DrawTexturedRect) ve [surface.DrawTexturedRectRotated](https://gmod.tr/wiki/surface.DrawTexturedRectRotated).

> **NOT:** Eğer bir .png resmi kullanıyorsanız ve döşeme (tiling) yapmayı planlıyorsanız, [Material](https://gmod.tr/wiki/Global.Material) fonksiyonunun ikinci parametresi olarak "noclamp" bayrağını sağlamanız gerekir.

> **NOT:** Eğer `surface.DrawTexturedRectUV`'nin doku koordinatlarınızı (u0, v0), (u1, v1) yanlış aldığını ve [CreateMaterial](https://gmod.tr/wiki/Global.CreateMaterial) ile oluşturulmuş bir materyal ile renderleme yaptığınızı fark ederseniz, bunları aşağıdaki kodla ayarlamayı deneyin:
>
> ```lua
> local du = 0.5 / 32 -- half pixel anticorrection
> local dv = 0.5 / 32 -- half pixel anticorrection
> local u0, v0 = (u0 - du) / (1 - 2 * du), (v0 - dv) / (1 - 2 * dv)
> local u1, v1 = (u1 - du) / (1 - 2 * du), (v1 - dv) / (1 - 2 * dv)
> ```
>
> **Açıklama:** `surface.DrawTexturedRectUV`, doku koordinatlarını yarım piksel kadar düzeltmeye çalışır (örnekleme ile ilgili bir durum) ve bu düzeltmeyi `IMaterial::GetMappingWidth()`/`GetMappingHeight()` kullanarak hesaplar. Eğer materyal bir `$basetexture` olmadan oluşturulduysa, `GetMappingWidth()`/`GetMappingHeight()` hata materyalinin genişliğini ve yüksekliğini (ki bu 32x32'dir) kullanır.

> **NOT:** Bu, 2D renderlama bağlamı gerektiren bir renderlama fonksiyonudur.
>
> Bu, yalnızca [2D Renderlama Kancaları (2d Rendering Hooks)](https://gmod.tr/wiki/2D_Rendering_Hooks) içinde çalışacağı anlamına gelir.

> **HATA:** UV ofsetleri, doğru döşeme sonuçları için (alt) piksel düzeltmesi gerektirebilir.
> Hata Takipçisi (Issue Tracker): [3173](https://github.com/Facepunch/garrysmod-issues/issues/3173)

## Argümanlar

1. [number](https://gmod.tr/wiki/number) **x**: X tam sayı koordinatı.
2. [number](https://gmod.tr/wiki/number) **y**: Y tam sayı koordinatı.
3. [number](https://gmod.tr/wiki/number) **width**: Dikdörtgenin tam sayı genişliği.
4. [number](https://gmod.tr/wiki/number) **height**: Dikdörtgenin tam sayı yüksekliği.
5. [number](https://gmod.tr/wiki/number) **startU**: Dikdörtgen başlangıcının U doku haritalaması.
6. [number](https://gmod.tr/wiki/number) **startV**: Dikdörtgen başlangıcının V doku haritalaması.
7. [number](https://gmod.tr/wiki/number) **endU**: Dikdörtgen bitişinin U doku haritalaması.
8. [number](https://gmod.tr/wiki/number) **endV**: Dikdörtgen bitişinin V doku haritalaması.

### Örnek

Fonksiyonun kullanımını gösterir.

```lua
local mat = Material( "gui/tool.png" )
hook.Add( "HUDPaint", "DrawTexturedRectUV_example1", function()
	surface.SetDrawColor( color_white )
	surface.SetMaterial( mat )

	surface.DrawTexturedRect( 25, 25, 100, 100 )
	surface.DrawTexturedRectUV( 25, 130, 100, 100, 0, 0, 1, 1 ) -- Exactly same as above line

	-- Draws right half of the texture
	-- Note that we also change the width of the rectangle to avoid stretcing of the texture
	-- This is for demonstration purposes, you can do whatever it is you need
	surface.DrawTexturedRectUV( 130, 130, 50, 100, 0.5, 0, 1, 1 )
end )
```

### Örnek

Bir panelin üzerine tekrarlanan bir doku çizer.

```lua
local mat = Material( "icon16/box.png", "noclamp" )
function PANEL:Paint( w, h )
	-- Size of your texture, texW - width, texH - height
	local texW = 16
	local texH = 16

	surface.SetMaterial( mat )
	surface.SetDrawColor( color_white )
	surface.DrawTexturedRectUV( 0, 0, w, h, 0, 0, w / texW, h / texH )
end
```

- [GMod Wiki ana sayfası](https://gmod.tr/wiki)

---

[Tüm sunucular](https://gmod.tr/) · [GmodTR Launcher](https://gmod.tr/launcher) · [Rehber](https://gmod.tr/rehber) · [GMod Wiki](https://gmod.tr/wiki) · [GmodTR nedir?](https://gmod.tr/hakkinda) · [Sunucu ekle](https://gmod.tr/sunucu-ekle) · [Discord](https://discord.gg/gmodtr)

Kaynak: https://gmod.tr/wiki/surface.DrawTexturedRectUV
