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
dekking island
koch island
koch ff curve
hexagon spacefill
 
e-mail
SQUARE KNOT CURVE
lsys square knot curve
comparison mouseover shows alternate form

PROGRAM LSYS_SQUARE_KNOT   !( 26th April 2004)
SET WINDOW 0,1199,0,903
SET background color "white"
SET color 0
PRINT"Number of iterations try 1,2,3,4,5,6,7 size try 320"
INPUT depth,size
CLEAR
SET COLOR MIX (100)0.3,0.3,0.3   !dark gray
SET COLOR MIX (200)0.4,1.0,0.4   !emerald green
SET COLOR 16
FLOOD 1,1
LET w=2^depth
LET h=size/w
LET x=600-h*(w-0.5)
LET y=450+h*(w-1.5)
LET k=90
LET a=0
CALL grid(w,h)
SET color 12
CALL axiom(depth,h,a,k,r,x,y)
END

SUB axiom(depth,h,a,k,r,x,y)
CALL lsys(depth,h,a,k,r,x,y)
CALL moveON(h,x,y,a)
CALL turnLEFT(a,k)
CALL moveON(h,x,y,a)
CALL turnLEFT(a,k)
CALL lsys(depth,h,a,k,r,x,y)
CALL moveON(h,x,y,a)
CALL turnLEFT(a,k)
CALL moveON(h,x,y,a)
END SUB

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

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

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

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

SUB grid(w,h)
SET COLOR 100
LET dxy=2*w*h
LET dx=600+h*w
LET dy=450+h*w
LET x1=x0
LET y1=y0
FOR k = 0 to 2*w
PLOT x1+dx,y0+dy; x1+dx-dxy,y0+dy
PLOT x0+dx,y1+dy; x0+dx,y1+dy-dxy
LET x0=x0-h
LET y0=y0-h
NEXT k
END SUB


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