[latex3-commits] [latex3/latex3] main: Add \draw_path_replace_bb: (cc9b93411)

github at latex-project.org github at latex-project.org
Thu Feb 22 23:36:14 CET 2024


Repository : https://github.com/latex3/latex3
On branch  : main
Link       : https://github.com/latex3/latex3/commit/cc9b93411f7f452fc23529810ea633fa25d0fee8

>---------------------------------------------------------------

commit cc9b93411f7f452fc23529810ea633fa25d0fee8
Author: Joseph Wright <joseph.wright at morningstar2.co.uk>
Date:   Thu Feb 22 22:36:14 2024 +0000

    Add \draw_path_replace_bb:


>---------------------------------------------------------------

cc9b93411f7f452fc23529810ea633fa25d0fee8
 l3experimental/CHANGELOG.md            |  3 +++
 l3experimental/l3draw/l3draw-paths.dtx | 32 ++++++++++++++++++++++++--------
 l3experimental/l3draw/l3draw.dtx       | 12 ++++++++++++
 3 files changed, 39 insertions(+), 8 deletions(-)

diff --git a/l3experimental/CHANGELOG.md b/l3experimental/CHANGELOG.md
index 197fa4254..205c753ec 100644
--- a/l3experimental/CHANGELOG.md
+++ b/l3experimental/CHANGELOG.md
@@ -7,6 +7,9 @@ this project uses date-based 'snapshot' version identifiers.
 
 ## [Unreleased]
 
+### Added
+- `\draw_path_replace_bb:`
+
 ## [2024-02-20]
 
 ### Fixed
diff --git a/l3experimental/l3draw/l3draw-paths.dtx b/l3experimental/l3draw/l3draw-paths.dtx
index f922fc4de..9c8bb6e12 100644
--- a/l3experimental/l3draw/l3draw-paths.dtx
+++ b/l3experimental/l3draw/l3draw-paths.dtx
@@ -840,10 +840,11 @@
 % \end{variable}
 %
 % \begin{macro}{\draw_path_use:n, \draw_path_use_clear:n}
+% \begin{macro}{\draw_path_replace_bb:}
 % \begin{macro}{\@@_path_use:n}
 % \begin{macro}{\@@_path_use_action_draw:, \@@_path_use_action_fillstroke:}
-% \begin{macro}{\@@_path_use_stroke_bb:}  
-% \begin{macro}{\@@_path_use_stroke_bb_aux:NnN}
+% \begin{macro}{\@@_path_use_bb:, \@@_path_use_stroke_bb:}  
+% \begin{macro}{\@@_path_use_bb:NnN}
 %   There are a range of actions which can apply to a path: they are handled
 %   in a single function which can carry out several of them. The first step
 %   is to deal with the special case of clearing the path.
@@ -864,6 +865,13 @@
       }
       { \@@_path_use:n { #1 , clear } }
   }
+\cs_new_protected:Npn \draw_path_replace_bb:
+  {
+    \@@_reset_bb:
+    \@@_path_use_bb:
+    \@@_softpath_clear:
+    \@@_path_reset_limits:
+  }
 %    \end{macrocode}
 %   Map over the actions and set up the data: mainly just booleans,
 %   but with the possibility to cover more complex cases. The business end
@@ -927,14 +935,21 @@
 %   Where the path is relevant to size and is stroked, we need to allow for
 %   the part which overlaps the edge of the bounding box.
 %    \begin{macrocode}
+\cs_new_protected:Npn \@@_path_use_bb:
+  {
+    \@@_path_use_bb:NnNN x { max } + 0
+    \@@_path_use_bb:NnNN y { max } + 0
+    \@@_path_use_bb:NnNN x { min } - 0
+    \@@_path_use_bb:NnNN y { min } - 0
+  }
 \cs_new_protected:Npn \@@_path_use_stroke_bb:
   {
-    \@@_path_use_stroke_bb_aux:NnN x { max } +
-    \@@_path_use_stroke_bb_aux:NnN y { max } +
-    \@@_path_use_stroke_bb_aux:NnN x { min } -
-    \@@_path_use_stroke_bb_aux:NnN y { min } -
+    \@@_path_use_bb:NnNN x { max } + 5
+    \@@_path_use_bb:NnNN y { max } + 5
+    \@@_path_use_bb:NnNN x { min } - 5
+    \@@_path_use_bb:NnNN y { min } - 5
   }
-\cs_new_protected:Npn \@@_path_use_stroke_bb_aux:NnN #1#2#3
+\cs_new_protected:Npn \@@_path_use_bb:NnNN #1#2#3#4
   {
     \dim_compare:nNnF { \dim_use:c { g_@@_ #1#2 _dim } } = { #3 -\c_max_dim }
       {
@@ -944,7 +959,7 @@
               { \dim_use:c { g_@@_ #1#2 _dim } }
               {
                   \dim_use:c { g_@@_path_ #1#2 _dim }
-                #3 0.5 \g_@@_linewidth_dim
+                #3 0.#4 \g_@@_linewidth_dim
               } 
           }
       }
@@ -955,6 +970,7 @@
 % \end{macro}
 % \end{macro}
 % \end{macro}
+% \end{macro}
 %
 % \subsection{Scoping paths}
 %
diff --git a/l3experimental/l3draw/l3draw.dtx b/l3experimental/l3draw/l3draw.dtx
index 2bfa4e00a..8445036d0 100644
--- a/l3experimental/l3draw/l3draw.dtx
+++ b/l3experimental/l3draw/l3draw.dtx
@@ -658,6 +658,18 @@
 %   at the macro level).
 % \end{function}
 %
+% \begin{function}{\draw_path_replace_bb:}
+%   \begin{syntax}
+%     \cs{draw_path_replace_bb:}
+%   \end{syntax}
+%   Replaces the current bounding box of the drawing with one specified by the
+%   current path: this will be applied even when \cs{l_draw_bb_update_bool}
+%   is \texttt{false}. The current path is then cleared. Note that
+%   \cs{l_draw_bb_update_bool} is \emph{not} changed by this function:
+%   the user may wish to set it to \texttt{false} so that the bounding box
+%   is then left unchanged by further operations.
+% \end{function}
+%
 % \subsubsection{Path operations on drawing axes}
 %
 % The standard path functions are all influenced by the active transformation





More information about the latex3-commits mailing list.