3

Trying to mimic a titlepage in a word document. I figured out how to do a custom shading, but can't figure out how to apply a fading (transparency) on top of it

Here is a MWE (except for the fading part).

\documentclass[paper=a4]{standalone}
\usepackage{xcolor}
\usepackage{tikz}
\usetikzlibrary{shadings}


\begin{document}

\definecolor{color1}{RGB}{42,137,149}   
\definecolor{color2}{RGB}{11,59,93}

\pgfdeclarehorizontalshading{myshading}{100bp}{color(0cm)=(color1); color(16bp)=(color1); color(100bp)=(color2)}    
\pgfdeclarehorizontalshading{myshadingtransparent}{100bp}{color(0cm)=(pgftransparent!0); color(16bp)=(pgftransparent!0); color(100bp)=(pgftransparent!50)}

\pgfdeclarefading{fade1}{\pgfuseshading{myshadingtransparent}}

\begin{tikzpicture}
\pgfpathmoveto{\pgfpointorigin}
\pgfpathlineto{\pgfpoint{0}{3cm}}
\pgfpathlineto{\pgfpoint{3cm}{1.5cm}}
\pgfpathclose
\pgfshadepath{myshading}{0}
\pgfsetfading{fade1}{}
\end{tikzpicture}
\end{document}

By the way, do I really have to do everything with pgf, or is it partly possible using tikz instructions? I tried mixing the two but my shading would'nt apply.

2

I've changed the colors and the effect a bit. Here are two versions:

\documentclass[tikz]{standalone}

\usetikzlibrary{shadings}
\pgfdeclarehorizontalshading{myshading}{100bp}{color(0cm)=(blue); color(16bp)=(blue); color(80bp)=(blue!40!yellow); color(100bp)=(yellow)}    
\pgfdeclarehorizontalshading{myshadingtransparent}{100bp}{color(0cm)=(pgftransparent!0); color(16bp)=(pgftransparent!20); color(100bp)=(pgftransparent!100)}
\pgfdeclarefading{fade1}{\pgfuseshading{myshadingtransparent}}
\begin{document}
\begin{tikzpicture}
    \shade[shading=myshading,path fading=fade1] (0,0) -- +(90:2) -- +(30:2) -- cycle;
\end{tikzpicture}

\end{document}

And in the lower level version

\documentclass[tikz]{standalone}

\usetikzlibrary{shadings}
\begin{document}

\pgfdeclarehorizontalshading{myshading}{100bp}{color(0cm)=(blue); color(16bp)=(blue); color(80bp)=(blue!40!yellow); color(100bp)=(yellow)}    
\pgfdeclarehorizontalshading{myshadingtransparent}{100bp}{color(0cm)=(pgftransparent!0); color(16bp)=(pgftransparent!20); color(100bp)=(pgftransparent!100)}

\pgfdeclarefading{fade1}{\pgfuseshading{myshadingtransparent}}

\begin{tikzpicture}
\pgfpathmoveto{\pgfpointorigin}
\pgfpathlineto{\pgfpoint{0}{3cm}}
\pgfpathlineto{\pgfpoint{3cm}{1.5cm}}
\pgfpathclose
\pgfsetfadingforcurrentpath{fade1}{}
\pgfshadepath{myshading}{0}

\end{tikzpicture}
\end{document}
  • Thank you for both anwser. I was not that far off.Any reason why applying \pgfshadepath before \pgfsetfading doesn't work? – Snow Aug 26 '16 at 13:32
  • @Snow Once the path is used it is thrown away. shadepath or usepath uses the path. – percusse Aug 26 '16 at 13:53
  • @Snow You should consider accepting the answer by clicking on the greyed out tick thing at the top left of the answer. – cfr Aug 26 '16 at 21:23
  • @cfr Done. I forgot ! – Snow Aug 28 '16 at 12:33

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.