# render.DrawSprite

- **Ortam:** İstemci
- **İngilizce aslı:** https://wiki.facepunch.com/gmod/render.DrawSprite
- **Çeviri tarihi:** 2026-05-14

```lua
render.DrawSprite( Vector position, number width, number height, Color color = Color( 255, 255, 255 ) )
```

## Açıklama

3 boyutlu uzayda bir spiriti çiziyor.

> **NOT:** Bu bir gösterimdir function that 3 boyutlu görüntüleme bağlamı gerektirir.
>
> Bu sadece çalışacak anlamına gelir. [3D Rendering Hooks](https://gmod.tr/wiki/3D_Rendering_Hooks).

## Argümanlar

1.. [Vektör](https://gmod.tr/wiki/Vector) **konumu**: Sprite'in konumu.
2.. [numara](https://gmod.tr/wiki/number) **genişliği**: Sprite'in genişliği.
3.. [numara](https://gmod.tr/wiki/number) **Yükseklik**: Sprite'in yüksekliği.
4.. [Renk](https://gmod.tr/wiki/Color) **Renkli** = Color( 255, 255, 255): Sprite'in rengi.

### Örnek

Haritanın ortasına bir cüce çiz.

```lua
local pos, material = Vector( 0, 0, 0 ), Material( "sprites/splodesprite" ) --Bu tür şeyleri daha verimli kod yapmak için döngülerin dışında tanımlayın.
hook.Add( "HUDPaint", "paintsprites", function()
	cam.Start3D() -- Ekrana çizebileceğimiz 3D'yi başlatın.
		render.SetMaterial( material ) - Ne istediğimizi söyleyin. Bu durumda gravgun'dan gelen flaş
		render.DrawSprite( pos, 16, 16, color_white ) -- Haritanın ortasında, 16x16 boyutunda orijinal renginde tam alfa ile spiriti çizin.
	cam.End3D()
end )
```

**Çıkış:** Haritada 0,0,0'da turuncu bir yıldız görünür.

### Örnek

Belirli bir görüntüleme bağlamına ihtiyaç duymadan verilen konumda sprite gösteren fonksiyon.

`draw.VectorSprite`( [Vektör](https://gmod.tr/wiki/Vector) konumu, [numara](https://gmod.tr/wiki/number) boyutu, [Renk](https://gmod.tr/wiki/Color) Rengi, [Boolean](https://gmod.tr/wiki/boolean) ConstantSize)

```lua
local toDraw3d = {}
local sprites3d = 0

local toDraw2d = {}
local sprites2d = 0

local material = Material( "sprites/light_ignorez" )

function draw.VectorSprite( position, size, color, constantSize )
	if ( not isvector( position ) ) then
		error( "bad argument #1 to draw.DrawVectorSprite (Vector expected, got " .. type( position ) .. ")" )
	end

	if ( not isnumber( size ) ) then
		error( "bad argument #2 to draw.DrawVectorSprite (number expected, got " .. type( size ) .. ")" )
	end

	if ( not IsColor( color ) ) then
		error( "bad argument #3 to draw.DrawVectorSprite (Color expected, got " .. type( color ) .. ")" )
	end

	local tbl = { position, size, color }

	if ( constantSize ) then
		sprites2d = sprites2d + 1
		toDraw2d[sprites2d] = tbl
	else
		sprites3d = sprites3d + 1
		toDraw3d[sprites3d] = tbl
	end
end

local render_SetMaterial = render.SetMaterial
local render_DrawSprite = render.DrawSprite
hook.Add( "PreDrawEffects", "draw.VectorSprite", function()
	if ( sprites3d ~= 0 ) then
		render_SetMaterial( material )

		for i = 1, sprites3d do
			local info = toDraw3d[i]
			toDraw3d[i] = nil -- Her çerçeveyi boşaltın.

			render_DrawSprite(info[1], info[2], info[2], info[3])
		end

		sprites3d = 0
	end
end )

local surface_SetMaterial = surface.SetMaterial
local surface_SetDrawColor = surface.SetDrawColor
local surface_DrawTexturedRect = surface.DrawTexturedRect
hook.Add( "DrawOverlay", "draw.VectorSprite", function()
	if ( sprites2d ~= 0 ) then
		surface_SetMaterial( material )

		for i = 1, sprites2d do
			local info = toDraw2d[i]
			toDraw2d[i] = nil

			local pos2d = info[1]:ToScreen()

			if pos2d.visible then
				surface_SetDrawColor( info[3] )
				surface_DrawTexturedRect( pos2d.x, pos2d.y, info[2], info[2] )
			end
		end

		sprites2d = 0
	end
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/render.DrawSprite
