blob: 0326066f004b275ebc7d6283ef17767df6968b23 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
|
% \iffalse meta-comment
%
%% File: l3draw-boxes.dtx Copyright(C) 2018 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}
%</driver>
% \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 2018-10-31}
%
% \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
{
\driver_draw_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}
%</initex|package>
% \end{macrocode}
%
% \end{implementation}
%
% \PrintIndex
|