<html><head><meta name="color-scheme" content="light dark"></head><body><pre style="word-wrap: break-word; white-space: pre-wrap;">%%% ----------------------------------------------------------------------------
%%% suanpan: draw suanpan(abacus) with LaTeX3
%%% Author    : Nan Geng &lt;nangeng@nwafu.edu.cn&gt;
%%% Repository: https://gitee.com/nwafu_nan/suan-span
%%% License   : The LaTeX Project Public License 1.3c
%%% ----------------------------------------------------------------------------

\NeedsTeXFormat{LaTeX2e}[2020/10/01]
\RequirePackage{expl3}
% \ProvidesExplPackage{suanpan}{2024-08-20}{v1.0.0} % åˆç¨¿
% \ProvidesExplPackage{suanpan}{2024-08-28}{v1.1.0} % ä¼˜åŒ–(ç»Ÿä¸€å°ºå¯¸è®¡ç®—ï¼Œæ·»åŠ&nbsp;ç©ºç™½å&nbsp;ä½)
% \ProvidesExplPackage{suanpan-l3}{2024-08-30}{v1.1.1} % æ›´åä¸ºsuanpan-l3
% \ProvidesExplPackage{suanpan-l3}{2024-08-31}{v1.1.2} % æ·»åŠ&nbsp;emptyä¸ç»˜åˆ¶ç©ºæ¡£é€‰é¡¹
% \ProvidesExplPackage{suanpan-l3}{2024-09-01}{v1.1.3} % æ·»åŠ&nbsp;bidæ‰¹å¤„ç†åŠç»˜åˆ¶é¢œè‰²é€‰é¡¹
%                                                      % å°†ç®—ç&nbsp;ä¸Žæ¡£æ†ç»˜åˆ¶æ”¹ä¸ºTikZ
% \ProvidesExplPackage{suanpan-l3}{2024-09-04}{v1.2.0} % æ·»åŠ&nbsp;\labæ¨ªæ¢æ–‡å­—æ&nbsp;‡è®°å‘½ä»¤
% \ProvidesExplPackage{suanpan-l3}{2024-09-05}{v1.2.1} % å°†è‰ç¨¿æ¨¡å¼æ‰€æœ‰ç®—ç&nbsp;æ”¹ä¸ºåœ†å†’
%                                                      % ç›´çº¿å¹¶å–æ¶ˆæ‰€æœ‰é«˜å…‰ç‰¹æ•ˆ
% \ProvidesExplPackage{suanpan-l3}{2024-09-07}{v1.2.2} % ä¸ºç&nbsp;é«˜ã€ç&nbsp;å®½ã€æ¡£æ†å®½åº¦å’Œ
%                                                      % è¾¹æ¡†å®½åº¦æ·»åŠ&nbsp;è®¾ç½®é€‰é¡¹
% \ProvidesExplPackage{suanpan-l3}{2024-09-07}{v1.2.3} % å°†ç®—ç&nbsp;é«˜å…‰æ”¹ä¸ºballç±»åž‹ï¼Œ
%                                                      % å¹¶æ·»åŠ&nbsp;é«˜å…‰ä½ç½®(è§’åº¦)é€‰é¡¹ã€‚
\ProvidesExplPackage{suanpan-l3}{2024-10-13}{v1.2.4} % åˆ&nbsp;é™¤tikzå®åŒ…åº“åŠ&nbsp;è½½è¡¥ä¸
  {draw suanpan(abacus) with LaTeX3}

\RequirePackage{l3keys2e}
\RequirePackage{xparse}
\RequirePackage{l3draw}

\RequirePackage {tikz}
% æ·»åŠ&nbsp;tikzå®åŒ…çš„åº“
\usetikzlibrary{shadings}

\cs_new:Npn \__suanpan_error:n { \msg_error:nn { suanpan(abacus) } }

% ç›’å­å®¹å™¨æ€»é«˜åº¦è®¡ç®—å‡½æ•°
\cs_new_nopar:Npn \__suanpan_coffin_ht_plus_dp:N #1
  {
    \coffin_ht:N #1 + \coffin_dp:N #1
  }

% =============é¢œè‰²å¤„ç†å‡½æ•°=============
% å¡«å……è‰²è¾…åŠ©å‡½æ•°
\cs_new_nopar:Nn \__suanpan_aux_color_boxfill:
  { }

