Re. Sierpinski triangle Christmas tree

Discussions related to graphics (2D and 3D), animation and games programming
Hated Moron

Re. Sierpinski triangle Christmas tree

Post by Hated Moron »

On 24/12/2023 13:44, markbanerji@hotmail.com wrote (cross-posted from the Discussion Group):
I would like to create a Christmas tree based on Sierpiński triangle ( using standard bbc basic graphic commands ). Any ideas?
Here's a Sierpinski Triangle, making it a Christmas tree I leave to you:

Code: Select all

      VDU 23,22,800;700;8,16,16,128
      PROCtriangle(0,0,1600)
      END

      DEF PROCtriangle(x,y,s) : IF s < 2 ENDPROC
      LOCAL h : h = s * SQR(3) / 2
      MOVE x,y : DRAW x+s,y : DRAW x+s/2,y+h : DRAW x,y
      PROCtriangle(x,y,s/2)
      PROCtriangle(x+s/2,y,s/2)
      PROCtriangle(x+s/4,y+h/2,s/2)
      ENDPROC
DDRM

Re: Re. Sierpinski triangle Christmas tree

Post by DDRM »

Modified slightly to make a Christmas tree?

:-)

D

Code: Select all

      VDU 23,22,800;700;8,16,16,128
      PROCtriangle(600,200,400,0)
      PROCtriangle(400,200,800,1)
      PROCtriangle(600,800,400,1)
      PROCtriangle(700,1100,200,1)
      END

      DEF PROCtriangle(x,y,s,orient) : IF s < 2 ENDPROC
      LOCAL h,o : h = s * SQR(3) / 2
      IF orient THEN  o = 1 ELSE o = -1
      MOVE x,y : DRAW x+s,y : DRAW x+s/2,y+h*o : DRAW x,y
      PROCtriangle(x,y,s/2,orient)
      PROCtriangle(x+s/2,y,s/2,orient)
      PROCtriangle(x+s/4,y+o*h/2,s/2,orient)
      ENDPROC