如何消除奥运五环中几乎看不见的模糊线条?

如何消除奥运五环中几乎看不见的模糊线条?

我想画奥运五环,并使用了这里,即

% Olympic rings
% Author: Paul Gaborit
\documentclass[a4paper]{article}
\usepackage{tikz}
\begin{document}
\begin{tikzpicture}
 \definecolor{r1}{RGB}{0,129,188}
 \definecolor{r2}{RGB}{252,177,49}
 \definecolor{r3}{RGB}{35,34,35}
 \definecolor{r4}{RGB}{0,157,87}
 \definecolor{r5}{RGB}{238,50,78}
 \begin{scope}
   \clip (-6,2) rectangle (6,-.9);
   \foreach \col/\xp/\yp in {
     r5/4/0, r4/2/-1.8, r3/0/0,
     r2/-2/-1.8, r1/-4/0
   } {
     \path[draw=white,line width=.08cm,
     fill=\col,even odd rule]
     (\xp, \yp) circle (1.9cm)
     (\xp, \yp) circle (1.5cm);
   }
 \end{scope}
 \begin{scope}
   \clip (-6,-.9) rectangle (6,-3.8);
   \foreach \col/\xp/\yp in {
     r1/-4/0, r2/-2/-1.8, r3/0/0,
     r4/2/-1.8, r5/4/0
   } {
     \path[draw=white,line width=.08cm,
     fill=\col,even odd rule]
     (\xp, \yp) circle (1.9cm)
     (\xp, \yp) circle (1.5cm);
   }
 \end{scope}
\end{tikzpicture}
\end{document}

但是我在 PDF 文件的中间看到了一条模糊的直线。您可以清楚地看到黑环下半部分的线条。如何去除它?

在此处输入图片描述

我已经尝试过 Paul Gaborit 建议的解决方案改进 PSTricks 代码以绘制奥林匹克旗帜,但问题仍然存在。我正在运行pdflatex我的代码。它是否会在图像中间创建模糊的线条?

编辑

Latex + dvips + ps2pdf这是我使用 Heiko Oberdiek 的建议并运行以下代码得到的输出,

\nofiles % .aux file is not needed
\documentclass{standalone}
\usepackage{tikz}
\usetikzlibrary{calc}
\usetikzlibrary{hobby}

\newcommand*{\xshift}{169.5538bp}
\newcommand*{\yshift}{-71.7013bp}
\newcommand*{\radius}{71.6821bp}
\newcommand*{\whitelinewidth}{3.762bp}
\newcommand*{\colorlinewidth}{12.9041bp}

\definecolor{color@A}{cmyk}{1, .25, 0, 0}
\definecolor{color@B}{cmyk}{0, .342, .91, 0}
\definecolor{color@C}{cmyk}{0, 0, 0, 1}
\definecolor{color@D}{cmyk}{1, 0, .91, .06}
\definecolor{color@E}{cmyk}{0, .94, .65, 0}

