In asymptote
, I would like to draw arbitrary paths as in the following image, but with multiple colors. In the example, the path shown in black is also drawn with two parallel red lines. I would like to do the same thing but with green on the inner diameter and red on the outer diameter. I need it to also work for arbitrary paths.
In the next image, I've created two pens using the makepen
function. The pen nibs are offset vertically in this example. However, I want a solution where the distance between the red and green curves is constant regardless of the path slope (as in the above image).
unitsize(1inch);
path path1 = arc((0,0), 0.6, 0, 180);
path path2 = (-0.5,0){E}..{S}(0.5,0);
pen pen1 = makepen(shift(-0.5,-2)*unitsquare)+green;
pen pen2 = makepen(shift(-0.5,+1)*unitsquare)+red;
draw(path1, pen1);
draw(path1, pen2);
draw(path1, black);
draw(path2, pen1);
draw(path2, pen2);
draw(path2, black);
Do you have an idea for how to keep the constant distance between the red and green curves for arbitrary paths?
FYI - The first image is produced in asymptote
by drawing a thick red line, then drawing a thin white line over it.
wheelpath
in tex.stackexchange.com/a/175968/484