tikzpicture 中的颜色从上到下角渐变

tikzpicture 中的颜色从上到下角渐变

在下面的示例矩形框中,是否可以从左下角到右上角制作颜色渐变(线性或径向)?

\documentclass{article}
\usepackage{tikz}

\usepackage{xcolor}

\definecolor{left} {HTML}{001528}

\begin{document}

  \begin{tikzpicture}[remember picture,overlay]
    \node [rectangle, left color=left, right color=left!30!white, anchor=north, minimum width=\paperwidth, minimum height=5.5cm] (box) at (current page.north){};
  \end{tikzpicture}



\end{document}

感谢您的帮助!

答案1

您可以使用shading = axisshading angle=135

\documentclass{article}
\usepackage{tikz}

\definecolor{left} {HTML}{001528}

\begin{document}

  \begin{tikzpicture}[remember picture,overlay]
    \node [shading = axis,rectangle, left color=left, right color=left!30!white,shading angle=135, anchor=north, minimum width=\paperwidth, minimum height=5.5cm] (box) at (current page.north){};
  \end{tikzpicture}
\end{document}

在此处输入图片描述

答案2

我希望这就是你的意思:

不同的明暗变化

\documentclass{article}
\usepackage{tikz}
\usetikzlibrary{positioning,fadings,through}

\definecolor{left} {HTML}{001528}

\begin{document}

  \begin{tikzpicture}[remember picture,overlay]
    \node [rectangle, left color=left, right color=left!30!white, anchor=north, minimum width=\paperwidth, minimum height=5.5cm] (box) at (current page.north){};
    % manual 181
    \node [rectangle, fill=left!30!white, postaction={path fading=north, fading angle=-45, fill=left}, anchor=north, below=10mm of box, minimum width=\paperwidth, minimum height=5.5cm] (box1) {};
    \begin{scope}
      \clip (box1.south west) +(0,-10mm) coordinate (c1) rectangle +(\paperwidth,-150mm) coordinate (c2);
      \node [inner color=left!30!white, outer color=left, circle through={(c1 |- c2)}] at (c1 -| c2) {};
    \end{scope}
  \end{tikzpicture}

\end{document}

相关内容