我找不到解决方案
- 将圆移动到原点 (0,0)。如您在图二中看到的,图片“扭曲”了(扇形圆也一样!)?。放置位置应根据所选的纸张尺寸任意调整。
- 实现一个明确的纸张尺寸(想要选择 A4 或 A5)且不带边距。也许通过独立包?目前在这方面的输出是可以的,但纸张尺寸不行。注意:黑色背景的纸张宽度和高度的提及会更改为字母格式(这从何而来?)。
\documentclass[tikz,border=0mm]{standalone}
\usepackage{color}
\usetikzlibrary{math,}
\definecolor{clr1}{RGB}{0.00,0.00,0.00}
\definecolor{clr2}{RGB}{40,0.00,40}%
\definecolor{clr3}{RGB}{60,0,60}%
\definecolor{clr4}{RGB}{80,0,80}%
\definecolor{clr5}{RGB}{100,255,100}%
\definecolor{clr6}{RGB}{139,0,139}%
\tikzset{
%%
%%
shade radial/.code={%
\tikzset{%
color four radial/.cd,%
#1,
cfradial
}%end second(!) tikzset
},%end code shade radial!
%
color four radial/.cd,%causes default path to be set to key(color four radial)
shade radial color/.code n args={2}
{\colorlet{cfradialcolor#1}{#2}},
shade radial color={1}{black},
shade radial color={2}{black},
shade radial color={3}{white},
shade radial color={4}{white},
shade radial color={5}{purple},
shade radial color={6}{purple},
%
cfradial/.style={/tikz/path picture={
\xdef\radius{\radius}
\pgfmathsetmacro{\rone}{0.65*\radius}
\pgfmathsetmacro{\rtwo}{0.90*\radius}
\pgfmathsetmacro{\rthree}{0.98*\radius}
\pgfmathsetmacro{\rfour}{0.99*\radius}
\pgfdeclareradialshading[cfradialcolor1,cfradialcolor2,cfradialcolor3,cfradialcolor4,cfradialcolor5,cfradialcolor6]
{cfradial}%shading name s. 3.01a, p. 1083
{\centerpoint}%center point
{color(0pt)=(cfradialcolor1); %color specifications
color(\rone pt)=(cfradialcolor2);
color(\rtwo pt)=(cfradialcolor3);
color(\rthree pt)=(cfradialcolor4);
color(\rfour pt)=(cfradialcolor5);
color(\radius)=(cfradialcolor6) %
}
\typeout{\radius,\rone,\rtwo}
\pgfuseshading{cfradial}
}%end path picture
}%end style cfradial
%%
%%
}%%en
\begin{document}
\begin{tikzpicture}%
\newdimen\circleradius
\tikzmath{
\circleradius=14.0 cm;
}%end tikzmath
\coordinate (circleorig) at (-1cm,0cm);%%wrong if differs from (0,0)
\tikzset{
recstyle/.style={minimum height=\paperheight,minimum width=\paperwidth,rectangle,draw=blue!50,fill=black!100,thick}
}
\node at (circleorig) [recstyle]{background black};
\node [shape=circle, opacity=.5,
inner sep=0cm,
shade radial={
shade radial color={1}{clr1},
shade radial color={2}{clr2},
shade radial color={3}{clr3},
shade radial color={4}{clr4},
shade radial color={5}{clr5},
shade radial color={6}{clr6}
},%the one parameter of shade radial
minimum size = \circleradius,
font=\sffamily
]
(thecircle) at (circleorig) {do};
\end{tikzpicture}
\end{document}
我尝试过边界框等等,但我的能力太小,无法获得所需的输出。
答案1
我混合使用了 Latex 和 Tikz 来解决这个问题。整个正确的阴影图片被放在一个迷你页面中,除了边缘边框外,它占用了与图片一样多的空间,如果需要的话,可以用 Latex 的方式消除这些边框(新问题)。
小页面将根据 hspace 的值向左和向右移动,根据 vspace 的值向上和向下移动。
\documentclass[a4paper]{scrartcl}
\usepackage[margin=0cm,showframe]{geometry}
\usepackage{color}
\usepackage{tikz}
\usetikzlibrary{math,}
\definecolor{clr1}{RGB}{0.00,0.00,0.00}
\definecolor{clr2}{RGB}{40,0.00,40}%
\definecolor{clr3}{RGB}{60,0,60}%
\definecolor{clr4}{RGB}{80,0,80}%
\definecolor{clr5}{RGB}{100,255,100}%
\definecolor{clr6}{RGB}{139,0,139}%
\tikzset{
%%
%%
shade radial/.code={%
\tikzset{%
color four radial/.cd,%
#1,
cfradial
}%end second(!) tikzset
},%end code shade radial!
%
color four radial/.cd,%causes default path to be set to key(color four radial)
shade radial color/.code n args={2}{\colorlet{cfradialcolor#1}{#2}},
shade radial color={1}{black},
shade radial color={2}{black},
shade radial color={3}{white},
shade radial color={4}{white},
shade radial color={5}{purple},
shade radial color={6}{purple},
%
cfradial/.style={/tikz/path picture={
\xdef\radius{\radius}
\pgfmathsetmacro{\rone}{0.65*\radius}
\pgfmathsetmacro{\rtwo}{0.90*\radius}
\pgfmathsetmacro{\rthree}{0.98*\radius}
\pgfmathsetmacro{\rfour}{0.99*\radius}
\pgfdeclareradialshading[cfradialcolor1,cfradialcolor2,cfradialcolor3,cfradialcolor4,cfradialcolor5,cfradialcolor6]
{cfradial}%shading name s. 3.01a, p. 1083
{\centerpoint}%center point
{color(0pt)=(cfradialcolor1); %color specifications
color(\rone pt)=(cfradialcolor2);
color(\rtwo pt)=(cfradialcolor3);
color(\rthree pt)=(cfradialcolor4);
color(\rfour pt)=(cfradialcolor5);
color(\radius)=(cfradialcolor6) %
}
\typeout{\radius,\rone,\rtwo}
\pgfuseshading{cfradial}
}%end path picture
}%end style cfradial
%%
%%
}%%end first tikzset
\begin{document}
%old code for black background replaced by this:
%https://tex.stackexchange.com/questions/56716/shading-over-a-single-page?rq=1
%replace white and orange by black and the job is done
\begin{tikzpicture}[remember picture,overlay]
\shade[left color=white,right color=orange!60]
(current page.south west) rectangle (current page.north east);
\end{tikzpicture}
%height above the picture. adding to vspace sets the circle lower
\vspace*{40mm}
%if zero, circle on most left place. adding to hspace shifts the circle to right side
\hspace*{50mm}
%\fbox{%just to see the minipage
\begin{minipage}{145mm}
\begin{tikzpicture}%
\newdimen\circleradius
\tikzmath{\circleradius=14.0 cm;}%end tikzmath
\coordinate (circleorig) at (0cm,0cm);
\node [shape=circle,
inner sep=0cm,
shade radial={
shade radial color={1}{clr1},
shade radial color={2}{clr2},
shade radial color={3}{clr3},
shade radial color={4}{clr4},
shade radial color={5}{clr5},
shade radial color={6}{clr6}
},%the one parameter of shade radial
minimum size = \circleradius,
font=\sffamily
]
(thecircle) at (circleorig) {do};
\end{tikzpicture}
\end{minipage}
%}%end fbox
\end{document}