Returning to one of my favorite shapes it is the nautilus, I've yet to get to grips with the CURVETO syntax, so here is the LINETO version. Pity the cfdg boys chose to work in degrees, nasty radian to degree conversions required.

` 1:startshape nautilus`

2:

3:#define PI 3.14159265

4:#define calcX(A) (0.8*cos(((A*0.8)/PI)*180)*exp((A*0.8)/tan((1.4/PI)*180)))

5:#define calcY(A) (0.8*sin(((A*0.8)/PI)*180)*exp((A*0.8)/tan((1.4/PI)*180)))

6:

7:background{b -1}

8:

9:rule nautilus{

10: spiral{r 20}

11:}

12:

13:path spiral{

14: MOVETO{x 0 y 0}

15: LINETO{x (calcX(0)) y (calcY(0))}

16: LINETO{x (calcX(1)) y (calcY(1))}

17: LINETO{x (calcX(2)) y (calcY(2))}

18: LINETO{x (calcX(3)) y (calcY(3))}

19: LINETO{x (calcX(4)) y (calcY(4))}

20: LINETO{x (calcX(5)) y (calcY(5))}

21: LINETO{x (calcX(6)) y (calcY(6))}

22: LINETO{x (calcX(7)) y (calcY(7))}

23: LINETO{x (calcX(8)) y (calcY(8))}

24: LINETO{x (calcX(9)) y (calcY(9))}

25: LINETO{x (calcX(10)) y (calcY(10))}

26: LINETO{x (calcX(11)) y (calcY(11))}

27: LINETO{x (calcX(12)) y (calcY(12))}

28: LINETO{x (calcX(13)) y (calcY(13))}

29: LINETO{x (calcX(14)) y (calcY(14))}

30: LINETO{x (calcX(15)) y (calcY(15))}

31: LINETO{x (calcX(16)) y (calcY(16))}

32: LINETO{x (calcX(17)) y (calcY(17))}

33: LINETO{x (calcX(18)) y (calcY(18))}

34: LINETO{x (calcX(19)) y (calcY(19))}

35: LINETO{x (calcX(20)) y (calcY(20))}

36: LINETO{x (calcX(21)) y (calcY(21))}

37: LINETO{x (calcX(22)) y (calcY(22))}

38: STROKE{b 1 hue 360 sat 1}

39:}

Taking the next step we could replace each instance of the LINETO with a concise pre-processor directive (makes for a long define though). I dare say you could write a macro say 0 to 22 increment x, as it is all static code.

` 1:startshape nautilus`

2:#define PI 3.14159265

3:#define lineto(A) LINETO{ x (0.8*cos(((A*0.8)/PI)*180)*exp((A*0.8)/tan((1.4/PI)*180))) y (0.8*sin(((A*0.8)/PI)*180)*exp((A*0.8)/tan((1.4/PI)*180)))}

4:background{b -1}

5:rule nautilus{

6:spiral{r 20}

7:}

8:

9:path spiral{

10: MOVETO{x 0 y 0}

11: lineto(0)

12: lineto(1)

13: lineto(2)

14: lineto(3)

15: lineto(4)

16: lineto(5)

17: lineto(6)

18: lineto(7)

19: lineto(8)

20: lineto(9)

21: lineto(10)

22: lineto(11)

23: lineto(12)

24: lineto(13)

25: lineto(14)

26: lineto(15)

27: lineto(16)

28: lineto(17)

29: lineto(18)

30: lineto(19)

31: lineto(20)

32: lineto(21)

33: lineto(22)

34: STROKE{b 1 hue 360 sat 1}

35:}

## No comments:

## Post a Comment