[Tex/LaTex] Box with rounder corners, but inverted

mdframed

I am a long time LaTeX user, and recently I needed something which I could not figure out by myself, so I would appreciate anyones time and help.

I need a box with rounded corners, which is easy to do – for example, this thread shows how:
How to draw frame with rounded corners around box

and I used the mdframed environment to do it. However, now I want to invert the rounded corners, so that the centre of the circle lies in the corner of the box. Actually, what I am trying to achieve is this:

enter image description here

But I don't know how to do it, so I would like to ask for your help.

Thanks in advance.

Best Answer

The lines of code could have been reduced but here it is using tcolorbox:

\documentclass{scrbook}
\usepackage{lipsum}
\usepackage{tcolorbox}

\tcbuselibrary{skins}
\usetikzlibrary{calc}
\pgfdeclarelayer{foreground}
\pgfsetlayers{main,foreground}

\newtcolorbox{mybox}{
  colback=red!5!white,
  %width=\linewidth/2, Change the width 
  left=20pt, % left space between content text and box
  top=20pt,
  bottom=20pt,
  right=20pt,
  skin=freelance,
  frame code={%
    \begin{pgfonlayer}{foreground}  
    \draw[line width = 2pt,color = blue!30] ($(frame.south west) +(-4pt,-4pt)$) rectangle ($(frame.north east)+(4pt,4pt)$); %% outer rectangle
    \clip (frame.south west) rectangle (frame.north east);
    \draw[line width = 2pt,color=red!75!black,fill = white] (frame.south west) circle (25pt);
    \draw[line width = 2pt,color=red!75!black,fill = white] (frame.north west) circle (25pt);
    \draw[line width = 2pt,color=red!75!black,fill = white] (frame.north east) circle (25pt);
    \draw[line width = 2pt,color=red!75!black,fill = white] (frame.south east) circle (25pt);
      \draw[line width = 4pt,color=red!75!black]
           ($(frame.south west) +(0pt,24pt)$) -- ($(frame.north west)+(0pt,-24pt)$)  ; %% west
      \draw[line width = 4pt,color=red!75!black]
           ($(frame.north west) +(24pt,0pt)$) -- ($(frame.north east)+(-24pt,0pt)$)  ; %% north
      \draw[line width = 4pt,color=red!75!black]
           ($(frame.north east) +(0pt,-24pt)$) -- ($(frame.south east)+(0pt,24pt)$)  ; %% east
      \draw[line width = 4pt,color=red!75!black]
           ($(frame.south west) +(24pt,0pt)$) -- ($(frame.south east)+(-24pt,0pt)$)  ; %% south      
    \end{pgfonlayer}
  },
}

\begin{document}

\begin{mybox}
\lipsum[1]
\end{mybox}

\end{document}

enter image description here