From 870c8fd4b4b924970069c4c4e6cc82a1ecfff2b6 Mon Sep 17 00:00:00 2001 From: Ohachiyo <115810806+Ohachiyo@users.noreply.github.com> Date: Mon, 14 Sep 2026 07:04:20 +0800 Subject: [PATCH] Update moderncvskillmatrix.sty --- moderncvskillmatrix.sty | 66 ++++++++++++++++++++++++++++++++++------- 1 file changed, 55 insertions(+), 11 deletions(-) diff --git a/moderncvskillmatrix.sty b/moderncvskillmatrix.sty index 18c2450..2b1fced 100644 --- a/moderncvskillmatrix.sty +++ b/moderncvskillmatrix.sty @@ -219,8 +219,11 @@ \DeclareOption{moderncvbodyv}{\@moderncvbodyifalse\@moderncvbodyiifalse\@moderncvbodyiiifalse\@moderncvbodyivfalse\@moderncvbodyvtrue} % If option `circle` is specified, use circles instead of small rectangles for rating skills +% If option `halfcircle` is specified, allows for half-filled circles \@initializeif{\if@cvskillcircle}\@cvskillcirclefalse +\@initializeif{\if@cvskillhalfcircle}\@cvskillhalfcirclefalse \DeclareOption{circle}{\@cvskillcircletrue} +\DeclareOption{halfcircle}{\@cvskillhalfcircletrue} \DeclareOption*{}% avoid choking on unknown options \ExecuteOptions{moderncvbodyi} @@ -239,15 +242,30 @@ % %------------------------------------------------------------------------------- % The code for the Skilllevel illustration with the little boxes. % This is idea stolen from the limecv package, see https://github.com/opieters/limecv.git + \@initializelength{\cvSkill@ShapeSize} \if@cvskillcircle% - \setlength{\cvSkill@ShapeSize}{.7ex}% + \setlength{\cvSkill@ShapeSize}{.8ex}% \def\cvSkill@Shape#1{\tikz\filldraw[#1] (0, 0) circle (\cvSkill@ShapeSize);} +\else\if@cvskillhalfcircle% + \setlength{\cvSkill@ShapeSize}{.8ex}% + \newcommand*\cvSkill@FullCircle[1][\cvSkill@ShapeSize]{% + \tikz\filldraw[skillmatrixfullcolor] (0,0) circle (#1);% + } + \newcommand*\cvSkill@HalfCircle[1][\cvSkill@ShapeSize]{% + \tikz{% + \fill[skillmatrixfullcolor] (0,0) -- (90:#1) arc (90:270:#1) -- cycle;% + \fill[skillmatrixemptycolor] (0,0) -- (-90:#1) arc (-90:90:#1) -- cycle;% + }% + } + \newcommand*\cvSkill@EmptyCircle[1][\cvSkill@ShapeSize]{% + \tikz\filldraw[skillmatrixemptycolor] (0,0) circle (#1);% + } \else \setlength{\cvSkill@ShapeSize}{1.2ex} \def\cvSkill@Shape#1{\tikz\filldraw[#1] (0, 0) rectangle (\cvSkill@ShapeSize, \cvSkill@ShapeSize);} -\fi -\newcount\my@repeat@count +\fi\fi + \DeclareDocumentCommand{\cvskill}{m}{% % Illustrate skill level with little colored boxes. % By default five skill levels are predefined. @@ -256,14 +274,40 @@ % integer between 0 and 5 % Example usage: % \cvskill{3} - \begingroup - \my@repeat@count=\z@ - \@whilenum\my@repeat@count<#1\do{\cvSkill@Shape{skillmatrixfullcolor}\advance% - \my@repeat@count\@ne\,}% - \my@repeat@count=\numexpr5-\z@\relax - \@whilenum\my@repeat@count>#1\do{\cvSkill@Shape{skillmatrixemptycolor}\advance% - \my@repeat@count\m@ne\,}% - \endgroup +% Option "circle" replaces the boxes by circles +% Option "halfcircle" allows for half-integer values for half-filled circles + \begingroup + \if@cvskillhalfcircle% + \pgfmathtruncatemacro{\full}{floor(#1)}% number of full circles + \pgfmathparse{(#1-\full) > 0.01 ? 1 : 0}% + \let\half\pgfmathresult% number of half circles + \pgfmathtruncatemacro{\empty}{5-\full-\half}% number of empty circles + \ifnum\full>0% + \foreach \z in {1,...,\full}% + {\cvSkill@FullCircle\,}% + \fi% + \ifnum\pgfmathresult=1% + {\cvSkill@HalfCircle\,}% + \fi% + \ifnum\empty>0% + \foreach \z in {1,...,\empty}% + {\cvSkill@EmptyCircle\,}% + \fi% + \else + % Only full shapes + \newcount\my@repeat@count + \my@repeat@count=\z@ + \@whilenum\my@repeat@count<#1\do{% + \cvSkill@Shape{skillmatrixfullcolor}% + \advance\my@repeat@count\@ne\,% + }% + \my@repeat@count=\numexpr5-\z@\relax + \@whilenum\my@repeat@count>#1\do{% + \cvSkill@Shape{skillmatrixemptycolor}% + \advance\my@repeat@count\m@ne\,% + }% + \fi + \endgroup }% end \cvskill % %-------------------------------------------------------------------------------