stairs Art/Electric
L-SYSTEMS
back to programs
 
koch snowflakes
general von koch
hilbert curve
pythagorean tree
H-H dragon curve
peano-gosper 19
'H' branching curve
plant
sierpinski square
sierpinski arrow
gosper square
sierpinski curve
spirograph circle
sierpinski carpet
sierpinski gasket
peano-gosper 13
peano-gosper 7
peano curve
penrose tiling
snowflake halls
peano octagon
peano hexagon
levy curve
sierpinski pentagon
not sierpinski
peano curve - H
square knot
sierpinski square 2
koch pentagram
fass curve
square cross
cesaro triangle
realistic snowflake
gray code dragon
sierpinski gasket 3
sierpinski sieve
koch square curve
koch curve 2
dekking island
koch island
koch ff curve
hexagon spacefill
 
e-mail
KOCH SQUARE CURVE L-SYSTEM
lsys koch square curve
von koch square curve

PROGRAM LSYS_KOCH_SQUARE_CURVE   ! © W.van Duyn 19th April 2004
OPTION ANGLE degrees
SET WINDOW 0,1199,0,903
SET COLOR "black"
BOX AREA 0,1199,0,903
FLOOD 1,1
SET background color "black"
SET color 15
PRINT "Input: x try 300, y try 600"
INPUT x,y
PRINT"INPUT: Size try 400, depth try 3, angle try 4"
INPUT size,level,ak
CLEAR
LET k=360/ak
LET r=3.25+cos(k)
LET d = size/(r^level)
LET a=0
FOR i = 1 to ak
SET COLOR i+9
CALL lsys(level,d,a,k,x,y)
CALL turnLEFT(a,k)
NEXT i
END

SUB lsys(level,d,a,k,x,y)
IF level=0 THEN
CALL moveON(d,x,y,a)
EXIT IF
ELSE
CALL lsys(level-1,d,a,k,x,y)
CALL lsys(level-1,d,a,k,x,y)
CALL turnRIGHT(a,k)
CALL lsys(level-1,d,a,k,x,y)
CALL turnRIGHT(a,k)
CALL lsys(level-1,d,a,k,x,y)
CALL turnRIGHT(a,k)
CALL lsys(level-1,d,a,k,x,y)
CALL turnRIGHT(a,k)
CALL lsys(level-1,d,a,k,x,y)
CALL turnRIGHT(a,k)
CALL lsys(level-1,d,a,k,x,y)
CALL turnLEFT(a,k)
CALL lsys(level-1,d,a,k,x,y)
END IF
END SUB

SUB moveON(d,x,y,a)
OPTION ANGLE degrees
LET dx=d*cos(a)
LET dy=d*sin(a)
PLOT x,y;x+dx,y+dy
LET x=x+dx
LET y=y+dy
END SUB

SUB turnRIGHT(a,k)
LET a=a-k
END SUB

SUB turnLEFT(a,k)
LET a=a+k
END SUB


Website, Text and Some Images Copyright © 2002 tzingaro.com, all rights reserved.