From e0c6872cf40896c7be36b11dcc744620f10adf1d Mon Sep 17 00:00:00 2001 From: Norbert Preining Date: Mon, 2 Sep 2019 13:46:59 +0900 Subject: Initial commit --- .../latex/contrib/l3experimental/l3draw-boxes.dtx | 155 +++++++++++++++++++++ 1 file changed, 155 insertions(+) create mode 100644 macros/latex/contrib/l3experimental/l3draw-boxes.dtx (limited to 'macros/latex/contrib/l3experimental/l3draw-boxes.dtx') diff --git a/macros/latex/contrib/l3experimental/l3draw-boxes.dtx b/macros/latex/contrib/l3experimental/l3draw-boxes.dtx new file mode 100644 index 0000000000..2eeacd0d0a --- /dev/null +++ b/macros/latex/contrib/l3experimental/l3draw-boxes.dtx @@ -0,0 +1,155 @@ +% \iffalse meta-comment +% +%% File: l3draw-boxes.dtx +% +% Copyright (C) 2018,2019 The LaTeX3 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 "l3experimental 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> +\RequirePackage{expl3} +\documentclass[full]{l3doc} +\begin{document} + \DocInput{\jobname.dtx} +\end{document} +% +% \fi +% +% \title{^^A +% The \pkg{l3draw-boxes} package\\ Boxes in drawings^^A +% } +% +% \author{^^A +% The \LaTeX3 Project\thanks +% {^^A +% E-mail: +% \href{mailto:latex-team@latex-project.org} +% {latex-team@latex-project.org}^^A +% }^^A +% } +% +% \date{Released 2019-08-25} +% +% \maketitle +% +% \begin{implementation} +% +% \section{\pkg{l3draw-boxes} implementation} +% +% \begin{macrocode} +%<*initex|package> +% \end{macrocode} +% +% \begin{macrocode} +%<@@=draw> +% \end{macrocode} +% +% Inserting boxes requires us to \enquote{interrupt} the drawing state, +% so is closely linked to scoping. At the same time, there are a few +% additional features required to make text work in a flexible way. +% +% \begin{variable}{\l_@@_tmp_box} +% \begin{macrocode} +\box_new:N \l_@@_tmp_box +% \end{macrocode} +% \end{variable} +% +% \begin{macro}{\draw_box_use:N} +% \begin{macro}{\@@_box_use:Nnnnn} +% Before inserting a box, we need to make sure that the bounding box is being +% updated correctly. As drawings track transformations as a whole, rather +% than as separate operations, we do the insertion using an almost-raw +% matrix. The process is split into two so that coffins are also supported. +% \begin{macrocode} +\cs_new_protected:Npn \draw_box_use:N #1 + { + \@@_box_use:Nnnnn #1 + { 0pt } { -\box_dp:N #1 } { \box_wd:N #1 } { \box_ht:N #1 } + } +\cs_new_protected:Npn \@@_box_use:Nnnnn #1#2#3#4#5 + { + \bool_if:NT \l_draw_bb_update_bool + { + \@@_point_process:nn + { \@@_path_update_limits:nn } + { \draw_point_transform:n { #2 , #3 } } + \@@_point_process:nn + { \@@_path_update_limits:nn } + { \draw_point_transform:n { #4 , #3 } } + \@@_point_process:nn + { \@@_path_update_limits:nn } + { \draw_point_transform:n { #4 , #5 } } + \@@_point_process:nn + { \@@_path_update_limits:nn } + { \draw_point_transform:n { #2 , #5 } } + } + \group_begin: + \hbox_set:Nn \l_@@_tmp_box + { + \use:x + { + \@@_backend_box_use:Nnnnn #1 + { \fp_use:N \l_@@_matrix_a_fp } + { \fp_use:N \l_@@_matrix_b_fp } + { \fp_use:N \l_@@_matrix_c_fp } + { \fp_use:N \l_@@_matrix_d_fp } + } + } + \hbox_set:Nn \l_@@_tmp_box + { + \tex_kern:D \l_@@_xshift_dim + \box_move_up:nn { \l_@@_yshift_dim } + { \box_use_drop:N \l_@@_tmp_box } + } + \box_set_ht:Nn \l_@@_tmp_box { 0pt } + \box_set_dp:Nn \l_@@_tmp_box { 0pt } + \box_set_wd:Nn \l_@@_tmp_box { 0pt } + \box_use_drop:N \l_@@_tmp_box + \group_end: + } +% \end{macrocode} +% \end{macro} +% \end{macro} +% +% \begin{macro}{\draw_coffin_use:Nnn} +% Slightly more than a shortcut: we have to allow for the fact that coffins +% have no apparent width before the reference point. +% \begin{macrocode} +\cs_new_protected:Npn \draw_coffin_use:Nnn #1#2#3 + { + \group_begin: + \hbox_set:Nn \l_@@_tmp_box + { \coffin_typeset:Nnnnn #1 {#2} {#3} { 0pt } { 0pt } } + \@@_box_use:Nnnnn \l_@@_tmp_box + { \box_wd:N \l_@@_tmp_box - \coffin_wd:N #1 } + { -\box_dp:N \l_@@_tmp_box } + { \box_wd:N \l_@@_tmp_box } + { \box_ht:N \l_@@_tmp_box } + \group_end: + } +% \end{macrocode} +% \end{macro} +% +% \begin{macrocode} +% +% \end{macrocode} +% +% \end{implementation} +% +% \PrintIndex -- cgit v1.2.3