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 CURVE
lsys square curve

PROGRAM LSYS_SQUARE_CURVE    !(© W.van Duyn 19thApril 2004)
SET WINDOW 0,1199,0,903
SET background color "white"
SET color 0
PRINT"Number of iterations chose 1,2,3,4,5,6 or 7 size try 320"
INPUT depth,f
CLEAR
SET COLOR MIX (100)0.9,0.9,0.9   !light gray
SET COLOR MIX (200)0.8,0.1,0.8   !light magenta
LET w=((2^depth)-1)
LET x=600-f/(2*w)
LET y=450-f+f/(2*w)
LET h=f/w
LET k=90
LET a=0
CALL grid(w,h)
SET color 200
CALL lsysL(depth,h,a,k,x,y)
END

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

SUB lsysX(depth,h,a,k,x,y)
IF depth=0 THEN
EXIT IF
ELSE
CALL lsysX(depth-1,h,a,k,x,y)
CALL moveON(h,x,y,a)
CALL turnRIGHT(a,k)
CALL moveON(h,x,y,a)
CALL turnLEFT(a,k)
CALL moveON(h,x,y,a)
CALL turnRIGHT(a,k)
CALL lsysX(depth-1,h,a,k,x,y)
CALL moveON(h,x,y,a)
CALL turnLEFT(a,k)
CALL moveON(h,x,y,a)
CALL turnLEFT(a,k)
CALL lsysX(depth-1,h,a,k,x,y)
CALL moveON(h,x,y,a)
CALL turnRIGHT(a,k)
CALL moveON(h,x,y,a)
CALL turnLEFT(a,k)
CALL moveON(h,x,y,a)
CALL turnRIGHT(a,k)
CALL lsysX(depth-1,h,a,k,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 turnRIGHT(a,k)
LET a=a-k
END SUB

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

SUB grid(w,h)
SET COLOR 100
LET dxy=2*(w+1)*h
LET dx=600+h*(w+1)/2
LET dy=450+h*(w+1)/2
LET x0=h*(w+1)/2
LET y0=h*(w+1)/2
LET x1=x0
LET y1=y0
FOR k = 0 to 2*(1+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.