4

How can I paint a crown (similar to the following) with color gradient? crown

I tried two different starting points: First gradient rectangle with cuttings and second draw lines similar to the above picture. In the first case I have the problem, that I cannot identify clear the coordinates for the white spaces. In the second cases, I do not know how to create gradient colors on the lines. Anyway, the lines have strange endings/corners. Both ideas are in my example:

\documentclass{article}
\usepackage[backend=biber]{biblatex}
\usepackage{tikz}
\usetikzlibrary{shapes}
\begin{document}
\begin{center}
\begin{tikzpicture}
\node[rectangle,shading=axis,left color = {rgb,255:red,255;green,215;blue,0}, right color = {rgb,255:red,205;green,133;blue,63}, shading angle= 30, minimum width=8cm, minimum height=8cm] at (0,0) {};
\fill [white] (-4,-4) -- ++(0,8) -- ++(2,0) -- ++(-2,-8); %left cut
\fill [white] (4,-4) -- ++(0,8) -- ++(-2,0) -- ++(2,-8); % right cut
\fill [white] (0,4) -- (-2,0) -- (-4,3) -- (-4,4) -- (0,4); % 
\fill [white] (0,3.5) -- (-1.5,0) -- (0,-2) -- (1.5,0) -- (0,3.6); % white filling below top
\fill [white] (0,4) -- (2,0) -- (4,3) -- (4,4) -- (0,4); % 
\end{tikzpicture}
\begin{tikzpicture}[line width=16pt]
\draw[line join=miter] (-6,-6) -- (0,6) -- (6,-6) -- (-6,-6) -- (0,6); %middle
\draw[line join=miter] (-6.2,-6.25) -- (-5.25,1.5) -- (-2,-6) -- (-6,-6); %left
\draw[line join=miter] (-5.3,1.7) -- (2,-6); %left
\draw[line join=miter] (6.2,-6.25) -- (5.25,1.5) -- (2,-6) -- (6,-6); %right
\draw[line join=miter] (5.25,1.5) -- (-2,-6); %right
\end{tikzpicture}
\end{center}
\end{document}

I found a solution that works but (in the code) looks ugly:

\fill[shading=axis,left color = {rgb,255:red,255;green,215;blue,0}, right color = {rgb,255:red,205;green,133;blue,63}, shading angle= 30] (0.01,-2.7) rectangle(2.99,-0.01) ;


\fill [white] (0,-2.7) -- (0.3,-0.75) -- (0.8,-1.3)-- (1.5,0) -- (0,0) -- (0,-2.7); % 
\fill [white] (3,-2.7) -- (2.7,-0.75) -- (2.2,-1.3)-- (1.5,0) -- (3,0) -- (3,-2.7); % 
\fill [white] (0.2,-2.4) -- (0.57,-1.72) -- (0.37,-1.18); % 
\fill [white] (0.53,-1.22) -- (0.73,-1.42) -- (0.66,-1.56); % 
\fill [white] (0.27,-2.56) -- (0.90,-2.56) -- (0.64,-1.89); % 
\fill [white] (1.03,-2.5) -- (1.41,-2.11) -- (0.84,-1.53) -- (0.73,-1.72); % 

\fill [white] (2.8,-2.4) -- (2.43,-1.72) -- (2.63,-1.18); % 
\fill [white] (2.47,-1.22) -- (2.27,-1.42) -- (2.34,-1.56); % 
\fill [white] (2.73,-2.56) -- (2.10,-2.56) -- (2.36,-1.89); % 
\fill [white] (1.97,-2.5) -- (1.59,-2.11) -- (2.16,-1.53) -- (2.27,-1.72); % 

\fill [white] (1.5,-2.0) -- (2.11,-1.4) -- (1.5,-0.33) -- (0.89,-1.4); % 
\fill [white] (1.5,-2.22) -- (1.85,-2.56) -- (1.15,-2.56); % 

The code was generated by copying the image to graphic programme and looking at the pixel-coordinates. This 'solution' has another weakness: If I want thinner or fatter lines, than I have to create a new image with a graphic programme and look at the coordinates again.

3

