# math.BSplinePoint

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

```lua
Vector math.BSplinePoint( number fraction, table points, number fractionMax )
```

## Açıklama

Bézier-Spline algoritması için temel kod.

## Argümanlar

1. [number](https://gmod.tr/wiki/number) **fraction**: `[0,fractionMax]` aralığında bir sayı. Eğrinin uzunluğu boyunca hangi konumun dönüş değeri olarak değerlendirileceğini kontrol eder.
2. [table](https://gmod.tr/wiki/table) **points**: Eğriyi oluşturan [Vektörlerden](https://gmod.tr/wiki/Vector) oluşan bir tablo. **En az** 4 nokta olmalıdır.
3. [number](https://gmod.tr/wiki/number) **fractionMax**: `fraction` argümanının alabileceği maksimum değer. Bunun için en yaygın değer `1`'dir.

## Döndürülen Değerler

1. [Vector](https://gmod.tr/wiki/Vector): Verilen `fraction` argümanına karşılık gelen Bézier eğrisi üzerindeki nokta.

### Örnek

4 noktadan oluşan bir Bézier eğrisi üzerinde hareket eden siyah bir kutu yapar.

```lua
local points = {
	Vector( 100, 100, 0 ),
	Vector( 200, 200, 0 ),
	Vector( 300, 100, 0 ),
	Vector( 400, 200, 0 )
}

hook.Add( "HUDPaint", "BSplinePointExample", function()
	-- Noktaları çiz
	for _, p in ipairs( points ) do
		draw.RoundedBox( 0, p.x - 2, p.y - 2, 4, 4, color_white )
	end

	-- Eğriyi çiz
	surface.SetDrawColor( 255, 0, 0, 255 )
	local lastPos = math.BSplinePoint( 0, points, 1 )
	for i=0, 10 do
		local pos = math.BSplinePoint( i / 10, points, 1 )
		surface.DrawLine( lastPos.x, lastPos.y, pos.x, pos.y )
		lastPos = pos
	end

	-- Eğri üzerine bir nokta çiz
	local pos = math.BSplinePoint( ( math.cos( CurTime() ) + 1 ) / 2, points, 1 )
	draw.RoundedBox( 0, pos.x - 2, pos.y - 2, 4, 4, color_black )

end )
```

### Örnek

İnteraktif demo

```lua
local PANEL = {}

PANEL.Init = function( panel )
	panel:SetText( "" )
	panel:SetSize( 24, 24 )
	panel.Dragging = false
end
PANEL.OnCursorMoved = function( panel, x, y )
	if ( panel.Dragging ) then
		local x, y = input.GetCursorPos()
		panel:SetPos( panel.StartPos.x + x - panel.CursorPos.x , panel.StartPos.y + y - panel.CursorPos.y )
	end
end
PANEL.OnMousePressed = function( panel, x, y )
	panel.Dragging = true
	local x, y = input.GetCursorPos()
	panel.CursorPos = { x = x, y = y }
	local x, y = panel:GetPos()
	panel.StartPos = { x = x, y = y }
end

PANEL.OnMouseReleased = function( panel, x, y ) panel.Dragging = false end
PANEL.OnCursorExited = PANEL.OnCursorMoved

local MovableButton = vgui.RegisterTable( PANEL, "DButton" )

local f = vgui.Create( "DFrame" )
f:SetSize( 500, 500 )
f:Center()
f:MakePopup()

local oldPaint = f.Paint
f.Paint = function( pnl, w, h )
	oldPaint( pnl, w, h )

	local points = {}
	for k, pnl in ipairs( pnl:GetChildren() ) do
		local x, y = pnl:GetPos()
		if ( pnl.Dragging != nil ) then
			table.insert( points, Vector( x, y, 0 ) )
			pnl:SetText( #points )
		end
	end

	surface.SetDrawColor( 255, 0, 0, 255 )
	local lastPos = math.BSplinePoint( 0, points, 1 )
	for i=0, 32 do
		local pos = math.BSplinePoint( i / 32, points, 1 )
		surface.DrawLine( lastPos.x, lastPos.y, pos.x, pos.y )
		lastPos = pos
	end
end

vgui.CreateFromTable( MovableButton, f ):SetPos( 100, 100 )
vgui.CreateFromTable( MovableButton, f ):SetPos( 200, 200 )
vgui.CreateFromTable( MovableButton, f ):SetPos( 300, 100 )
vgui.CreateFromTable( MovableButton, f ):SetPos( 400, 200 )

local addBtn = vgui.Create( "DButton", f )
addBtn:Dock( TOP )
addBtn:SetText( "Nokta Ekle" )
addBtn.DoClick = function() vgui.CreateFromTable( MovableButton, f ):SetPos( VectorRand( 20, 450 ):Unpack() ) 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/math.BSplinePoint
