1voidsetup(){

2size(300, 400);

3background(0, 0, 255);

4smooth();

5translate(width/2, height/3);

6noStroke();

7beginShape();

8for(intangle=0; angle<360; angle++){

9floatx=getX(angle*PI/180, 100);

10floaty;

11if((angle<90)||(angle>270)){

12 y=getY(angle*PI/180, 100, 60);

13}

14else{

15 y=getY(angle*PI/180, 100, 10);

16}

17vertex(x, y);

18}

19endShape();

20fill(224, 224, 34);

21ellipse(0.0, 0.0, 150.0, 152.0);

22}

23

24floatgetY(floattheta,floatr,floatk){

25return(k+r)*cos(theta);

26}

27

28floatgetX(floattheta,floatr){

29returnr*sin(theta);

30}

Deconstructing kiplings chicken and egg, I came up with the following (NB: some of the rules may be spurious/ignored it is after all a hack). The result I thought was rather impressive.

1startshapeshape

2

3background{b-1}

4

5ruleshape{egg{}}

6

7rulemound{

8CIRCLE{s2 1.5y-1z-1}

9 mound{s.999 .998 .999b0.5h60|h0.03sat0.5}

10}

11

12ruleegg{mound{|b-.2b.2y1z1s.7 1}

13}

Variation NVSTOK...

I don't know about you, but I got to see those funky moiré fringes again (I hate to think what it looks like on a CRT monitor), does make my processing effort look rather tame.

And for a less psychedelic version, where the hue orange/yellow does more or less what I expected there is this (sports my completely revised syntax highlighting for jedit, rule/path/shape names are now all highlighted as if they were functions):-

1startshapeshape

2

3background{b-1}

4

5ruleshape{ egg {hue40.4}}

6

7rulemound{

8CIRCLE{s2 1.5y-1z-1}

9 mound {s.999 .998 .999b0.01sat0.01}

10}

11

12ruleegg{ mound{|b-.2b.2y1z1s.7 1}

13}

Variation SBCPOV

Now that I've hacked kiplings code, I would like to understand it, but the documentation is terse to say the least:-

The key bits are:-

The geometry of shapes is defined by a two dimensional affine transform which is represented internally as a matrix.

No 3D then but we do have a 'z' translation.

The z-axis position determines which shape is on top when they overlap.

The z-axis position is not stored in the affine transform matrix and does not affect the shape of objects.

And in the comment explaining the 3 argument size adjustment eg {s 2 4 1} there is the following:-

The z-axis scale is not stored in the affine transform matrix and does not affect the shape of objects.

Line 8 above has a 'z' translation

Line 9 above has a 'size' adjustment with 3 arguments

Line 12 has a 'z' translation

Looks a bit like the OU logo!

ReplyDeleteThis comment has been removed by the author.

ReplyDeleteHave you had a chance to experiment much with cfdg yourself? Is there much advantage to the GUI on the Apple platform?

ReplyDeleteNo, not had much chance. I've been really busy with work. I can't compare the Mac version to anything else as I've only used the Mac one. It doesn't do much though, there is a panel to the left for the code and the area on the right is where the image is drawn.

ReplyDelete