BBC BASIC for Windows
Programming >> Graphics and Games >> Christmas Fractal
http://bb4w.conforums.com/index.cgi?board=graphics&action=display&num=1451047387

Christmas Fractal
Post by DDRM on Dec 25th, 2015, 11:43am

Greetings All, and Merry Christmas!

I'm sure this isn't novel, but I've never seen it before. It's based on Koch's snowflake, where you convert each line segment into a smaller copy of the whole curve, but in this case each point of the polygon gets expanded.

It makes some quite nice "Christmas wreaths" - or if you choose different parameters you can make things like Sierpinski gaskets, etc. Have fun!

D

Code:
      REM A Christmas Fractal Drawing by David Marples
      REM Merry Christmas to you all!
      MODE 21
      REM Parameters: centre point (x and y),
      REM number of points of polygon,
      REM starting angle (to rotate whole pattern)
      REM Starting side length
      REM Ratio between sides of consecutive generations
      REM Starting colour
      PROCDraw(800,600,8,0,350,0.40,1)
      END
      :
      DEFPROCDraw(px%,py%,np%,sa,r,dr,c%)
      LOCAL p%(),x%
      DIM p%(np%,1)
      IF c%>15 THEN c%=1
      GCOL c%
      FOR x%=0 TO np%
        p%(x%,0)=px%+r*COSRAD(sa+x%*360/np%)
        p%(x%,1)=py%+r*SINRAD(sa+x%*360/np%)
        CIRCLE FILL p%(x%,0),p%(x%,1),r*dr
      NEXT x%
      FOR x%=0 TO np%-1
        LINE  p%(x%,0),p%(x%,1),p%(x%+1,0),p%(x%+1,1)
      NEXT x%
      IF r>16 THEN
        FOR x%=0 TO np%-1
          PROCDraw(p%(x%,0),p%(x%,1),np%,sa,r*dr,dr,c%+1)
        NEXT x%
      ENDIF
      ENDPROC
 


Re: Christmas Fractal
Post by KenDown on Oct 25th, 2016, 12:55pm

Clever - and attractive.
Re: Christmas Fractal
Post by DDRM on Oct 25th, 2016, 3:58pm

Wow, that was a blast from the past!
grin
D