用 tikz 制作逼真的螺旋活页夹

用 tikz 制作逼真的螺旋活页夹

我正在观看此主题最近,我被 Gonzalo Medina 提供的出色答案所震撼(如下所示)。虽然这个答案很好,但我认为如果可以调整这个答案,使输出中的螺旋活页夹看起来更逼真,输出会更好。下图给出了两个我想要忠实再现的活页夹示例(顶部示例和底部示例)。如果不对给定的代码进行重大更改,我认为这些是不可能的(特别是因为在最好的情况下在弧线中添加渐变填充也很棘手)。在一次失败的尝试中,我尝试使用路径淡入淡出来实现基本的渐变,但效果与我想要的效果相差太大,并且不会显示在我的 PDF 预览中(似乎是 Mac 的问题)。我想不出其他方法来实现与下面两幅图类似的渐变,这是在解决活页夹后部以比 Medina 的答案中介绍的更好的方式(即没有间隙)进入纸张后面的问题之前,并且活页夹的前部以更无缝的方式进入纸张上的孔(参见下面我提供的图像中的两个示例)

尽管如此,我还是很乐意看到那些比我更有 tikz 天赋的人从提供的文档开始尝试重现这些活页夹样式。 在此处输入图片描述

\documentclass{article}
\usepackage[contents={}]{background}
\usepackage{tikzpagenodes}
\usetikzlibrary{shadows,calc}
\usepackage{lipsum}

\def\ShadowXshift{0.5ex}
\def\ShadowYshift{-0.5ex}

