4

I'm trying to draw a rounded rectangle with round "holes" using this answer but I need the rectangle borders to be thick and "holes" borders to be thin. Is there a better way to do so than:

\begin{tikzpicture}[x=1mm, y=1mm]
    % Background    
    \fill[fill=black!10] (1.5, 1.5) rectangle (15, -15); 
    % Fill
    \fill[fill=black!2, even odd rule, rounded corners=0.5mm] 
        (0, 0) rectangle (10, -10) 
        (2, -2) circle[radius=1.25mm]
        (2, -5) circle[radius=1.25mm];
    % Rectangle border
    \draw[thick, rounded corners=0.5mm] (0, 0) rectangle (10, -10);
    % Holes borders
    \draw[thin] (2, -2) circle (1.25mm);
    \draw[thin] (2, -5) circle (1.25mm);
\end{tikzpicture}

The result image should look like this:

rounded rectangle with transparent holes

1 Answer 1

1

The code already outputs the image you posted, however, if you want to increase the difference, you can specify ultra thin or ultra thick (for additional fun). I suggest you only specify ultra thin though, because the other one makes the picture look ugly:

enter image description here

5
  • I know, what the code does :) But it could be better if could write something like this instead of drawing the filling and the borders separately: \draw[fill=black!2, even odd rule, rounded corners=0.5mm, thick] (0, 0) rectangle (10, -10) (2, -2) circle[radius=1.25mm, thin] (2, -5) circle[radius=1.25mm, thin]; Commented May 20, 2015 at 9:43
  • @GeMir Ah, you want to simplify the command?
    – Alenanno
    Commented May 20, 2015 at 9:45
  • 1
    @GeMir No, you would need to specify the shapes of course. It's impossible to make it in one command, unless you do a \newcommand, but even then, you'd need to specify the shapes in the original definition of the \newcommand.
    – Alenanno
    Commented May 20, 2015 at 9:47
  • @GeMir By the way, you can also specify the line width like [line width=.1pt] (1pt is thick already).
    – Alenanno
    Commented May 20, 2015 at 9:55
  • 1
    My question was not about thickness definition, it was about simplifying the code. It seems to be impossible. Thank you. Commented May 20, 2015 at 9:59

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .