# Drawing on a 3d cone with tikz

I can draw a cube as:

\documentclass[12pt]{standalone}
\usepackage{tikz}

\begin{document}
\begin{tikzpicture}
\pgfmathsetmacro{\cubex}{2}
\pgfmathsetmacro{\cubey}{1}
\pgfmathsetmacro{\cubez}{3}
\draw[draw = brown!30!black, fill = brown] (0,0,0) -- ++(-\cubex,0,0) -- ++(0,-\cubey,0) -- ++(\cubex,0,0) -- cycle;
\draw[draw = brown!30!black, fill = brown] (0,0,0) -- ++(0,0,-\cubez) -- ++(0,-\cubey,0) -- ++(0,0,\cubez) -- cycle;
\draw[draw = brown!30!black, fill = brown] (0,0,0) -- ++(-\cubex,0,0) -- ++(0,0,-\cubez) -- ++(\cubex,0,0) -- cycle;
\end{tikzpicture}
\end{document}


My question now is, how would I draw on top of this, i.e. I want to draw on this to extend the x, y, and z scale. An example of what I want to do is:

Using the drawing that I have already defined, how would I draw the water part of the image? I realize that this was probably done using another software but I would like to slowly build it up using tikz, concentrating now on the water part.

-
Trying use Ipe to draw in latex. –  mvfs314 Jul 20 '14 at 17:10

Would take a bit of work to get up to the full picture but it's a start I suppose:

\documentclass[border=5]{standalone}
\usepackage{tikz}
\tikzset{darken down/.style={top color=#1, bottom color=#1!75!black}}

\def\tikzcubecs#1,#2,#3\@{%
\pgfpointxyz{(#1)*(1+(#3)/75}{(#2)*(1+(#1)/50)*(1+(#3)/50)}{(#3)*(1+(#1)/75)}%
}
\tikzdeclarecoordinatesystem{cube}{\tikzcubecs#1\@}
\colorlet{earth}{brown}
\colorlet{water}{blue!35!white}
\begin{document}

\begin{tikzpicture}[x=(340:1cm),y=(90:1cm), z=(200:1cm)]
\path
(cube cs:-10, 0,-10) coordinate (A1) (cube cs: 10, 0,-10) coordinate (B1)
(cube cs: 10, 0, 10) coordinate (C1) (cube cs:-10, 0, 10) coordinate (D1);

\path
(cube cs:-10, -10,-10) coordinate (A2) (cube cs: 10, -10,-10) coordinate (B2)
(cube cs: 10, -10, 10) coordinate (C2) (cube cs:-10, -10, 10) coordinate (D2);

\fill [earth] (A1) -- (B1) -- (B2) -- (C2) -- (D2) -- (D1) --  cycle;
\path  [darken down=earth!80!white] (B1) -- (B2) -- (C2) -- (C1) -- cycle;
\path [darken down=earth!80!black]  (D1) -- (D2) -- (C2) -- (C1) -- cycle;

\path [darken down=water!80!black]
(cube cs:-9,0,10) -- (cube cs:10,0,10) -- (cube cs:10,-9,10)
.. controls (cube cs:5,-9,10)  and  (cube cs:7.5,-5,10)  .. (cube cs:0,-5,10)
.. controls (cube cs:-5,-5,10) and  (cube cs:-5,-1,10) .. (cube cs:-9,-1,10)
-- cycle;

\path [darken down=water]
(cube cs:10,0,-9) -- (cube cs:10,0,10) -- (cube cs:10,-9,10)
.. controls (cube cs:10,-9,0)  and  (cube cs:10,-5,7.5)  .. (cube cs:10,-5,0)
.. controls (cube cs:10,-5,-5) and  (cube cs:10,-1,-5) .. (cube cs:10,-1,-9)
-- cycle;
\path [darken down=water!50!white]
(cube cs:10,0,-9) -- (cube cs:10,0,10) -- (cube cs:-9,0,10)
.. controls (cube cs:-9,0,5) and (cube cs:-5,0,5) ..
(cube cs:-5,0,-5)
.. controls (cube cs:-5,0,-9) and (cube cs:5,0,-9) ..
cycle;
\end{tikzpicture}
\end{document}


And here is a similar sort of thing with no fancy coordinate system.

\documentclass[border=20]{standalone}
\usepackage{tikz}
\colorlet{earth}{brown}
\colorlet{water}{blue!35!white}
\begin{document}

\begin{tikzpicture}
\fill [earth]
(-10,0) -- (0,4) -- (10,0) -- (10,-5) -- (0,-12)
-- (-10,-5) -- cycle;
\fill [water]
(0,-11)
.. controls ++(150:4) and ++(330:4) .. (-5, -6)
.. controls ++(150:4) and ++(330:4) .. (-9,-2) -- (-9,-1/2)
.. controls ++(30:2) and ++(210:4) ..
(-2,1)
.. controls ++(30:4) and ++(150:2) ..
(9,-1/2)  -- (9,-3/2)
.. controls ++(210:4) and ++(30:4) .. (5,-6)
.. controls ++(210:4) and ++(30:4) .. cycle;

\fill [black, opacity=1/3]
(-10,0) -- (0,-5) -- (0,-12) -- (-10,-5) -- cycle;
\fill [black, opacity=1/5]
(10,0) -- (0,-5) -- (0,-12) -- (10,-5) -- cycle;
\end{tikzpicture}
\end{document}


-
Have you done this in a real drawing program or did you come up with those coordinates yourself? –  1010011010 Jul 20 '14 at 18:21
@1010011010 I came up with the coordinates myself. For the sides the control points have the same y-coordinate as their respective endpoints, so the steepness of the curve is determined by how far the x- (or z-) coordinate of the controls is towards its opposite end point. In general, with with this sort of thing I usually start with the end points, mentally visualize the curve and then add controls which should (more or less) obtain some degree of smoothness through the relevant end-points. –  Mark Wibrow Jul 20 '14 at 19:39
I get an error with the water portion of the code: File ended while scanning use of \tikz@collect@coordinate@onpath. If I comment out the \fill[water] section of the code it runs, but including the water results in this error. –  KatyB Jul 21 '14 at 8:12
@KatyB I suspect this is the use of .. cycle in the curves for the "water" paths. This wasn't supported in earlier versions of PGF but (I think) was supported from the latest 3.0 release. The solution in this case is to add the first point in the path and then draw a line like this .. (0,-11) -- cycle –  Mark Wibrow Jul 21 '14 at 8:19

Well first that's a different projection so it's not a cube you are trying to achieve if the end goal is this image. Also it's not that trivial to do in my humble opinion. Draw it in any mouse-based tool and convert it to TikZ code. Then it would be done with no hassle. But if you really want to do this then you can still use the 3d coords. I randomly scribbled some curves.

\documentclass[tikz]{standalone}
\usetikzlibrary{calc}
\begin{document}
\begin{tikzpicture}
\def\cubex{4}\def\cubey{1}\def\cubez{6}
\coordinate (x) at (\cubex,0,0);
\coordinate (y) at (0,\cubey,0);
\coordinate (z) at (0,0,\cubez);
\draw[draw = brown!30!black, fill = brown] (x)|-(y) -- ($(z)+(0,\cubey,0)$)coordinate (zup) --(z)--++(\cubex,0,0) coordinate(zea)-- cycle;
\filldraw[fill=blue!30!white] (x|-y) to[in=20,out=-140] (zup) to[bend left] (zea) arc(-25:-10:6cm and 3cm) to[bend right,looseness=0.4] (x|-y);
\draw[brown!30!black] (zup) -| (zea) (zup-|zea) -- (x|-y);
\end{tikzpicture}
\end{document}


-