% \iffalse meta-comment
%
%% File: l3opacity.dtx
%
% Copyright (C) 2021-2025 The LaTeX Project
%
% It may be distributed and/or modified under the conditions of the
% LaTeX Project Public License (LPPL), either version 1.3c of this
% license or (at your option) any later version.  The latest version
% of this license is in the file
%
%    http://www.latex-project.org/lppl.txt
%
% This file is part of the "l3kernel bundle" (The Work in LPPL)
% and all files in that bundle must be distributed together.
%
% -----------------------------------------------------------------------
%
% The development version of the bundle can be found at
%
%    https://github.com/latex3/latex3
%
% for those people who are interested.
%
%<*driver>
\documentclass[full]{l3doc}
\begin{document}
  \DocInput{\jobname.dtx}
\end{document}
%</driver>
% \fi
%
% \title{^^A
%   The \pkg{l3opacity} module\\ Opacity (transparency) support^^A
% }
%
% \author{^^A
%  The \LaTeX{} Project\thanks
%    {^^A
%      E-mail:
%        \href{mailto:latex-team@latex-project.org}
%          {latex-team@latex-project.org}^^A
%    }^^A
% }
%
% \date{Released 2025-11-06}
%
% \maketitle
%
% \begin{documentation}
%
% \section{Selecting opacity}
%
% Opacity (transparency) shares many characteristics with color. However,
% limitations in terms of backends mean that it is not always possible
% to use a dedicated stack for tracking opacity. The best results when
% breaking pages are therefore likely to result using direct PDF output
% (\pdfTeX{}, \LuaTeX{}).
%
% For users of PostScript-based routes, note that there are security
% restrictions which can prevent opacity being available in output. In
% particular, using Adobe Distiller, you will need to enable transparency
% in the (text-based) configuration: this is not selectable from the GUI.
%
% For users of PDF-based routes, note that opacity only takes effect if
% a \cs{DocumentMetadata}|{}| is added \emph{before}
% \cs[no-index]{documentclass}, which loads and activates
% the PDF management.
% See \file{pdfmanagement-testphase.pdf} for more info.
%
% \begin{function}[added = 2025-03-27]{\opacity_select:n}
%   \begin{syntax}
%     \cs{opacity_select:n} \Arg{expression}
%   \end{syntax}
%   Evaluates the \meta{expression}, which should yield a value in the range $[0,1]$.
%   This is then activated as an opacity for both filling and stroking.
% \end{function}
%
% \begin{function}[added = 2025-03-27]{\opacity_fill:n, \opacity_stroke:n}
%   \begin{syntax}
%     \cs{opacity_fill:n} \Arg{expression}
%   \end{syntax}
%   Evaluates the \meta{expression}, which should yield a value in the range $[0,1]$.
%   This is then activated as an opacity for filling or stroking, respectively.
% \end{function}
%
% \end{documentation}
%
% \begin{implementation}
%
% \section{\pkg{l3opacity} implementation}
%
%    \begin{macrocode}
%<*code>
%    \end{macrocode}
%
%    \begin{macrocode}
%<@@=opacity>
%    \end{macrocode}
%
% Transitional support.
%    \begin{macrocode}
\cs_if_exist:NT \@expl@finalise@setup@@@@
  {
    \tl_gput_right:Nn \@expl@finalise@setup@@@@
      { \declare@file@substitution { l3opacity.sty } { null.tex } }
  }
%    \end{macrocode}
%
% \begin{variable}{\l_@@_tmp_fp}
%   Temporary storage.
%    \begin{macrocode}
\fp_new:N \l_@@_tmp_fp
%    \end{macrocode}
% \end{variable}
%
% \begin{macro}{\opacity_select:n, \opacity_fill:n, \opacity_stroke:n}
% \begin{macro}{\@@_select:nN}
%   Thin wrapper with error checking. Opacity is passed to backend
% functions as a bounded, evaluated decimal number.
%    \begin{macrocode}
\cs_new_protected:Npn \opacity_select:n #1
  { \@@_select:nN {#1} \@@_backend_select:n }
\cs_new_protected:Npn \opacity_fill:n #1
  { \@@_select:nN {#1} \@@_backend_fill:n }
\cs_new_protected:Npn \opacity_stroke:n #1
  { \@@_select:nN {#1} \@@_backend_stroke:n }
\cs_new_protected:Npn \@@_select:nN #1#2
  {
    \fp_set:Nn \l_@@_tmp_fp { #1 }
    \bool_lazy_or:nnTF
      { \fp_compare_p:nNn \l_@@_tmp_fp < \c_zero_fp }
      { \fp_compare_p:nNn \l_@@_tmp_fp > \c_one_fp }
      { \msg_error:nnn { opacity } { out-of-range } {#1} }
      { \exp_args:Ne #2 { \fp_use:N \l_@@_tmp_fp } }
  }
\msg_new:nnnn { opacity } { out-of-range }
  { Opacity~value~out~of~range. }
  {
    LaTeX~was~asked~to~set~opacity~of~#1,~but~only~values~in~the~range~
    0~to~1~are~supported.
  }
%    \end{macrocode}
% \end{macro}
% \end{macro}
%
%    \begin{macrocode}
%</code>
%    \end{macrocode}
%
% \end{implementation}
%
% \PrintIndex
