Take the 2-minute tour ×
TeX - LaTeX Stack Exchange is a question and answer site for users of TeX, LaTeX, ConTeXt, and related typesetting systems. It's 100% free, no registration required.

I would like to create a filled rectangle with one curved side such as one shown in the picture below: enter image description here

\begin{tikzpicture}
\draw[red,thick] (0,-3) -- (0,0) -- (3,0) -- (3,-3) edge [bend left] (1,-3);
\draw[red,thick,fill] (1,-3)  edge [bend right] ( 0, -3) ;
\end{tikzpicture}

I am not able to fill it correctly.

share|improve this question

3 Answers 3

up vote 9 down vote accepted

You can use tape shape from shapes tikz` library.

\documentclass[tikz]{standalone}
\usetikzlibrary{shapes}
\begin{document}
  \begin{tikzpicture}
\node[tape, draw]{ABCD};
\node[tape, draw, tape bend top=none,tape bend height=2mm,   %% tape bend bottom=none
            tape bend bottom=out and in,fill=red,minimum width=2cm,minimum height=3cm] at (2.5, 0) {};
\end{tikzpicture}
\end{document}

enter image description here

If you want to draw them deliberately, here you go:

\documentclass[tikz]{standalone}
\usetikzlibrary{shapes}
\begin{document}
\begin{tikzpicture}
\draw[red,thick,fill=olive!40] (0,-3) -- (0,0) -- (3,0) -- (3,-3) 
                        to [out=220,in=30]  ( 0, -3) --cycle ;
\end{tikzpicture}
\begin{tikzpicture}
\draw[red,thick,fill=olive] (0,-3) -- (0,0) -- (3,0) -- (3,-3)
                        to [out=220,in=-40]  (1,-3) 
                        to [out=140,in=30] ( 0, -3) --cycle ;
\end{tikzpicture}
\end{document}

enter image description here

share|improve this answer
    
Thank you. This is good. –  Sandeep May 9 at 0:19

This is a try with MetaPost, but I guess it can easily be adapted to tikz using the hobby package: it takes advantage of MetaPost's powerful path specifications and constructions (using John Hobby's algorithm) that the hobby package allows to import to tikz. It suffices to specify adequate directions (as angles) at the two basis points of the rectangle.

To be processed with whatever engine (LaTeX, pdfLaTeX…) in shell-escape mode.

EDIT I've added a tikz version, using thus the hobby package, at the end of this post, producing the same picture. The code is certainly a bit rudimentary since I don't know much of tikz yet.

\documentclass{article}
\usepackage[shellescape]{gmp}
\begin{document}
\begin{mpost*}
  u = 1cm; % scale
  myangle = 30; % "curving" parameter, in degrees
  z = (2u, 3u); 
  path rect; rect = origin{dir myangle} .. (x, 0){dir myangle} -- z -- (0, y) -- cycle;
  fill rect withcolor red; draw rect withcolor blue;
\end{mpost*}
\end{document}

enter image description here

\documentclass{article}
\usepackage{tikz}
\usetikzlibrary{hobby}
\begin{document}
\begin{tikzpicture} 
  \draw[blue, fill=red, use Hobby shortcut] ([out angle = 30, in angle = -150]0,0)  .. (2,0) 
  -- (2,3) -- (0,3) -- cycle ; 
\end{tikzpicture}
\end{document}
share|improve this answer

I accomplished this by piecing together two arcs with a rectangle:

\documentclass[]{article}

\usepackage{tikz}

\begin{document}
\def\x{34.0} % Angle parameter
\def\y{1.79} % Radius parameter
\begin{tikzpicture}
\fill[red,thick] (0,-3) -- (0,0) -- (3,0) -- (3,-3) -- cycle; 
\filldraw[red] (3,-2.99) arc (-90+\x:-90-\x:\y);
\filldraw[white] (0,-3.01) arc (90+\x:90-\x:\y/2);
\end{tikzpicture}

\end{document}

shape

When overlaid with the original outline (in blue):

orignal

share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.