Page 1 of 1

draw-order confusion

Posted: Thu May 07, 2009 8:18 am
by spacefish
Hi all,

Please help! I suspect this is just my being a noob, but I can't work out why the following doesn't work:

Code: Select all

startshape bl;

rule bl 0.97 {
  CIRCLE {};
  bl {y 0.11};
  CIRCLE {s 0.8 sat -1 b 1 };
}

rule bl 0.03 {}
In my mind, this should draw a line of black circles, followed by a line of smaller white circles, so that the end effect is a (slightly bobbly) white line with a black border. In actuality, it draws a black circle then a white circle then a black circle then a white circle and so forth, so that the end result is a sort of stack.

Image

What have I done wrong? Is there more to the CF draw order than meets the eye?

All help gratefully received, apologies if this has been answered elsewhere (I did search, honest!)

Alex

Posted: Thu May 07, 2009 1:16 pm
by MtnViewJohn
Yes there is more to it than meets the eye. The drawing order for a rule is that all of the primitive shapes (CIRCLEs, SQUARES, TRIANGLEs, and paths) are drawn first. All of the non-primitive shapes are tossed into a queue and drawn later.

Fab!

Posted: Thu May 07, 2009 1:59 pm
by spacefish
You are a scholar and a gentleman sir! That's exactly what I needed to make it work.

Code: Select all

startshape bl;

rule circle {
  CIRCLE {}
}

rule bl 0.97 {
  circle {};
  bl {y 0.11};
  circle {s 0.8 sat -1 b 1 };
}

rule bl 0.03 {}
Many thanks!

... another solution

Posted: Fri May 08, 2009 1:00 am
by kipling
The other solution is to put "z 1" in the white CIRCLEs, so that while the initial drawing will be BWBWBW, there will be a redrawing at the end where black circles in layer "z=0" are drawn before the white circles in layer "z=1".
Once you get the hang of this, you will be using it a lot.