Code: Alles auswählen
InitSprite()
InitKeyboard()
OpenScreen(800,600,32,"Plotomatic")
#plotx = 200
#ploty = 140
Dim fx.f(#plotx,#ploty)
Global rot.f, offsetx.f, offsety.f, sizex.f,sizey.f,posx.f,posy.f,mode.b
sizex = 2
sizey = 2
offsetx = 100
offsety = 100
posx = -#plotx/2
posy = -#ploty/2
#exp = 2.7182818
pot = 1
Repeat
ExamineKeyboard()
If KeyboardPushed(#PB_Key_W)
offsety - 5
EndIf
If KeyboardPushed(#PB_Key_S)
offsety + 5
EndIf
If KeyboardPushed(#PB_Key_A)
offsetx - 5
EndIf
If KeyboardPushed(#PB_Key_D)
offsetx + 5
EndIf
If KeyboardPushed(#PB_Key_1)
sizex + 0.1
EndIf
If KeyboardPushed(#PB_Key_2)
sizex - 0.1
EndIf
If KeyboardPushed(#PB_Key_3)
sizey + 0.1
EndIf
If KeyboardPushed(#PB_Key_4)
sizey - 0.1
EndIf
If KeyboardPushed(#PB_Key_Up)
posy - 5
EndIf
If KeyboardPushed(#PB_Key_Down)
posy + 5
EndIf
If KeyboardPushed(#PB_Key_Left)
posx - 5
EndIf
If KeyboardPushed(#PB_Key_Right)
posx + 5
EndIf
If KeyboardReleased(#PB_Key_P)
If pot = 0
pot = 1
Else
pot = 0
EndIf
EndIf
rot + 0.1
min.f = 0
max.f = 0
For x = 0 To #plotx:For y = 0 To #ploty
nx.f = x + posx
ny.f = y + posy
rad.f = nx*ny
;Das ist die Formel
fx(x,y) = (100/(Pow((posx+x)/50,2)+1))*1/(Pow((posy+y)/50,2)+1)*Sin(Sqr(Pow((x+posx)/10,2)+Pow((y+posy)/10,2))+rot)
If x = 0 And y = 0
min = fx(x,y)
max = fx(x,y)
EndIf
If fx(x,y) < min
min = fx(x,y)
EndIf
If fx(x,y) > max
max = fx(x,y)
EndIf
Next:Next
range.f = max - min
StartDrawing(ScreenOutput())
For x = 0 To #plotx:For y = 0 To #ploty
tempx.f = x*sizex + y + offsetx
tempy.f = y*sizey+fx(x,y)*pot + offsety
If tempx > 10 And tempy > 10 And tempx < 790 And tempy < 590
If KeyboardPushed(#PB_Key_M) = 0
Plot(tempx,tempy,RGB((255/range)*(fx(x,y)-min),(255/range)*(fx(x,y)-min),200))
Else
If x < #plotx
xtempx.f = (x+1)*sizex + y + offsetx
xtempy.f = y*sizey+fx(x+1,y)*pot + offsety
LineXY(tempx,tempy,xtempx,xtempy,RGB((255/range)*(fx(x,y)-min),(255/range)*(fx(x,y)-min),200))
EndIf
EndIf
EndIf
Next:Next
DrawText(0,0,StrF(range))
StopDrawing()
FlipBuffers()
ClearScreen(RGB(0,0,0))
Until KeyboardPushed(#PB_Key_Escape)
CloseScreen()
End
Taste 2 : stretcht die ausgabe in x richtung - 1
Taste 3 : stretcht die ausgabe in y richtung + 1
Taste 4 : stretcht die ausgabe in y richtung - 1
W A S D : verschieben die Ausgabe entsprechend auf dem Screen
Pfeiltasten : verchieben den Offset
P : Flatmode
M : Linemode (extrem langsam)
läuft nicht besonders schnell, aber wollt mal wieder etwas Posten.