我正在尝试这样做(不要注意蓝色节点上方的红线和节点内的线):
到目前为止我有这个:
使用此代码:
\documentclass[tikz,12pt]{standalone}
\usepackage[T1]{fontenc}
\usepackage[utf8]{inputenc}
\usepackage[english,french,russian]{babel}
\usepackage{chemfig}
\usepackage{mathptmx}
\usepackage{esvect}
\usepackage{tikz}
\usetikzlibrary{arrows,decorations.pathmorphing,decorations.pathreplacing,shadows,calc,decorations.markings}
\usetikzlibrary{shapes,shadows}
\usetikzlibrary{intersections}
\usetikzlibrary{positioning}
\definecolor{Green}{RGB}{0,220,70}
\tikzstyle{vecArrow} = [thick, decoration={markings,mark=at position
1 with {\arrow[semithick,fill=blue]{triangle 60}}}, double distance=1.8pt, shorten >= 5.5pt,
preaction = {decorate},
postaction = {draw,line width=1.4pt, white,shorten >= 4.5pt}]
\tikzstyle{vecArrowBlue} = [thick, decoration={markings, mark=at position
1 with {\arrow[semithick, fill=blue]{triangle 60}}},
double distance=1.4pt, shorten >= 5.5pt,
preaction = {decorate},
postaction = {draw, line width=1.4pt, blue, shorten >= 4.5pt}]
\begin{document}
\begin{tikzpicture}[font=\small,line width=1pt,node distance=0]
\tikzset{line width=2pt}
\node[draw,line width=2pt,rounded corners=4pt,minimum width=0.5cm, minimum height=.8cm,shade, shading=axis, top color=Green, bottom color=blue!80,shading angle=0,circular drop shadow={color=red!60!black}] (box) at (0,0) {};
\draw[vecArrowBlue] ($(box.south)+(0,3pt)$) to ($(box.north)-(0,3pt)$);
\end{tikzpicture}
\end{document}
有没有办法在节点周围制造光晕?我试过阴影,但没有成功。
先感谢您。
答案1
我搜索了很多,并将我的代码与示例代码结合起来。最后我得到了这个:
\documentclass[tikz,12pt]{standalone}
\usepackage[T1]{fontenc}
\usepackage[utf8]{inputenc}
\usepackage[english,french,russian]{babel}
\usepackage{chemfig}
\usepackage{mathptmx}
\usepackage{esvect}
\usepackage{tikz}
\usetikzlibrary{arrows,decorations.pathmorphing,decorations.pathreplacing,shadows,calc,decorations.markings}
\usetikzlibrary{shapes,shadows}
\usetikzlibrary{intersections}
\usetikzlibrary{positioning}
\definecolor{Green}{RGB}{0,220,70}
\tikzstyle{vecArrow} = [thick, decoration={markings,mark=at position
1 with {\arrow[semithick,fill=blue]{triangle 60}}}, double distance=1.8pt, shorten >= 5.5pt,
preaction = {decorate},
postaction = {draw,line width=1.4pt, white,shorten >= 4.5pt}]
\tikzstyle{vecArrowBlue} = [thick, decoration={markings, mark=at position
1 with {\arrow[semithick, fill=blue]{triangle 60}}},
double distance=1.4pt, shorten >= 5.5pt,
preaction = {decorate},
postaction = {draw, line width=1.4pt, blue, shorten >= 4.5pt}]
\begin{document}
\def\shadowshift{0pt,0pt}
\def\shadowradius{35pt}
% this draws a shadow under a rectangle node
\newcommand\drawshadow[1]{
\begin{pgfonlayer}{shadow}
\shade[red,inner color=red,outer color=white] ($(#1.center)$) circle (\shadowradius);
\end{pgfonlayer}
}
% create a shadow layer, so that we don't need to worry about overdrawing other things
\pgfdeclarelayer{shadow}
\pgfsetlayers{shadow,main}
\begin{tikzpicture}[font=\small,line width=1pt,node distance=0]
\tikzset{line width=2pt}
\tikzset{
shrink inner sep/.code={
\pgfkeysgetvalue{/pgf/inner xsep}{\currentinnerxsep}
\pgfkeysgetvalue{/pgf/inner ysep}{\currentinnerysep}
\pgfkeyssetvalue{/pgf/inner xsep}{\currentinnerxsep - 0.5\pgflinewidth}
\pgfkeyssetvalue{/pgf/inner ysep}{\currentinnerysep - 0.5\pgflinewidth}
}
}
\tikzset{horizontal shaded border/.style args={#1 and #2}{
append after command={
\pgfextra{%
\begin{pgfinterruptpath}
\path[rounded corners,left color=#1,right color=#2]
($(\tikzlastnode.south west)+(-\pgflinewidth,-\pgflinewidth)$)
rectangle
($(\tikzlastnode.north east)+(\pgflinewidth,\pgflinewidth)$);
\end{pgfinterruptpath}
}
}
},
vertical shaded border/.style args={#1 and #2}{
append after command={
\pgfextra{%
\begin{pgfinterruptpath}
\path[rounded corners,top color=#1,bottom color=#2]
($(\tikzlastnode.south west)+(-\pgflinewidth,-\pgflinewidth)$)
rectangle
($(\tikzlastnode.north east)+(\pgflinewidth,\pgflinewidth)$);
\end{pgfinterruptpath}
}
}
}
}
\node[rectangle,
rounded corners,thick,shrink inner sep,minimum width=0.5cm, minimum height=.8cm,shade, shading=axis, top color=Green, bottom color=blue!80!red!50,shading angle=0,vertical shaded border=Green and blue!80!red!50] (box) at (0,0) {};
\drawshadow{box}
\draw[vecArrowBlue] ($(box.south)+(0,3pt)$) to ($(box.north)-(0,3pt)$);
\end{tikzpicture}
\end{document}