
我試圖在圖像上覆蓋一個陰影透明框,以便能夠在框內書寫,如下所示:
\documentclass{report}
\usepackage{xcolor}
\definecolor{lblue}{RGB}{15,77,158}
\usepackage{tikz}
\begin{document}
\begin{tikzpicture}
\node[] at (0,0) {\includegraphics[width=0.9\textwidth,]{IMG_2124_Everest.jpg}};
\shade [left color=lblue, right color=lblue, opacity=0.6] (-4,1) rectangle (4,2.5);
\node[shift={(-0.0cm,1.73cm)}] at (0,0) { \textcolor{white}{\Huge\textbf{Mount Everest}} };
\end{tikzpicture}
\end{document}
我想淡化陰影框的邊框,以降低定義它的線的可見性。
我讀過了:
但我不知道如何將其應用於陰影框。這可能嗎?
圖片來自:http://upload.wikimedia.org/wikipedia/commons/0/00/IMG_2124_Everest.jpg
答案1
此解決方案使用foreach
循環從內部矩形框轉到具有圓角的外部框。其他解決方案,請參閱 OP 中的連結問題。
\documentclass[tikz, border=1cm]{standalone}
\usetikzlibrary{fadings}
\pgfmathsetmacro{\mywidth}{9}
\pgfmathsetmacro{\myheight}{3.5}
\pgfmathsetmacro{\myfadewidth}{1}
\begin{tikzfadingfrompicture}[name=myfading]
\foreach \i in {100,...,0}
\fill[transparent!\i, rounded corners=\myfadewidth/100*\i cm] (-\mywidth/2-\myfadewidth/100*\i+\myfadewidth,-\myheight/2-\myfadewidth/100*\i+\myfadewidth) rectangle (\mywidth/2+\myfadewidth/100*\i-\myfadewidth,\myheight/2+\myfadewidth/100*\i-\myfadewidth);
\end{tikzfadingfrompicture}
\begin{document}
\begin{tikzpicture}
\node {\includegraphics[width=12cm]{example-image}};
\node[
fill=blue, text=white,
fill opacity=0.6, text opacity=1,
minimum width=\mywidth cm, minimum height=\myheight cm,
path fading=myfading, fit fading=false,
font=\Huge\bf,
yshift=1.5cm, fading transform={yshift=1.5cm},
] {Mount Everest};
\end{tikzpicture}
\end{document}
可以使用a 代替循環\pgfdeclarefunctionalshading
,但這並不簡單,並且此警告在手冊中:
這些陰影是所有陰影中可移植性最差的,它們給渲染器帶來了最重的負擔。它們速度很慢,可能無法正確列印!