I would like to draw a rectangle along the border of a circle. The \draw
with the \angle
operation might do it, but it is rather cumbersome.
I was wondering if there is another more elegant/shorter solution, i.e. a command that draws shapes along other shapes.
Ok sorry for the late update. What I want to do is more something along the following:
A (badly) drawn rectangle following the border of a circle.
Best Answer
Draw Arched "Rectangle" Around Circle:
Below is a macro that draws the desired shape around the circle:
\DrawAlong{(Center)}{\Radius}{\Separation}{120}{60}
yields the blue shape from120
to60
degrees, and\DrawAlong[draw=black,fill=yellow, fill opacity=0.4]{(Center)}{\Radius}{\Separation}{-30}{-60}
yields the filled in yellow shape from-30
to-60
degrees:Further Enhancements
Code:
Draw Rectangle Around Circle:
If you know the radius of the circle, you can simple coordinate calculations to draw the rectangle. The circle radius is specified in
\Radius
and\Separation
defines the separation you want between the circle and rectangle:Alternatively, you could define a custom shape that has a rectangle around the circle, then simply using it as a node shape you would obtain the desired results:
Code: Known Radius:
Code: Node Shape
This is a modified version from How to draw inside a TikZ node, using node style?