startshape A
rule A {
50* { y 0.4 r -0.9 } B { }
}
rule B {
SQUARE { s 20 1 }
SQUARE { x -2.5 s 10 1 b .5 }
SQUARE { x -2.5 s 7 1 b .7 }
SQUARE { x -2.5 s 2.5 1 b 1 }
}
Which produces this:
Anyone have any thoughts on how I work around this?
This is caused by anti-aliasing of the edges of the squares. In addition to all of the opaque black, gray, and white pixels that you are drawing there are translucent pixels at the edges of the squares. If you draw a translucent white pixel on top of a gray pixel you get gray, not white. This code will show you what happens when the edges of these four squares stack on top of each other:
MtnViewJohn wrote:This is caused by anti-aliasing of the edges of the squares. In addition to all of the opaque black, gray, and white pixels that you are drawing there are translucent pixels at the edges of the squares. If you draw a translucent white pixel on top of a gray pixel you get gray, not white. This code will show you what happens when the edges of these four squares stack on top of each other:
There are other strategies. For instance, you can force the drawing order so that all the blacks get laid down first, then greys, then whites. The "z" attribute is your friend here:
startshape A
rule A {
50* { y 0.4 r -0.9 } B { }
}
rule B {
SQUARE { s 20 1 }
SQUARE { x -2.5 s 10 1 b .5 z 1 }
SQUARE { x -2.5 s 7 1 b .7 z 2 }
SQUARE { x -2.5 s 2.5 1 b 1 z 3 }
}
kipling wrote:There are other strategies. For instance, you can force the drawing order so that all the blacks get laid down first, then greys, then whites. The "z" attribute is your friend here:
startshape A
rule A {
50* { y 0.4 r -0.9 } B { }
}
rule B {
SQUARE { s 20 1 }
SQUARE { x -2.5 s 10 1 b .5 z 1 }
SQUARE { x -2.5 s 7 1 b .7 z 2 }
SQUARE { x -2.5 s 2.5 1 b 1 z 3 }
}
Actually, you're still going to have trouble there. Try calling B {} just once and you'll see it looks exactly like my first picture.
The key here is to scale them y-wise just slightly.