| 1 |
% File: hawkdraw.sty |
| 2 |
% Copyright 2026 Jasper Habicht (mail(at)jasperhabicht.de). |
| 3 |
% |
| 4 |
% This work may be distributed and/or modified under the |
| 5 |
% conditions of the LaTeX Project Public License version 1.3c, |
| 6 |
% available at http://www.latex-project.org/lppl/. |
| 7 |
% |
| 8 |
% This file is part of the `hawkdraw' package (The Work in LPPL) |
| 9 |
% and all files in that bundle must be distributed together. |
| 10 |
% |
| 11 |
% This work has the LPPL maintenance status `maintained'. |
| 12 |
% |
| 13 |
\ProvidesExplPackage {hawkdraw} {2026-05-25} {0.0.7} |
| 14 |
{An experimental package for drawing vector graphics with the l3draw package and a TikZ-like syntax.} |
| 15 |
|
| 16 |
\msg_new:nnn { hawkdraw } { old-kernel } { |
| 17 |
LaTeX ~ kernel ~ too ~ old. \iow_newline: |
| 18 |
The ~ hawkdraw ~ package ~ does ~ not ~ support ~ this ~ LaTeX ~ version. \iow_newline: |
| 19 |
Please ~ update ~ to ~ a ~ newer ~ version. |
| 20 |
} |
| 21 |
|
| 22 |
\msg_new:nnn { hawkdraw } { compat-mode } { |
| 23 |
Old ~ version ~ of ~ l3draw ~ detected. \iow_newline: |
| 24 |
Compatibility ~ mode ~ activated. |
| 25 |
} |
| 26 |
|
| 27 |
\msg_new:nnn { hawkdraw } { documentmetadata-required } { |
| 28 |
\token_to_str:N \DocumentMetadata \c_space_tl ~ must ~ be ~ set ~ |
| 29 |
to ~ enable ~ full ~ functionality. |
| 30 |
} |
| 31 |
|
| 32 |
\cs_if_exist:NF \ProcessKeyOptions { |
| 33 |
\msg_critical:nn { hawkdraw } { old-kernel } |
| 34 |
} |
| 35 |
|
| 36 |
% === |
| 37 |
|
| 38 |
\ProcessKeyOptions [ ] |
| 39 |
|
| 40 |
\RequirePackage { l3draw } |
| 41 |
|
| 42 |
\IfPDFManagementActiveTF { } { |
| 43 |
\msg_warning:nn { hawkdraw } { documentmetadata-required } |
| 44 |
} |
| 45 |
|
| 46 |
% === |
| 47 |
|
| 48 |
\IfExplAtLeastTF { 2025-04-14 } { } { |
| 49 |
\RequirePackage { l3opacity } |
| 50 |
} |
| 51 |
|
| 52 |
% backward compatibility |
| 53 |
\cs_if_exist:NF \draw_set_linewidth:n { |
| 54 |
\cs_set_eq:NN \draw_set_linewidth:n \draw_linewidth:n |
| 55 |
} |
| 56 |
\cs_if_exist:NF \draw_set_baseline:n { |
| 57 |
\cs_set_eq:NN \draw_set_baseline:n \draw_baseline:n |
| 58 |
} |
| 59 |
\cs_if_exist:NF \draw_set_cap_round: { |
| 60 |
\cs_set_eq:NN \draw_set_cap_round: \draw_cap_round: |
| 61 |
} |
| 62 |
\cs_if_exist:NF \draw_set_join_round: { |
| 63 |
\cs_set_eq:NN \draw_set_join_round: \draw_join_round: |
| 64 |
} |
| 65 |
\cs_if_exist:NF \draw_point_interpolate_curve:nnnnn { |
| 66 |
\cs_set_eq:NN \draw_point_interpolate_curve:nnnnn \draw_point_interpolate_curve:nnnnnn |
| 67 |
} |
| 68 |
\cs_if_exist:NF \draw_point_interpolate_curve:nnnn { |
| 69 |
\cs_set:Npn \draw_point_interpolate_curve:nnnn #1#2#3#4 { |
| 70 |
\draw_point_interpolate_curve:nnnnn {#1} {#2} { |
| 71 |
( #2 + 2 * #3 ) / 3 |
| 72 |
} { |
| 73 |
( #4 + 2 * #3 ) / 3 |
| 74 |
} {#4} |
| 75 |
} |
| 76 |
} |
| 77 |
\cs_if_exist:NF \draw_point_interpolate_arc_axes:nnnnnn { |
| 78 |
\cs_set_eq:NN \draw_point_interpolate_arc_axes:nnnnnn \draw_point_interpolate_arcaxes:nnnnnn |
| 79 |
} |
| 80 |
\IfExplAtLeastTF { 2026-04-28 } { } { |
| 81 |
\msg_warning:nn { hawkdraw } { compat-mode } |
| 82 |
\cs_set_eq:NN \__hawkdraw_compat_draw_path_arc:nnnn \draw_path_arc:nnnn |
| 83 |
\cs_set_protected:Npn \draw_path_arc:nnnn #1#2#3#4 { |
| 84 |
\__hawkdraw_compat_draw_path_arc:nnnn {#3} {#4} {#1} {#2} |
| 85 |
} |
| 86 |
\cs_set_protected:Npn \draw_path_arc:nnn #1#2#3 { |
| 87 |
\__hawkdraw_compat_draw_path_arc:nnnn {#2} {#3} {#1} {#1} |
| 88 |
} |
| 89 |
\cs_set_protected:Npn \draw_path_arc_axes:nnnn #1#2#3#4 { |
| 90 |
\group_begin: |
| 91 |
\draw_transform_triangle:nnn { 0cm , 0cm } {#1} {#2} |
| 92 |
\__hawkdraw_compat_draw_path_arc:nnnn {#3} {#4} { 1pt } { 1pt } |
| 93 |
\group_end: |
| 94 |
} |
| 95 |
} |
| 96 |
\IfExplAtLeastTF { 2026-05-26 } { |
| 97 |
\cs_set_eq:NN \draw_layer_new:n \use_none:n |
| 98 |
} { |
| 99 |
\cs_set:Npn \__draw_point_interpolate_line_aux:nnnnnn #1#2#3#4#5#6 { |
| 100 |
\draw_point:n { #1 * #3 + #2 * #5 , #1 * #4 + #2 * #6 } |
| 101 |
} |
| 102 |
\cs_set:Npn \__draw_point_interpolate_curve_auxvii:nnnnnnnn #1#2#3#4#5#6#7#8 { |
| 103 |
\__draw_point_interpolate_curve_auxviii:eeeenn |
| 104 |
{ \fp_eval:n { #1 * #3 + #2 * #5 } } |
| 105 |
{ \fp_eval:n { #1 * #4 + #2 * #6 } } |
| 106 |
{ \fp_eval:n { #1 * #5 + #2 * #7 } } |
| 107 |
{ \fp_eval:n { #1 * #6 + #2 * #8 } } |
| 108 |
{#1} {#2} |
| 109 |
} |
| 110 |
\cs_set:Npn \__draw_point_interpolate_curve_auxviii:nnnnnn #1#2#3#4#5#6 { |
| 111 |
\draw_point:n { |
| 112 |
{ #5 * #1 + #6 * #3 , #5 * #2 + #6 * #4 } |
| 113 |
} |
| 114 |
} |
| 115 |
} |
| 116 |
% === |
| 117 |
|
| 118 |
\msg_new:nnn { hawkdraw } { style-undefined } { |
| 119 |
The ~ style ~ `#1` ~ is ~ undefined. |
| 120 |
} |
| 121 |
\msg_new:nnn { hawkdraw } { module-missing } { |
| 122 |
The ~ module ~ `#1` ~ is ~ missing. |
| 123 |
} |
| 124 |
|
| 125 |
\cs_new_protected:Npn \hawkdraw_modules_load:n #1 { |
| 126 |
\clist_map_inline:nn {#1} { |
| 127 |
\file_if_exist_input:nF { hawkdraw- ##1 .code.tex } { |
| 128 |
\msg_warning:nnn { hawkdraw } { module-missing } {##1} |
| 129 |
} |
| 130 |
} |
| 131 |
} |
| 132 |
|
| 133 |
\hawkdraw_modules_load:n { nodes , arrows } |
| 134 |
|
| 135 |
\IfPDFManagementActiveTF { |
| 136 |
\hawkdraw_modules_load:n { patterns } |
| 137 |
} { |
| 138 |
\msg_warning:nn { hawkdraw } { documentmetadata-required } |
| 139 |
\keys_define:nn { hawkdraw / path } { |
| 140 |
fill ~ pattern .code:n = { } , |
| 141 |
pattern ~ style ~ set .code:n = { } , |
| 142 |
pattern ~ style ~ add .code:n = { } , |
| 143 |
pattern ~ x .code:n = { } , |
| 144 |
pattern ~ y .code:n = { } , |
| 145 |
} |
| 146 |
} |
| 147 |
|
| 148 |
% === |
| 149 |
|
| 150 |
\clist_new:N \l__hawkdraw_keys_unprocessed_clist |
| 151 |
|
| 152 |
\int_new:N \g_hawkdraw_id_int |
| 153 |
|
| 154 |
\bool_new:N \l_hawkdraw_instance_overlay_bool |
| 155 |
\fp_new:N \l_draw_instance_baseline_fp |
| 156 |
|
| 157 |
\tl_new:N \g_hawkdraw_path_current_tl |
| 158 |
\tl_new:N \l_hawkdraw_path_preactions_tl |
| 159 |
\tl_new:N \l_hawkdraw_path_postactions_tl |
| 160 |
|
| 161 |
\clist_new:N \l_hawkdraw_path_use_clist |
| 162 |
\bool_new:N \g__hawkdraw_path_use_clip_bool |
| 163 |
\bool_new:N \l__hawkdraw_path_ignore_keys_bool |
| 164 |
\str_new:N \l_hawkdraw_path_stroke_color_str |
| 165 |
\str_new:N \l_hawkdraw_path_fill_color_str |
| 166 |
\fp_new:N \l_hawkdraw_path_stroke_opacity_fp |
| 167 |
\fp_new:N \l_hawkdraw_path_fill_opacity_fp |
| 168 |
\dim_new:N \l_hawkdraw_path_linewidth_dim |
| 169 |
|
| 170 |
\str_new:N \l_hawkdraw_path_cap_str |
| 171 |
\str_new:N \l_hawkdraw_path_join_str |
| 172 |
\fp_new:N \l_hawkdraw_path_miterlimit_fp |
| 173 |
\clist_new:N \l_hawkdraw_path_corner_arc_clist |
| 174 |
\str_new:N \l_hawkdraw_path_fill_rule_str |
| 175 |
|
| 176 |
\clist_new:N \l_hawkdraw_path_dash_pattern_clist |
| 177 |
\dim_new:N \l_hawkdraw_path_dash_phase_dim |
| 178 |
|
| 179 |
\str_new:N \l__hawkdraw_path_type_str |
| 180 |
\fp_new:N \g_hawkdraw_path_first_point_fp |
| 181 |
\fp_new:N \g_hawkdraw_path_last_point_fp |
| 182 |
\fp_new:N \g_hawkdraw_path_first_slope_fp |
| 183 |
\fp_new:N \g_hawkdraw_path_last_slope_fp |
| 184 |
\fp_new:N \l__hawkdraw_point_o_fp |
| 185 |
\fp_new:N \l__hawkdraw_point_a_fp |
| 186 |
\fp_new:N \l__hawkdraw_point_b_fp |
| 187 |
\fp_new:N \l__hawkdraw_point_c_fp |
| 188 |
|
| 189 |
\str_new:N \l_hawkdraw_scope_layer_str |
| 190 |
|
| 191 |
\cs_generate_variant:Nn \color_select:n { V } |
| 192 |
\cs_generate_variant:Nn \color_fill:n { V } |
| 193 |
\cs_generate_variant:Nn \color_stroke:n { V } |
| 194 |
\cs_generate_variant:Nn \opacity_select:n { V } |
| 195 |
\cs_generate_variant:Nn \opacity_fill:n { V } |
| 196 |
\cs_generate_variant:Nn \opacity_stroke:n { V } |
| 197 |
\cs_generate_variant:Nn \draw_set_linewidth:n { V } |
| 198 |
\cs_generate_variant:Nn \draw_set_miterlimit:n { V } |
| 199 |
\cs_generate_variant:Nn \draw_set_dash_pattern:nn { VV } |
| 200 |
\cs_generate_variant:Nn \draw_path_corner_arc:nn { ee } |
| 201 |
\cs_generate_variant:Nn \draw_path_use_clear:n { e } |
| 202 |
\cs_generate_variant:Nn \draw_layer_begin:n { V } |
| 203 |
|
| 204 |
\exp_args_generate:n { NNNe } |
| 205 |
|
| 206 |
\cs_new_protected:Npn \__hawkdraw_style_set:nn #1#2 { |
| 207 |
\clist_if_exist:cF { l__hawkdraw_style_ #1 _value_clist } { |
| 208 |
\clist_new:c { l__hawkdraw_style_ #1 _value_clist } |
| 209 |
} |
| 210 |
\clist_put_right:cn { l__hawkdraw_style_ #1 _value_clist } {#2} |
| 211 |
\keys_define:ne { hawkdraw / path } { |
| 212 |
#1 .meta:n = { |
| 213 |
\clist_use:c { l__hawkdraw_style_ #1 _value_clist } |
| 214 |
} |
| 215 |
} |
| 216 |
} |
| 217 |
|
| 218 |
\cs_new_protected:Npn \__hawkdraw_style_put_right:nn #1#2 { |
| 219 |
\clist_if_exist:cTF { l__hawkdraw_style_ #1 _value_clist } { |
| 220 |
\clist_put_right:cn { l__hawkdraw_style_ #1 _value_clist } {#2} |
| 221 |
\keys_define:ne { hawkdraw / path } { |
| 222 |
#1 .meta:n = { |
| 223 |
\clist_use:c { l__hawkdraw_style_ #1 _value_clist } |
| 224 |
} |
| 225 |
} |
| 226 |
} { |
| 227 |
\msg_error:nnn { hawkdraw } { style-undefined } {#1} |
| 228 |
} |
| 229 |
} |
| 230 |
|
| 231 |
\keys_define:nn { hawkdraw / path } { |
| 232 |
style ~ set .code:n = { |
| 233 |
\keyval_parse:NNn \use:n \__hawkdraw_style_set:nn {#1} |
| 234 |
} , |
| 235 |
style ~ add .code:n = { |
| 236 |
\keyval_parse:NNn \use:n \__hawkdraw_style_put_right:nn {#1} |
| 237 |
} , |
| 238 |
} |
| 239 |
|
| 240 |
\keys_define:nn { hawkdraw / path } { |
| 241 |
stroke .code:n = { |
| 242 |
\clist_put_right:Nn \l_hawkdraw_path_use_clist { stroke } |
| 243 |
} , |
| 244 |
fill .code:n = { |
| 245 |
\clist_put_right:Nn \l_hawkdraw_path_use_clist { fill } |
| 246 |
} , |
| 247 |
clip .bool_gset:N = \g__hawkdraw_path_use_clip_bool , |
| 248 |
clip .default:n = { true } , |
| 249 |
clip .initial:n = { false } , |
| 250 |
% === |
| 251 |
stroke ~ color .str_set:N = \l_hawkdraw_path_stroke_color_str , |
| 252 |
stroke ~ color .initial:n = { . } , |
| 253 |
fill ~ color .str_set:N = \l_hawkdraw_path_fill_color_str , |
| 254 |
fill ~ color .initial:n = { . } , |
| 255 |
stroke ~ opacity .fp_set:N = \l_hawkdraw_path_stroke_opacity_fp , |
| 256 |
stroke ~ opacity .initial:n = { 1 } , |
| 257 |
fill ~ opacity .fp_set:N = \l_hawkdraw_path_fill_opacity_fp , |
| 258 |
fill ~ opacity .initial:n = { 1 } , |
| 259 |
% === |
| 260 |
line ~ width .dim_set:N = \l_hawkdraw_path_linewidth_dim , |
| 261 |
line ~ width .initial:V = \l_draw_default_linewidth_dim , |
| 262 |
line ~ cap .choice: , |
| 263 |
line ~ cap / butt .code:n = { |
| 264 |
\str_set:Nn \l_hawkdraw_path_cap_str { butt } |
| 265 |
} , |
| 266 |
line ~ cap / round .code:n = { |
| 267 |
\str_set:Nn \l_hawkdraw_path_cap_str { round } |
| 268 |
} , |
| 269 |
line ~ cap / rectangle .code:n = { |
| 270 |
\str_set:Nn \l_hawkdraw_path_cap_str { rectangle } |
| 271 |
} , |
| 272 |
line ~ cap .initial:n = { butt } , |
| 273 |
line ~ join .choice: , |
| 274 |
line ~ join / miter .code:n = { |
| 275 |
\str_set:Nn \l_hawkdraw_path_join_str { miter } |
| 276 |
} , |
| 277 |
line ~ join / round .code:n = { |
| 278 |
\str_set:Nn \l_hawkdraw_path_join_str { round } |
| 279 |
} , |
| 280 |
line ~ join / bevel .code:n = { |
| 281 |
\str_set:Nn \l_hawkdraw_path_join_str { bevel } |
| 282 |
} , |
| 283 |
line ~ join .initial:n = { miter } , |
| 284 |
miter ~ limit .fp_set:N = \l_hawkdraw_path_miterlimit_fp , |
| 285 |
miter ~ limit .initial:n = { 10 } , |
| 286 |
dash ~ pattern .clist_set:N = \l_hawkdraw_path_dash_pattern_clist , |
| 287 |
dash ~ pattern .initial:n = { } , |
| 288 |
dash ~ phase .dim_set:N = \l_hawkdraw_path_dash_phase_dim , |
| 289 |
dash ~ phase .initial:n = { 0pt } , |
| 290 |
corner ~ arc .clist_set:N = \l_hawkdraw_path_corner_arc_clist , |
| 291 |
corner ~ arc .initial:n = { 0pt } , |
| 292 |
fill ~ rule .choice: , |
| 293 |
fill ~ rule / even-odd .code:n = { |
| 294 |
\str_set:Nn \l_hawkdraw_path_fill_rule_str { evenodd } |
| 295 |
} , |
| 296 |
fill ~ rule / non-zero .code:n = { |
| 297 |
\str_set:Nn \l_hawkdraw_path_fill_rule_str { nonzero } |
| 298 |
} , |
| 299 |
fill ~ rule .initial:n = { non-zero } , |
| 300 |
% === |
| 301 |
shift .code:n = { |
| 302 |
\draw_transform_shift:n {#1} |
| 303 |
} , |
| 304 |
rotate .code:n = { |
| 305 |
\draw_transform_rotate:n {#1} |
| 306 |
} , |
| 307 |
scale .code:n = { |
| 308 |
\int_compare:nNnTF { \clist_count:n {#1} } > { 1 } { |
| 309 |
\draw_transform_xscale:n { |
| 310 |
\clist_item:nn {#1} { 1 } |
| 311 |
} |
| 312 |
\draw_transform_yscale:n { |
| 313 |
\clist_item:nn {#1} { 2 } |
| 314 |
} |
| 315 |
} { |
| 316 |
\draw_transform_scale:n {#1} |
| 317 |
} |
| 318 |
} , |
| 319 |
slant .code:n = { |
| 320 |
\int_compare:nNnTF { \clist_count:n {#1} } > { 1 } { |
| 321 |
\draw_transform_xslant:n { |
| 322 |
\clist_item:nn {#1} { 1 } |
| 323 |
} |
| 324 |
\draw_transform_yslant:n { |
| 325 |
\clist_item:nn {#1} { 2 } |
| 326 |
} |
| 327 |
} { |
| 328 |
\draw_transform_slant:n {#1} |
| 329 |
} |
| 330 |
} , |
| 331 |
} |
| 332 |
|
| 333 |
\cs_new:Npn \__hawkdraw_fp_tuple_use_i:w ( #1 , #2 ) {#1} |
| 334 |
\cs_new:Npn \hawkdraw_fp_tuple_use_i:n #1 { |
| 335 |
\fp_to_dim:n { |
| 336 |
\exp_last_unbraced:Ne |
| 337 |
\__hawkdraw_fp_tuple_use_i:w { \fp_eval:n {#1} } |
| 338 |
} |
| 339 |
} |
| 340 |
\cs_generate_variant:Nn \hawkdraw_fp_tuple_use_i:n { V } |
| 341 |
|
| 342 |
\cs_new:Npn \__hawkdraw_fp_tuple_use_ii:w ( #1 , #2 ) {#2} |
| 343 |
\cs_new:Npn \hawkdraw_fp_tuple_use_ii:n #1 { |
| 344 |
\fp_to_dim:n { |
| 345 |
\exp_last_unbraced:Ne |
| 346 |
\__hawkdraw_fp_tuple_use_ii:w { \fp_eval:n {#1} } |
| 347 |
} |
| 348 |
} |
| 349 |
\cs_generate_variant:Nn \hawkdraw_fp_tuple_use_ii:n { V } |
| 350 |
|
| 351 |
\cs_new_protected:Npn \hawkdraw_set_path_options: { |
| 352 |
\color_stroke:V \l_hawkdraw_path_stroke_color_str |
| 353 |
\color_fill:V \l_hawkdraw_path_fill_color_str |
| 354 |
\opacity_stroke:V \l_hawkdraw_path_stroke_opacity_fp |
| 355 |
\opacity_fill:V \l_hawkdraw_path_fill_opacity_fp |
| 356 |
\draw_set_linewidth:V \l_hawkdraw_path_linewidth_dim |
| 357 |
\draw_set_miterlimit:V\l_hawkdraw_path_miterlimit_fp |
| 358 |
\use:c { draw_set_cap_ \l_hawkdraw_path_cap_str : } |
| 359 |
\use:c { draw_set_join_ \l_hawkdraw_path_join_str : } |
| 360 |
\int_compare:nNnTF { \clist_count:N \l_hawkdraw_path_corner_arc_clist } > { 1 } { |
| 361 |
\draw_path_corner_arc:ee { |
| 362 |
\clist_item:Nn \l_hawkdraw_path_corner_arc_clist { 1 } |
| 363 |
} { |
| 364 |
\clist_item:Nn \l_hawkdraw_path_corner_arc_clist { 2 } |
| 365 |
} |
| 366 |
} { |
| 367 |
\draw_path_corner_arc:ee { |
| 368 |
\clist_item:Nn \l_hawkdraw_path_corner_arc_clist { 1 } |
| 369 |
} { |
| 370 |
\clist_item:Nn \l_hawkdraw_path_corner_arc_clist { 1 } |
| 371 |
} |
| 372 |
} |
| 373 |
\use:c { draw_set_ \l_hawkdraw_path_fill_rule_str _rule: } |
| 374 |
\draw_set_dash_pattern:VV \l_hawkdraw_path_dash_pattern_clist |
| 375 |
\l_hawkdraw_path_dash_phase_dim |
| 376 |
} |
| 377 |
|
| 378 |
% === |
| 379 |
|
| 380 |
\scan_new:N \s__hawkdraw_stop |
| 381 |
|
| 382 |
\fp_new:N \l_hawkdraw_point_at_fp |
| 383 |
\tl_new:N \l_hawkdraw_point_name_tl |
| 384 |
\fp_new:N \l_hawkdraw_point_at_path_part_fp |
| 385 |
|
| 386 |
\keys_define:nn { hawkdraw / path / point } { |
| 387 |
at .fp_set:N = \l_hawkdraw_point_at_fp , |
| 388 |
name .tl_set:N = \l_hawkdraw_point_name_tl , |
| 389 |
at ~ path ~ part .fp_set:N = \l_hawkdraw_point_at_path_part_fp , |
| 390 |
} |
| 391 |
|
| 392 |
\cs_new_protected:cpn { __hawkdraw_process_path_ p :w } point #1 [ #2 ] #3 \s__hawkdraw_stop { |
| 393 |
\fp_set_eq:NN \l_hawkdraw_point_at_fp \g_hawkdraw_path_last_point_fp |
| 394 |
\fp_set:Nn \l_hawkdraw_point_at_path_part_fp { nan } |
| 395 |
\keys_set:nn { hawkdraw / path / point } {#2} |
| 396 |
\fp_if_nan:nF { \l_hawkdraw_point_at_path_part_fp } { |
| 397 |
\fp_set:Nn \l_hawkdraw_point_at_fp { |
| 398 |
\cs_if_exist_use:cT { |
| 399 |
__hawkdraw_point_part_ \l__hawkdraw_path_type_str :V |
| 400 |
} { |
| 401 |
\l_hawkdraw_point_at_path_part_fp |
| 402 |
} |
| 403 |
} |
| 404 |
} |
| 405 |
\prop_gput:cVV { g__hawkdraw_points_ \int_use:N \g_hawkdraw_id_int _prop } |
| 406 |
\l_hawkdraw_point_name_tl |
| 407 |
\l_hawkdraw_point_at_fp |
| 408 |
\tl_trim_spaces_apply:nN {#3} \__hawkdraw_continue_path:n |
| 409 |
} |
| 410 |
|
| 411 |
\cs_new_protected:Npn \hawkdraw_parse_point:Nn #1#2 { |
| 412 |
\prop_if_in:cnTF { |
| 413 |
g__hawkdraw_points_ \int_use:N \g_hawkdraw_id_int _prop |
| 414 |
} {#2} { |
| 415 |
\exp_args:NNe |
| 416 |
\fp_set:Nn #1 { |
| 417 |
\prop_item:cn { |
| 418 |
g__hawkdraw_points_ \int_use:N \g_hawkdraw_id_int _prop |
| 419 |
} {#2} |
| 420 |
} |
| 421 |
} { |
| 422 |
\tl_if_in:nnTF {#2} { > } { |
| 423 |
\fp_set:Nn #1 { |
| 424 |
\__hawkdraw_parse_point_polar:w #2 \s__hawkdraw_stop |
| 425 |
} |
| 426 |
} { |
| 427 |
\tl_if_in:nVTF {#2} \c_colon_str { |
| 428 |
\fp_set:Nn #1 { |
| 429 |
\__hawkdraw_parse_point_polar_compat:w #2 \s__hawkdraw_stop |
| 430 |
} |
| 431 |
} { |
| 432 |
\fp_set:Nn #1 {#2} |
| 433 |
} |
| 434 |
} |
| 435 |
} |
| 436 |
} |
| 437 |
|
| 438 |
\cs_new:Npn \__hawkdraw_parse_point_polar:w #1 > #2 \s__hawkdraw_stop { |
| 439 |
\int_compare:nNnTF { \clist_count:n {#2} } > { 1 } { |
| 440 |
\draw_point_polar:nnn { |
| 441 |
\clist_item:nn {#1} { 1 } |
| 442 |
} { |
| 443 |
\clist_item:nn {#1} { 2 } |
| 444 |
} {#2} |
| 445 |
} { |
| 446 |
\draw_point_polar:nn {#1} {#2} |
| 447 |
} |
| 448 |
} |
| 449 |
|
| 450 |
\exp_last_unbraced:NNNNo |
| 451 |
\cs_new:Npn \__hawkdraw_parse_point_polar_compat:w #1 \c_colon_str #2 \s__hawkdraw_stop { |
| 452 |
\int_compare:nNnTF { \clist_count:n {#2} } > { 1 } { |
| 453 |
\draw_point_polar:nnn { |
| 454 |
\clist_item:nn {#2} { 1 } |
| 455 |
} { |
| 456 |
\clist_item:nn {#2} { 2 } |
| 457 |
} {#1} |
| 458 |
} { |
| 459 |
\draw_point_polar:nn {#2} {#1} |
| 460 |
} |
| 461 |
} |
| 462 |
|
| 463 |
% === |
| 464 |
|
| 465 |
\cs_new:Npn \hawkdraw_calculate_slope:nn #1#2 { |
| 466 |
\fp_eval:n { |
| 467 |
atand( |
| 468 |
\hawkdraw_fp_tuple_use_ii:n {#2} - |
| 469 |
\hawkdraw_fp_tuple_use_ii:n {#1} |
| 470 |
, |
| 471 |
\hawkdraw_fp_tuple_use_i:n {#2} - |
| 472 |
\hawkdraw_fp_tuple_use_i:n {#1} |
| 473 |
) - 90 |
| 474 |
} |
| 475 |
} |
| 476 |
\cs_generate_variant:Nn \hawkdraw_calculate_slope:nn { nV , Vn , VV } |
| 477 |
|
| 478 |
% === |
| 479 |
|
| 480 |
\cs_new_protected:Npn \hawkdraw_path:w #1 ; { |
| 481 |
\draw_scope_begin: |
| 482 |
\tl_gset:Nn \g_hawkdraw_path_current_tl {#1} |
| 483 |
\tl_use:N \l_hawkdraw_path_preactions_tl |
| 484 |
\tl_trim_spaces_apply:nN {#1} \__hawkdraw_process_path:e |
| 485 |
\clist_remove_duplicates:N \l_hawkdraw_path_use_clist |
| 486 |
\draw_path_use_clear:e { \clist_use:N \l_hawkdraw_path_use_clist } |
| 487 |
\tl_use:N \l_hawkdraw_path_postactions_tl |
| 488 |
\draw_scope_end: |
| 489 |
\bool_if:NT \g__hawkdraw_path_use_clip_bool { |
| 490 |
\__hawkdraw_process_path_clip:V \g_hawkdraw_path_current_tl |
| 491 |
} |
| 492 |
} |
| 493 |
|
| 494 |
\cs_new_protected:Npn \__hawkdraw_process_path_clip:n #1 { |
| 495 |
\bool_set_true:N \l__hawkdraw_path_ignore_keys_bool |
| 496 |
\tl_trim_spaces_apply:nN {#1} \__hawkdraw_process_path:e |
| 497 |
\draw_path_use_clear:n { clip } |
| 498 |
\bool_set_false:N \l__hawkdraw_path_ignore_keys_bool |
| 499 |
\bool_gset_false:N \g__hawkdraw_path_use_clip_bool |
| 500 |
} |
| 501 |
\cs_generate_variant:Nn \__hawkdraw_process_path_clip:n { V } |
| 502 |
|
| 503 |
\cs_new_protected:Npn \__hawkdraw_process_path:n #1 { |
| 504 |
\cs_if_exist_use:cT { |
| 505 |
__hawkdraw_process_path_ \tl_head:n {#1} :w |
| 506 |
} { |
| 507 |
#1 \s__hawkdraw_stop |
| 508 |
} |
| 509 |
} |
| 510 |
\cs_generate_variant:Nn \__hawkdraw_process_path:n { e } |
| 511 |
|
| 512 |
\cs_new_protected:Npn \__hawkdraw_continue_path:n #1 { |
| 513 |
\tl_if_blank:nF {#1} { |
| 514 |
\__hawkdraw_process_path:n {#1} |
| 515 |
} |
| 516 |
} |
| 517 |
|
| 518 |
\cs_new_protected:cpn { __hawkdraw_process_path_ [ :w } [ #1 ] #2 \s__hawkdraw_stop { |
| 519 |
\bool_if:NF \l__hawkdraw_path_ignore_keys_bool { |
| 520 |
\keys_set:nn { hawkdraw / path } {#1} |
| 521 |
\hawkdraw_set_path_options: |
| 522 |
} |
| 523 |
\tl_trim_spaces_apply:nN {#2} \__hawkdraw_continue_path:n |
| 524 |
} |
| 525 |
|
| 526 |
\cs_new_protected:cpn { __hawkdraw_process_path_ ( :w } ( #1 ) #2 \s__hawkdraw_stop { |
| 527 |
\hawkdraw_parse_point:Nn \l__hawkdraw_point_a_fp {#1} |
| 528 |
\draw_path_moveto:n { |
| 529 |
\l__hawkdraw_point_a_fp |
| 530 |
} |
| 531 |
\fp_gset_eq:NN \g_hawkdraw_path_first_point_fp \l__hawkdraw_point_a_fp |
| 532 |
\fp_gset_eq:NN \g_hawkdraw_path_last_point_fp \l__hawkdraw_point_a_fp |
| 533 |
\tl_trim_spaces_apply:nN {#2} \__hawkdraw_continue_path:n |
| 534 |
} |
| 535 |
|
| 536 |
% === |
| 537 |
|
| 538 |
\cs_generate_variant:Nn \draw_point_interpolate_line:nnn { nVV } |
| 539 |
\cs_generate_variant:Nn \draw_point_interpolate_curve:nnnn { nVVV } |
| 540 |
\cs_generate_variant:Nn \draw_point_interpolate_curve:nnnnn { nVVVV } |
| 541 |
\cs_generate_variant:Nn \draw_point_interpolate_arc_axes:nnnnnn { nnVVVV } |
| 542 |
\cs_generate_variant:Nn \draw_point_polar:nnn { VV } |
| 543 |
|
| 544 |
\cs_new:Npn \__hawkdraw_point_part_line:n #1 { |
| 545 |
\draw_point_interpolate_line:nVV {#1} |
| 546 |
\l__hawkdraw_point_o_fp |
| 547 |
\l__hawkdraw_point_a_fp |
| 548 |
} |
| 549 |
\cs_generate_variant:Nn \__hawkdraw_point_part_line:n { V } |
| 550 |
|
| 551 |
\cs_new:Npn \__hawkdraw_point_part_line_orthogonal:n #1 { |
| 552 |
\fp_compare:nNnTF {#1} > { 0.5 } { |
| 553 |
\draw_point_interpolate_line:nnn { 2 * ( #1 - 0.5 ) } |
| 554 |
{ \l__hawkdraw_point_b_fp } |
| 555 |
{ \l__hawkdraw_point_a_fp } |
| 556 |
} { |
| 557 |
\draw_point_interpolate_line:nnn { 2 * #1 } |
| 558 |
{ \l__hawkdraw_point_o_fp } |
| 559 |
{ \l__hawkdraw_point_b_fp } |
| 560 |
} |
| 561 |
} |
| 562 |
\cs_generate_variant:Nn \__hawkdraw_point_part_line_orthogonal:n { V } |
| 563 |
|
| 564 |
\cs_new:Npn \__hawkdraw_point_part_curve_quadratic:n #1 { |
| 565 |
\draw_point_interpolate_curve:nVVV {#1} |
| 566 |
\l__hawkdraw_point_o_fp |
| 567 |
\l__hawkdraw_point_a_fp |
| 568 |
\l__hawkdraw_point_b_fp |
| 569 |
} |
| 570 |
\cs_generate_variant:Nn \__hawkdraw_point_part_curve_quadratic:n { V } |
| 571 |
|
| 572 |
\cs_new:Npn \__hawkdraw_point_part_curve_cubic:n #1 { |
| 573 |
\draw_point_interpolate_curve:nVVVV {#1} |
| 574 |
\l__hawkdraw_point_o_fp |
| 575 |
\l__hawkdraw_point_a_fp |
| 576 |
\l__hawkdraw_point_b_fp |
| 577 |
\l__hawkdraw_point_c_fp |
| 578 |
} |
| 579 |
\cs_generate_variant:Nn \__hawkdraw_point_part_curve_cubic:n { V } |
| 580 |
|
| 581 |
\cs_new:Npn \__hawkdraw_point_part_arc:n #1 { |
| 582 |
\bool_if:NTF \l_hawkdraw_path_arc_axes_bool { |
| 583 |
\draw_point_interpolate_arc_axes:nnVVVV {#1} |
| 584 |
{ |
| 585 |
( |
| 586 |
\hawkdraw_fp_tuple_use_i:V \l_hawkdraw_path_arc_vector_a_fp * |
| 587 |
cosd( \l_hawkdraw_path_arc_angle_start_fp ) + |
| 588 |
\hawkdraw_fp_tuple_use_i:V \l_hawkdraw_path_arc_vector_b_fp * |
| 589 |
sind( \l_hawkdraw_path_arc_angle_start_fp ) |
| 590 |
, |
| 591 |
\hawkdraw_fp_tuple_use_ii:V \l_hawkdraw_path_arc_vector_a_fp * |
| 592 |
cosd( \l_hawkdraw_path_arc_angle_start_fp ) + |
| 593 |
\hawkdraw_fp_tuple_use_ii:V \l_hawkdraw_path_arc_vector_b_fp * |
| 594 |
sind( \l_hawkdraw_path_arc_angle_start_fp ) |
| 595 |
) * -1 |
| 596 |
} |
| 597 |
\l_hawkdraw_path_arc_vector_a_fp |
| 598 |
\l_hawkdraw_path_arc_vector_b_fp |
| 599 |
\l_hawkdraw_path_arc_angle_start_fp |
| 600 |
\l_hawkdraw_path_arc_angle_end_fp |
| 601 |
} { |
| 602 |
( |
| 603 |
\draw_point_polar:VVn \l_hawkdraw_path_arc_radius_a_dim \l_hawkdraw_path_arc_radius_b_dim { |
| 604 |
\l_hawkdraw_path_arc_angle_start_fp + |
| 605 |
#1 * ( \l_hawkdraw_path_arc_angle_end_fp - \l_hawkdraw_path_arc_angle_start_fp ) |
| 606 |
} |
| 607 |
) - |
| 608 |
( |
| 609 |
\draw_point_polar:VVn \l_hawkdraw_path_arc_radius_a_dim \l_hawkdraw_path_arc_radius_b_dim { |
| 610 |
\l_hawkdraw_path_arc_angle_start_fp |
| 611 |
} |
| 612 |
) |
| 613 |
} |
| 614 |
} |
| 615 |
\cs_generate_variant:Nn \__hawkdraw_point_part_arc:n { V } |
| 616 |
|
| 617 |
% === |
| 618 |
|
| 619 |
\cs_new:Npn \__hawkdraw_process_line_path:n #1 { |
| 620 |
\cs_if_exist_use:cT { |
| 621 |
__hawkdraw_process_path_line_ \tl_head:n {#1} :w |
| 622 |
} { |
| 623 |
#1 \s__hawkdraw_stop |
| 624 |
} |
| 625 |
} |
| 626 |
|
| 627 |
\cs_new_protected:cpn { __hawkdraw_process_path_ - :w } - #1 \s__hawkdraw_stop { |
| 628 |
\tl_trim_spaces_apply:nN {#1} \__hawkdraw_process_line_path:n |
| 629 |
} |
| 630 |
|
| 631 |
\cs_new_protected:cpn { __hawkdraw_process_path_line_ - :w } - #1 ( #2 ) #3 \s__hawkdraw_stop { |
| 632 |
% what do we do with #1? |
| 633 |
\str_set:Nn \l__hawkdraw_path_type_str { line } |
| 634 |
\fp_set_eq:NN \l__hawkdraw_point_o_fp \g_hawkdraw_path_last_point_fp |
| 635 |
\hawkdraw_parse_point:Nn \l__hawkdraw_point_a_fp {#2} |
| 636 |
\draw_path_lineto:n { |
| 637 |
\l__hawkdraw_point_a_fp |
| 638 |
} |
| 639 |
\fp_if_nan:nT { \g_hawkdraw_path_first_slope_fp } { |
| 640 |
\fp_gset:Nn \g_hawkdraw_path_first_slope_fp { |
| 641 |
\hawkdraw_calculate_slope:VV \l__hawkdraw_point_a_fp \l__hawkdraw_point_o_fp |
| 642 |
} |
| 643 |
} |
| 644 |
\fp_gset:Nn \g_hawkdraw_path_last_slope_fp { |
| 645 |
\hawkdraw_calculate_slope:VV \l__hawkdraw_point_o_fp \l__hawkdraw_point_a_fp |
| 646 |
} |
| 647 |
\fp_gset_eq:NN \g_hawkdraw_path_last_point_fp \l__hawkdraw_point_a_fp |
| 648 |
\tl_trim_spaces_apply:nN {#3} \__hawkdraw_continue_path:n |
| 649 |
} |
| 650 |
|
| 651 |
\cs_new_protected:cpn { __hawkdraw_process_path_line_ | :w } | #1 ( #2 ) #3 \s__hawkdraw_stop { |
| 652 |
% what do we do with #1? |
| 653 |
\str_set:Nn \l__hawkdraw_path_type_str { line_orthogonal } |
| 654 |
\fp_set_eq:NN \l__hawkdraw_point_o_fp \g_hawkdraw_path_last_point_fp |
| 655 |
\hawkdraw_parse_point:Nn \l__hawkdraw_point_a_fp {#2} |
| 656 |
\hawkdraw_parse_point:Nn \l__hawkdraw_point_b_fp { |
| 657 |
( |
| 658 |
\hawkdraw_fp_tuple_use_i:V \l__hawkdraw_point_a_fp |
| 659 |
, |
| 660 |
\hawkdraw_fp_tuple_use_ii:V \l__hawkdraw_point_o_fp |
| 661 |
) |
| 662 |
} |
| 663 |
\draw_path_lineto:n { |
| 664 |
\l__hawkdraw_point_b_fp |
| 665 |
} |
| 666 |
\draw_path_lineto:n { |
| 667 |
\l__hawkdraw_point_a_fp |
| 668 |
} |
| 669 |
\fp_if_nan:nT { \g_hawkdraw_path_first_slope_fp } { |
| 670 |
\fp_gset:Nn \g_hawkdraw_path_first_slope_fp { |
| 671 |
\hawkdraw_calculate_slope:VV \l__hawkdraw_point_b_fp \l__hawkdraw_point_o_fp |
| 672 |
} |
| 673 |
} |
| 674 |
\fp_gset:Nn \g_hawkdraw_path_last_slope_fp { |
| 675 |
\hawkdraw_calculate_slope:VV \l__hawkdraw_point_b_fp \l__hawkdraw_point_a_fp |
| 676 |
} |
| 677 |
\fp_gset_eq:NN \g_hawkdraw_path_last_point_fp \l__hawkdraw_point_a_fp |
| 678 |
\tl_trim_spaces_apply:nN {#3} \__hawkdraw_continue_path:n |
| 679 |
} |
| 680 |
|
| 681 |
|
| 682 |
\cs_new_protected:cpn { __hawkdraw_process_path_ | :w } |- #1 ( #2 ) #3 \s__hawkdraw_stop { |
| 683 |
% what do we do with #1? |
| 684 |
\str_set:Nn \l__hawkdraw_path_type_str { line_orthogonal } |
| 685 |
\fp_set_eq:NN \l__hawkdraw_point_o_fp \g_hawkdraw_path_last_point_fp |
| 686 |
\hawkdraw_parse_point:Nn \l__hawkdraw_point_a_fp {#2} |
| 687 |
\hawkdraw_parse_point:Nn \l__hawkdraw_point_b_fp { |
| 688 |
( |
| 689 |
\hawkdraw_fp_tuple_use_i:V \l__hawkdraw_point_o_fp |
| 690 |
, |
| 691 |
\hawkdraw_fp_tuple_use_ii:V \l__hawkdraw_point_a_fp |
| 692 |
) |
| 693 |
} |
| 694 |
\draw_path_lineto:n { |
| 695 |
\l__hawkdraw_point_b_fp |
| 696 |
} |
| 697 |
\draw_path_lineto:n { |
| 698 |
\l__hawkdraw_point_a_fp |
| 699 |
} |
| 700 |
\fp_if_nan:nT { \g_hawkdraw_path_first_slope_fp } { |
| 701 |
\fp_gset:Nn \g_hawkdraw_path_first_slope_fp { |
| 702 |
\hawkdraw_calculate_slope:VV \l__hawkdraw_point_b_fp \l__hawkdraw_point_o_fp |
| 703 |
} |
| 704 |
} |
| 705 |
\fp_gset:Nn \g_hawkdraw_path_last_slope_fp { |
| 706 |
\hawkdraw_calculate_slope:VV \l__hawkdraw_point_b_fp \l__hawkdraw_point_a_fp |
| 707 |
} |
| 708 |
\fp_gset_eq:NN \g_hawkdraw_path_last_point_fp \l__hawkdraw_point_a_fp |
| 709 |
\tl_trim_spaces_apply:nN {#3} \__hawkdraw_continue_path:n |
| 710 |
} |
| 711 |
|
| 712 |
% === |
| 713 |
|
| 714 |
\cs_new:Npn \__hawkdraw_process_curve_path:n #1 { |
| 715 |
\cs_if_exist_use:cT { |
| 716 |
__hawkdraw_process_path_curve_ \tl_head:n {#1} :w |
| 717 |
} { |
| 718 |
#1 \s__hawkdraw_stop |
| 719 |
} |
| 720 |
} |
| 721 |
|
| 722 |
\cs_new_protected:cpn { __hawkdraw_process_path_ . :w } .. #1 ( #2 ) #3 \s__hawkdraw_stop { |
| 723 |
% what do we do with #1? |
| 724 |
\fp_set_eq:NN \l__hawkdraw_point_o_fp \g_hawkdraw_path_last_point_fp |
| 725 |
\hawkdraw_parse_point:Nn \l__hawkdraw_point_a_fp {#2} |
| 726 |
\tl_trim_spaces_apply:nN {#3} \__hawkdraw_process_curve_path:n |
| 727 |
} |
| 728 |
|
| 729 |
\cs_new_protected:cpn { __hawkdraw_process_path_curve_ . :w } .. #1 ( #2 ) #3 \s__hawkdraw_stop { |
| 730 |
% what do we do with #1? |
| 731 |
\str_set:Nn \l__hawkdraw_path_type_str { curve_quadratic } |
| 732 |
\hawkdraw_parse_point:Nn \l__hawkdraw_point_b_fp {#2} |
| 733 |
\draw_path_curveto:nn { |
| 734 |
\l__hawkdraw_point_a_fp |
| 735 |
} { |
| 736 |
\l__hawkdraw_point_b_fp |
| 737 |
} |
| 738 |
\fp_if_nan:nT { \g_hawkdraw_path_first_slope_fp } { |
| 739 |
\fp_gset:Nn \g_hawkdraw_path_first_slope_fp { |
| 740 |
\hawkdraw_calculate_slope:VV \l__hawkdraw_point_a_fp \l__hawkdraw_point_o_fp |
| 741 |
} |
| 742 |
} |
| 743 |
\fp_gset:Nn \g_hawkdraw_path_last_slope_fp { |
| 744 |
\hawkdraw_calculate_slope:VV \l__hawkdraw_point_a_fp \l__hawkdraw_point_b_fp |
| 745 |
} |
| 746 |
\fp_gset_eq:NN \g_hawkdraw_path_last_point_fp \l__hawkdraw_point_b_fp |
| 747 |
\tl_trim_spaces_apply:nN {#3} \__hawkdraw_continue_path:n |
| 748 |
} |
| 749 |
|
| 750 |
\cs_new_protected:cpn { __hawkdraw_process_path_curve_ & :w } & #1 ( #2 ) #3 .. #4 ( #5 ) #6 \s__hawkdraw_stop { |
| 751 |
% what do we do with #1, #3, #4? |
| 752 |
\str_set:Nn \l__hawkdraw_path_type_str { curve_cubic } |
| 753 |
\hawkdraw_parse_point:Nn \l__hawkdraw_point_b_fp {#2} |
| 754 |
\hawkdraw_parse_point:Nn \l__hawkdraw_point_c_fp {#5} |
| 755 |
\draw_path_curveto:nnn { |
| 756 |
\l__hawkdraw_point_a_fp |
| 757 |
} { |
| 758 |
\l__hawkdraw_point_b_fp |
| 759 |
} { |
| 760 |
\l__hawkdraw_point_c_fp |
| 761 |
} |
| 762 |
\fp_if_nan:nT { \g_hawkdraw_path_first_slope_fp } { |
| 763 |
\fp_gset:Nn \g_hawkdraw_path_first_slope_fp { |
| 764 |
\hawkdraw_calculate_slope:VV \l__hawkdraw_point_a_fp \l__hawkdraw_point_o_fp |
| 765 |
} |
| 766 |
} |
| 767 |
\fp_gset:Nn \g_hawkdraw_path_last_slope_fp { |
| 768 |
\hawkdraw_calculate_slope:VV \l__hawkdraw_point_b_fp \l__hawkdraw_point_c_fp |
| 769 |
} |
| 770 |
\fp_gset_eq:NN \g_hawkdraw_path_last_point_fp \l__hawkdraw_point_c_fp |
| 771 |
\tl_trim_spaces_apply:nN {#6} \__hawkdraw_continue_path:n |
| 772 |
} |
| 773 |
|
| 774 |
\cs_new_protected:cpn { __hawkdraw_process_path_ ! :w } ! #1 \s__hawkdraw_stop { |
| 775 |
\draw_path_close: |
| 776 |
\fp_gset:Nn \g_hawkdraw_path_first_slope_fp { nan } |
| 777 |
\fp_gset:Nn \g_hawkdraw_path_last_slope_fp { nan } |
| 778 |
\fp_gset_eq:NN \g_hawkdraw_path_last_point_fp \g_hawkdraw_path_first_point_fp |
| 779 |
\tl_trim_spaces_apply:nN {#1} \__hawkdraw_continue_path:n |
| 780 |
} |
| 781 |
|
| 782 |
% === |
| 783 |
|
| 784 |
\dim_new:N \l_hawkdraw_path_circle_radius_dim |
| 785 |
|
| 786 |
\cs_generate_variant:Nn \draw_path_circle:nn { VV } |
| 787 |
|
| 788 |
\keys_define:nn { hawkdraw / path / circle } { |
| 789 |
radius .dim_set:N = \l_hawkdraw_path_circle_radius_dim , |
| 790 |
radius .initial:n = { 1cm } , |
| 791 |
} |
| 792 |
|
| 793 |
\cs_new_protected:cpn { __hawkdraw_process_path_ c :w } circle #1 [ #2 ] #3 \s__hawkdraw_stop { |
| 794 |
\str_set:Nn \l__hawkdraw_path_type_str { circle } |
| 795 |
\fp_set_eq:NN \l__hawkdraw_point_o_fp \g_hawkdraw_path_last_point_fp |
| 796 |
\keys_set:nn { hawkdraw / path / circle } {#2} |
| 797 |
\draw_path_circle:VV \g_hawkdraw_path_last_point_fp |
| 798 |
\l_hawkdraw_path_circle_radius_dim |
| 799 |
\tl_trim_spaces_apply:nN {#3} \__hawkdraw_continue_path:n |
| 800 |
} |
| 801 |
|
| 802 |
\fp_new:N \l_hawkdraw_path_ellipse_vector_a_fp |
| 803 |
\fp_new:N \l_hawkdraw_path_ellipse_vector_b_fp |
| 804 |
|
| 805 |
\cs_generate_variant:Nn \draw_path_ellipse:nnn { VVV } |
| 806 |
|
| 807 |
\keys_define:nn { hawkdraw / path / ellipse } { |
| 808 |
vector ~ a .fp_set:N = \l_hawkdraw_path_ellipse_vector_a_fp , |
| 809 |
vector ~ a .initial:n = { ( 1cm , 0pt ) } , |
| 810 |
vector ~ b .fp_set:N = \l_hawkdraw_path_ellipse_vector_b_fp , |
| 811 |
vector ~ b .initial:n = { ( 0pt , 1cm ) } , |
| 812 |
radius ~ a .code:n = { |
| 813 |
\fp_set:Nn \l_hawkdraw_path_ellipse_vector_a_fp { ( #1 , 0pt ) } |
| 814 |
} , |
| 815 |
radius ~ b .code:n = { |
| 816 |
\fp_set:Nn \l_hawkdraw_path_ellipse_vector_b_fp { ( 0pt , #1 ) } |
| 817 |
} , |
| 818 |
} |
| 819 |
|
| 820 |
\cs_new_protected:cpn { __hawkdraw_process_path_ e :w } ellipse #1 [ #2 ] #3 \s__hawkdraw_stop { |
| 821 |
\str_set:Nn \l__hawkdraw_path_type_str { ellipse } |
| 822 |
\fp_set_eq:NN \l__hawkdraw_point_o_fp \g_hawkdraw_path_last_point_fp |
| 823 |
\keys_set:nn { hawkdraw / path / ellipse } {#2} |
| 824 |
\draw_path_ellipse:VVV \g_hawkdraw_path_last_point_fp |
| 825 |
\l_hawkdraw_path_ellipse_vector_a_fp |
| 826 |
\l_hawkdraw_path_ellipse_vector_b_fp |
| 827 |
\tl_trim_spaces_apply:nN {#3} \__hawkdraw_continue_path:n |
| 828 |
} |
| 829 |
|
| 830 |
\bool_new:N \l_hawkdraw_path_arc_axes_bool |
| 831 |
\dim_new:N \l_hawkdraw_path_arc_radius_a_dim |
| 832 |
\dim_new:N \l_hawkdraw_path_arc_radius_b_dim |
| 833 |
\fp_new:N \l_hawkdraw_path_arc_vector_a_fp |
| 834 |
\fp_new:N \l_hawkdraw_path_arc_vector_b_fp |
| 835 |
\fp_new:N \l_hawkdraw_path_arc_angle_start_fp |
| 836 |
\fp_new:N \l_hawkdraw_path_arc_angle_end_fp |
| 837 |
|
| 838 |
\cs_generate_variant:Nn \draw_path_arc:nnnn { VVVV } |
| 839 |
\cs_generate_variant:Nn \draw_path_arc_axes:nnnn { VVVV } |
| 840 |
|
| 841 |
\keys_define:nn { hawkdraw / path / arc } { |
| 842 |
radius ~ a .code:n = { |
| 843 |
\bool_set_false:N \l_hawkdraw_path_arc_axes_bool |
| 844 |
\dim_set:Nn \l_hawkdraw_path_arc_radius_a_dim {#1} |
| 845 |
} , |
| 846 |
radius ~ a .initial:n = { 1cm } , |
| 847 |
radius ~ b .code:n = { |
| 848 |
\bool_set_false:N \l_hawkdraw_path_arc_axes_bool |
| 849 |
\dim_set:Nn \l_hawkdraw_path_arc_radius_b_dim {#1} |
| 850 |
} , |
| 851 |
radius ~ b .initial:n = { 1cm } , |
| 852 |
radius .code:n = { |
| 853 |
\bool_set_false:N \l_hawkdraw_path_arc_axes_bool |
| 854 |
\dim_set:Nn \l_hawkdraw_path_arc_radius_a_dim {#1} |
| 855 |
\dim_set:Nn \l_hawkdraw_path_arc_radius_b_dim {#1} |
| 856 |
} , |
| 857 |
vector ~ a .code:n = { |
| 858 |
\bool_set_true:N \l_hawkdraw_path_arc_axes_bool |
| 859 |
\fp_set:Nn \l_hawkdraw_path_arc_vector_a_fp {#1} |
| 860 |
} , |
| 861 |
vector ~ b .code:n = { |
| 862 |
\bool_set_true:N \l_hawkdraw_path_arc_axes_bool |
| 863 |
\fp_set:Nn \l_hawkdraw_path_arc_vector_b_fp {#1} |
| 864 |
} , |
| 865 |
angle ~ start .fp_set:N = \l_hawkdraw_path_arc_angle_start_fp , |
| 866 |
angle ~ start .initial:n = { 0 } , |
| 867 |
angle ~ end .fp_set:N = \l_hawkdraw_path_arc_angle_end_fp , |
| 868 |
angle ~ end .initial:n = { 90 } , |
| 869 |
angle ~ delta .code:n = { |
| 870 |
\fp_set:Nn \l_hawkdraw_path_arc_angle_end_fp { |
| 871 |
\l_hawkdraw_path_arc_angle_start_fp + ( #1 ) |
| 872 |
} |
| 873 |
} , |
| 874 |
} |
| 875 |
|
| 876 |
\cs_new_protected:cpn { __hawkdraw_process_path_ a :w } arc #1 [ #2 ] #3 \s__hawkdraw_stop { |
| 877 |
\str_set:Nn \l__hawkdraw_path_type_str { arc } |
| 878 |
\fp_set_eq:NN \l__hawkdraw_point_o_fp \g_hawkdraw_path_last_point_fp |
| 879 |
\keys_set:nn { hawkdraw / path / arc } {#2} |
| 880 |
\bool_if:NTF \l_hawkdraw_path_arc_axes_bool { |
| 881 |
\draw_path_arc_axes:VVVV \l_hawkdraw_path_arc_vector_a_fp |
| 882 |
\l_hawkdraw_path_arc_vector_b_fp |
| 883 |
\l_hawkdraw_path_arc_angle_start_fp |
| 884 |
\l_hawkdraw_path_arc_angle_end_fp |
| 885 |
} { |
| 886 |
\draw_path_arc:VVVV \l_hawkdraw_path_arc_radius_a_dim |
| 887 |
\l_hawkdraw_path_arc_radius_b_dim |
| 888 |
\l_hawkdraw_path_arc_angle_start_fp |
| 889 |
\l_hawkdraw_path_arc_angle_end_fp |
| 890 |
} |
| 891 |
\bool_if:NTF \l_hawkdraw_path_arc_axes_bool { |
| 892 |
\fp_if_nan:nT { \g_hawkdraw_path_first_slope_fp } { |
| 893 |
\fp_gset:Nn \g_hawkdraw_path_first_slope_fp { |
| 894 |
atand( |
| 895 |
\hawkdraw_fp_tuple_use_ii:V \l_hawkdraw_path_arc_vector_b_fp * |
| 896 |
cosd( \l_hawkdraw_path_arc_angle_start_fp ) - |
| 897 |
\hawkdraw_fp_tuple_use_ii:V \l_hawkdraw_path_arc_vector_a_fp * |
| 898 |
sind( \l_hawkdraw_path_arc_angle_start_fp ) |
| 899 |
, |
| 900 |
\hawkdraw_fp_tuple_use_i:V \l_hawkdraw_path_arc_vector_b_fp * |
| 901 |
cosd( \l_hawkdraw_path_arc_angle_start_fp ) - |
| 902 |
\hawkdraw_fp_tuple_use_i:V \l_hawkdraw_path_arc_vector_a_fp * |
| 903 |
sind( \l_hawkdraw_path_arc_angle_start_fp ) |
| 904 |
) + 90 |
| 905 |
} |
| 906 |
} |
| 907 |
\fp_gset:Nn \g_hawkdraw_path_last_slope_fp { |
| 908 |
atand( |
| 909 |
\hawkdraw_fp_tuple_use_ii:V \l_hawkdraw_path_arc_vector_b_fp * |
| 910 |
cosd( \l_hawkdraw_path_arc_angle_end_fp ) - |
| 911 |
\hawkdraw_fp_tuple_use_ii:V \l_hawkdraw_path_arc_vector_a_fp * |
| 912 |
sind( \l_hawkdraw_path_arc_angle_end_fp ) |
| 913 |
, |
| 914 |
\hawkdraw_fp_tuple_use_i:V \l_hawkdraw_path_arc_vector_b_fp * |
| 915 |
cosd( \l_hawkdraw_path_arc_angle_end_fp ) - |
| 916 |
\hawkdraw_fp_tuple_use_i:V \l_hawkdraw_path_arc_vector_a_fp * |
| 917 |
sind( \l_hawkdraw_path_arc_angle_end_fp ) |
| 918 |
) - 90 |
| 919 |
} |
| 920 |
} { |
| 921 |
\fp_if_nan:nT { \g_hawkdraw_path_first_slope_fp } { |
| 922 |
\fp_gset:Nn \g_hawkdraw_path_first_slope_fp { |
| 923 |
atand( |
| 924 |
\l_hawkdraw_path_arc_radius_b_dim * ( |
| 925 |
- cosd( \l_hawkdraw_path_arc_angle_start_fp ) |
| 926 |
) |
| 927 |
, |
| 928 |
\l_hawkdraw_path_arc_radius_a_dim * ( |
| 929 |
sind( \l_hawkdraw_path_arc_angle_start_fp ) |
| 930 |
) |
| 931 |
) - 90 |
| 932 |
} |
| 933 |
} |
| 934 |
\fp_gset:Nn \g_hawkdraw_path_last_slope_fp { |
| 935 |
atand( |
| 936 |
\l_hawkdraw_path_arc_radius_b_dim * ( |
| 937 |
- cosd( \l_hawkdraw_path_arc_angle_end_fp ) |
| 938 |
) |
| 939 |
, |
| 940 |
\l_hawkdraw_path_arc_radius_a_dim * ( |
| 941 |
sind( \l_hawkdraw_path_arc_angle_end_fp ) |
| 942 |
) |
| 943 |
) + 90 |
| 944 |
} |
| 945 |
} |
| 946 |
\bool_if:NTF \l_hawkdraw_path_arc_axes_bool { |
| 947 |
\group_begin: |
| 948 |
\draw_transform_triangle:nnn { \l__hawkdraw_point_o_fp } { |
| 949 |
\l_hawkdraw_path_arc_vector_a_fp |
| 950 |
} { |
| 951 |
\l_hawkdraw_path_arc_vector_b_fp |
| 952 |
} |
| 953 |
\fp_gset:Nn \g_hawkdraw_path_last_point_fp { |
| 954 |
\draw_point_transform:n { |
| 955 |
cosd( \l_hawkdraw_path_arc_angle_end_fp ) - |
| 956 |
cosd( \l_hawkdraw_path_arc_angle_start_fp ) |
| 957 |
, |
| 958 |
sind( \l_hawkdraw_path_arc_angle_end_fp ) - |
| 959 |
sind( \l_hawkdraw_path_arc_angle_start_fp ) |
| 960 |
} |
| 961 |
} |
| 962 |
\group_end: |
| 963 |
} { |
| 964 |
\fp_gset:Nn \g_hawkdraw_path_last_point_fp { |
| 965 |
( |
| 966 |
\hawkdraw_fp_tuple_use_i:V \l__hawkdraw_point_o_fp + |
| 967 |
\l_hawkdraw_path_arc_radius_a_dim * ( |
| 968 |
cosd( \l_hawkdraw_path_arc_angle_end_fp ) - |
| 969 |
cosd( \l_hawkdraw_path_arc_angle_start_fp ) |
| 970 |
) |
| 971 |
, |
| 972 |
\hawkdraw_fp_tuple_use_ii:V \l__hawkdraw_point_o_fp + |
| 973 |
\l_hawkdraw_path_arc_radius_b_dim * ( |
| 974 |
sind( \l_hawkdraw_path_arc_angle_end_fp ) - |
| 975 |
sind( \l_hawkdraw_path_arc_angle_start_fp ) |
| 976 |
) |
| 977 |
) |
| 978 |
} |
| 979 |
} |
| 980 |
\tl_trim_spaces_apply:nN {#3} \__hawkdraw_continue_path:n |
| 981 |
} |
| 982 |
|
| 983 |
\bool_new:N \l_hawkdraw_path_rectangle_relative_bool |
| 984 |
\fp_new:N \l_hawkdraw_path_rectangle_corner_fp |
| 985 |
|
| 986 |
\cs_generate_variant:Nn \draw_path_rectangle:nn { ee , VV } |
| 987 |
\cs_generate_variant:Nn \draw_path_rectangle_corners:nn { VV } |
| 988 |
|
| 989 |
\keys_define:nn { hawkdraw / path / rectangle } { |
| 990 |
relative .bool_set:N = \l_hawkdraw_path_rectangle_relative_bool , |
| 991 |
relative .default:n = { true } , |
| 992 |
relative .initial:n = { false } , |
| 993 |
corner .fp_set:N = \l_hawkdraw_path_rectangle_corner_fp , |
| 994 |
corner .initial:n = { ( 1cm , 1cm ) } , |
| 995 |
} |
| 996 |
|
| 997 |
\cs_new_protected:cpn { __hawkdraw_process_path_ r :w } rectangle #1 [ #2 ] #3 \s__hawkdraw_stop { |
| 998 |
\str_set:Nn \l__hawkdraw_path_type_str { rectangle } |
| 999 |
\fp_set_eq:NN \l__hawkdraw_point_o_fp \g_hawkdraw_path_last_point_fp |
| 1000 |
\keys_set:nn { hawkdraw / path / rectangle } {#2} |
| 1001 |
\fp_set_eq:NN \l__hawkdraw_point_a_fp \g_hawkdraw_path_last_point_fp |
| 1002 |
\bool_if:NTF \l_hawkdraw_path_rectangle_relative_bool { |
| 1003 |
\draw_path_rectangle:VV \l__hawkdraw_point_a_fp |
| 1004 |
\l_hawkdraw_path_rectangle_corner_fp |
| 1005 |
\fp_gset:Nn \g_hawkdraw_path_last_point_fp { |
| 1006 |
\l__hawkdraw_point_a_fp + \l_hawkdraw_path_rectangle_corner_fp |
| 1007 |
} |
| 1008 |
} { |
| 1009 |
\draw_path_rectangle_corners:VV \l__hawkdraw_point_a_fp |
| 1010 |
\l_hawkdraw_path_rectangle_corner_fp |
| 1011 |
\fp_gset_eq:NN \g_hawkdraw_path_last_point_fp \l_hawkdraw_path_rectangle_corner_fp |
| 1012 |
} |
| 1013 |
\tl_trim_spaces_apply:nN {#3} \__hawkdraw_continue_path:n |
| 1014 |
} |
| 1015 |
|
| 1016 |
\clist_new:N \l_hawkdraw_path_grid_step_clist |
| 1017 |
\fp_new:N \l_hawkdraw_path_grid_corner_fp |
| 1018 |
|
| 1019 |
\cs_generate_variant:Nn \draw_path_grid:nnnn { eeVV } |
| 1020 |
|
| 1021 |
\keys_define:nn { hawkdraw / path / grid } { |
| 1022 |
step .clist_set:N = \l_hawkdraw_path_grid_step_clist , |
| 1023 |
step .initial:n = { 1cm } , |
| 1024 |
corner .fp_set:N = \l_hawkdraw_path_grid_corner_fp , |
| 1025 |
corner .initial:n = { ( 1cm , 1cm ) } , |
| 1026 |
} |
| 1027 |
|
| 1028 |
\cs_new_protected:cpn { __hawkdraw_process_path_ g :w } grid #1 [ #2 ] #3 \s__hawkdraw_stop { |
| 1029 |
\str_set:Nn \l__hawkdraw_path_type_str { grid } |
| 1030 |
\fp_set_eq:NN \l__hawkdraw_point_o_fp \g_hawkdraw_path_last_point_fp |
| 1031 |
\keys_set:nn { hawkdraw / path / grid } {#2} |
| 1032 |
\int_compare:nNnTF { \clist_count:N \l_hawkdraw_path_grid_step_clist } > { 1 } { |
| 1033 |
\draw_path_grid:eeVV { |
| 1034 |
\clist_item:Nn \l_hawkdraw_path_grid_step_clist { 1 } |
| 1035 |
} { |
| 1036 |
\clist_item:Nn \l_hawkdraw_path_grid_step_clist { 2 } |
| 1037 |
} |
| 1038 |
\g_hawkdraw_path_last_point_fp |
| 1039 |
\l_hawkdraw_path_grid_corner_fp |
| 1040 |
} { |
| 1041 |
\draw_path_grid:eeVV { |
| 1042 |
\clist_item:Nn \l_hawkdraw_path_grid_step_clist { 1 } |
| 1043 |
} { |
| 1044 |
\clist_item:Nn \l_hawkdraw_path_grid_step_clist { 1 } |
| 1045 |
} |
| 1046 |
\g_hawkdraw_path_last_point_fp |
| 1047 |
\l_hawkdraw_path_grid_corner_fp |
| 1048 |
} |
| 1049 |
\fp_gset_eq:NN \g_hawkdraw_path_last_point_fp \l_hawkdraw_path_grid_corner_fp |
| 1050 |
\tl_trim_spaces_apply:nN {#3} \__hawkdraw_continue_path:n |
| 1051 |
} |
| 1052 |
|
| 1053 |
% === |
| 1054 |
|
| 1055 |
\int_new:N \l_hawkdraw_map_count_int |
| 1056 |
\clist_new:N \l_hawkdraw_map_list_clist |
| 1057 |
\fp_new:N \l_hawkdraw_map_start_fp |
| 1058 |
\fp_new:N \l_hawkdraw_map_step_fp |
| 1059 |
\fp_new:N \l_hawkdraw_map_end_fp |
| 1060 |
|
| 1061 |
\cs_generate_variant:Nn \fp_step_function:nnnN { VVV } |
| 1062 |
|
| 1063 |
\keys_define:nn { hawkdraw /path / map } { |
| 1064 |
list .clist_set:N = \l_hawkdraw_map_list_clist , |
| 1065 |
start .fp_set:N = \l_hawkdraw_map_start_fp , |
| 1066 |
start .initial:n = { 1 } , |
| 1067 |
step .fp_set:N = \l_hawkdraw_map_step_fp , |
| 1068 |
step .initial:n = { 1 } , |
| 1069 |
end .fp_set:N = \l_hawkdraw_map_end_fp , |
| 1070 |
end .initial:n = { 1 } |
| 1071 |
} |
| 1072 |
|
| 1073 |
\cs_new_protected:cpn { __hawkdraw_process_path_ m :w } map #1 [ #2 ] #3#4 \s__hawkdraw_stop { |
| 1074 |
\keys_set:nn { hawkdraw / path / map } {#2} |
| 1075 |
\cs_set_protected:Npn \__hawkdraw_map_function:n ##1 { |
| 1076 |
\tl_trim_spaces_apply:nN {#3} \__hawkdraw_continue_path:n |
| 1077 |
} |
| 1078 |
\int_compare:nNnTF { \clist_count:N \l_hawkdraw_map_list_clist } > { 0 } { |
| 1079 |
\clist_map_function:NN |
| 1080 |
\l_hawkdraw_map_list_clist |
| 1081 |
\__hawkdraw_map_function:n |
| 1082 |
} { |
| 1083 |
\fp_step_function:VVVN |
| 1084 |
\l_hawkdraw_map_start_fp |
| 1085 |
\l_hawkdraw_map_step_fp |
| 1086 |
\l_hawkdraw_map_end_fp |
| 1087 |
\__hawkdraw_map_function:n |
| 1088 |
} |
| 1089 |
\tl_trim_spaces_apply:nN {#4} \__hawkdraw_continue_path:n |
| 1090 |
} |
| 1091 |
|
| 1092 |
\cs_new:Npn \__hawkdraw_map_function:n #1 { } |
| 1093 |
|
| 1094 |
% === |
| 1095 |
|
| 1096 |
\keys_define:nn { hawkdraw / instance } { |
| 1097 |
baseline .fp_set:N = \l_draw_instance_baseline_fp , |
| 1098 |
layers .code:n = { |
| 1099 |
\clist_map_inline:nn {#1} { |
| 1100 |
\clist_if_in:NnF \l_draw_layers_clist {##1} { |
| 1101 |
\draw_layer_new:n {##1} |
| 1102 |
} |
| 1103 |
} |
| 1104 |
\clist_set:Nn \l_draw_layers_clist {#1} |
| 1105 |
} , |
| 1106 |
overlay .bool_set:N = \l_hawkdraw_instance_overlay_bool , |
| 1107 |
overlay .default:n = { true } , |
| 1108 |
overlay .initial:n = { false } , |
| 1109 |
} |
| 1110 |
|
| 1111 |
\keys_define:nn { hawkdraw / scope } { |
| 1112 |
layer .str_set:N = \l_hawkdraw_scope_layer_str , |
| 1113 |
} |
| 1114 |
|
| 1115 |
% === |
| 1116 |
|
| 1117 |
\NewDocumentCommand \hawkdrawsetcolor { m m m } { |
| 1118 |
\str_if_eq:nnTF {#2} { named } { |
| 1119 |
\color_set:nn {#1} {#3} |
| 1120 |
} { |
| 1121 |
\color_set:nnn {#1} {#2} {#3} |
| 1122 |
} |
| 1123 |
} |
| 1124 |
|
| 1125 |
\NewDocumentCommand \hawkdrawset { m } { |
| 1126 |
\keys_set:nn { hawkdraw / path } {#1} |
| 1127 |
} |
| 1128 |
|
| 1129 |
\NewDocumentEnvironment { hawkdraw } { O{} } { |
| 1130 |
\mode_leave_vertical: |
| 1131 |
\nullfont |
| 1132 |
% ensure that relevant characters are not active |
| 1133 |
\int_gincr:N \g_hawkdraw_id_int |
| 1134 |
\prop_if_exist:cF { |
| 1135 |
g__hawkdraw_points_ \int_use:N \g_hawkdraw_id_int _prop |
| 1136 |
} { |
| 1137 |
\prop_new_linked:c { |
| 1138 |
g__hawkdraw_points_ \int_use:N \g_hawkdraw_id_int _prop |
| 1139 |
} |
| 1140 |
} |
| 1141 |
\cs_set_eq:NN \path \hawkdraw_path:w |
| 1142 |
\cs_set:Npn \stroke { \path [ stroke ] } |
| 1143 |
\cs_set:Npn \fill { \path [ fill ] } |
| 1144 |
\cs_set:Npn \clip { \path [ clip ] } |
| 1145 |
\cs_set:Npn \node { \path ( 0pt , 0pt ) node } |
| 1146 |
\cs_set:Npn \point { \path ( 0pt , 0pt ) point } |
| 1147 |
\cs_set:Npn \map { \path ( 0pt , 0pt ) map } |
| 1148 |
\NewExpandableDocumentCommand \firstpoint { } { |
| 1149 |
\fp_use:N \g_hawkdraw_path_first_point_fp |
| 1150 |
} |
| 1151 |
\NewExpandableDocumentCommand \lastpoint { } { |
| 1152 |
\fp_use:N \g_hawkdraw_path_last_point_fp |
| 1153 |
} |
| 1154 |
\NewExpandableDocumentCommand \firstslope { } { |
| 1155 |
\fp_use:N \g_hawkdraw_path_first_slope_fp |
| 1156 |
} |
| 1157 |
\NewExpandableDocumentCommand \lastslope { } { |
| 1158 |
\fp_use:N \g_hawkdraw_path_last_slope_fp |
| 1159 |
} |
| 1160 |
\fp_set:Nn \l__hawkdraw_point_a_fp { ( 0pt , 0pt ) } |
| 1161 |
\fp_set:Nn \l__hawkdraw_point_b_fp { ( 0pt , 0pt ) } |
| 1162 |
\fp_gset:Nn \g_hawkdraw_path_first_point_fp { ( 0pt , 0pt ) } |
| 1163 |
\fp_gset:Nn \g_hawkdraw_path_last_point_fp { ( 0pt , 0pt ) } |
| 1164 |
\fp_gset:Nn \g_hawkdraw_path_first_slope_fp { nan } |
| 1165 |
\fp_gset:Nn \g_hawkdraw_path_last_slope_fp { nan } |
| 1166 |
\NewDocumentEnvironment { scope } { O{} } { |
| 1167 |
\draw_scope_begin: |
| 1168 |
\clist_clear:N \l__hawkdraw_keys_unprocessed_clist |
| 1169 |
\keys_set_known:nnN { hawkdraw / scope } {##1} |
| 1170 |
\l__hawkdraw_keys_unprocessed_clist |
| 1171 |
\keys_set:nV { hawkdraw / path } \l__hawkdraw_keys_unprocessed_clist |
| 1172 |
\str_if_empty:NF \l_hawkdraw_scope_layer_str { |
| 1173 |
\draw_layer_begin:V \l_hawkdraw_scope_layer_str |
| 1174 |
} |
| 1175 |
} { |
| 1176 |
\str_if_empty:NF \l_hawkdraw_scope_layer_str { |
| 1177 |
\draw_layer_end: |
| 1178 |
} |
| 1179 |
\draw_scope_end: |
| 1180 |
} |
| 1181 |
\fp_set:Nn \l_draw_instance_baseline_fp { nan } |
| 1182 |
\draw_begin: |
| 1183 |
\clist_clear:N \l__hawkdraw_keys_unprocessed_clist |
| 1184 |
\keys_set_known:nnN { hawkdraw / instance } {#1} |
| 1185 |
\l__hawkdraw_keys_unprocessed_clist |
| 1186 |
\keys_set:nV { hawkdraw / path } \l__hawkdraw_keys_unprocessed_clist |
| 1187 |
\fp_if_nan:nF { \l_draw_instance_baseline_fp } { |
| 1188 |
\draw_set_baseline:n { |
| 1189 |
\fp_to_dim:n { \l_draw_instance_baseline_fp } |
| 1190 |
} |
| 1191 |
} |
| 1192 |
\bool_if:NT \l_hawkdraw_instance_overlay_bool { |
| 1193 |
\bool_set_false:N \l_draw_bb_update_bool |
| 1194 |
} |
| 1195 |
} { |
| 1196 |
\draw_end: |
| 1197 |
} |
| 1198 |
|
| 1199 |
% EOF |