RosettaCodeData/Task/Koch-curve/BASIC256/koch-curve.basic
2023-07-01 13:44:08 -04:00

49 lines
974 B
Text

global RtoD, DtoR
RtoD = 180 / Pi
DtoR = Pi / 180
global posX, posY, angulo
posX = 170 : posY = 100 : angulo = 0
global ancho, alto
ancho = 650 : alto = 650
graphsize ancho, alto
subroutine kochLado(longitud, fondo)
if fondo = 0 then
dx = cos(angulo*DtoR) * longitud
dy = sin(angulo*DtoR) * longitud
color rgb(5,100,24)
line (posX, posY, posX+dx, posY+dy)
posX += dx
posY += dy
else
call kochLado(longitud/3.0, fondo-1)
angulo += 60
call kochLado(longitud/3.0, fondo-1)
angulo -= 120
call kochLado(longitud/3.0, fondo-1)
angulo += 60
call kochLado(longitud/3.0, fondo-1)
end if
end subroutine
subroutine CopoNieveKoch(longitud, recursionfondo)
for i = 1 to 6
call kochLado(longitud,recursionfondo)
angulo -= 300
next i
end subroutine
for n = 0 To 7
clg
fastgraphics
text 3,4, "Copo de nieve de Koch"
text 4,16, "Iteración número: " & n
call CopoNieveKoch(280, n)
pause 0.8
refresh
next n
imgsave "Koch_curve.jpg", "jpg"
end