我有一个整页图形(背景),我想用 复制它Tikz
。原始图形是在 MS 2010 power point 中创建的(所有详细信息和参数都包含在下方,作为初始 MWE)。
我想知道是否Tikz
可以让我控制 Power point 所执行的以下参数。
- n 个中间颜色(内部和外部足够合理,但如果有一些额外的停止点就更好了)。我确实尝试过叠加不同大小的图像,但得到的是条纹,而不是渐变,现在我不记得我以前是如何做到这一点的。
- 位置 - 我认为最好通过页面宽度和/或高度的百分比来实现,以控制颜色的分割程度。例如,编译我的 MWE 表明角落中的黑色三角形比 PowerPoint 控件中的大得多,这是通过位置百分比进行调整的。
- 亮度和透明度(我认为这些是不言自明的并且将是一致的并且取决于所提供的颜色)。
以下是我在 PowerPoint 中制作的径向渐变填充的三个停止点的 PowerPoint 详细信息
站 1
- 颜色:黑色
- 头寸 3%
- 亮度 -15%
- 透明度 0%
第 2 站
- 颜色:黑色
- 排名 96%
- 亮度 0%
- 透明度 0%
站 3
- 颜色:水绿色(强调色 5)
- 位置 50%
- 亮度 0%
- 透明度 0%
\documentclass{article}
\usepackage{tikz}
\usetikzlibrary{positioning,fadings,through}
\usepackage{flowfram}
\usepackage{tcolorbox}
\usepackage[%
%showframe,
%letterpaper,
papersize={100cm,100cm},
%includehead,
%includefoot,
left=1.0cm,
right=1.0cm,
top=1.0cm,
headheight=0.0cm,
bottom=1.0cm,
footskip=1.0cm
%hmargin=3cm,vmargin=3.75cm %only used to get rid of a overfull \hbox warning.
]{geometry}
%Aqua accent 5 is close to
%75-172-198
%HEX Number:
%4bacc6
\definecolor{AquaA5}{HTML}{4bacc6}
%Black is pre-coded so it doesn't need to be redefined but for reference here are some values
%RGB CODE:
%0-0-0
%HEX Number:
%000000
\begin{document}
\begin{tikzpicture}[remember picture,overlay]
\node [rectangle, inner color=AquaA5, outer color=black, anchor=north, minimum width=\paperwidth, minimum height=\paperheight] (box) at (current page.north){};
\end{tikzpicture}
\end{document}
目前,我只是导入从 power point 保存的 jpeg 并将tikz
其保存为整页背景,但我希望能够对任何大小的页面几何形状动态地执行此操作,而不必从 power point 保存新版本。
\documentclass[]{article}
\usepackage[%
%showframe,
%letterpaper,
papersize={100cm,100cm},
%includehead,
%includefoot,
left=1.0cm,
right=1.0cm,
top=1.0cm,
headheight=0.0cm,
bottom=1.0cm,
footskip=1.0cm
%hmargin=3cm,vmargin=3.75cm %only used to get rid of a overfull \hbox warning.
]{geometry}
\usepackage{tikz}
\pagestyle{empty}
\begin{document}
\begin{tikzpicture}[remember picture,overlay]
% draw image
\node[inner sep=0] at (current page.center)
{\includegraphics[width=\paperwidth,height=\paperheight]{RadialPictureExport.jpg}};
\end{tikzpicture}
\end{document}
最后:是的,这是我的第一个TikZ
问题。
答案1
像这样吗?
\documentclass[border=5pt, multi, tikz]{standalone}
\pgfdeclareradialshading[fradialcolour]{fradial}{\pgfpoint{0}{0}}{% manual 1082-1083
color(0)=(black);
color(20bp)=(fradialcolour);
color(40bp)=(black)
}
\colorlet{fradialcolour}{blue!50!cyan}
\begin{document}
\begin{tikzpicture}
\fill [shading=fradial] (0,0) rectangle (2,2);
\end{tikzpicture}
\end{document}
您可以进行此项设置,以便在指定图片中的路径设置时可以指定阴影中使用的三种颜色中的任意一种或全部。(当然,您可以定义涉及三种以上颜色的阴影。)
例如,
\pgfdeclareradialshading[fradialcolour1,fradialcolour2,fradialcolour3]{fradial}{\pgfpoint{0}{0}}{% manual 1082-1083; later - shading is assumed to be 100bp diameter ??
color(0)=(fradialcolour1);
color(20bp)=(fradialcolour2);
color(40bp)=(fradialcolour3)
}
这使得阴影取决于三种颜色的列表,fradialcolour1
和fradialcolour2
,fradialcolour3
然后可以tikzpicture
通过设置一些适当的 PGF/TikZ 键在内进行设置。
\tikzset{%
首先用一些代码来设置每种颜色。
fradial inner colour/.code={
\colorlet{fradialcolour1}{#1}
},
fradial mid colour/.code={
\colorlet{fradialcolour2}{#1}
},
fradial outer colour/.code={
\colorlet{fradialcolour3}{#1}
},
现在设置一些默认值,以便这些默认值始终被定义。
fradial inner colour=black,
fradial outer colour=black,
fradial mid colour=white,
无需指定颜色即可进行阴影化的键。
fancy radial/.style={
shading=fradial,
},
现在有一些键可以改变其中一种颜色并使用阴影。
fancy radial inner/.style={
fradial inner colour=#1,
shading=fradial,
},
fancy radial outer/.style={
fradial outer colour=#1,
shading=fradial,
},
fancy radial mid/.style={
fradial mid colour=#1,
shading=fradial,
},
}
我们可以这样说:
\begin{tikzpicture}
\fill [fancy radial] (0,0) rectangle +(2,2);
\fill [fancy radial inner=blue!50!cyan] (2,0) rectangle +(2,2);
\fill [fancy radial outer=blue!50!cyan] (4,0) rectangle +(2,2);
\fill [fancy radial mid=blue!50!cyan] (6,0) rectangle +(2,2);
\fill [fancy radial inner=blue!50!cyan!25!black, fancy radial outer=blue!50!cyan!50!black, fancy radial mid=blue!50!cyan!25!white] (8,0) rectangle +(2,2);
\end{tikzpicture}
产生这个结果:
完整代码:
\documentclass[border=5pt, multi, tikz]{standalone}
\pgfdeclareradialshading[fradialcolour1,fradialcolour2,fradialcolour3]{fradial}{\pgfpoint{0}{0}}{% manual 1082-1083; later - shading is assumed to be 100bp diameter ??
color(0)=(fradialcolour1);
color(20bp)=(fradialcolour2);
color(40bp)=(fradialcolour3)
}
\tikzset{%
fradial inner colour/.code={
\colorlet{fradialcolour1}{#1}
},
fradial mid colour/.code={
\colorlet{fradialcolour2}{#1}
},
fradial outer colour/.code={
\colorlet{fradialcolour3}{#1}
},
fradial inner colour=black,
fradial outer colour=black,
fradial mid colour=white,
fancy radial/.style={
shading=fradial,
},
fancy radial inner/.style={
fradial inner colour=#1,
shading=fradial,
},
fancy radial outer/.style={
fradial outer colour=#1,
shading=fradial,
},
fancy radial mid/.style={
fradial mid colour=#1,
shading=fradial,
},
}
\begin{document}
\begin{tikzpicture}
\fill [fancy radial] (0,0) rectangle +(2,2);
\fill [fancy radial inner=blue!50!cyan] (2,0) rectangle +(2,2);
\fill [fancy radial outer=blue!50!cyan] (4,0) rectangle +(2,2);
\fill [fancy radial mid=blue!50!cyan] (6,0) rectangle +(2,2);
\fill [fancy radial inner=blue!50!cyan!25!black, fancy radial outer=blue!50!cyan!50!black, fancy radial mid=blue!50!cyan!25!white] (8,0) rectangle +(2,2);
\end{tikzpicture}
\end{document}
编辑
要将其用作页面背景,您可以使用如下方法:
\documentclass{article}
\usepackage{tikz}
\pgfdeclareradialshading[fradialcolour1,fradialcolour2,fradialcolour3]{fradial}{\pgfpoint{0}{0}}{% manual 1082-1083; later - shading is assumed to be 100bp diameter ??
color(0)=(fradialcolour1);
color(20bp)=(fradialcolour2);
color(40bp)=(fradialcolour3)
}
\tikzset{%
fradial inner colour/.code={
\colorlet{fradialcolour1}{#1}
},
fradial mid colour/.code={
\colorlet{fradialcolour2}{#1}
},
fradial outer colour/.code={
\colorlet{fradialcolour3}{#1}
},
fradial inner colour=black,
fradial outer colour=black,
fradial mid colour=white,
fancy radial/.style={
shading=fradial,
},
fancy radial inner/.style={
fradial inner colour=#1,
shading=fradial,
},
fancy radial outer/.style={
fradial outer colour=#1,
shading=fradial,
},
fancy radial mid/.style={
fradial mid colour=#1,
shading=fradial,
},
}
\usepackage[%
%showframe,
%letterpaper,
papersize={100cm,100cm},
%includehead,
%includefoot,
left=1.0cm,
right=1.0cm,
top=1.0cm,
headheight=0.0cm,
bottom=1.0cm,
footskip=1.0cm
%hmargin=3cm,vmargin=3.75cm %only used to get rid of a overfull \hbox warning.
]{geometry}
\pagestyle{empty}
\begin{document}
\begin{tikzpicture}[remember picture,overlay]
\fill [fancy radial mid=blue!50!cyan] (current page.south west) rectangle (current page.north east);
\end{tikzpicture}
\end{document}