Брезенхем
r.w=100
x.w=-r
y.w=0
err.w=2-2*r
xm=160
ym=100
If InitSprite() And OpenWindow(0,0,0,320,200,"SineWave",#PB_Window_SystemMenu) And OpenWindowedScreen(WindowID(0),0,0,320,200,0,0,0)
;Repeat
StartDrawing(ScreenOutput())
; While -x<0
cl:
Box(xm-x,ym+y,1,1,$FFFFFF)
Box(xm-y,ym-x,1,1,$FFFFFF)
Box(xm+x,ym-y,1,1,$FFFFFF)
Box(xm+y,ym+x,1,1,$FFFFFF)
r=err
If r<=y
y+1
err=err+1+2*y
EndIf
If (r>x) Or (err>y)
x+1
err=err+1+x*2
EndIf
If x<0:Goto cl:EndIf;Wend
StopDrawing()
FlipBuffers()
Repeat
Until WindowEvent()=#PB_Event_CloseWindow
EndIf
x.w=-r
y.w=0
err.w=2-2*r
xm=160
ym=100
If InitSprite() And OpenWindow(0,0,0,320,200,"SineWave",#PB_Window_SystemMenu) And OpenWindowedScreen(WindowID(0),0,0,320,200,0,0,0)
;Repeat
StartDrawing(ScreenOutput())
; While -x<0
cl:
Box(xm-x,ym+y,1,1,$FFFFFF)
Box(xm-y,ym-x,1,1,$FFFFFF)
Box(xm+x,ym-y,1,1,$FFFFFF)
Box(xm+y,ym+x,1,1,$FFFFFF)
r=err
If r<=y
y+1
err=err+1+2*y
EndIf
If (r>x) Or (err>y)
x+1
err=err+1+x*2
EndIf
If x<0:Goto cl:EndIf;Wend
StopDrawing()
FlipBuffers()
Repeat
Until WindowEvent()=#PB_Event_CloseWindow
EndIf
Взято из C=hacking9
If InitSprite() And OpenWindow(0,0,0,640,480,"Circles",#PB_Window_SystemMenu) And OpenWindowedScreen(WindowID(0),0,0,640,480,0,0,0)
StartDrawing(ScreenOutput())
X=40
Y=0:TX=X:XO=160:YO=100
L30:
;down
Plot(X+XO,Y+YO,RGB(255,0,0))
Plot(Y+XO,X+YO,RGB(255,0,0))
Plot(XO-X,YO+Y,RGB(255,0,0))
Plot(XO-Y,YO+X,RGB(255,0,0))
;up
Plot(XO-X,YO-Y,RGB(255,0,0))
Plot(XO-Y,YO-X,RGB(255,0,0))
Plot(XO+X,YO-Y,RGB(255,0,0))
Plot(XO+Y,YO-X,RGB(255,0,0))
If X<=Y:Goto L100:EndIf
Y=Y+1:TX=TX-Y
If TX<0:X=X-1:TX=TX+X:EndIf
Goto L30
L100:
StopDrawing()
FlipBuffers()
Repeat: Until WindowEvent()=#PB_Event_CloseWindow
EndIf
Вариация Minsky Circle
If InitSprite() And OpenWindow(0,0,0,256,192,"SMinsky",#PB_Window_SystemMenu) And OpenWindowedScreen(WindowID(0),0,0,256,192,0,0,0)
a=256
c=64*256;32768/4
s=a
; Repeat
StartDrawing(ScreenOutput())
For i=0 To 8000
c=c-Int(s/a)
s=s+Int(c/a)
;Debug "c="+Str(c)+",s="+Str(s)
Box(s/256+127,c/256+63,1,1,$FFFFFF)
Next i
StopDrawing()
FlipBuffers()
Repeat
Until WindowEvent()=#PB_Event_CloseWindow
EndIf
Комментарии
Отправить комментарий