Skip to content

Commit

Permalink
Re-introduce draw support for coffins
Browse files Browse the repository at this point in the history
This time actually dealing with the bounding box correctly (at least for non-rotated coffins).

Question: do we want to support coffins rotated at the
'standard' level, or should this be left to drawing matrix work?
  • Loading branch information
josephwright committed Mar 4, 2018
1 parent 69a0e98 commit 22f5412
Show file tree
Hide file tree
Showing 2 changed files with 53 additions and 5 deletions.
36 changes: 31 additions & 5 deletions l3experimental/l3draw/l3draw-boxes.dtx
Expand Up @@ -69,27 +69,33 @@
% \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.
% 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 { 0pt , \box_dp:N #1 } }
{ \draw_point_transform:n { #2 , #3 } }
\@@_point_process:nn
{ \@@_path_update_limits:nn }
{ \draw_point_transform:n { \box_wd:N #1 , \box_dp:N #1 } }
{ \draw_point_transform:n { #4 , #3 } }
\@@_point_process:nn
{ \@@_path_update_limits:nn }
{ \draw_point_transform:n { 0pt , \box_ht:N #1 } }
{ \draw_point_transform:n { #4 , #5 } }
\@@_point_process:nn
{ \@@_path_update_limits:nn }
{ \draw_point_transform:n { \box_wd:N #1 , \box_ht:N #1 } }
{ \draw_point_transform:n { #2 , #5 } }
}
\group_begin:
\hbox_set:Nn \l_@@_tmp_box
Expand Down Expand Up @@ -117,6 +123,26 @@
}
% \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>
Expand Down
22 changes: 22 additions & 0 deletions l3experimental/l3draw/l3draw.dtx
Expand Up @@ -933,6 +933,28 @@
% \end{demo}
% \end{function}
%
% \begin{function}{\draw_coffin_use:Nnn}
% \begin{syntax}
% \cs{draw_coffin_use:N} \meta{coffin} \Arg{hpole} \Arg{vpole}
% \end{syntax}
% Inserts the \meta{coffin} into a drawing, taking account of the current
% transformation matrix and shift, and adjusting the drawing bounding
% box to contain the (apparent) size of the box if this is active
% (see \cs{l_draw_bb_update_bool}). The alignment point of the coffin to
% the origin is specified by the intersection of the \meta{hpole} and the
% \meta{vpole}.
% \begin{demo}
% \draw_begin:
% \draw_path_moveto:n { 0cm , 0cm }
% \draw_path_lineto:n { 0cm , 1cm }
% \draw_path_use_clear:n { stroke }
% \hcoffin_set:Nn \l_tmpa_coffin
% { This~is~text. }
% \draw_coffin_use:Nnn \l_tmpa_coffin { hc } { vc }
% \draw_end:
% \end{demo}
% \end{function}
%
% \subsection{Color}
%
% \begin{function}{\draw_color:n, \draw_color_fill:n, \draw_color_stroke:n}
Expand Down

0 comments on commit 22f5412

Please sign in to comment.