I clean up the document and coordinates, to keep everything within one smooth shape - you can adjust the coordinates to your liking:

\documentclass{article}
\usepackage{tikz}
\begin{document}
\begin{tikzpicture}[line width=16pt]
\draw (-6,-6) -- (0,6) -- (6,-6);
\draw[red] (-6,-6) -- (-5.25,1.5) -- (2,-6) -- cycle;
\draw[green] (6,-6) -- (5.25,1.5) -- (-2,-6) -- cycle;
\draw[blue] (-5.25,1.5) -- (-2,-6);
\draw[yellow] (5.25,1.5) -- (2,-6);
\end{tikzpicture}
\end{document}

Black, red, green, blue, yellow crown

The same in black, with one path:

\documentclass{article}
\usepackage{tikz}
\begin{document}
\begin{tikzpicture}[line width=16pt]
\draw (-6,-6) -- (0,6) -- (6,-6) (-6,-6) -- (-5.25,1.5) -- (2,-6) -- cycle (6,-6) -- (5.25,1.5) -- (-2,-6) -- cycle (-5.25,1.5) -- (-2,-6) (5.25,1.5) -- (2,-6);
\end{tikzpicture}
\end{document}

Black crown

Now I am stuck - it does not work with the fadings library, and I have been reading the manual and many posts on this site - it can be done with methods involving custom code from e.g. Tikz: Shading a path without any filling

In this attempt, there are several things I do not fully understand - e.g. the scaling. Some writes that a custom fading needs to be 2cmx2cm while others use 1cmx1cm.

\documentclass{article}
\usepackage{tikz}
\usetikzlibrary{fadings}
\begin{tikzfadingfrompicture}[name=myfading]
 \fill[transparent!0](-1,-1) rectangle (1,1);
 \draw[scale=0.1, line width=1.6pt,  path fading=west](-6,-6) -- (0,6) -- (6,-6) (-6,-6) -- (-5.25,1.5) -- (2,-6) -- cycle (6,-6) -- (5.25,1.5) -- (-2,-6) -- cycle (-5.25,1.5) -- (-2,-6) (5.25,1.5) -- (2,-6);
 \end{tikzfadingfrompicture}
\begin{document}
\begin{tikzpicture}
\fill[path fading=myfading, fill=black] (-6,-6) rectangle (6,6);
\end{tikzpicture}
\end{document}

Black and white faded crown

Edit:

By using the comment from OP, and the colors from OP, I get this result:

\documentclass{article}
\usepackage{tikz}
\usetikzlibrary{fadings}
\begin{tikzfadingfrompicture}[name=myfading]
\draw[scale=0.1, line width=2pt,  transparent!0](-6,-6) -- (0,6) -- (6,-6) (-6,-6) -- (-5.5,2) -- (2,-6) -- cycle (6,-6) -- (5.5,2) -- (-2,-6) -- cycle (-5.5,2) -- (-2,-6) (5.5,2) -- (2,-6);  \fill[black, path fading=north, fading angle = 195](-1,-1) rectangle (1,1);  
\end{tikzfadingfrompicture}
\begin{document}
\begin{tikzpicture}
\fill[path fading=myfading, left color = {rgb,255:red,255;green,215;blue,0}, right color = {rgb,255:red,205;green,133;blue,63}] (-6,-6) rectangle (6,6);
\end{tikzpicture}
\end{document}

Yellow faded crown

There is still the problem with the unexplained scaling.

| improve this answer | |
  • By changing a little the "myfading". I got a solution that works for me. Thank you very much:\begin{tikzfadingfrompicture}[name=myfading2] \draw[scale=0.1, line width=2pt, transparent!0](-6,-6) -- (0,6) -- (6,-6) (-6,-6) -- (-5.5,2) -- (2,-6) -- cycle (6,-6) -- (5.5,2) -- (-2,-6) -- cycle (-5.5,2) -- (-2,-6) (5.5,2) -- (2,-6); \fill[black, path fading=north, fading angle = 195](-1,-1) rectangle (1,1); \end{tikzfadingfrompicture} – Thomas Jul 1 at 14:17

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.