椭圆的不透明度和阴影

椭圆的不透明度和阴影

我正在制作一幅潮汐力对地球影响的图片。我目前的图片还不错,但我希望边缘凸起的地方蓝色稍微深一点,但我不想让球体比现在更暗。

我怎样才能做到这一点?

我希望水彩的颜色尽可能深这张照片

在此处输入图片描述

\documentclass{article}
\usepackage{tikz}
\usetikzlibrary{calc,fadings,decorations.pathreplacing}
%% helper macros

\newcommand\pgfmathsinandcos[3]{%
  \pgfmathsetmacro#1{sin(#3)}%
  \pgfmathsetmacro#2{cos(#3)}%
}
\newcommand\LongitudePlane[3][current plane]{%
  \pgfmathsinandcos\sinEl\cosEl{#2} % elevation
  \pgfmathsinandcos\sint\cost{#3} % azimuth
  \tikzset{#1/.estyle={cm={\cost,\sint*\sinEl,0,\cosEl,(0,0)}}}
}
\newcommand\LatitudePlane[3][current plane]{%
  \pgfmathsinandcos\sinEl\cosEl{#2} % elevation
  \pgfmathsinandcos\sint\cost{#3} % latitude
  \pgfmathsetmacro\yshift{\cosEl*\sint}
  \tikzset{#1/.estyle={cm={\cost,0,0,\cost*\sinEl,(0,\yshift)}}} %
}
\newcommand\DrawLongitudeCircle[2][1]{
  \LongitudePlane{\angEl}{#2}
  \tikzset{current plane/.prefix style={scale=#1}}
   % angle of "visibility"
  \pgfmathsetmacro\angVis{atan(sin(#2)*cos(\angEl)/sin(\angEl))} %
  \draw[current plane] (\angVis:1) arc (\angVis:\angVis+180:1);
  \draw[current plane,dashed] (\angVis-180:1) arc (\angVis-180:\angVis:1);
}
\newcommand\DrawLatitudeCircle[2][1]{
  \LatitudePlane{\angEl}{#2}
  \tikzset{current plane/.prefix style={scale=#1}}
  \pgfmathsetmacro\sinVis{sin(#2)/cos(#2)*sin(\angEl)/cos(\angEl)}
  % angle of "visibility"
  \pgfmathsetmacro\angVis{asin(min(1,max(\sinVis,-1)))}
  \draw[current plane] (\angVis:1) arc (\angVis:-\angVis-180:1);
  \draw[current plane,dashed] (180-\angVis:1) arc (180-\angVis:\angVis:1);
}

%% document-wide tikz options and styles

\tikzset{%
  >=latex, % option for nice arrows
  inner sep=0pt,%
  outer sep=2pt,%
  mark coordinate/.style={inner sep=0pt,outer sep=0pt,minimum size=3pt,
    fill=black,circle}%
}

\begin{document}
\begin{figure}[H]
  \centering
  \begin{tikzpicture}[line join = round, line cap = round, >=triangle 45]
    \def\R{1.75} % sphere radius                                                   
    \def\angEl{35} % elevation angle                                               

    \filldraw[ball color = green] (0,0) circle (\R);
    \foreach \t in {-80,-60,...,80} { \DrawLatitudeCircle[\R]{\t} }
    \foreach \t in {-5,-35,...,-175} { \DrawLongitudeCircle[\R]{\t} }
    \filldraw[blue!50, opacity = .4] (0,0) ellipse (2.5cm and 1.8cm);
  \end{tikzpicture}
  \caption{Exaggeration of the bulge caused by the tidal force of the moon.}
\end{figure}
\end{document}

答案1

如果将不透明度设置为 0.4,则会出现问题,无法获得强烈的蓝色。我需要更改绘图对象的顺序,以便将地球绘制在椭圆上方。然后,您可以忽略不透明度,并且不会出现任何问题,获得颜色的强度:

\documentclass{article}
\usepackage{tikz}
\usetikzlibrary{calc,fadings,decorations.pathreplacing,arrows}
%% helper macros

\newcommand\pgfmathsinandcos[3]{%
  \pgfmathsetmacro#1{sin(#3)}%
  \pgfmathsetmacro#2{cos(#3)}%
}
\newcommand\LongitudePlane[3][current plane]{%
  \pgfmathsinandcos\sinEl\cosEl{#2} % elevation
  \pgfmathsinandcos\sint\cost{#3} % azimuth
  \tikzset{#1/.estyle={cm={\cost,\sint*\sinEl,0,\cosEl,(0,0)}}}
}
\newcommand\LatitudePlane[3][current plane]{%
  \pgfmathsinandcos\sinEl\cosEl{#2} % elevation
  \pgfmathsinandcos\sint\cost{#3} % latitude
  \pgfmathsetmacro\yshift{\cosEl*\sint}
  \tikzset{#1/.estyle={cm={\cost,0,0,\cost*\sinEl,(0,\yshift)}}} %
}
\newcommand\DrawLongitudeCircle[2][1]{
  \LongitudePlane{\angEl}{#2}
  \tikzset{current plane/.prefix style={scale=#1}}
   % angle of "visibility"
  \pgfmathsetmacro\angVis{atan(sin(#2)*cos(\angEl)/sin(\angEl))} %
  \draw[current plane] (\angVis:1) arc (\angVis:\angVis+180:1);
  \draw[current plane,dashed] (\angVis-180:1) arc (\angVis-180:\angVis:1);
}
\newcommand\DrawLatitudeCircle[2][1]{
  \LatitudePlane{\angEl}{#2}
  \tikzset{current plane/.prefix style={scale=#1}}
  \pgfmathsetmacro\sinVis{sin(#2)/cos(#2)*sin(\angEl)/cos(\angEl)}
  % angle of "visibility"
  \pgfmathsetmacro\angVis{asin(min(1,max(\sinVis,-1)))}
  \draw[current plane] (\angVis:1) arc (\angVis:-\angVis-180:1);
  \draw[current plane,dashed] (180-\angVis:1) arc (180-\angVis:\angVis:1);
}

%% document-wide tikz options and styles

\tikzset{%
  >=latex, % option for nice arrows
  inner sep=0pt,%
  outer sep=2pt,%
  mark coordinate/.style={inner sep=0pt,outer sep=0pt,minimum size=3pt,
    fill=black,circle}%
}



\begin{document}
\begin{figure}[H]
  \centering
  \begin{tikzpicture}[line join = round, line cap = round, >=triangle 45]
  \begin{scope}
      \clip (0,0)ellipse(2.5cm and 1.8cm);
%     \pgfsetfillopacity{0.4}
    \pgfdeclareradialshading{sphere}{\pgfpoint{0cm}{0cm}}%
{rgb(0cm)=(0,0,0.9);
rgb(1.8cm)=(0,0,0.9);
rgb(2.5cm)=(0,0,0.7)}
\pgfuseshading{sphere}
  \end{scope}
    \def\R{1.75} % sphere radius                                                   
    \def\angEl{35} % elevation angle                                               

    \filldraw[ball color = green] (0,0) circle (\R);
    \foreach \t in {-80,-60,...,80} { \DrawLatitudeCircle[\R]{\t} }
    \foreach \t in {-5,-35,...,-175} { \DrawLongitudeCircle[\R]{\t} }

%     \filldraw[opacity = .4] (0,0) ellipse (2.5cm and 1.8cm);
  \end{tikzpicture}
  \caption{Exaggeration of the bulge caused by the tidal force of the moon.}
\end{figure}
\end{document}

在此处输入图片描述

相关内容