Наткнулся на программу, запустилось не сразу.
;https://www.pythoninformer.com/python-projects/graphics-projects/spirographs/
Procedure.l GCD(x.l, y.l)
; The greatest common denominator (GCD) is the largest positive integer
; that divides into both numbers without a remainder.
; Examples: GCD(256,64)=64, GCD(12,8)=4, GCD(5,3)=1
g.l
; Work With absolute values (positive integers)
If x < 0 : x = -x : EndIf
If y < 0 : y = -y : EndIf
If x + y > 0
g = y
; Iterate Until x = 0
While x > 0
g = x
x = y % x
y = g
Wend
ProcedureReturn g
Else
; Error, both parameters zero
ProcedureReturn 0
EndIf
EndProcedure
If OpenWindow(0, 0, 0, 640, 480, "spirograph", #PB_Window_SystemMenu | #PB_Window_ScreenCentered)
CanvasGadget(0, 0, 0, 640, 480)
If StartDrawing(CanvasOutput(0))
Box(0,0,640,480,0)
a=16
b=11
d=7
t.f=0
dt.f=0.01
scale=20
While t<2*#PI*b/gcd(a, b)
x.f = (a - b) * Cos(t) + d * Cos((a - b)/b * t)
y.f = (a - b) * Sin(t) - d * Sin((a - b)/b * t)
x=320+x*scale
y=240+y*scale
If t=0
x0=x
y0=y
Else
LineXY(x,y,x0,y0,255)
x0=x
y0=y
EndIf
t+dt
Wend
StopDrawing()
EndIf
Repeat
Event = WindowEvent()
Until Event = #PB_Event_CloseWindow
EndIf
Procedure.l GCD(x.l, y.l)
; The greatest common denominator (GCD) is the largest positive integer
; that divides into both numbers without a remainder.
; Examples: GCD(256,64)=64, GCD(12,8)=4, GCD(5,3)=1
g.l
; Work With absolute values (positive integers)
If x < 0 : x = -x : EndIf
If y < 0 : y = -y : EndIf
If x + y > 0
g = y
; Iterate Until x = 0
While x > 0
g = x
x = y % x
y = g
Wend
ProcedureReturn g
Else
; Error, both parameters zero
ProcedureReturn 0
EndIf
EndProcedure
If OpenWindow(0, 0, 0, 640, 480, "spirograph", #PB_Window_SystemMenu | #PB_Window_ScreenCentered)
CanvasGadget(0, 0, 0, 640, 480)
If StartDrawing(CanvasOutput(0))
Box(0,0,640,480,0)
a=16
b=11
d=7
t.f=0
dt.f=0.01
scale=20
While t<2*#PI*b/gcd(a, b)
x.f = (a - b) * Cos(t) + d * Cos((a - b)/b * t)
y.f = (a - b) * Sin(t) - d * Sin((a - b)/b * t)
x=320+x*scale
y=240+y*scale
If t=0
x0=x
y0=y
Else
LineXY(x,y,x0,y0,255)
x0=x
y0=y
EndIf
t+dt
Wend
StopDrawing()
EndIf
Repeat
Event = WindowEvent()
Until Event = #PB_Event_CloseWindow
EndIf
Комментарии
Отправить комментарий