summaryrefslogtreecommitdiff
path: root/macros/latex/contrib/circledtext/circledtext.sty
diff options
context:
space:
mode:
Diffstat (limited to 'macros/latex/contrib/circledtext/circledtext.sty')
-rw-r--r--macros/latex/contrib/circledtext/circledtext.sty324
1 files changed, 271 insertions, 53 deletions
diff --git a/macros/latex/contrib/circledtext/circledtext.sty b/macros/latex/contrib/circledtext/circledtext.sty
index f70b716814..47c62817e7 100644
--- a/macros/latex/contrib/circledtext/circledtext.sty
+++ b/macros/latex/contrib/circledtext/circledtext.sty
@@ -19,7 +19,7 @@
%%
\NeedsTeXFormat{LaTeX2e}[2020/10/01]
\RequirePackage{expl3}
-\ProvidesExplPackage{circledtext}{2022-04-28}{v1.1.0}
+\ProvidesExplPackage{circledtext}{2024-09-09}{v1.1.1}
{Typeset circled text with l3draw}
\RequirePackage { xtemplate, l3keys2e, l3draw, xparse }
@@ -187,18 +187,18 @@
% 正方形边长
\dim_compare:nNnTF \l_tmpa_dim > \l_tmpb_dim
{
- \dim_gset_eq:NN \l__circledtext_char_box_size_dim \l_tmpa_dim
+ \dim_set_eq:NN \l__circledtext_char_box_size_dim \l_tmpa_dim
}
{
- \dim_gset_eq:NN \l__circledtext_char_box_size_dim \l_tmpb_dim
+ \dim_set_eq:NN \l__circledtext_char_box_size_dim \l_tmpb_dim
}
% 设置基字符盒子正方形宽和高(相等)
- \dim_gset_eq:NN \charboxwd \l__circledtext_char_box_size_dim
- \dim_gset_eq:NN \charboxht \l__circledtext_char_box_size_dim
+ \dim_set_eq:NN \charboxwd \l__circledtext_char_box_size_dim
+ \dim_set_eq:NN \charboxht \l__circledtext_char_box_size_dim
% 外接圆半径
- \dim_gset:Nn \l__circledtext_char_box_radius_dim
+ \dim_set:Nn \l__circledtext_char_box_radius_dim
{
\fp_to_dim:n
{
@@ -244,6 +244,8 @@
% 类似\cs_new:cn __circledtext_char_box_construct_type_none:nnnnnn
\cs_new:cn { \__circledtext_char_box_type:n {#1} }
}
+\cs_generate_variant:Nn \__circledtext_new_char_box_construct:nn { V }
+\cs_generate_variant:Nn \__circledtext_new_char_box_construct:nn { x }
% 定义字符边框盒子类型
@@ -328,6 +330,105 @@
}
}
+% 无反色底层填充正方形
+\__circledtext_new_char_box_construct:nn { __lowerfilledsquare }
+ {
+ \draw_scope_begin:
+ \color_fill:n { lowerbgboxfill }
+ \draw_transform_shift:n { (#3-#3*#5)/2, (#4-#4*#6)/2 }
+ \draw_path_rectangle:nn { #1, #2 } { #3*#5, #4*#6 }
+ \draw_path_use_clear:n { fill }
+ \draw_scope_end:
+ }
+
+% 无反色上层填充正方形
+\__circledtext_new_char_box_construct:nn { __upperfilledsquare }
+ {
+ \draw_scope_begin:
+ \color_fill:n { upperbgboxfill }
+ \draw_transform_shift:n { (#3-#3*#5)/2, (#4-#4*#6)/2 }
+ \draw_path_rectangle:nn { #1, #2 } { #3*#5, #4*#6 }
+ \draw_path_use_clear:n { fill }
+ \draw_scope_end:
+ }
+
+% 无反色阴影填充正方形
+\__circledtext_new_char_box_construct:nn { __shadowfilledsquare }
+ {
+ \draw_scope_begin:
+ \color_fill:n { shadowboxfill }
+ \draw_transform_shift:n { (#3-#3*#5)/2 + \charboxwd * 0.1,
+ (#4-#4*#6)/2 - \charboxht * 0.1 }
+ \draw_path_rectangle:nn { #1, #2 } { #3*#5, #4*#6 }
+ \draw_path_use_clear:n { fill }
+ \draw_scope_end:
+ }
+
+% 无反色底层填充内切圆
+\__circledtext_new_char_box_construct:nn { __innerlowerfilledcircle }
+ {
+ \draw_scope_begin:
+ \color_fill:n { lowerbgboxfill }
+ \draw_path_circle:nn { #3/2, #4/2 } { #3*#5/2 }
+ \draw_path_use_clear:n { fill }
+ \draw_scope_end:
+ }
+
+% 无反色上层填充内切圆
+\__circledtext_new_char_box_construct:nn { __innerupperfilledcircle }
+ {
+ \draw_scope_begin:
+ \color_fill:n { upperbgboxfill }
+ \draw_path_circle:nn { #3/2, #4/2 } { #3*#5/2 }
+ \draw_path_use_clear:n { fill }
+ \draw_scope_end:
+ }
+
+% 无反色阴影填充内切圆
+\__circledtext_new_char_box_construct:nn { __innershadowfilledcircle }
+ {
+ \draw_scope_begin:
+ \color_fill:n { shadowboxfill }
+ \draw_transform_shift:n { \charboxwd*0.1, -\charboxht*0.1 }
+ \draw_path_circle:nn { #3/2, #4/2 } { #3*#5/2 }
+ \draw_path_use_clear:n { fill }
+ \draw_scope_end:
+ }
+
+% 无反色底层填充外接圆
+\__circledtext_new_char_box_construct:nn { __outerlowerfilledcircle }
+ {
+ \draw_scope_begin:
+ \color_fill:n { lowerbgboxfill }
+ \draw_path_circle:nn { #3/2, #4/2 }
+ { \l__circledtext_char_box_radius_dim*#5 }
+ \draw_path_use_clear:n { fill }
+ \draw_scope_end:
+ }
+
+% 无反色上层填充外接圆
+\__circledtext_new_char_box_construct:nn { __outerupperfilledcircle }
+ {
+ \draw_scope_begin:
+ \color_fill:n { upperbgboxfill }
+ \draw_path_circle:nn { #3/2, #4/2 }
+ { \l__circledtext_char_box_radius_dim*#5 }
+ \draw_path_use_clear:n { fill }
+ \draw_scope_end:
+ }
+
+% 无反色阴影填充外接圆
+\__circledtext_new_char_box_construct:nn { __outershadowfilledcircle }
+ {
+ \draw_scope_begin:
+ \color_fill:n { shadowboxfill }
+ \draw_transform_shift:n { \charboxwd*0.1, -\charboxht*0.1 }
+ \draw_path_circle:nn { #3/2, #4/2 }
+ { \l__circledtext_char_box_radius_dim*#5 }
+ \draw_path_use_clear:n { fill }
+ \draw_scope_end:
+ }
+
% 正方形边框
\__circledtext_new_char_box_construct:nn { __squarebox }
{
@@ -499,35 +600,47 @@
}
% 填充内切圆叠加正方形正十字线与内切圆边框
-\__circledtext_new_char_box_construct:nn { o+ }
+\clist_map_variable:nNn {o+,+o} \l_tmpa_tl
{
- \__circledtext_char_box_type_c:n { __innerfilledcircle } {#1} {#2} {#3} {#4} {#5} {#6}
- \__circledtext_char_box_type_c:n { __scross } {#1} {#2} {#3} {#4} {#5} {#6}
- \__circledtext_char_box_type_c:n { __innercirclebox } {#1} {#2} {#3} {#4} {#5} {#6}
+ \__circledtext_new_char_box_construct:Vn \l_tmpa_tl
+ {
+ \__circledtext_char_box_type_c:n { __innerfilledcircle } {#1} {#2} {#3} {#4} {#5} {#6}
+ \__circledtext_char_box_type_c:n { __scross } {#1} {#2} {#3} {#4} {#5} {#6}
+ \__circledtext_char_box_type_c:n { __innercirclebox } {#1} {#2} {#3} {#4} {#5} {#6}
+ }
}
% 填充内切圆叠加内切圆斜十字线与内切圆边框
-\__circledtext_new_char_box_construct:nn { ox }
+\clist_map_variable:nNn {ox,xo} \l_tmpa_tl
{
- \__circledtext_char_box_type_c:n { __innerfilledcircle } {#1} {#2} {#3} {#4} {#5} {#6}
- \__circledtext_char_box_type_c:n { __innerdcross } {#1} {#2} {#3} {#4} {#5} {#6}
- \__circledtext_char_box_type_c:n { __innercirclebox } {#1} {#2} {#3} {#4} {#5} {#6}
+ \__circledtext_new_char_box_construct:Vn \l_tmpa_tl
+ {
+ \__circledtext_char_box_type_c:n { __innerfilledcircle } {#1} {#2} {#3} {#4} {#5} {#6}
+ \__circledtext_char_box_type_c:n { __innerdcross } {#1} {#2} {#3} {#4} {#5} {#6}
+ \__circledtext_char_box_type_c:n { __innercirclebox } {#1} {#2} {#3} {#4} {#5} {#6}
+ }
}
% 填充内切圆叠加内切圆正斜十字线与内切圆边框
-\__circledtext_new_char_box_construct:nn { ox+ }
+\clist_map_variable:nNn {ox+,o+x,xo+,x+o,+ox,+xo} \l_tmpa_tl
{
- \__circledtext_char_box_type_c:n { __innerfilledcircle } {#1} {#2} {#3} {#4} {#5} {#6}
- \__circledtext_char_box_type_c:n { __innerdcross } {#1} {#2} {#3} {#4} {#5} {#6}
- \__circledtext_char_box_type_c:n { __scross } {#1} {#2} {#3} {#4} {#5} {#6}
- \__circledtext_char_box_type_c:n { __innercirclebox } {#1} {#2} {#3} {#4} {#5} {#6}
+ \__circledtext_new_char_box_construct:Vn \l_tmpa_tl
+ {
+ \__circledtext_char_box_type_c:n { __innerfilledcircle } {#1} {#2} {#3} {#4} {#5} {#6}
+ \__circledtext_char_box_type_c:n { __innerdcross } {#1} {#2} {#3} {#4} {#5} {#6}
+ \__circledtext_char_box_type_c:n { __scross } {#1} {#2} {#3} {#4} {#5} {#6}
+ \__circledtext_char_box_type_c:n { __innercirclebox } {#1} {#2} {#3} {#4} {#5} {#6}
+ }
}
% 内切圆斜十字线叠加正十字线
-\__circledtext_new_char_box_construct:nn { x+ }
+\clist_map_variable:nNn {x+,+x} \l_tmpa_tl
{
- \__circledtext_char_box_type_c:n { __innerdcross } {#1} {#2} {#3} {#4} {#5} {#6}
- \__circledtext_char_box_type_c:n { __scross } {#1} {#2} {#3} {#4} {#5} {#6}
+ \__circledtext_new_char_box_construct:Vn \l_tmpa_tl
+ {
+ \__circledtext_char_box_type_c:n { __innerdcross } {#1} {#2} {#3} {#4} {#5} {#6}
+ \__circledtext_char_box_type_c:n { __scross } {#1} {#2} {#3} {#4} {#5} {#6}
+ }
}
% 填充正方形叠加正方形边框
@@ -538,35 +651,47 @@
}
% 填充正方形叠加正方形正十字线与正方形边框
-\__circledtext_new_char_box_construct:nn { O+ }
+\clist_map_variable:nNn {O+,+O} \l_tmpa_tl
{
- \__circledtext_char_box_type_c:n { __filledsquare } {#1} {#2} {#3} {#4} {#5} {#6}
- \__circledtext_char_box_type_c:n { __scross } {#1} {#2} {#3} {#4} {#5} {#6}
- \__circledtext_char_box_type_c:n { __squarebox } {#1} {#2} {#3} {#4} {#5} {#6}
+ \__circledtext_new_char_box_construct:Vn \l_tmpa_tl
+ {
+ \__circledtext_char_box_type_c:n { __filledsquare } {#1} {#2} {#3} {#4} {#5} {#6}
+ \__circledtext_char_box_type_c:n { __scross } {#1} {#2} {#3} {#4} {#5} {#6}
+ \__circledtext_char_box_type_c:n { __squarebox } {#1} {#2} {#3} {#4} {#5} {#6}
+ }
}
% 填充正方形叠加正方形斜十字线与正方形边框
-\__circledtext_new_char_box_construct:nn { OX }
+\clist_map_variable:nNn {OX,XO} \l_tmpa_tl
{
- \__circledtext_char_box_type_c:n { __filledsquare } {#1} {#2} {#3} {#4} {#5} {#6}
- \__circledtext_char_box_type_c:n { __dcross } {#1} {#2} {#3} {#4} {#5} {#6}
- \__circledtext_char_box_type_c:n { __squarebox } {#1} {#2} {#3} {#4} {#5} {#6}
+ \__circledtext_new_char_box_construct:Vn \l_tmpa_tl
+ {
+ \__circledtext_char_box_type_c:n { __filledsquare } {#1} {#2} {#3} {#4} {#5} {#6}
+ \__circledtext_char_box_type_c:n { __dcross } {#1} {#2} {#3} {#4} {#5} {#6}
+ \__circledtext_char_box_type_c:n { __squarebox } {#1} {#2} {#3} {#4} {#5} {#6}
+ }
}
% 填充正方形叠加正方形斜正十字线与正方形边框
-\__circledtext_new_char_box_construct:nn { OX+ }
+\clist_map_variable:nNn {OX+,O+X,XO+,X+O,+OX,+XO} \l_tmpa_tl
{
- \__circledtext_char_box_type_c:n { __filledsquare } {#1} {#2} {#3} {#4} {#5} {#6}
- \__circledtext_char_box_type_c:n { __dcross } {#1} {#2} {#3} {#4} {#5} {#6}
- \__circledtext_char_box_type_c:n { __scross } {#1} {#2} {#3} {#4} {#5} {#6}
- \__circledtext_char_box_type_c:n { __squarebox } {#1} {#2} {#3} {#4} {#5} {#6}
+ \__circledtext_new_char_box_construct:Vn \l_tmpa_tl
+ {
+ \__circledtext_char_box_type_c:n { __filledsquare } {#1} {#2} {#3} {#4} {#5} {#6}
+ \__circledtext_char_box_type_c:n { __dcross } {#1} {#2} {#3} {#4} {#5} {#6}
+ \__circledtext_char_box_type_c:n { __scross } {#1} {#2} {#3} {#4} {#5} {#6}
+ \__circledtext_char_box_type_c:n { __squarebox } {#1} {#2} {#3} {#4} {#5} {#6}
+ }
}
% 正方形斜十字线叠加正十字线
-\__circledtext_new_char_box_construct:nn { X+ }
+\clist_map_variable:nNn {X+,+X} \l_tmpa_tl
{
- \__circledtext_char_box_type_c:n { __dcross } {#1} {#2} {#3} {#4} {#5} {#6}
- \__circledtext_char_box_type_c:n { __scross } {#1} {#2} {#3} {#4} {#5} {#6}
+ \__circledtext_new_char_box_construct:Vn \l_tmpa_tl
+ {
+ \__circledtext_char_box_type_c:n { __dcross } {#1} {#2} {#3} {#4} {#5} {#6}
+ \__circledtext_char_box_type_c:n { __scross } {#1} {#2} {#3} {#4} {#5} {#6}
+ }
}
% 内切圆叠加同心82%内切圆边框
@@ -578,11 +703,14 @@
}
% 反色正方形叠加内切填充圆
-\__circledtext_new_char_box_construct:nn { Oo }
+\clist_map_variable:nNn {Oo,oO} \l_tmpa_tl
{
- \__circledtext_char_box_type_c:n { __negfilledsquare } {#1} {#2} {#3} {#4} {#5} {#6}
- \__circledtext_char_box_type_c:n { __innerfilledcircle } {#1} {#2} {#3} {#4} {#5} {#6}
- \__circledtext_char_box_type_c:n { __squarebox } {#1} {#2} {#3} {#4} {#5} {#6}
+ \__circledtext_new_char_box_construct:Vn \l_tmpa_tl
+ {
+ \__circledtext_char_box_type_c:n { __negfilledsquare } {#1} {#2} {#3} {#4} {#5} {#6}
+ \__circledtext_char_box_type_c:n { __innerfilledcircle } {#1} {#2} {#3} {#4} {#5} {#6}
+ \__circledtext_char_box_type_c:n { __squarebox } {#1} {#2} {#3} {#4} {#5} {#6}
+ }
}
% 正方形叠加同心82%正方形边框
@@ -592,6 +720,53 @@
\__circledtext_char_box_type_c:n { __squarebox } {#1} {#2} {#3} {#4} {#5} {#6}
\__circledtext_char_box_type_c:n { __squarebox } {#1} {#2} {#3} {#4} {0.82} {0.82}
}
+
+% 3同心圆叠加(类似中国象棋棋子形状)
+\__circledtext_new_char_box_construct:nn { ooo }
+ {
+ % 绘制填充外接圆阴影
+ \__circledtext_char_box_type_c:n { __outershadowfilledcircle }
+ {#1} {#2} {#3} {#4} {1.0} {1.0}
+ % 绘制填充外接圆外圈背景
+ \__circledtext_char_box_type_c:n { __outerlowerfilledcircle }
+ {#1} {#2} {#3} {#4} {#5} {#6}
+ % 绘制填充外接边环背景
+ \__circledtext_char_box_type_c:n { __outerupperfilledcircle }
+ {#1} {#2} {#3} {#4} {0.88} {0.88}
+ % 绘制填充外接圆内圈背景
+ \__circledtext_char_box_type_c:n { __outerlowerfilledcircle }
+ {#1} {#2} {#3} {#4} {0.72} {0.72}
+ % 绘制双边刻环线
+ \__circledtext_char_box_type_c:n { __outercirclebox }
+ {#1} {#2} {#3} {#4} {0.88} {0.88}
+ \__circledtext_char_box_type_c:n { __outercirclebox }
+ {#1} {#2} {#3} {#4} {0.72} {0.72}
+
+ }
+
+% 3同心正方形叠加
+\__circledtext_new_char_box_construct:nn { OOO }
+ {
+ % 绘制填充正方形阴影
+ \__circledtext_char_box_type_c:n { __shadowfilledsquare }
+ {#1} {#2} {#3} {#4} {1.0} {1.0}
+ % 绘制填充正方形外圈背景
+ \__circledtext_char_box_type_c:n { __lowerfilledsquare}
+ {#1} {#2} {#3} {#4} {#5} {#6}
+ % 绘制填充正方形边环背景
+ \__circledtext_char_box_type_c:n { __upperfilledsquare}
+ {#1} {#2} {#3} {#4} {0.88} {0.88}
+ % 绘制填充正方形内圈背景
+ \__circledtext_char_box_type_c:n { __lowerfilledsquare}
+ {#1} {#2} {#3} {#4} {0.72} {0.72}
+ % 绘制双边刻环线
+ \__circledtext_char_box_type_c:n { __squarebox }
+ {#1} {#2} {#3} {#4} {0.88} {0.88}
+ \__circledtext_char_box_type_c:n { __squarebox }
+ {#1} {#2} {#3} {#4} {0.72} {0.72}
+
+ }
+
\msg_new:nnn { circledtext } { box-exists } { The~ box~ type~ `#1~ not~ exists. }
% 缩放类型名称生成函数
@@ -874,6 +1049,49 @@
\cs_set_nopar:Npn \__circledtext_aux_color_boxfill:
{ \color_fill:nn #1 }
} ,
+
+ % 无反色时底层盒子背景填充颜色
+ lowerbgcolor .code:n = { \exp_args:Nx \tl_if_empty:nTF {#1}
+ {
+ \__circledtext_color_select:nn { lowerbgboxfill }
+ { yellow!70!red }
+ \cs_set_nopar:Npn \__circledtext_aux_color_boxfill:
+ { \color_fill:n { yellow!70!red } }
+ }{ \__circledtext_color_select:nn { lowerbgboxfill } { #1 }
+ \cs_set_nopar:Npn \__circledtext_aux_color_boxfill:
+ { \color_fill:n { #1 } }
+ }
+ } ,
+ lowerbgcolor .initial:n = {} ,
+
+ % 无反色时上层盒子背景填充颜色
+ upperbgcolor .code:n = { \exp_args:Nx \tl_if_empty:nTF {#1}
+ {
+ \__circledtext_color_select:nn { upperbgboxfill }
+ { yellow!80!black }
+ \cs_set_nopar:Npn \__circledtext_aux_color_boxfill:
+ { \color_fill:n { yellow!80!black } }
+ }{ \__circledtext_color_select:nn { upperbgboxfill } { #1 }
+ \cs_set_nopar:Npn \__circledtext_aux_color_boxfill:
+ { \color_fill:n { #1 } }
+ }
+ } ,
+ upperbgcolor .initial:n = {} ,
+
+ % 盒子阴影填充颜色
+ shadowcolor .code:n = { \exp_args:Nx \tl_if_empty:nTF {#1}
+ {
+ \__circledtext_color_select:nn { shadowboxfill }
+ { black!35!white }
+ \cs_set_nopar:Npn \__circledtext_aux_color_boxfill:
+ { \color_fill:n { black!35!white } }
+ }{ \__circledtext_color_select:nn { shadowboxfill } { #1 }
+ \cs_set_nopar:Npn \__circledtext_aux_color_boxfill:
+ { \color_fill:n { #1 } }
+ }
+ } ,
+ shadowcolor .initial:n = {} ,
+
% 笔画参数
charstroke .choice:,
charstroke .value_required:n = true,
@@ -965,17 +1183,17 @@
% 复制盒子准备缩放与输出
\coffin_set_eq:NN \l__circledtext_box_coffin \l__circledtext_char_coffin
- % % 测量盒子容器总高度(用内切圆则不需要)
- % \dim_set:Nn \l_tmpa_dim
- % { \__circledtext_coffin_ht_plus_dp:N \l__circledtext_box_coffin }
- % % 缩放字符盒子容器到字符大小
- % \coffin_scale:Nnn \l__circledtext_box_coffin
- % {
- % \dim_ratio:nn { \charboxht } { \l_tmpa_dim }
- % }
- % {
- % \dim_ratio:nn { \charboxht } { \l_tmpa_dim }
- % }
+ % 测量盒子容器总高度(用内切圆则不需要)
+ \dim_set:Nn \l_tmpa_dim
+ { \__circledtext_coffin_ht_plus_dp:N \l__circledtext_box_coffin }
+ % 缩放字符盒子容器到字符大小
+ \coffin_scale:Nnn \l__circledtext_box_coffin
+ {
+ \dim_ratio:nn { \charboxht } { \l_tmpa_dim }
+ }
+ {
+ \dim_ratio:nn { \charboxht } { \l_tmpa_dim }
+ }
% 根据指定的方式缩放盒子
\__circledtext_resize_c:n { \l__circledtext_resize_method_tl }