tikz 上下文中的褪色/渐变背景颜色页面

tikz 上下文中的褪色/渐变背景颜色页面

我可以将以下 Tikz 代码放在一个页面上:

\tikz[remember picture,overlay] 
\shade[top color=green!30, bottom color=blue!30] 
(current page.north west) rectangle (current page.south east);

但是,如果我尝试将其用作所有页面的背景,则会失败。

我也不确定是否要使用覆盖或图层 - 都试过了(见下文)

\usemodule[t-tikz]
\usetikzlibrary[shapes.geometric,arrows,arrows.meta,positioning,mindmap,shadows,trees,calc]

\defineoverlay[sombra][
\tikz[remember picture,overlay] 
\shade[top color=green!30, bottom color=blue!30] 
(current page.north west) rectangle (current page.south east);
]

%\setupbackgrounds[page][background=sombra]


\setlayer[mybg] % name of the layer
%[hoffset=1cm, voffset=1cm]  % placement (from upper left corner of the layer)
{\tikz[remember picture,overlay] 
\shade[top color=green!30, bottom color=blue!30] 
(current page.north west) rectangle (current page.south east);
}  % the actual contents of the layer


\setupbackgrounds[page][background=mybg,
state=repeat % repeat each page
]

\starttext

asdf asdf

\stoptext

编辑

我能够用这个让它工作——尽管我必须用一些我目前无法弄清楚的偏移来修复这个白色部分。

\setuppagenumbering
 [alternative=doublesided]

\setupcolors
 [state=start]

\definelayer
 [fundo]
 [repeat=yes,
  width=\paperwidth,
  height=\paperheight]

\usemodule[t-tikz]
\usetikzlibrary[shapes.geometric,arrows,arrows.meta,positioning,mindmap,shadows,trees,calc]

\setlayer
[fundo]
[preset=middle]
{\tikz[remember picture,overlay] 
\shade[top color=green!30, bottom color=blue!30](current page.north west) rectangle (current page.south east);}


\setupbackgrounds
[page]
[background=fundo]


\starttext
asdf
\page
asdf
\stoptext

答案1

虽然一些 TikZ 向导来解释方法,但让我提出 ConTeXt 方法,在颜色手册

\setuppapersize[A6]
\startuseMPgraphic{shade}
%You could directly apply this with any fill operation
%but it's better to keep it separated for reuse
defineshade covershade
withshademethod "linear" 
withshadevector (dir 180) %play with angles to see what happens
%MetaPost understands colors differently
%Hence the white
withshadecolors (.3[white,green],.3[white,blue])
;
StartPage;
fill Page shaded covershade;
StopPage;
\stopuseMPgraphic
\definelayer[shade][state=repeat]
\setlayer[shade]{\useMPgraphic{shade}}
\setupbackgrounds[page][background=shade]
\starttext
\dorecurse{3}%
{
\samplefile{quevedo-es}
\samplefile{knuth}
}
\stoptext

而且我们有一个不涉及 TikZ 的良好背景。:D

在此处输入图片描述

相关内容