draw-order confusion

If you're having trouble using Context Free or don't understand the language, ask for help here.

Moderators: MtnViewJohn, chris, mtnviewmark

Post Reply
spacefish
Posts: 2
Joined: Thu May 07, 2009 8:02 am

draw-order confusion

Post 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

User avatar
MtnViewJohn
Site Admin
Posts: 882
Joined: Fri May 06, 2005 2:26 pm
Location: Mountain View, California
Contact:

Post 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.

spacefish
Posts: 2
Joined: Thu May 07, 2009 8:02 am

Fab!

Post 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!

User avatar
kipling
Posts: 91
Joined: Wed Jun 18, 2008 2:36 am

... another solution

Post 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.

Post Reply