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
SIERPINSKI ARROW
lsys sierpinski arrow
comparison mouseover between even and odd recursion depths

PROGRAM LSYS_SIERPINSKI_ARROW   !( © W.van Duyn 19th April 2004)
SET WINDOW 0,1199,0,903
SET background color "white"
SET color 0
PRINT"depth of recursion try 7 ; size try 400"
INPUT depth,size
CLEAR
SET COLOR MIX (100)0.3,0.3,0.3   !dark gray
SET COLOR MIX (200)0.3,1.0,0.4   !bright green
SET COLOR 16
BOX AREA 0,1199,0,903
FLOOD 1,1
LET w=2^depth   !scale factor adjusted for depth
LET h=size/w
LET x=(1200-h*(w+1))/2
LET y=(900-h*(w-1))/2
LET k=60
LET a=0
CALL grid(w,h)
SET color 200
IF mod(depth,2) = 1 THEN CALL turnLEFT(a,k)
CALL lsysY(depth,h,a,k,r,x,y)
END

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

SUB lsysY(depth,h,a,k,r,x,y)
IF depth=0 THEN
CALL moveON(h,x,y,a)
EXIT IF
ELSE
CALL lsysX(depth-1,h,a,k,r,x,y)
CALL turnRIGHT(a,k)
CALL lsysY(depth-1,h,a,k,r,x,y)
CALL turnRIGHT(a,k)
CALL lsysX(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 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=(w+1)*h
LET dx=600+h*(w)/2
LET dy=450+h*(w+2)/2
LET x1=x0
LET y1=y0
FOR k = 0 to w+1
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.