我正在使用 tikz 库 spy 放大图像。我放大的图像是二进制黑白图像。但我希望放大部分的圆圈用同一图像的彩色版本填充。这可能吗?
\documentclass[12 pt,onecolumn]{article}
\usepackage{fullpage}
\usepackage{graphicx}
\usepackage{amsmath}
\usepackage{tikz}
\usepackage{pgfplots}
\usepackage{xcolor}
\usetikzlibrary{spy}
\pgfplotsset{compat=1.5}
\begin{document}
\begin{figure}
\begin{tikzpicture}[spy using outlines={circle,yellow,magnification=5,size=5cm, connect spies}]
\node[anchor=south west,inner sep=0] at (0,0) {\includegraphics[width=\textwidth]{images/film-stupid-duck}};
\spy on (12.2,5.2) in node [left] at (16,10);
\spy on (6,4) in node [left] at (10,10);
\path[fill=white] (5,0) rectangle (12,2);
\end{tikzpicture}
\caption{}
\label{}
\end{figure}
\end{document}
下面的图片是我目前的结果。我希望这两张放大的图像来自第二张在空间上匹配的图像
答案1
不知道这是否正确,但它似乎工作(尽管没有经过任何方式的全面测试)。
\documentclass[tikz,border=5]{standalone}
\usetikzlibrary{spy}
\begin{document}
\makeatletter
\tikzset{spy on other/.code={%
\pgfutil@g@addto@macro\tikz@lib@spy@collection{%
\setbox\tikz@lib@spybox=\hbox{\pgfpicture#1\endpgfpicture}}}}
\makeatother
\begin{tikzpicture}[spy using outlines={circle,yellow,magnification=5,size=5cm, connect spies}]
\fill [black, even odd rule]
(0,0) rectangle (15, 15) (7.5,7.5) circle [radius=5] circle [radius=2.5]
(6,0) rectangle (9,15) (0,6) rectangle (15,9);
\tikzset{spy on other={
\fill [left color=red, right color=blue, even odd rule]
(0,0) rectangle (15, 15) (7.5,7.5) circle [radius=5] circle [radius=2.5]
(6,0) rectangle (9,15) (0,6) rectangle (15,9);
}}
\spy on (9,12) in node [right] at (16,12);
\spy on (12,6) in node [right] at (16,3);
\spy on (6,3) in node [left] at (-1,3);
\spy on (3,9) in node [left] at (-1,12);
\end{tikzpicture}
\end{document}