How can I rotate FillDraw in Label command?

To achieve the desired output, put the label without rotation into a frame, and then rotate the frame. Rotating the label within the frame and the frame itself will result in a rotated box with the text misaligned.

The mistake you made is that the argument of the Rotate function is a transformation, and you gave it a pair. Instead we can just use the rotate function, that takes in an angle to rotate by.

unitsize(1cm);
path h = (0, 0) -- (3, -1);
real rotate_angle = degrees(dir(h));

frame f;
label(f, "text", yellow, FillDraw(blue, green));

add(rotate(rotate_angle)*f, midpoint(h) + 0.3*dir(rotate_angle - 90));
draw(h);

1

Tags:

Asymptote