Re: Kurvenlinie zeichnen - Wie?
Verfasst: 03.02.2010 13:46
keine ahnung ob du damit was anfangen kannst, aber schau mal hier
Code: Alles auswählen
InitSprite()
InitKeyboard()
screenW = 1024
screenH = 768
OpenScreen(1920, 1080, 32, "Bezier")
Procedure Bezier(x0.f, y0.f, x1.f, y1.f, x2.f, y2.f, x3.f, y3.f, color.l, detail.l)
Protected lastX.f, lastY.f, newX.f, newY.f
lastX = x0
lastY = y0
For u = 0 To detail
i.f = u/detail
newX = x0*(1 - i)*(1 - i)*(1 - i) + x1*3*i*(1 - i)*(1 - i) + x2*3*i*i*(1 - i) + x3*i*i*i
newY = y0*(1 - i)*(1 - i)*(1 - i) + y1*3*i*(1 - i)*(1 - i) + y2*3*i*i*(1 - i) + y3*i*i*i
LineXY(lastX, lastY, newX, newY, color)
lastX = newX
lastY = newY
Next
EndProcedure
Structure bez
x.f
y.f
xb.f
yb.f
EndStructure
num = 32
Dim bez.bez(num)
For n = 0 To num
bez(n)\x = n * 256
bez(n)\y = screenH/2
bez(n)\xb = bez(n)\x - Random(256)
bez(n)\yb = bez(n)\y + Random(256)
Next
Repeat
ExamineKeyboard()
ClearScreen(0)
StartDrawing(ScreenOutput())
For n = 1 To num
Bezier(bez(n - 1)\x, bez(n - 1)\y, 2*bez(n - 1)\x - bez(n - 1)\xb, 2*bez(n - 1)\y - bez(n - 1)\yb, bez(n)\xb, bez(n)\yb, bez(n)\x, bez(n)\y, RGB(255, 255, 255), 64)
Next
StopDrawing()
FlipBuffers()
Delay(10)
Until KeyboardPushed(#PB_Key_Escape)
CloseScreen()
End