\makeatletter
\define@key{educnotebook}{spiralnumber}{\def\SpiralNumber{#1}}
\define@key{educnotebook}{nbcolorbg}{\def\NbColorBg{#1}}
\define@key{educnotebook}{minorgridcolor}{\def\MinorGridColor{#1}}
\define@key{educnotebook}{majorgridcolor}{\def\MajorGridColor{#1}}
\define@boolkey{educnotebook}{majorgrid}[false]{
\ifKV@educnotebook@majorgrid 
  \def\DrawMajorGrid{
    \path[clip,rounded corners=10pt]
        ([xshift=-30pt,yshift=20pt]current page text area.north west) rectangle
        ([xshift=30pt,yshift=-20pt]current page text area.south east);
    \draw[\MajorGridColor,opacity=0.3]
          ([xshift=30pt,yshift=-20pt]current page text area.south east) grid[step=10mm]
          ([xshift=-30pt,yshift=20pt]current page text area.north west);
  }
\else
  \def\DrawMajorGrid{\relax}
\fi
}
\define@boolkey{educnotebook}{minorgrid}[false]{
\ifKV@educnotebook@minorgrid 
  \def\DrawMinorGrid{
    \path[clip,rounded corners=10pt]
        ([xshift=-30pt,yshift=20pt]current page text area.north west) rectangle
        ([xshift=30pt,yshift=-20pt]current page text area.south east);
    \draw[\MinorGridColor,opacity=0.3]
          ([xshift=30pt,yshift=-20pt]current page text area.south east) grid[step=1mm]
          ([xshift=-30pt,yshift=20pt]current page text area.north west);
  }
\else
  \def\DrawMinorGrid{\relax}
\fi
}
\define@choicekey+{educnotebook}{spiralposition}[\val\nr]{left,right,top}[left]{%
  \ifcase\nr\relax
    \def\SpiralPosition{
      ([xshift=9pt,yshift=3pt-\Valor*\textheight/(\SpiralNumber-1)]current page text area.north west)
    }
    \def\RotateAngle{0}
  \or
    \def\SpiralPosition{
      ([xshift=-9pt,yshift=-5pt-\Valor*\textheight/(\SpiralNumber-1)]current page text area.north east)
    }
    \def\RotateAngle{180}
    \def\ShadowXshift{-0.5ex}
    \def\ShadowYshift{-0.5ex}
  \or
    \def\SpiralPosition{
      ([yshift=-19pt,xshift=5pt+\Valor*\textwidth/(\SpiralNumber-1)]current page text area.north west)
      }
    \def\RotateAngle{270}
  \fi
}{}

\setkeys{educnotebook}{
  nbcolorbg=white,
  minorgrid=false,
  majorgrid=false,
  minorgridcolor=black!20,
  majorgridcolor=black!60,
  spiralposition=left,
  spiralnumber=15
  }
\def\RotateAngle{0}
\def\ShadowXshift{0.5ex}
\def\ShadowYshift{-0.5ex}

\makeatother

\tikzset{
spiral/.pic={
  \draw[rotate=\RotateAngle,
    draw=black,
    left color=black!70,
    right color=black!60,
    middle color=gray!40
    ] 
    (-1.1,-0.35) rectangle ++(10pt,10pt);
  \draw[
    rotate=\RotateAngle,
    double=gray!80,
    double distance=1pt,
    ]
    (-1,-0.2) arc (40:-250:10pt and 2pt);
  \draw[
    rotate=\RotateAngle,
    double=gray!80,
    double distance=1pt,
    ]
    (-1,-0.05) arc (40:-250:10pt and 2pt);
  }
}

\newcommand\EducNotebook[1][]{%
\begingroup
\AddEverypageHook{%
  \setkeys{educnotebook}{#1}%
  \backgroundsetup{
    scale=1,
    opacity=1,
    color=black,
    angle=0,
    contents={
      \tikz[remember picture,overlay]
      {
      \draw[rounded corners=10pt,fill=\NbColorBg,drop shadow={shadow xshift=\ShadowXshift, shadow yshift=\ShadowYshift}]
        ([xshift=-30pt,yshift=20pt]current page text area.north west) rectangle
        ([xshift=30pt,yshift=-20pt]current page text area.south east);
      \foreach \Valor in {0,1,...,\numexpr\SpiralNumber-1\relax}
        \pic at \SpiralPosition {spiral};
      \DrawMajorGrid
      \DrawMinorGrid
      }  
      }
    }
  \BgMaterial
  }
\endgroup
}

\EducNotebook

\begin{document}
\lipsum[1-4]
\end{document}

答案1

\documentclass{article}
\usepackage[a4paper, hmargin=2cm, tmargin=4cm, bmargin=2cm]{geometry}
\usepackage{lipsum}
\usepackage{tikz}
\usepackage{tikzpagenodes}
\usetikzlibrary{shadings, fadings, shadows}
\colorlet{bgdcolor}{teal!20}
\tikzset{
spiral/.pic={
\shade[top color=black!80, bottom color=bgdcolor] (-0.39,-0.79) circle[radius=0.28];
\draw[black!10, path fading=north] (-0.39,-0.79) circle[radius=0.28];
\clip (-0.67,-0.79) arc[start angle=-180, end angle=0, radius=0.28] -- (0.36,0.00) -- (0.36,0.94) -|cycle;
\shade[top color=black!90, bottom color=black!90, middle color=black!20] (0.00,0.88) .. controls (0.16,0.85) and (0.27,0.25) .. (0.27,0.00) -- (0.00,0.00) .. controls (-0.02,0.32) and (-0.05,0.53) .. (-0.15,0.73) -- cycle (0,-0.4);
\shade[top color=black!90, bottom color=black!80, middle color=white] (0.00,0.92) .. controls (-0.32,0.71) and (-0.38,-0.34) .. (-0.23,-1.08) -- (-0.52,-1.08) .. controls (-0.61,-0.43) and (-0.64,0.61) .. (-0.29,0.92) -- cycle (0,2);
\draw[black!10, path fading=north] (0.00,0.88) .. controls (0.16,0.85) and (0.27,0.25) .. (0.27,0.00) -- (0.00,0.00) .. controls (-0.02,0.32) and (-0.05,0.53) .. (-0.15,0.73) -- cycle (0,-0.4);
\shade[top color=black!50, bottom color=black!90, middle color=black!20] (0.02,0.92) .. controls (0.11,0.91) and (0.25,0.62) .. (0.30,0.00) -- (0.23,0.00) .. controls (0.19,0.49) and (0.08,0.89) .. (-0.03,0.84) .. controls (-0.27,0.72) and (-0.35,-0.43) .. (-0.21,-1.06) -- (-0.28,-1.08) .. controls (-0.45,-0.11) and (-0.28,0.95) .. (0.02,0.92) -- cycle;
\draw[black!10, path fading=south] (0.02,0.92) .. controls (0.11,0.91) and (0.25,0.62) .. (0.30,0.00) -- (0.23,0.00) .. controls (0.19,0.49) and (0.08,0.89) .. (-0.03,0.84) .. controls (-0.27,0.72) and (-0.35,-0.43) .. (-0.21,-1.06) -- (-0.28,-1.08) .. controls (-0.45,-0.11) and (-0.28,0.95) .. (0.02,0.92) -- cycle;
}}
\begin{document}
\pagestyle{empty}
\pagecolor{bgdcolor}
\begin{tikzpicture}[remember picture, overlay]
\fill[white, drop shadow={shadow xshift=0.3cm, shadow yshift=-0.3cm}] ([xshift=-1cm] current page text area.south west) rectangle ([xshift=1cm, yshift=2cm]current page text area.north east);
\path ([yshift=2cm]current page text area.north west) -- ([xshift=1cm, yshift=2cm]current page text area.north east) foreach \t in {0, 0.05, ..., 1} {pic [pos=\t] {spiral}};
\end{tikzpicture}
\section{Introduction}
\lipsum[2-4]
\end{document}

在此处输入图片描述

放大阴影螺旋

相关内容