% é¢œè‰²å‘½åå‡½æ•°
% #1 é¢œè‰²åç§°
% #2 é¢œè‰²è¡¨è¾¾å¼
\cs_set_nopar:Npn \__suanpan_color_select:nn #1#2
  {
    \colorlet { #1 } { #2 }
  }
\cs_generate_variant:Nn \__suanpan_color_select:nn {nx}

% é¢œè‰²å‘½åå‡½æ•°
% #1 é¢œè‰²åç§°
% #2 é¢œè‰²ç©ºé—´
% #3 é¢œè‰²åˆ†é‡å€¼
\cs_set_nopar:Npn \__suanpan_color_select:nnn #1#2#3
  {
    \definecolor { #1 } { #2 } { #3 }
  }
\cs_generate_variant:Nn \__suanpan_color_select:nnn {nnx}

% å®šä¹‰å˜é‡
% ç®—ç›˜åŸºç¡€å°ºå¯¸
\dim_new:N \l__suanpan_bid_h_dim
\dim_new:N \l__suanpan_bid_d_dim
\dim_new:N \l__suanpan_rod_d_dim
\dim_new:N \l__suanpan_frame_b_dim
\dim_new:N \l__suanpan_bid_sep_dim
\dim_new:N \l__suanpan_rod_sep_dim

% ç®—ç›˜åŸºç¡€å°ºå¯¸åˆå€¼(å‚è€ƒ QBT1747-1993 ç®—ç›˜æ&nbsp;‡å‡†)
\dim_set:Nn \l__suanpan_bid_h_dim { 12mm }
\dim_set:Nn \l__suanpan_bid_d_dim { 23mm }
\dim_set:Nn \l__suanpan_rod_d_dim { 7mm }
\dim_set:Nn \l__suanpan_frame_b_dim { 13mm }
\dim_set:Nn \l__suanpan_bid_sep_dim { 1.8pt }
\dim_set:Nn \l__suanpan_rod_sep_dim { 3.0pt }

% åŠé•¿åº¦
\dim_new:N \l__suanpan_bid_h_half_dim
\dim_new:N \l__suanpan_bid_d_half_dim
\dim_new:N \l__suanpan_rod_d_half_dim
\dim_new:N \l__suanpan_frame_b_half_dim

% ä¸Šç&nbsp;åç§»
\dim_new:N \l__suanpan_bid_upper_offset_dim
% ä¸‹ç&nbsp;åç§»
\dim_new:N \l__suanpan_bid_lower_offset_dim
% ä¸Šæ¡£æ†é•¿åº¦
\dim_new:N \l__suanpan_rod_upper_h_dim
% ä¸‹æ¡£æ†é•¿åº¦
\dim_new:N \l__suanpan_rod_lower_h_dim
% ä¸Šæ¡£æ†åç§»
\dim_new:N \l__suanpan_rod_upper_offset_dim
% ä¸‹æ¡£æ†åç§»
\dim_new:N \l__suanpan_rod_lower_offset_dim
% ä¸Šæ¡£æ†ä½ç½®
\dim_new:N \l__suanpan_rod_upper_dim
% ä¸‹æ¡£æ†ä½ç½®
\dim_new:N \l__suanpan_rod_lower_dim
% ä¸Šè¾¹æ¡†å†…çº¿åç§»
\dim_new:N \l__suanpan_frame_upper_inner_offset_dim
% ä¸‹è¾¹æ¡†å†…çº¿åç§»
\dim_new:N \l__suanpan_frame_lower_inner_offset_dim
% ä¸Šè¾¹æ¡†å¤–çº¿åç§»
\dim_new:N \l__suanpan_frame_upper_outer_offset_dim
% ä¸‹è¾¹æ¡†å¤–çº¿åç§»
\dim_new:N \l__suanpan_frame_lower_outer_offset_dim
% ç®—ç&nbsp;ä¸Šè¾¹ç¼˜
\dim_new:N \l__suanpan_bid_upper_dim
% ç®—ç&nbsp;ä¸‹è¾¹ç¼˜
\dim_new:N \l__suanpan_bid_lower_dim
% ç®—ç&nbsp;ç»˜åˆ¶é«˜åº¦
\dim_new:N \l__suanpan_bid_draw_h_dim
% ç®—ç&nbsp;ç»˜åˆ¶åŠé«˜åº¦
\dim_new:N \l__suanpan_bid_draw_h_half_dim
% ç®—ç&nbsp;åœ†è§’åŠå¾„
\dim_new:N \l__suanpan_bid_arc_dim
% æ¨ªæ¢è®¡ä½ç‚¹åŠå¾„
\dim_new:N \l__suanpan_frame_unit_r_dim
% è¾¹æ¡†å¤–çº¿åŠå®½åº¦
\dim_new:N \l__suanpan_frame_outer_half_dim
% æ¡£æ†æ€»æˆå®½åº¦
\dim_new:N \l__suanpan_support_d_dim
% æ¡£æ†æ€»æˆåŠå®½åº¦
\dim_new:N \l__suanpan_support_d_half_dim
% æ¡£æ†æ€»æˆç»„è£…åž‚ç›´åç§»
\dim_new:N \l__suanpan_support_y_offset_dim

% ä¸Šè¾¹æ¡†å†…çº¿ä½ç½®
\dim_new:N \l__suanpan_frame_inner_upper_dim
% ä¸‹è¾¹æ¡†å†…çº¿ä½ç½®
\dim_new:N \l__suanpan_frame_inner_lower_dim

% è¾¹æ¡†å†…çº¿é«˜åº¦
\dim_new:N \l__suanpan_frame_inner_h_dim
% è¾¹æ¡†å¤–çº¿é«˜åº¦
\dim_new:N \l__suanpan_frame_outer_h_dim

\dim_new:N \l__suanpan_frame_inner_linewidth_dim
\dim_new:N \l__suanpan_frame_outer_linewidth_dim
\dim_new:N \l__suanpan_rod_linewidth_dim
\dim_new:N \l__suanpan_bid_linewidth_dim

% çŠ¶æ€å˜é‡
\bool_new:N \l__suanpan_support_frame_bool
\bool_set_true:N \l__suanpan_support_frame_bool
\bool_new:N \l__suanpan_support_unit_bool
\bool_set_false:N \l__suanpan_support_unit_bool
\bool_new:N \l__suanpan_draft_bool
\bool_new:N \l__suanpan_empty_rod_bool

% å®¹å™¨(ç›’å­)
\coffin_new:N \l__suanpan_inner_bid_coffin
\coffin_new:N \l__suanpan_outer_bid_coffin
\coffin_new:N \l__suanpan_float_bid_coffin
\coffin_new:N \l__suanpan_support_coffin
\coffin_new:N \l_tmpc_coffin
\coffin_new:N \l_tmpd_coffin

% å‡­æ®è¡¨(Token)
\tl_new:N \l__suanpan_bid_draw_color_tl
\tl_new:N \l__suanpan_bid_fill_color_tl
\tl_new:N \l__suanpan_scale_tl
\tl_new:N \l__suanpan_mark_font_tl
\tl_new:N \l__suanpan_bid_spot_angle_tl

% æ¡£ä½æœ€å¤§å€¼
\int_new:N \l__suanpan_rod_max_int
\int_zero:N \l__suanpan_rod_max_int

% æ¡£ä½ç®—ç&nbsp;ä½ç½®åˆ—è¡¨
\clist_new:N \l__suanpan_bids_pos_clist

% æ¡£ä½æ•°å­—ä¸Žç®—ç&nbsp;ä½ç½®å¯¹ç…§å±žæ€§è¡¨å¸¸é‡(å†…ç&nbsp;å’Œå¤–ç&nbsp;)
% {x, y}==&gt;x: ç®—ç&nbsp;ä½ç½®(1-11, 1-7---ä¸‹ç&nbsp;ï¼Œ8-10---ä¸Šç&nbsp;ï¼Œ11---æ‚¬ç&nbsp;)
%          y: ç®—ç&nbsp;ç±»åž‹(0---å¤–ç&nbsp;ï¼Œ1---å†…ç&nbsp;)
\prop_const_from_keyval:Nn \l__suanpan_rods_val_prop
  {
    0  = {{1, 0}, {2, 0}, {3, 0}, {4, 0}, {5, 0}, {9, 0}, {10, 0}},
    1  = {{1, 0}, {2, 0}, {3, 0}, {4, 0}, {7, 1}, {9, 0}, {10, 0}},
    2  = {{1, 0}, {2, 0}, {3, 0}, {6, 1}, {7, 1}, {9, 0}, {10, 0}},
    3  = {{1, 0}, {2, 0}, {5, 1}, {6, 1}, {7, 1}, {9, 0}, {10, 0}},
    4  = {{1, 0}, {4, 1}, {5, 1}, {6, 1}, {7, 1}, {9, 0}, {10, 0}},
    5  = {{1, 0}, {2, 0}, {3, 0}, {4, 0}, {5, 0}, {8, 1}, {10, 0}},
    6  = {{1, 0}, {2, 0}, {3, 0}, {4, 0}, {7, 1}, {8, 1}, {10, 0}},
    7  = {{1, 0}, {2, 0}, {3, 0}, {6, 1}, {7, 1}, {8, 1}, {10, 0}},
    8  = {{1, 0}, {2, 0}, {5, 1}, {6, 1}, {7, 1}, {8, 1}, {10, 0}},
    9  = {{1, 0}, {4, 1}, {5, 1}, {6, 1}, {7, 1}, {8, 1}, {10, 0}},
    10 = {{3, 1}, {4, 1}, {5, 1}, {6, 1}, {7, 1}, {8, 1}, {10, 0}},
    11 = {{1, 0}, {2, 0}, {3, 0}, {4, 0}, {7, 1}, {8, 1}, {9 , 1}},
    12 = {{1, 0}, {2, 0}, {3, 0}, {6, 1}, {7, 1}, {8, 1}, {9 , 1}},
    13 = {{1, 0}, {2, 0}, {5, 1}, {6, 1}, {7, 1}, {8, 1}, {9 , 1}},
    14 = {{1, 0}, {4, 1}, {5, 1}, {6, 1}, {7, 1}, {8, 1}, {9 , 1}},
    15 = {{3, 1}, {4, 1}, {5, 1}, {6, 1}, {7, 1}, {8, 1}, {9 , 1}},
    16 = {{1, 0}, {2, 0}, {3, 0}, {4, 0}, {7, 1}, {8, 1}, {11, 1}},
    17 = {{1, 0}, {2, 0}, {3, 0}, {6, 1}, {7, 1}, {8, 1}, {11, 1}},
    18 = {{1, 0}, {2, 0}, {5, 1}, {6, 1}, {7, 1}, {8, 1}, {11, 1}},
    19 = {{1, 0}, {4, 1}, {5, 1}, {6, 1}, {7, 1}, {8, 1}, {11, 1}},
    20 = {{3, 1}, {4, 1}, {5, 1}, {6, 1}, {7, 1}, {8, 1}, {11, 1}}
  }

% å°ºå¯¸è®¡ç®—å‡½æ•°
\cs_new:Nn \__suanpan_dim_calc:
  {
    % åŸºç¡€å°ºå¯¸åŠé•¿åº¦
    \dim_set:Nn \l__suanpan_bid_h_half_dim { \l__suanpan_bid_h_dim / 2 }
    \dim_set:Nn \l__suanpan_bid_d_half_dim { \l__suanpan_bid_d_dim / 2 }
    \dim_set:Nn \l__suanpan_rod_d_half_dim { \l__suanpan_rod_d_dim / 2 }
    \dim_set:Nn \l__suanpan_frame_b_half_dim { \l__suanpan_frame_b_dim / 2 }
    % ä¸Šç&nbsp;åç§»(8å·ç®—ç&nbsp;)
    \dim_set:Nn \l__suanpan_bid_upper_offset_dim
              { \l__suanpan_frame_b_half_dim + \l__suanpan_bid_h_half_dim }
    % ä¸‹ç&nbsp;åç§»(1å·ç®—ç&nbsp;)
    \dim_set:Nn \l__suanpan_bid_lower_offset_dim
             { -\l__suanpan_frame_b_half_dim - \l__suanpan_bid_h_dim * 7 +
                \l__suanpan_bid_h_half_dim }
    % ä¸Šæ¡£æ†é•¿åº¦
    \dim_set:Nn \l__suanpan_rod_upper_h_dim { \l__suanpan_bid_h_dim * 3 }
    % ä¸‹æ¡£æ†é•¿åº¦
    \dim_set:Nn \l__suanpan_rod_lower_h_dim { \l__suanpan_bid_h_dim * 7 }
    % ä¸Šæ¡£æ†åç§»
    \dim_set:Nn \l__suanpan_rod_upper_offset_dim { \l__suanpan_frame_b_half_dim }
    % ä¸‹æ¡£æ†åç§»
    \dim_set:Nn \l__suanpan_rod_lower_offset_dim
              { -\l__suanpan_frame_b_half_dim - \l__suanpan_rod_lower_h_dim }
    % ä¸Šæ¡£æ†ä½ç½®
    \dim_set:Nn \l__suanpan_rod_upper_dim
              { \l__suanpan_rod_upper_offset_dim + \l__suanpan_rod_upper_h_dim }
    % ä¸‹æ¡£æ†ä½ç½®
    \dim_set:Nn \l__suanpan_rod_lower_dim { -\l__suanpan_frame_b_half_dim }

    % ä¸Šè¾¹æ¡†å†…çº¿åç§»
    \dim_set:Nn \l__suanpan_frame_upper_inner_offset_dim
              { \l__suanpan_frame_b_half_dim + \l__suanpan_rod_upper_h_dim }
    % ä¸‹è¾¹æ¡†å†…çº¿åç§»
    \dim_set:Nn \l__suanpan_frame_lower_inner_offset_dim
             { -\l__suanpan_frame_b_half_dim - \l__suanpan_rod_lower_h_dim }
    % ä¸Šè¾¹æ¡†å¤–çº¿åç§»
    \dim_set:Nn \l__suanpan_frame_upper_outer_offset_dim
              { \l__suanpan_frame_b_dim + \l__suanpan_frame_b_half_dim +
                \l__suanpan_rod_upper_h_dim }
    % ä¸‹è¾¹æ¡†å¤–çº¿åç§»
    \dim_set:Nn \l__suanpan_frame_lower_outer_offset_dim
             { -\l__suanpan_frame_b_dim - \l__suanpan_frame_b_half_dim -
                \l__suanpan_rod_lower_h_dim }

    % ç®—ç&nbsp;ä¸Šè¾¹ç¼˜
    \dim_set:Nn \l__suanpan_bid_upper_dim
              { \l__suanpan_bid_h_half_dim - \l__suanpan_bid_sep_dim / 2 }
    % ç®—ç&nbsp;ä¸Šè¾¹ç¼˜
    \dim_set:Nn \l__suanpan_bid_lower_dim
             { -\l__suanpan_bid_h_half_dim + \l__suanpan_bid_sep_dim / 2 }
    % ç®—ç&nbsp;ç»˜åˆ¶é«˜åº¦
    \dim_set:Nn \l__suanpan_bid_draw_h_dim
              { \l__suanpan_bid_upper_dim - \l__suanpan_bid_lower_dim }
    % ç®—ç&nbsp;ç»˜åˆ¶åŠé«˜åº¦
    \dim_set:Nn \l__suanpan_bid_draw_h_half_dim
              { \l__suanpan_bid_draw_h_dim / 2 }
    % ç®—ç&nbsp;åœ†è§’åŠå¾„
    \dim_set:Nn \l__suanpan_bid_arc_dim
              { \l__suanpan_bid_draw_h_half_dim - 1pt}

    % æ¨ªæ¢è®¡ä½ç‚¹åŠå¾„
    \dim_set:Nn \l__suanpan_frame_unit_r_dim { \l__suanpan_frame_b_dim / 4 }

    % è¾¹æ¡†å¤–çº¿åŠå®½åº¦
    \dim_set:Nn \l__suanpan_frame_outer_half_dim
              { \l__suanpan_frame_outer_linewidth_dim / 2 }

    % æ¡£æ†æ€»æˆå®½åº¦
    \dim_set:Nn \l__suanpan_support_d_dim
              { \l__suanpan_bid_d_dim + \l__suanpan_rod_sep_dim }
    % æ¡£æ†æ€»æˆåŠå®½åº¦
    \dim_set:Nn \l__suanpan_support_d_half_dim
              { \l__suanpan_bid_d_half_dim + \l__suanpan_rod_sep_dim / 2 }

    % æ¡£æ†æ€»æˆç»„è£…åž‚ç›´åç§»
    \dim_set:Nn \l__suanpan_support_y_offset_dim
            { ( \l__suanpan_frame_upper_outer_offset_dim -
                \l__suanpan_frame_lower_outer_offset_dim +
                \l__suanpan_frame_outer_linewidth_dim ) / 2 -
                \l__suanpan_frame_upper_outer_offset_dim -
                \l__suanpan_frame_outer_half_dim
            }

    % ä¸Šè¾¹æ¡†å†…çº¿ä½ç½®
    \dim_set:Nn \l__suanpan_frame_inner_upper_dim
              { \l__suanpan_frame_upper_inner_offset_dim +
                \l__suanpan_frame_inner_linewidth_dim / 2 }
    % ä¸‹è¾¹æ¡†å†…çº¿ä½ç½®
    \dim_set:Nn \l__suanpan_frame_inner_lower_dim
              { \l__suanpan_frame_lower_inner_offset_dim -
                \l__suanpan_frame_inner_linewidth_dim / 2 }

    % è¾¹æ¡†å†…çº¿é«˜åº¦
    \dim_set:Nn \l__suanpan_frame_inner_h_dim
              { \l__suanpan_rod_upper_h_dim +
                \l__suanpan_rod_lower_h_dim +
                \l__suanpan_frame_b_dim }
    % è¾¹æ¡†å¤–çº¿é«˜åº¦
    \dim_set:Nn \l__suanpan_frame_outer_h_dim
              { \l__suanpan_rod_upper_h_dim +
                \l__suanpan_rod_lower_h_dim +
                \l__suanpan_frame_b_dim * 3 }
  }

% é€‰é¡¹å¤„ç†
% ============å®åŒ…é€‰é¡¹=================
\keys_define:nn { suanpan }
  {
    % è‰ç¨¿æ¨¡å¼
    draft .choice:,
    draft / true  .code:n = {%
                              \bool_set_true:N  \l__suanpan_draft_bool
                              \bool_set_false:N  \l__suanpan_empty_rod_bool
                            },
    draft / false .code:n = {%
                              \bool_set_false:N \l__suanpan_draft_bool
                              \bool_set_true:N  \l__suanpan_empty_rod_bool
                            },
    draft .default:n = true,
    draft .initial:n = false,

    % æ˜¯å¦ç»˜åˆ¶æ¡£çš„æ•°å€¼ä¸º0çš„ç©ºæ¡£ç®—ç&nbsp;
    empty .choice:,
    empty / true  .code:n = { \bool_set_true:N  \l__suanpan_empty_rod_bool },
    empty / false .code:n = { \bool_set_false:N \l__suanpan_empty_rod_bool },
    empty .default:n = true,
    empty .initial:n = true,

    unknown .code:n = { \msg_error:nn { suanpan } { unknown-option } }
  }

% key_valueé€‰é¡¹è®¾è®¡
\keys_define:nn { suanpan }
  {
    % ç»˜å›¾çº¿å®½
    linewd .code:n = { % ç®—ç›˜è¾¹æ¡†å†…çº¿çº¿å®½
                       \dim_set:Nn \l__suanpan_frame_inner_linewidth_dim {#1}
                       % ç®—ç›˜è¾¹æ¡†å¤–çº¿çº¿å®½
                       \dim_set:Nn \l__suanpan_frame_outer_linewidth_dim
                         {
                           \fp_to_dim:n
                             {
                               \fp_eval:n {%
                                 \l__suanpan_frame_inner_linewidth_dim * 7.0 }
                             }
                         }
                       % æ¡£æ†çº¿å®½
                       \dim_set:Nn \l__suanpan_rod_linewidth_dim
                         {
                           \fp_to_dim:n
                             {
                               \fp_eval:n {%
                                 \l__suanpan_frame_inner_linewidth_dim * 0.2 }
                             }
                         }
                       % ç®—ç&nbsp;çº¿å®½
                       \dim_set:Nn \l__suanpan_bid_linewidth_dim
                         {
                           \fp_to_dim:n
                             {
                               \fp_eval:n {%
                                 \l__suanpan_frame_inner_linewidth_dim * 0.2 }
                             }
                         }
                       % è®¡ç®—å…¶å®ƒå°ºå¯¸
                       \__suanpan_dim_calc:
                     },
    linewd .initial:n = 2.0pt,

    % ç®—ç&nbsp;é«˜åº¦
    bidh .code:n = {%
                       \dim_set:Nn \l__suanpan_bid_h_dim { #1 }
                       % è®¡ç®—å…¶å®ƒå°ºå¯¸
                       \__suanpan_dim_calc:
                     },
    bidh .initial:n = 12mm,

    % ç®—ç&nbsp;ç›´å¾„
    bidd .code:n = {%
                       \dim_set:Nn \l__suanpan_bid_d_dim { #1 }
                       % è®¡ç®—å…¶å®ƒå°ºå¯¸
                       \__suanpan_dim_calc:
                     },
    bidd .initial:n = 23mm,

    % æ¡£æ†ç›´å¾„(åº”å°äºŽç®—ç&nbsp;ç›´å¾„bidd)
    rodd .code:n = {%
                       \dim_set:Nn \l__suanpan_rod_d_dim { #1 }
                       % è®¡ç®—å…¶å®ƒå°ºå¯¸
                       \__suanpan_dim_calc:
                     },
    rodd .initial:n = 7mm,

    % è¾¹æ¡†å®½åº¦
    framew .code:n = {%
                       \dim_set:Nn \l__suanpan_frame_b_dim { #1 }
                       % è®¡ç®—å…¶å®ƒå°ºå¯¸
                       \__suanpan_dim_calc:
                     },
    framew .initial:n = 13mm,

    % æ¡£é—´é—´è·
    rodsep .code:n = {%
                       \dim_set:Nn \l__suanpan_rod_sep_dim { #1 }
                       % è®¡ç®—å…¶å®ƒå°ºå¯¸
                       \__suanpan_dim_calc:
                     },
    rodsep .initial:n = 3.0pt,

    % ç®—ç&nbsp;é—´è·
    bidsep .code:n = {%
                       \dim_set:Nn \l__suanpan_bid_sep_dim { #1 }
                       % è®¡ç®—å…¶å®ƒå°ºå¯¸
                       \__suanpan_dim_calc:
                     },
    bidsep .initial:n = 0.0pt,

    % ç¼©æ”¾å‚æ•°
    scale .tl_set:N = \l__suanpan_scale_tl,
    scale .initial:n = 1.0,

    % è¾¹æ¡†ç»˜å›¾é¢œè‰²
    framedraw  .code:n = { \__suanpan_color_select:nn { framecolor } {#1} },
    framedraw  .initial:n = black,
    framedraw* .code:n = { \__suanpan_color_select:nnn { framecolor } #1 },

    % æ¡£æ†ç»˜å›¾é¢œè‰²
    roddraw  .code:n = { \__suanpan_color_select:nn { roddrawcolor } {#1} },
    roddraw  .initial:n = black,
    roddraw* .code:n = { \__suanpan_color_select:nnn { roddrawcolor } #1 },
    % æ¡£æ†å¡«å……é¢œè‰²
    rodfill  .code:n = { \__suanpan_color_select:nn { rodfillcolor } {#1} },
    rodfill  .initial:n = black!20,
    rodfill* .code:n = { \__suanpan_color_select:nnn { rodfillcolor } #1 },

    % å¤–ç&nbsp;ç»˜å›¾é¢œè‰²
    outerdraw  .code:n = { \__suanpan_color_select:nn { outerdrawcolor } {#1} },
    outerdraw  .initial:n = black,
    outerdraw* .code:n = { \__suanpan_color_select:nnn { outerdrawcolor } #1 },
    % å¤–ç&nbsp;å¡«å……é¢œè‰²
    outerfill  .code:n = { \__suanpan_color_select:nn { outerfillcolor } {#1} },
    outerfill  .initial:n = black!40,
    outerfill* .code:n = { \__suanpan_color_select:nnn { outerfillcolor } #1 },

    % å†…ç&nbsp;ç»˜å›¾é¢œè‰²
    innerdraw  .code:n = { \__suanpan_color_select:nn { innerdrawcolor } {#1} },
    innerdraw  .initial:n = black,
    innerdraw* .code:n = { \__suanpan_color_select:nnn { innerdrawcolor } #1 },
    % å†…ç&nbsp;å¡«å……é¢œè‰²
    innerfill  .code:n = { \__suanpan_color_select:nn { innerfillcolor } {#1} },
    innerfill  .initial:n = black,
    innerfill* .code:n = { \__suanpan_color_select:nnn { innerfillcolor } #1 },
    innerfill  .initial:n = black,

    % æ¨ªæ¢æ&nbsp;‡è®°å­—ç¬¦æ&nbsp;¼å¼
    font .tl_set:N = \l__suanpan_mark_font_tl,
    font .initial:n = \bfseries\Large,

    % ç®—ç&nbsp;é«˜å…‰ç‚¹ä½ç½®(è§’åº¦)
    bidspot .tl_set:N = \l__suanpan_bid_spot_angle_tl,
    bidspot .initial:n = 0,

    unknown .code:n = { \msg_error:nn { suanpan } { unknown-option } }
  }

% å‡ºé”™è¾“å‡ºä¿¡æ¯
\msg_new:nnn { suanpan } { unknown-option }
  { package~ option~ "\l_keys_key_tl"~ is~ unknown. }

% é€‰é¡¹é»˜è®¤å€¼
\keys_set:nn { suanpan }
  {
    linewd = 2.0pt,
    rodsep = 3.0pt,
    bidsep = 1.8pt,
    scale  = 1.0,
    empty  = true,
  }

% å°†æ–‡æ¡£ç±»é€‰é¡¹ä¼&nbsp;ç»™suanpan
\ProcessKeysOptions { suanpan }

% æž„å»ºå†…ç&nbsp;(é&nbsp;è¿‘æ¨ªæ¢ï¼Œå‚ä¸Žè®¡æ•°)å®¹å™¨(ç›’å­)
\cs_new:Nn \__suanpan_inner_bid_construct:
  {
    \dim_set:Nn \l_tmpa_dim
      { \l__suanpan_bid_d_half_dim - \l__suanpan_bid_draw_h_half_dim }

    \tikzset{bid/.style = {% å†…ç&nbsp;é«˜å…‰å¡«å……æ&nbsp;·å¼
        shading         = ball,
        ball~color      = innerfillcolor,
        shading~angle   = \l__suanpan_bid_spot_angle_tl,
        line~width      = \l__suanpan_bid_linewidth_dim,
        rounded~corners = \l__suanpan_bid_arc_dim,
      },
      draftline/.style = {% å†…ç&nbsp;è‰ç¨¿æ¨¡å¼ç»˜åˆ¶æ&nbsp;·å¼
        draw       = innerfillcolor,
        line~cap   = round,% åœ†è§’çº¿å†’
        line~width = \l__suanpan_bid_draw_h_dim,
      }
    }

    \group_begin:
      \hcoffin_gset:Nn \l__suanpan_inner_bid_coffin
        {
          % åˆ¤æ–­æ˜¯å¦ä¸ºè‰ç¨¿æ¨¡å¼
          \bool_if:NTF \l__suanpan_draft_bool
            {
              \begin{tikzpicture}
                \draw[draftline]
                  ( -\l_tmpa_dim, 0) -- ( \l_tmpa_dim, 0);
              \end{tikzpicture}
            }{
              \begin{tikzpicture}
                \shadedraw[bid]
                  ( -\l__suanpan_bid_d_half_dim, \l__suanpan_bid_lower_dim)
                  rectangle
                  (  \l__suanpan_bid_d_half_dim, \l__suanpan_bid_upper_dim);
              \end{tikzpicture}
            }
        }
    \group_end:
  }

% æž„å»ºå¤–ç&nbsp;(è¿œç¦»æ¨ªæ¢ï¼Œä¸å‚ä¸Žè®¡æ•°)å®¹å™¨(ç›’å­)
\cs_new:Nn \__suanpan_outer_bid_construct:
  {
    \dim_set:Nn \l_tmpa_dim
      { \l__suanpan_bid_d_half_dim - \l__suanpan_bid_draw_h_half_dim }

    \tikzset{bid/.style ={
        shading         = ball,
        ball~color      = outerfillcolor,
        shading~angle   = \l__suanpan_bid_spot_angle_tl,
        line~width      = \l__suanpan_bid_linewidth_dim,
        rounded~corners = \l__suanpan_bid_arc_dim,
      },
      draftline/.style = {
        draw       = outerfillcolor,
        line~cap   = round,
        line~width = \l__suanpan_bid_draw_h_dim,
      }
    }

    \group_begin:
      \hcoffin_gset:Nn \l__suanpan_outer_bid_coffin
        {
          % åˆ¤æ–­æ˜¯å¦ä¸ºè‰ç¨¿æ¨¡å¼
          \bool_if:NTF \l__suanpan_draft_bool
            {
              \begin{tikzpicture}
                \draw[draftline]
                  ( -\l_tmpa_dim, 0) -- ( \l_tmpa_dim, 0 );
              \end{tikzpicture}
            }{
              \begin{tikzpicture}
                \shadedraw[bid]%
                  ( -\l__suanpan_bid_d_half_dim, \l__suanpan_bid_lower_dim)
                  rectangle
                  (  \l__suanpan_bid_d_half_dim, \l__suanpan_bid_upper_dim);
              \end{tikzpicture}
            }
        }
    \group_end:
  }

% æž„å»ºæµ®ç&nbsp;å®¹å™¨(ç›’å­)
% æµ®ç&nbsp;æŒ‡å¯ä»¥åœ¨ç®—ç›˜ä¸­ä»»æ„å¸ƒç½®çš„ç®—ç&nbsp;
% #1 ç»˜åˆ¶é¢œè‰²
% #2 å¡«å……é¢œè‰²
\cs_new:Npn \__suanpan_float_bid_construct:nn #1#2
  {
    \dim_set:Nn \l_tmpa_dim
      { \l__suanpan_bid_d_half_dim - \l__suanpan_bid_draw_h_half_dim }

    \tikzset{bid/.style~args = { #1/#2 }{
        draw            = #1,
        shading         = ball,
        ball~color      = #2,
        shading~angle   = 0,
        shading~angle   = \l__suanpan_bid_spot_angle_tl,
        line~width      = \l__suanpan_bid_linewidth_dim,
        rounded~corners = \l__suanpan_bid_arc_dim,
      },
      draftline/.style = {
        line~cap   = round,
        line~width = \l__suanpan_bid_draw_h_dim,
      }
    }

    \group_begin:
      \hcoffin_gset:Nn \l__suanpan_float_bid_coffin
        {
          % åˆ¤æ–­æ˜¯å¦ä¸ºè‰ç¨¿æ¨¡å¼
          \bool_if:NTF \l__suanpan_draft_bool
            {
              \begin{tikzpicture}
                \draw[draw=#2, draftline]
                  ( -\l_tmpa_dim, 0) -- ( \l_tmpa_dim, 0 );
              \end{tikzpicture}
            }{
              \begin{tikzpicture}
                \shadedraw[bid=#1/#2]
                  ( -\l__suanpan_bid_d_half_dim, \l__suanpan_bid_lower_dim)
                  rectangle
                  (  \l__suanpan_bid_d_half_dim, \l__suanpan_bid_upper_dim);
              \end{tikzpicture}
            }
        }
    \group_end:
  }

% æž„å»ºæ¡£æ†å®¹å™¨(ç›’å­)
\cs_new:Nn \__suanpan_support_construct:
  {
    % TikZç»˜å›¾æ&nbsp;·å¼
    \tikzset{%
      rod/.style = {% æ¡£æ†
        inner~color = rodfillcolor!30,
        outer~color = rodfillcolor,
        draw        = roddrawcolor,
        line~width  = \l__suanpan_rod_linewidth_dim,
      },
      beam/.style = {% æ¨ªæ¢
        bottom~color = framecolor!60,
        top~color    = framecolor!60,
        middle~color = framecolor!5,
      },
      frame/.style = {% ä¸Šä¸‹æ¢
        bottom~color = framecolor!95,
        top~color    = framecolor!95,
        middle~color = framecolor!15,
      },
      rodline/.style = {% æ¡£æ†è¾¹çº¿
        draw       = roddrawcolor,
        line~width = \l__suanpan_rod_linewidth_dim,
      },
      frameinner/.style = {% å†…è¾¹æ¡†çº¿
        draw       = framecolor,
        line~width = \l__suanpan_frame_inner_linewidth_dim,
      },
      frameouter/.style = {% å¤–è¾¹æ¡†çº¿
        draw       = framecolor,
        line~width = \l__suanpan_frame_outer_linewidth_dim,
      },
    }

    \group_begin:
      \hcoffin_gset:Nn \l__suanpan_support_coffin
        {
          % åˆ¤æ–­æ˜¯å¦ä¸ºè‰ç¨¿æ¨¡å¼
          \bool_if:NTF \l__suanpan_draft_bool
            {
              \begin{tikzpicture}
                % ç»˜åˆ¶ä¸‹æ†
                \draw[rodline]
                  ( -\l__suanpan_rod_d_half_dim, \l__suanpan_rod_lower_offset_dim )
                  rectangle
                  (  \l__suanpan_rod_d_half_dim, \l__suanpan_rod_lower_dim );
                % ç»˜åˆ¶ä¸Šæ†
                \draw[rodline]
                  ( -\l__suanpan_rod_d_half_dim, \l__suanpan_rod_upper_offset_dim )
                  rectangle
                  (  \l__suanpan_rod_d_half_dim, \l__suanpan_rod_upper_dim );

                % ç»˜åˆ¶æ¨ªæ¢
                \draw[frameinner]
                  ( -\l__suanpan_support_d_half_dim,  \l__suanpan_frame_b_half_dim )
                  --
                  ( \l__suanpan_support_d_half_dim,  \l__suanpan_frame_b_half_dim );
                \draw[frameinner]
                  ( -\l__suanpan_support_d_half_dim, -\l__suanpan_frame_b_half_dim )
                  --
                  ( \l__suanpan_support_d_half_dim, -\l__suanpan_frame_b_half_dim );

                % ç»˜åˆ¶ä¸Šæ¢ä¸‹è¾¹çº¿
                \draw[frameinner]
                  ( -\l__suanpan_support_d_half_dim,
                     \l__suanpan_frame_upper_inner_offset_dim )
                  --
                  ( \l__suanpan_support_d_half_dim,
                    \l__suanpan_frame_upper_inner_offset_dim );
                % ç»˜åˆ¶ä¸Šæ¢ä¸Šè¾¹çº¿
                \draw[frameouter]
                  ( -\l__suanpan_support_d_half_dim,
                     \l__suanpan_frame_upper_outer_offset_dim -
                     \l__suanpan_frame_outer_linewidth_dim / 2)
                  --
                  ( \l__suanpan_support_d_half_dim,
                     \l__suanpan_frame_upper_outer_offset_dim -
                     \l__suanpan_frame_outer_linewidth_dim / 2);

                % ç»˜åˆ¶ä¸‹æ¢ä¸Šè¾¹çº¿
                \draw[frameinner]
                  ( -\l__suanpan_support_d_half_dim,
                     \l__suanpan_frame_lower_inner_offset_dim )
                  --
                  ( \l__suanpan_support_d_half_dim,
                    \l__suanpan_frame_lower_inner_offset_dim );
                % ç»˜åˆ¶ä¸‹æ¢ä¸‹è¾¹çº¿
                \draw[frameouter]
                  ( -\l__suanpan_support_d_half_dim,
                    \l__suanpan_frame_lower_outer_offset_dim +
                    \l__suanpan_frame_outer_linewidth_dim / 2 )
                  --
                  ( \l__suanpan_support_d_half_dim,
                    \l__suanpan_frame_lower_outer_offset_dim +
                    \l__suanpan_frame_outer_linewidth_dim / 2 );

                % ç»˜åˆ¶è®¡ä½ç‚¹(é»‘è‰²åœ†ç‚¹)
                \bool_if:NT \l__suanpan_support_unit_bool
                  {
                    \fill[%
                      fill=black,
                      ] (0pt, 0pt) circle
                        [radius = \l__suanpan_frame_unit_r_dim];
                  }
              \end{tikzpicture}
            }{
              \begin{tikzpicture}
                % ç»˜åˆ¶ä¸‹æ†
                \shadedraw[rod]
                  ( -\l__suanpan_rod_d_half_dim, \l__suanpan_rod_lower_offset_dim )
                  rectangle
                  (  \l__suanpan_rod_d_half_dim, \l__suanpan_rod_lower_dim );
                % ç»˜åˆ¶ä¸Šæ†
                \shadedraw[rod]
                  ( -\l__suanpan_rod_d_half_dim, \l__suanpan_rod_upper_offset_dim )
                  rectangle
                  (  \l__suanpan_rod_d_half_dim, \l__suanpan_rod_upper_dim );

                % ç»˜åˆ¶æ¨ªæ¢
                \shade[beam]
                  ( -\l__suanpan_support_d_half_dim, -\l__suanpan_frame_b_half_dim )
                  rectangle
                  ( \l__suanpan_support_d_half_dim,  \l__suanpan_frame_b_half_dim );
                \draw[frameinner]
                  ( -\l__suanpan_support_d_half_dim,  \l__suanpan_frame_b_half_dim )
                  --
                  ( \l__suanpan_support_d_half_dim,  \l__suanpan_frame_b_half_dim );
                \draw[frameinner]
                  ( -\l__suanpan_support_d_half_dim, -\l__suanpan_frame_b_half_dim )
                  --
                  ( \l__suanpan_support_d_half_dim, -\l__suanpan_frame_b_half_dim );

                % ç»˜åˆ¶ä¸Šæ¢ä¸‹è¾¹çº¿
                \draw[frameinner]
                  ( -\l__suanpan_support_d_half_dim,
                     \l__suanpan_frame_upper_inner_offset_dim )
                  --
                  ( \l__suanpan_support_d_half_dim,
                    \l__suanpan_frame_upper_inner_offset_dim );
                % ç»˜åˆ¶ä¸Šæ¢ä¸Šè¾¹çº¿
                \draw[frameouter]
                  ( -\l__suanpan_support_d_half_dim,
                     \l__suanpan_frame_upper_outer_offset_dim -
                     \l__suanpan_frame_outer_linewidth_dim / 2)
                  --
                  ( \l__suanpan_support_d_half_dim,
                     \l__suanpan_frame_upper_outer_offset_dim -
                     \l__suanpan_frame_outer_linewidth_dim / 2);

                % ç»˜åˆ¶ä¸‹æ¢ä¸Šè¾¹çº¿
                \draw[frameinner]
                  ( -\l__suanpan_support_d_half_dim,
                     \l__suanpan_frame_lower_inner_offset_dim )
                  --
                  ( \l__suanpan_support_d_half_dim,
                    \l__suanpan_frame_lower_inner_offset_dim );
                % ç»˜åˆ¶ä¸‹æ¢ä¸‹è¾¹çº¿
                \draw[frameouter]
                  ( -\l__suanpan_support_d_half_dim,
                    \l__suanpan_frame_lower_outer_offset_dim +
                    \l__suanpan_frame_outer_linewidth_dim / 2 )
                  --
                  ( \l__suanpan_support_d_half_dim,
                    \l__suanpan_frame_lower_outer_offset_dim +
                    \l__suanpan_frame_outer_linewidth_dim / 2 );

                % ç»˜åˆ¶è®¡ä½ç‚¹(é»‘è‰²åœ†ç‚¹)
                \bool_if:NT \l__suanpan_support_unit_bool
                  {
                    \shade[%
                        shading       = ball,
                        ball~color    = black,
                        shading~angle = \l__suanpan_bid_spot_angle_tl,
                      ] (0pt, 0pt) circle
                        [radius = \l__suanpan_frame_unit_r_dim];
                  }
              \end{tikzpicture}
            }
        }
    \group_end:
  }

% ç»˜åˆ¶ç®—ç&nbsp;
% #1: ç®—ç&nbsp;ä½ç½®ç¼–å·
%     o o o o o o o | o o o
%     1 2 3 4 5 6 7   8 9 10
%                   |    o
%                        11
%     å…¶ä¸­ï¼Œ11æ˜¯æ‚¬ç&nbsp;ä½ç½®
% #2: ç®—ç&nbsp;ç±»åž‹
%     0â€”â€”å¤–ç&nbsp;ï¼Œ1â€”â€”å†…ç&nbsp;ï¼Œ2â€”â€”æµ®ç&nbsp;
\cs_new:Npn \__suanpan_bid_layout:nn #1#2
  {
    % ç®—ç&nbsp;åž‚ç›´åç§»
    \int_compare:nNnTF { #1 } &gt; { 7 }
      {
        \int_compare:nNnTF { #1 } &lt; { 11 }
          {
            % ä¸Šç&nbsp;
            \dim_set:Nn \l_tmpb_dim{ \l__suanpan_bid_upper_offset_dim +
                                     \l__suanpan_bid_h_dim * (#1 - 8) }
          }{
            % æ‚¬ç&nbsp;
            \dim_set:Nn \l_tmpb_dim{ \l__suanpan_frame_b_half_dim +
                                     \l__suanpan_bid_h_dim * 2 }
          }
      }{
        % ä¸‹ç&nbsp;
        \dim_set:Nn \l_tmpb_dim{ \l__suanpan_bid_lower_offset_dim +
                                 \l__suanpan_bid_h_dim * (#1 - 1) }
      }

    % ç»˜å›¾ç®—ç&nbsp;
    \draw_scope_begin:
      \draw_transform_yshift:n { \l_tmpb_dim }
      \int_case:nnF { #2 }
        {
          { 0 } { \draw_coffin_use:Nnn \l__suanpan_outer_bid_coffin { hc } { vc } }
          { 1 } { \draw_coffin_use:Nnn \l__suanpan_inner_bid_coffin { hc } { vc } }
          { 2 } { \draw_coffin_use:Nnn \l__suanpan_float_bid_coffin { hc } { vc } }
        }{ \msg_error:nnn { suanpan } { bid-type-error } {#2} }
    \draw_scope_end:
  }

\msg_new:nnn { suanpan } { bid-type-error }
  { #1~ bid~ type~ is~ unknown. }

% å‡½æ•°å˜ä½“
\cs_generate_variant:Nn \__suanpan_bid_layout:nn {xx}

% ç»„è£…ä¸€ä¸ªæ¡£ä½
% #1: æ¡£ä½ç¼–å·(åŸºäºŽ1ï¼Œä»Žå·¦å‘å³è®¡æ•°)
% #2: æ¡£ä½æ•°å­—
\cs_new:Npn \__suanpan_assemble_rod:nn #1#2
  {
    \tl_set:Nn \l_tmpb_tl { #2 }
    % ç»˜åˆ¶
    \draw_scope_begin:
      % æ°´å¹³æ–¹å‘åç§»
      \draw_transform_xshift:n { \l__suanpan_support_d_dim * (#1 - 1) }

      % æ¡£æ†
      \draw_coffin_use:Nnnn \l__suanpan_support_coffin
        { hc } { vc } { 0pt, -\l__suanpan_support_y_offset_dim }

      % ç®—ç&nbsp;
      \int_compare:nNnTF { #2 } = { 0 }
        {
          % åˆ¤æ–­0å€¼ç©ºæ¡£ç®—ç&nbsp;æ˜¯å¦éœ€è¦ç»˜åˆ¶
          \bool_if:NT \l__suanpan_empty_rod_bool
            {
              % å–å¾—æ¡£ä½æ•°å­—å¯¹åº”ç®—ç&nbsp;ä½ç½®åŠå†…ç&nbsp;/å¤–ç&nbsp;ç¼–å·
              \prop_get:NnN \l__suanpan_rods_val_prop { #2 } \l_tmpa_tl
              \clist_clear:N \l__suanpan_bids_pos_clist
              \clist_set:NV \l__suanpan_bids_pos_clist \l_tmpa_tl

              \clist_map_inline:Nn \l__suanpan_bids_pos_clist
                {
                  \clist_set:Nn \l_tmpa_clist { ##1 }
                  \__suanpan_bid_layout:xx { \clist_item:Nn \l_tmpa_clist { 1 } }
                                           { \clist_item:Nn \l_tmpa_clist { 2 } }
                }
            }
        }{
          % ä¸æ˜¯0å€¼ç©ºæ¡£ç®—ç&nbsp;ï¼Œéœ€è¦ç»˜åˆ¶
          % å–å¾—æ¡£ä½æ•°å­—å¯¹åº”ç®—ç&nbsp;ä½ç½®åŠå†…ç&nbsp;/å¤–ç&nbsp;ç¼–å·
          \prop_get:NnN \l__suanpan_rods_val_prop { #2 } \l_tmpa_tl
          \clist_clear:N \l__suanpan_bids_pos_clist
          \clist_set:NV \l__suanpan_bids_pos_clist \l_tmpa_tl

          \clist_map_inline:Nn \l__suanpan_bids_pos_clist
            {
              \clist_set:Nn \l_tmpa_clist { ##1 }
              \__suanpan_bid_layout:xx { \clist_item:Nn \l_tmpa_clist { 1 } }
                                       { \clist_item:Nn \l_tmpa_clist { 2 } }
            }
        }
    \draw_scope_end:
  }

% æŒ‡å®šä¸€ä¸ªæ¡£ä½ä¸Šæµ®ç&nbsp;çš„é¢œè‰²
% #1: æ¡£ä½ç¼–å·(ä»Žå·¦å‘å³)
% #2: ç®—ç&nbsp;ä½ç½®([1, 11])
\cs_new:Npn \__suanpan_float_bid:nn #1#2
  {
    \draw_scope_begin:
      % æ°´å¹³åç§»
      \draw_transform_xshift:n { \l__suanpan_support_d_dim * ( #1 - 1 ) }

      % è¦†ç›–ç»˜åˆ¶
      \__suanpan_bid_layout:xx { #2 }{ 2 }
    \draw_scope_end:
  }

% ä¸ºä¸€ä¸ªæ¡£ä½æ·»åŠ&nbsp;è®¡æ•°æ&nbsp;‡è®°
% #1: æ¡£ä½ç¼–å·(åŸºäºŽ1ï¼Œä»Žå·¦å‘å³)
% #2: æ&nbsp;‡è®°å†…å®¹
\cs_new:Npn \__suanpan_rod_mark:nn #1#2
  {
    \hcoffin_set:Nn \l_tmpa_coffin
      {
        \begin{tikzpicture}
          \node at ( 0, 0 ) [font=\l__suanpan_mark_font_tl] { #2 };
        \end{tikzpicture}
      }

    \draw_scope_begin:
      % æ°´å¹³åç§»
      \draw_transform_xshift:n { \l__suanpan_support_d_dim * ( #1 - 1 ) }
      \draw_coffin_use:Nnn \l_tmpa_coffin { hc } { vc }
    \draw_scope_end:
  }

% ç»˜åˆ¶è¾¹æ¡†
% #1 ç¬¬ä¸€æ¡£ç¼–å·(å·¦)
% #2 æœ€åŽä¸€æ¡£ç¼–å·(å³)
\cs_new:Npn \__suanpan_frame_layout:nn #1#2
  {
    % TikZç»˜åˆ¶æ&nbsp;·å¼
    \tikzset{%
      hframe/.style = {% ä¸Šä¸‹æ¢
        bottom~color = framecolor!95,
        top~color    = framecolor!95,
        middle~color = framecolor!15,
        draw         = framecolor,
        line~width   = \l__suanpan_frame_inner_linewidth_dim,
      },
      vframe/.style = {% å·¦å³æ¢
        left~color   = framecolor!95,
        right~color  = framecolor!95,
        middle~color = framecolor!15,
        draw         = framecolor,
        line~width   = \l__suanpan_frame_inner_linewidth_dim,
      },
      mframe/.style = {% æ¨ªæ¢
        top~color    = framecolor!60,
        bottom~color = framecolor!60,
        middle~color = framecolor!5,
        line~width   = \l__suanpan_frame_inner_linewidth_dim,
      },
      frameline/.style = {% æ¢è¿žçº¿
        draw       = framecolor,
        line~width = \l__suanpan_frame_inner_linewidth_dim,
      },
      framefill/.style = {% å¤–æ¡†å¡«å……
        draw       = framecolor,
        fill       = framecolor,
        line~width = \l__suanpan_frame_inner_linewidth_dim,
      },
      arcline/.style = {% è½¬è§’çº¿
        draw            = framecolor,
        line~width      = \l__suanpan_frame_inner_linewidth_dim,
        rounded~corners = \l__suanpan_frame_inner_linewidth_dim / 2,
      },
    }

    % æ€»å®½åº¦
    \dim_set:Nn \l_tmpa_dim {
       \fp_to_dim:n {
           \fp_eval:n { \l__suanpan_support_d_dim * ( #2 - #1 + 1.0) }
         }
     }
    % å‡åŠæ¡£å®½åº¦
    \dim_set:Nn \l_tmpb_dim {
       \fp_to_dim:n {
           \fp_eval:n { \l__suanpan_support_d_dim * ( #2 - #1 ) +
                        \l__suanpan_support_d_half_dim}
         }
     }

    \group_begin:
      % ä¸Šä¸‹è¾¹æ¡†åŸºç¡€å®¹å™¨(ç›’å­)
      \hcoffin_set:Nn \l_tmpa_coffin
        {
          % åˆ¤æ–­æ˜¯å¦ä¸ºè‰ç¨¿æ¨¡å¼
          \bool_if:NTF \l__suanpan_draft_bool
            {
              \begin{tikzpicture}
                \draw[framefill]
                    ( 0pt, 0pt ) --
                  ++( \l_tmpa_dim, 0) --
                  ++( \l__suanpan_frame_b_dim, \l__suanpan_frame_b_dim ) --
                  ++( -\l__suanpan_frame_b_dim, 0 ) --
                  ++( -\l_tmpa_dim, 0 ) --
                  ++( -\l__suanpan_frame_b_dim, 0 ) --
                  cycle;
              \end{tikzpicture}
            }{
              \begin{tikzpicture}
                \shadedraw[hframe]
                    ( 0pt, 0pt ) --
                  ++( \l_tmpa_dim, 0) --
                  ++( \l__suanpan_frame_b_dim, \l__suanpan_frame_b_dim ) --
                  ++( -\l__suanpan_frame_b_dim, 0 ) --
                  ++( -\l_tmpa_dim, 0 ) --
                  ++( -\l__suanpan_frame_b_dim, 0 ) --
                  cycle;
              \end{tikzpicture}
            }
        }

      % å·¦å³è¾¹æ¡†åŸºç¡€å®¹å™¨(ç›’å­)
      \hcoffin_set:Nn \l_tmpb_coffin
        {
          % åˆ¤æ–­æ˜¯å¦ä¸ºè‰ç¨¿æ¨¡å¼
          \bool_if:NTF \l__suanpan_draft_bool
            {
              \begin{tikzpicture}
                \draw[framefill]
                    ( 0, 0 ) --
                  ++( 0, \l__suanpan_frame_inner_h_dim) --
                  ++( -\l__suanpan_frame_b_dim, \l__suanpan_frame_b_dim ) --
                  ++( 0, -\l__suanpan_frame_outer_h_dim ) --
                  cycle;
                \draw[arcline]
                    ( 0, 0 )
                  ++( 0,  \l__suanpan_frame_inner_h_dim )
                  ++( 0,  \l__suanpan_frame_b_dim )
                  ++( 0,  \l__suanpan_frame_inner_linewidth_dim * 0.9 )
                  ++( -\l__suanpan_frame_b_half_dim, 0 ) --
                  ++( -\l__suanpan_frame_b_half_dim, 0 ) --
                  ++( -\l__suanpan_frame_inner_linewidth_dim * 0.9, 0 ) --
                  ++( 0, -\l__suanpan_frame_b_half_dim );
                \draw[arcline]
                    ( 0, 0 )
                  ++( 0, -\l__suanpan_frame_b_dim )
                  ++( 0, -\l__suanpan_frame_inner_linewidth_dim * 0.9 )
                  ++( -\l__suanpan_frame_b_half_dim, 0 ) --
                  ++( -\l__suanpan_frame_b_half_dim, 0 ) --
                  ++( -\l__suanpan_frame_inner_linewidth_dim * 0.9, 0 ) --
                  ++( 0, \l__suanpan_frame_b_half_dim );
              \end{tikzpicture}
            }{
              \begin{tikzpicture}
                \shadedraw[vframe]
                    ( 0, 0 ) --
                  ++( 0, \l__suanpan_frame_inner_h_dim) --
                  ++( -\l__suanpan_frame_b_dim, \l__suanpan_frame_b_dim ) --
                  ++( 0, -\l__suanpan_frame_outer_h_dim ) --
                  cycle;
                \draw[arcline]
                    ( 0, 0 )
                  ++( 0,  \l__suanpan_frame_inner_h_dim )
                  ++( 0,  \l__suanpan_frame_b_dim )
                  ++( 0,  \l__suanpan_frame_inner_linewidth_dim * 0.9 )
                  ++( -\l__suanpan_frame_b_half_dim, 0 ) --
                  ++( -\l__suanpan_frame_b_half_dim, 0 ) --
                  ++( -\l__suanpan_frame_inner_linewidth_dim * 0.9, 0 ) --
                  ++( 0, -\l__suanpan_frame_b_half_dim );
                \draw[arcline]
                    ( 0, 0 )
                  ++( 0, -\l__suanpan_frame_b_dim )
                  ++( 0, -\l__suanpan_frame_inner_linewidth_dim * 0.9 )
                  ++( -\l__suanpan_frame_b_half_dim, 0 ) --
                  ++( -\l__suanpan_frame_b_half_dim, 0 ) --
                  ++( -\l__suanpan_frame_inner_linewidth_dim * 0.9, 0 ) --
                  ++( 0, \l__suanpan_frame_b_half_dim );
              \end{tikzpicture}
            }
        }

      % æ¨ªæ¢æŽ¥å¤´åŸºç¡€å®¹å™¨(ç›’å­)
      \hcoffin_set:Nn \l_tmpc_coffin
        {
          % åˆ¤æ–­æ˜¯å¦ä¸ºè‰ç¨¿æ¨¡å¼
          \bool_if:NTF \l__suanpan_draft_bool
            {
              \begin{tikzpicture}
                \fill[fill=white,
                      line~width=\l__suanpan_frame_inner_linewidth_dim]
                  ( 0pt, 0pt ) --++( 0, \l__suanpan_frame_b_dim) --
                  ++(-\l__suanpan_frame_inner_linewidth_dim, 0) --
                  ++(-\l__suanpan_frame_b_dim / 3, -\l__suanpan_frame_b_dim / 2) --
                  ++( \l__suanpan_frame_b_dim / 3, -\l__suanpan_frame_b_dim / 2) --
                  cycle;
                \draw[frameline]%
                  ( 0, \l__suanpan_frame_b_dim) --
                  ++(-\l__suanpan_frame_inner_linewidth_dim, 0) --
                  ++(-\l__suanpan_frame_b_dim / 3, -\l__suanpan_frame_b_dim / 2) --
                  ++( \l__suanpan_frame_b_dim / 3, -\l__suanpan_frame_b_dim / 2) --
                  ++( \l__suanpan_frame_inner_linewidth_dim, 0);
              \end{tikzpicture}
            }{
              \begin{tikzpicture}
                \shade[mframe]
                  ( 0pt, 0pt ) --++( 0, \l__suanpan_frame_b_dim) --
                  ++(-\l__suanpan_frame_inner_linewidth_dim, 0) --
                  ++(-\l__suanpan_frame_b_dim / 3, -\l__suanpan_frame_b_dim / 2) --
                  ++( \l__suanpan_frame_b_dim / 3, -\l__suanpan_frame_b_dim / 2) --
                  cycle;
                \draw[frameline]%
                  ( 0, \l__suanpan_frame_b_dim) --
                  ++(-\l__suanpan_frame_inner_linewidth_dim, 0) --
                  ++(-\l__suanpan_frame_b_dim / 3, -\l__suanpan_frame_b_dim / 2) --
                  ++( \l__suanpan_frame_b_dim / 3, -\l__suanpan_frame_b_dim / 2) --
                  ++( \l__suanpan_frame_inner_linewidth_dim, 0);
              \end{tikzpicture}
            }
        }

    % å¸ƒç½®ä¸Šè¾¹æ¡†
    \draw_scope_begin:
      \draw_transform_xshift:n { -\l__suanpan_support_d_half_dim -
                                  \l__suanpan_frame_inner_linewidth_dim / 2 }
      \draw_transform_yshift:n { \l__suanpan_frame_inner_upper_dim -
                                 \l__suanpan_frame_inner_linewidth_dim }
      \draw_coffin_use:Nnnn \l_tmpa_coffin { l } { b }
                         { -\l__suanpan_frame_b_dim, 0pt }
    \draw_scope_end:

    % å¸ƒç½®ä¸‹è¾¹æ¡†
    \draw_scope_begin:
      \coffin_rotate:Nn \l_tmpa_coffin { 180 }
      \draw_transform_xshift:n { \l_tmpa_dim - \l__suanpan_support_d_half_dim +
                                 \l__suanpan_frame_inner_linewidth_dim / 2 }

      \draw_transform_yshift:n { \l__suanpan_frame_inner_lower_dim +
                                 \l__suanpan_frame_inner_linewidth_dim }
      \draw_coffin_use:Nnnn \l_tmpa_coffin { l } { b }
                          { \l__suanpan_frame_b_dim, 0pt }
    \draw_scope_end:

    % å¸ƒç½®å·¦è¾¹æ¡†
    \draw_scope_begin:
      \draw_transform_xshift:n { -\l__suanpan_support_d_half_dim -
                                  \l__suanpan_frame_b_dim -
                                  \l__suanpan_frame_inner_linewidth_dim * 1.5 }
      \draw_transform_yshift:n { \l__suanpan_frame_inner_lower_dim -
                                  \l__suanpan_frame_inner_linewidth_dim }

      \draw_coffin_use:Nnnn \l_tmpb_coffin { l } { b }
                          { 0pt, -\l__suanpan_frame_b_dim }
    \draw_scope_end:

    % å¸ƒç½®å³è¾¹æ¡†
    \draw_scope_begin:
      \coffin_rotate:Nn \l_tmpb_coffin { 180 }
      \draw_transform_xshift:n { \l_tmpb_dim +
                                 \l__suanpan_frame_b_dim +
                                 \l__suanpan_frame_inner_linewidth_dim * 1.5}% -
      \draw_transform_yshift:n { \l__suanpan_frame_inner_upper_dim +
                                 \l__suanpan_frame_inner_linewidth_dim }
      \draw_coffin_use:Nnnn \l_tmpb_coffin { l } { b }
                          { 0pt, \l__suanpan_frame_b_dim }
    \draw_scope_end:

    % å¸ƒç½®å·¦æ¨ªæ¢æŽ¥å¤´
    \draw_scope_begin:
      \draw_transform_xshift:n { -\l__suanpan_support_d_half_dim -
                                  \l__suanpan_frame_b_dim / 3 -
                                  \l__suanpan_frame_inner_linewidth_dim / 2 }
      \draw_transform_yshift:n { -\l__suanpan_frame_b_dim / 2 -
                                  \l__suanpan_frame_inner_linewidth_dim / 2 }
      \draw_coffin_use:Nnnn \l_tmpc_coffin { l } { b } { 0pt, 0pt }
    \draw_scope_end:

    % å¸ƒç½®å³æ¨ªæ¢æŽ¥å¤´
    \draw_scope_begin:
      \coffin_rotate:Nn \l_tmpc_coffin { 180 }
      \draw_transform_xshift:n { \l_tmpb_dim +
                                 \l__suanpan_frame_b_dim / 3 +
                                 \l__suanpan_frame_inner_linewidth_dim / 2 }
      \draw_transform_yshift:n { \l__suanpan_frame_b_dim / 2 +
                                 \l__suanpan_frame_inner_linewidth_dim / 2 }
      \draw_coffin_use:Nnnn \l_tmpc_coffin { l } { b } { 0pt, 0pt }
    \draw_scope_end:
    \group_end:
  }

% ç®—ç›˜æŽ’ç‰ˆç”¨æˆ·æŽ¥å£
% ç®—ç›˜æŽ’ç‰ˆçŽ¯å¢ƒ
% #1 suanpançŽ¯å¢ƒé€‰é¡¹
% #2 suanpançŽ¯å¢ƒå†…å®¹(!bå‚æ•°)
\NewDocumentEnvironment{ suanpan }{ o !b }
  {
    \group_begin:
      % è®¾ç½®é€‰é¡¹
      \IfNoValueF{ #1 }
        {
          \keys_set:nn { suanpan }{ #1 }
        }

      % æž„é€&nbsp;åŸºç¡€å®¹å™¨(ç›’å­)
      \__suanpan_inner_bid_construct:
      \__suanpan_outer_bid_construct:
      \__suanpan_support_construct:

      % åˆ&nbsp;é™¤#2(!b)å‚æ•°å–å¾—çš„çŽ¯å¢ƒå†…å®¹ä¸­çš„ç©ºç™½
      \str_set:Nn \l_tmpa_str { #2 }
      \str_remove_all:Nn \l_tmpa_str {~}
      % å°†strè¿˜åŽŸä¸ºtl
      \tl_set_rescan:Nno \l_tmpa_tl {}{ \l_tmpa_str }

      % åœ¨å®¹å™¨(ç›’å­)ä¸­ç”¨#2(!b)å‚æ•°å–å¾—çš„æŒ‰çŽ¯å¢ƒå†…å®¹å®žçŽ°ç»˜åˆ¶
      \hcoffin_set:Nn \l_tmpa_coffin
        {
          \draw_begin:
            \l_tmpa_tl
          \draw_end:
        }

      \hcoffin_set:Nn \l_tmpb_coffin
        {
          % å°†åŽŸå›¾ç¼©å°50%
          \coffin_scale:Nnn \l_tmpa_coffin { 0.50 } { 0.50 }
          \coffin_typeset:Nnnnn \l_tmpa_coffin{ l }{ b }{ 0pt }{ 0pt }
        }
  }{
      % æŒ‰ç”¨æˆ·æŒ‡å®šæ¯”ä¾‹ç¼©æ”¾
      \coffin_scale:Nnn \l_tmpb_coffin
        { \l__suanpan_scale_tl } { \l__suanpan_scale_tl }

      % è®¾ç½®åŸºå­—ç¬¦ç›’å­(æŽ’ç‰ˆæ·±åº¦)
      \hbox_set:Nn \l_tmpa_box { x }
      % ç›’å­æ·±åº¦
      \dim_set:Nn \l_tmpa_dim { \box_dp:N \l_tmpa_box}

      % è¾“å‡ºç®—ç›˜å®¹å™¨(ç›’å­)
      \coffin_typeset:Nnnnn \l_tmpb_coffin{ l }{ b }{ 0pt }{ -\l_tmpa_dim }
      \int_zero:N \l__suanpan_rod_max_int
    \group_end:
  }

% æŽ’ç‰ˆç®—ç›˜ä¸€ä¸ªæ¡£ä½ï¼ŒåŒ…æ‹¬æ¡£æ†å’Œç®—ç&nbsp;
% #1 æ˜Ÿå·å‘½ä»¤ï¼Œç»˜åˆ¶è®¡ä½ç‚¹(é»‘è‰²åœ†ç‚¹)
% #2 æ¡£ä½ç¼–å·(åŸºäºŽ1ï¼Œä»Žå·¦å‘å³è®¡æ•°)
% #3 æœ¬æ¡£æ•°å­—(0-20ï¼Œ10-15éœ€ç”¨åˆ°é¡¶ç&nbsp;å’Œåº•ç&nbsp;ï¼Œ16-20éœ€è¦ç”¨åˆ°æ‚¬ç&nbsp;)
\NewDocumentCommand{ \rod }{ s m m }
  {
    % è®°å½•åŽŸçŠ¶æ€å˜é‡
    \bool_set_eq:NN \l_tmpa_bool \l__suanpan_support_unit_bool
    % æ˜Ÿå·å‘½ä»¤ï¼Œç”¨äºŽåœ¨æ¨ªæ¢ç»˜åˆ¶è®¡ä½ç‚¹
    \IfBooleanTF{#1}
      {
        \bool_set_true:N \l__suanpan_support_unit_bool
      }{
        \bool_set_false:N \l__suanpan_support_unit_bool
      }

    % å¦‚çŠ¶æ€å‘ç”Ÿæ”¹å˜ï¼Œåˆ™é‡æ–°ç»˜åˆ¶æ¡£æ†å•å…ƒ
    \bool_if:NTF \l_tmpa_bool
      {
        \bool_if:NF \l__suanpan_support_unit_bool
          {
            \__suanpan_support_construct:
          }
      }{
        \bool_if:NT \l__suanpan_support_unit_bool
          {
            \__suanpan_support_construct:
          }
      }

    % ç»„è£…ä¸€ä¸ªæ¡£ä½
    \__suanpan_assemble_rod:nn { #2 }{ #3 }

    % ç»Ÿè®¡æ¡£ä½æ€»æ•°
    \int_set:Nn \l__suanpan_rod_max_int
      { \int_max:nn { \l__suanpan_rod_max_int }{ #2 } }
  }

% æŽ’ç‰ˆç®—ç›˜å¤šä¸ªæ¡£ä½ï¼ŒåŒ…æ‹¬æ¡£æ†å’Œç®—ç&nbsp;
% #1 æœ¬æ¡£æ•°å­—(0-20ï¼Œ10-15éœ€ç”¨åˆ°é¡¶ç&nbsp;å’Œåº•ç&nbsp;ï¼Œ16-20éœ€è¦ç”¨åˆ°æ‚¬ç&nbsp;)
%    å„æ•°å­—ä¹‹é—´éœ€è¦ç”¨é€—å·åˆ†éš”ã€‚
\NewDocumentCommand{ \rods }{ m }
  {
    % æž„é€&nbsp;æ¡£ä½æ•°å­—åˆ—è¡¨
    \clist_set:Nn \l_tmpa_clist { #1 }
    % åˆå§‹åŒ–æ¡£ä½è®¡æ•°å™¨
    \int_set:Nn \l_tmpa_int { 0 }

    \clist_map_inline:Nn \l_tmpa_clist
      {
        % æ¡£ä½è®¡æ•°å™¨è‡ªå¢ž1
        \int_incr:N \l_tmpa_int

        % ç»„è£…å½“å‰æ¡£ä½
        \__suanpan_assemble_rod:nn {\l_tmpa_int }{ ##1 }
      }

    % è®°å½•æ¡£ä½æ€»æ•°
    \int_set:Nn \l__suanpan_rod_max_int
      { \int_max:nn { \l__suanpan_rod_max_int }{ \l_tmpa_int } }
  }

% æŒ‡å®šæŸæ¡£ä¸ŠæŸä¸ªç®—ç&nbsp;çš„é¢œè‰²
% #1 æ¡£ä½(åŸºäºŽ1ï¼Œä»Žå·¦å‘å³è®¡æ•°)
% #2 ç®—ç&nbsp;ä½ç½®åˆ—è¡¨(1--11ï¼Œ11ä¸ºæ‚¬ç&nbsp;ä½ç½®)
% #3 ç®—ç&nbsp;å¡«å……é¢œè‰²
% #4 ç®—ç&nbsp;ç»˜åˆ¶é¢œè‰²(é»˜è®¤ä¸ºå†…ç&nbsp;ç»˜åˆ¶é¢œè‰²)
\NewDocumentCommand{ \bid }{ m m m O{innerdrawcolor} }
  {
    % æž„é€&nbsp;æµ®ç&nbsp;
    \__suanpan_float_bid_construct:nn { #4 }{ #3 }

    % æž„é€&nbsp;ç®—ç&nbsp;ä½ç½®åˆ—è¡¨
    \clist_set:Nn \l_tmpa_clist { #2 }

    \clist_map_inline:Nn \l_tmpa_clist
      {
        % ç»˜åˆ¶æµ®ç&nbsp;
        \__suanpan_float_bid:nn { #1 }{ ##1 }
      }
  }

% æŒ‡å®šæŸæ¡£ä¸Šæ‰€æœ‰å†…ç&nbsp;æˆ–å¤–ç&nbsp;çš„é¢œè‰²
% #1 æ˜Ÿå·å‘½ä»¤ï¼Œé€‰æ‹©å†…ç&nbsp;æˆ–å¤–ç&nbsp;
% #2 æ¡£ä½(åŸºäºŽ1ï¼Œä»Žå·¦å‘å³è®¡æ•°)
% #3 è¯¥æ¡£æ•°å­—
% #4 ç®—ç&nbsp;å¡«å……é¢œè‰²(ç»˜å›¾é¢œè‰²é‡‡ç”¨åŽŸå†…/å¤–ç&nbsp;ç»˜åˆ¶é¢œè‰²)
\NewDocumentCommand{ \bids }{ s m m m }
  {
    % å–å¾—æ¡£ä½æ•°å­—å¯¹åº”ç®—ç&nbsp;ä½ç½®åŠå†…ç&nbsp;/å¤–ç&nbsp;ç¼–å·
    \prop_get:NnN \l__suanpan_rods_val_prop { #3 } \l_tmpa_tl
    \clist_clear:N \l__suanpan_bids_pos_clist
    \clist_set:NV \l__suanpan_bids_pos_clist \l_tmpa_tl

    % æ˜Ÿå·å‘½ä»¤ï¼Œç”¨äºŽé€‰æ‹©å¤–ç&nbsp;ç€è‰²
    \IfBooleanTF{#1}
      {
        % æž„é€&nbsp;æµ®ç&nbsp;
        \__suanpan_float_bid_construct:nn { outerdrawcolor }{ #4 }

        \clist_map_inline:Nn \l__suanpan_bids_pos_clist
          {
            \clist_set:Nn \l_tmpa_clist { ##1 }
            % é€‰æ‹©å¤–ç&nbsp;
            \int_compare:nNnT { \clist_item:Nn \l_tmpa_clist { 2 }  } = { 0 }
              {
                \__suanpan_float_bid:nn { #2 }{ \clist_item:Nn \l_tmpa_clist { 1 } }
              }
          }
      }{
        % æž„é€&nbsp;æµ®ç&nbsp;
        \__suanpan_float_bid_construct:nn { innerdrawcolor }{ #4 }

        \clist_map_inline:Nn \l__suanpan_bids_pos_clist
          {
            \clist_set:Nn \l_tmpa_clist { ##1 }
            % é€‰æ‹©å†…ç&nbsp;
            \int_compare:nNnT { \clist_item:Nn \l_tmpa_clist { 2 }  } = { 1 }
              {
                \__suanpan_float_bid:nn { #2 }{ \clist_item:Nn \l_tmpa_clist { 1 } }
              }
          }
      }
  }

% å·¦å³è¾¹æ¡†
\NewDocumentCommand{ \mkframe }{ }
  {
    \__suanpan_frame_layout:nn { 1 }{ \l__suanpan_rod_max_int }
  }

% ä¸ºå„æ¡£æ·»åŠ&nbsp;è®¡ä½æ&nbsp;‡è®°
% #1 èµ·å§‹æ¡£ä½(åŸºäºŽ1ï¼Œä»Žå·¦å‘å³è®¡æ•°)
% #2 æ&nbsp;‡è®°åˆ—è¡¨
\NewDocumentCommand{ \rodmark }{ O{1} m }
  {
    % æ&nbsp;‡è®°åˆ—è¡¨
    \clist_set:Nn \l_tmpa_clist { #2 }

    % è®¡æ•°å™¨
    \int_set:Nn \l_tmpa_int { #1 }

    % éåŽ†åˆ—è¡¨
    \clist_map_inline:Nn \l_tmpa_clist
      {
        % è¾“å‡ºæ&nbsp;‡è®°
        \__suanpan_rod_mark:nn { \l_tmpa_int }{ ##1 }

        % è°ƒæ•´è®¡æ•°å™¨
        \int_incr:N \l_tmpa_int

        % è¶…å‡ºæœ€å¤§æ¡£ä½
        \int_compare:nNnT { \l_tmpa_int } &gt; { \l__suanpan_rod_max_int }
          {
            \clist_map_break:
          }
      }
  }

% é€‰é¡¹è®¾ç½®ç”¨æˆ·æŽ¥å£
\NewDocumentCommand{ \suanpanset } { m }
  {
    \IfNoValueF { #1}
      {
        \keys_set:nn { suanpan } { #1 }
      }
  }

\endinput
</pre></body></html>