\begin{document}
  \begin{tikzpicture}[
    use Hobby shortcut,
    every path/.style = {
      line width      = \whitelinewidth,
      double distance = \colorlinewidth,
      white,
    },
  ]
    % define center coordinates for the five rings
    \path
      (0,0) coordinate (center@A)
      ++(\xshift, 0) coordinate (center@C)
      ++(\xshift, 0) coordinate (center@E)
      ($(center@A)!.5!(center@C)$) ++(0, \yshift) coordinate (center@B)
      ++(\xshift, 0) coordinate (center@D)
    ;
    % \drawring draws the first part of the ring with blank parts
    \newcommand*{\drawring}[4]{%
      \draw[
        save Hobby path = {path@#1},
        double          = {color@#1},
        overlay,
      ]
        (center@#1)
        +([closed] 225:\radius) .. +([#2] 315:\radius) ..
        +([#3] 45:\radius) .. +([#4] 135:\radius)
      ;
    }
    % \finishring draws the blank parts of the rings
    \newcommand*{\finishring}[1]{%
      \draw[
        double                     = {color@#1},
        restore and use Hobby path = {path@#1}{
          disjoint, 
          invert soft blanks
        },
      ];
    }
    \drawring{A}{}{blank=soft}{}
    \drawring{B}{}{}{blank=soft}
    \drawring{C}{}{blank=soft}{}
    \finishring{B}
    \finishring{A}
    \drawring{E}{blank=soft}{}{}
    \drawring{D}{}{}{}
    \finishring{C}
    \finishring{E}
    % set calculated bounding box
    \useasboundingbox
      let \n{r} = {\radius + \colorlinewidth/2}
      in
        (center@A) +(-\n{r}, \n{r}) % upper left corner
        (center@B -| center@E) +(\n{r}, -\n{r}) % lower right corner
    ;
  \end{tikzpicture}
\end{document}

我得到的输出是,

在此处输入图片描述

请注意,除绿线外,每个环都包含两条暗线。

答案1

版本,使用不间断的圆圈(没有模糊的线条),其中间隙是通过剪切创建的。此解决方案不使用任何白色背景颜色。尺寸和颜色取自我的回答编程谜题和代码高尔夫

\nofiles % .aux file is not needed
\documentclass{standalone}
\usepackage{tikz}
\usetikzlibrary{calc}

\newcommand*{\xShift}{169.5538bp}
\newcommand*{\yShift}{-71.7013bp}
\newcommand*{\Radius}{71.6821bp}
\newcommand*{\WhiteLineWidth}{3.762bp}
\newcommand*{\ColorLineWidth}{12.9041bp}

\definecolor{color@A}{cmyk}{1, .25, 0, 0}    % blue
\definecolor{color@B}{cmyk}{0, .342, .91, 0} % yellow
\definecolor{color@C}{cmyk}{0, 0, 0, 1}      % black
\definecolor{color@D}{cmyk}{1, 0, .91, .06}  % green
\definecolor{color@E}{cmyk}{0, .94, .65, 0}  % red

% Radii
\pgfmathsetlengthmacro{\InnerColorRadius}{\Radius - \ColorLineWidth/2}
\pgfmathsetlengthmacro{\OuterColorRadius}{\Radius + \ColorLineWidth/2}
\pgfmathsetlengthmacro{\InnerWhiteRadius}{\InnerColorRadius - \WhiteLineWidth}
\pgfmathsetlengthmacro{\OuterWhiteRadius}{\OuterColorRadius + \WhiteLineWidth}

% Positions of circle centers
\newcommand{\xA}{0pt}
\newcommand{\yA}{0pt}
\pgfmathsetlengthmacro{\xC}{\xA + \xShift}
\let\yC\yA
\pgfmathsetlengthmacro{\xE}{\xC + \xShift}
\let\yE\yC
\pgfmathsetlengthmacro{\xB}{(\xA + \xC)/2}
\pgfmathsetlengthmacro{\yB}{\xA + \yShift}
\pgfmathsetlengthmacro{\xD}{(\xC + \xE)/2}
\let\yD\yB

% Bounding Box
\pgfmathsetlengthmacro\llxBB{\xA - \OuterColorRadius}
\pgfmathsetlengthmacro\llyBB{\yB - \OuterColorRadius}
\pgfmathsetlengthmacro\urxBB{\xE + \OuterColorRadius}
\pgfmathsetlengthmacro\uryBB{\yE + \OuterColorRadius}

% Clipping box (a little larger as bounding box)
\pgfmathsetlengthmacro\llxClip{\llxBB - 1pt}
\pgfmathsetlengthmacro\llyClip{\llyBB - 1pt}
\pgfmathsetlengthmacro\urxClip{\urxBB + 1pt}
\pgfmathsetlengthmacro\uryClip{\uryBB + 1pt}

\begin{document}
  \begin{tikzpicture}[
    line width=\ColorLineWidth,
    radius=\Radius,
  ]
    \def\ClipBoxArea{%
      (\llxClip, \llyClip) rectangle (\urxClip, \uryClip)
    }
    \def\Gap(#1,#2)(#3:#4){%
      ($(#1,#2) + (#3:\OuterWhiteRadius)$)
      arc(#3:#4:\OuterWhiteRadius) --
      ($(#1,#2) + (#4:\InnerWhiteRadius)$)
      arc(#4:#3:\InnerWhiteRadius) --
      cycle
    }
    % Upper rings
    \begin{scope}[even odd rule]
      \clip
        \ClipBoxArea
        % Gap by yellow ring in blue ring
        \Gap(\xB,\yB)(225:135)
        % Gap by yellow ring in black ring
        \Gap(\xB, \yB)(90:45)
        % Gap by green ring in black ring
        \Gap(\xD, \yD)(225:135)
        % Gap by green ring in red ring
        \Gap(\xD, \yD)(90:45)
      ;
      \draw[color@A] (\xA, \yA) circle;
      \draw[color@C] (\xC, \yC) circle;
      \draw[color@E] (\xE, \yE) circle;
    \end{scope}
    % Lower rings
    \begin{scope}[even odd rule]
      \clip
        \ClipBoxArea
        % Gap by blue ring in yellow ring
        \Gap(\xA, \yA)(45:-45)
        % Gap by black ring in yellow ring
        \Gap(\xC, \yC)(225:270)
        % Gap by black ring in green ring
        \Gap(\xC, \yC)(45:-45)
        % Gap by red ring in green ring
        \Gap(\xE, \yE)(225:270)
      ;
      \draw[color@B] (\xB, \yB) circle;
      \draw[color@D] (\xD, \yD) circle;
    \end{scope}
    \useasboundingbox (\llxBB, \llyBB) rectangle (\urxBB, \uryBB);
  \end{tikzpicture}
\end{document}

结果

答案2

这似乎是使用 tikz 库knots的完美问题!当前解决方案比原始解决方案有所改进,原始解决方案存在一些小的“剪辑问题”(有关更多信息,请参阅这里)我认为这个解决方案非常优雅,因为代码非常简单,清晰和简短。

\documentclass{article}
\usepackage{tikz}
\usetikzlibrary{knots}
\begin{document} 
\begin{tikzpicture}
\definecolor{blue1}{RGB}{0,129,188}
\definecolor{yellow1}{RGB}{252,177,49}
\definecolor{black1}{RGB}{35,34,35}
\definecolor{green1}{RGB}{0,157,87}
\definecolor{red1}{RGB}{238,50,78}
\begin{knot}[clip width=1.4,clip radius=0.3cm]
    \strand[line width=0.25cm,red1] (3,0) circle(1.25cm);
    \strand[line width=0.25cm,green1] (1.5,-1.375) circle(1.25cm);
    \strand[line width=0.25cm,black1] (0,0) circle(1.25cm);
    \strand[line width=0.25cm,yellow1] (-1.5,-1.375) circle(1.25cm);
    \strand[line width=0.25cm,blue1] (-3,0) circle(1.25cm);
    \flipcrossings{2,4,6,8}
\end{knot}
\end{tikzpicture}
\end{document}

结果是:

在此处输入图片描述

答案3

采用最新的 PSTricks 解决方案pstricks-add http://comedy.dante.de/~herbert/texnik/tex/generic/pstricks-add/pstricks-add.tex 几天后将在 CTAN 上推出:运行方式xelatex

\documentclass{article}
\usepackage{pstricks-add}
\pagestyle{empty}
\begin{document}

\begin{pspicture}(-4.5,-3)(4.5,1.5)
\psOlympicRings(0,0)
\psOlympicRings[psscale=0.2](1.5,-1.5)
\psOlympicRings[psscale=0.2](-1.5,-1.5)
\end{pspicture}

\end{document}

在此处输入图片描述

相关内容