2

I want to draw something like this picture:

enter image description here

As the shadow is curved, i decided to draw a trapezium and then draw a shadow on it. The problem is i want the coordinates of the trapezium corners. here is my code

\documentclass{standalone}
\usepackage{tikz}
\usetikzlibrary{shapes.geometric}

\usetikzlibrary{shadows}
\usetikzlibrary{shapes.symbols}
\definecolor{mycolor}{rgb}{0.55,0.9,0.55}
\begin{document}
\begin{tikzpicture}[y=.3cm, x=1.2cm,font=\sffamily]
%\node[circle,fill=black] at (0,0) {};
\node[circle,fill=black] at (5.59,-8.3) {};
\node[circle,fill=black] at (-2.1,-8.3) {};
\node[circle,fill=black] at (-5.59,8.3) {};
%rotate = -140
\node[trapezium, minimum width=10cm,trapezium left angle=130, trapezium right angle=50, minimum height = 5cm,fill=mycolor]  at (0,0){};

\filldraw[fill=gray]
(5.55,-8.3) -- (5.55,-8) -- (-2.1,-8) -- (-5.6,8) -- (-5.59,8.3) -- (-2.1,-8.3) -- cycle;

\end{tikzpicture}
\end{document}

I tried to figure out the coordinates by drawing circles in the arbitrary locations and correct them manually.

Is there away to find these coordinates accurately?, and am i thinking a hard way and there is an easy way to do this?.

  • Do you require your shape to be a node? If not, you can simply draw it giving the required coordinates. If you need to reuse that shape at different locations/angles you can create a pic with it. – JLDiaz Jul 22 '15 at 10:27
  • I want to add this part to a larger tikz picture in different angles. can i do it as a 4 points not as a node?. – Misaki Jul 22 '15 at 10:35
6

You can draw the shape inside a pic definition, and then use that pic to reuse the figure at any place/scale/angle. This pic feature requires a recent version of Tikz/PGF.

This is an example:

\documentclass{article}
\usepackage{tikz}

\tikzset{
  patch/.pic = {
    \draw[fill=green!30] (-2,0) to[out=10, in=190] (0,1)
            to (2,0)
            to[out=-140, in=45] (0,-1)
            to[out=145, in=-35] (-2,0)
            -- cycle;
    \draw[fill=black!60] (0,-1) 
            to[out=145, in=-35] (-2,0)
            -- (-2,-.2) -- (0,-1.5) -- cycle;
    \draw[fill=black!30] (2,0)        
            to[out=-140, in=45] (0,-1)
            -- (0,-1.5) -- (2, -.2) -- cycle;
    },
}  

\begin{document}
\begin{tikzpicture}
\pic at (0,0) {patch};
\pic[scale=0.5, rotate=20] at (2,2) {patch};
\pic[scale=0.5, rotate=-20] at (-2,2) {patch};
\end{tikzpicture}
\end{document}

This is the result:

Result

  • WOW. would you please explain how in and out work in this code. Thanks alot. – Misaki Jul 22 '15 at 11:06
  • 1
    They just refer to the angle of entry and departure for a particular path. – daleif Jul 22 '15 at 11:10

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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