%% file: knufakelogo.sty
%%
%% knufakelogo
%%
%% (C) Copyright 2020-2022 In-Sung Cho <ischo at ktug.org>
%%
%% This work may be distributed and/or modified 
%% under the conditions of the LaTeX Project Public License, 
%% either version 1.3c of this license or (at your option) any later version.
%% The latest version of this license is in
%%  http://www.latex-project.org/lppl.txt.
%%
%% -------------------------------------------------
\ProvidesPackage{knufakelogo}[2024/11/11 v0.93 KNU Fake Logo]

\RequirePackage{xparse}
\RequirePackage{tzplot}
%\usetikzlibrary{calc,intersections}
\usetikzlibrary{decorations.text}

%% fonts: TeX Gyre Adventor, Oswald, KoPubWorldDottum
%%-------------------------------------------------
\newfontfamily\KNUmainfont{Oswald}%{TeX Gyre Adventor} % 메인 글씨 (KNU)
\newfontfamily\KNUengfont{TeX Gyre Adventor}           % 테두리 영어
\newfontfamily\KNUyearfont{TeX Gyre Adventor}          % 1948년
\newhangulfontfamily\KNUkorfont{KoPubWorldDotum Bold}  % 테두리 한글
%\definecolor{KNUblue}{rgb}{.28,.36,.7}
%\definecolor{KNUgreen}{rgb}{0,.652,.332}
\definecolor{KNUblue}{RGB}{23,71,158}
\definecolor{KNUgreen}{RGB}{0,177,76}
\definecolor{KNUgray}{RGB}{220,221,222}
%%-------------------------------------------------
%% for \KNUfakelogoColor
\definecolor{KNUfill}{RGB}{23,71,158}    % 작은 원의 바탕색 (KNUblue)
\definecolor{KNUroof}{RGB}{255,255,255}  % roof, lines, KNU (white)
\definecolor{KNUtext}{RGB}{0,177,76}     % 테두리 글씨      (KNUgreen)
\definecolor{KNUcircle}{RGB}{23,61,158}  % 바깥 테두리 원   (KNUblue)
\definecolor{KNUwhite}{RGB}{255,255,255}
\definecolor{KNUblack}{RGB}{35,31,32}
\definecolor{KNUbox}{RGB}{220,221,222}   % *버전 box 바탕색 (KNUgray)
%-------------------------------------------------
%\newlength\KNUmain\setlength\KNUmain{130pt}
\def\KNUmainsize{130pt}%{\KNUmain}
\newlength\KNUeng\setlength\KNUeng{32pt}
%\def\KNUengsize{#2\KNUeng}
\newlength\KNUkor\setlength\KNUkor{31pt}
%\def\KNUkorsize{#2\KNUkor}

%% definition: texts, roof, circles, lines, colors
%% 공통부분
%% 바깥 테두리, 
\def\KNUdef{%
  % perimeter
  \fill [\KCIRCLE,even odd rule]
    (0,0) circle (10cm)
    (0,0) circle (9.7cm);
  % preparing circle texts
  \def\KNU{%
    |\sffamily\bfseries\color{\KTEXT}\KNUengfont%
     \fontsize{\KNUengsize}{\KNUengsize}\selectfont|%
     KONGJU NATIONAL UNIVERSITY%
  }
  \def\KNUko{%
    |\sffamily\bfseries\color{\KTEXT}\KNUkorfont%
     \fontsize{\KNUkorsize}{\KNUkorsize}\selectfont|%
     공주대학교%
  }
  % printing "KONGJU NATIONAL UNIVERSITY": circled
  \path [transform shape,
    postaction={decorate,
    decoration={
                 text along path,
                 text={\KNU},
  %               text align=fit to path,
                 text color=\KTEXT,
               }
              }
        ]
    ([shift={(221:74mm)}]0,0) arc (221:-41:74mm);
  % printing "공주대학교": circled
  \begin{scope}[transform shape]
  \path [
    postaction={decorate},
    preaction={decorate,
               decoration={
                 text along path,
                 text={\KNUko},
                 text align=center,
                 text align=fit to path,
                 text color=\KTEXT,
                 },
              }
        ]
    ([shift={(236:90mm)}]0,0) arc (236:304:90mm);
  \end{scope}
  % printing dots: circled
  \node [transform shape] at (228:83mm) 
    [circle,fill=\KTEXT,inner sep=0pt,minimum size=14pt]{};
  \node [transform shape] at (312:83mm) 
    [circle,fill=\KTEXT,inner sep=0pt,minimum size=14pt]{};
  % background color (small circle)
  \fill [\KFILL] (0,0) circle (68mm);
  % defining top coordinates and roof base line
  \coordinate (top) at (0,6.5);
  \coordinate (top2) at (0,4.85);
  \coordinate (top3) at (0,4.05);
  \path [name path=base,yellow,very thin] (-5,2.54) -- (5,2.54);
  % naming paths for roof
  \path [name path=lineR] (top) -- ++(-45:90mm);
  \path [name path=lineL] (top) -- ++(-135:90mm);
  \path [name intersections={of=base and lineR,by=RR}];
  \path [name intersections={of=base and lineL,by=LL}];
  % naming paths for roof inner triangle
  \path [name path=lineR2] (top2) -- ++(-45:90mm);
  \path [name path=lineL2] (top2) -- ++(-135:90mm);
  \path [name intersections={of=base and lineR2,by=RR2}];
  \path [name intersections={of=base and lineL2,by=LL2}];
  % AT LAST, coloring roof (basic version: white)
  \fill [\KROOF,even odd rule] 
       (top) -- (RR) -- ([xshift=-8.5mm]RR) -- 
       ([yshift=-8.5mm]top) -- ([xshift=8.5mm]LL) -- 
       (LL) -- cycle
  %
       (top2) -- (RR2) -- (LL2) -- cycle
  %
       (top3) -- +(-45:13.5mm) -- +(-135:13.5mm) -- cycle ;
  %% KNU main
  \node [\KROOF,transform shape] at (-90:6.2mm) [centered]
    {\KNUmainfont
     \fontsize{\KNUmainsize}{\KNUmainsize}\selectfont KNU} ;
  % top line
  \fill [\KROOF] (-5.45,1.65) rectangle (5.45,2.1);
  % bottom lines
  \fill [\KROOF] (-5.05,-3.3)  rectangle (5.05,-2.85);
  \begin{scope}
  \clip (0,0) circle (68mm);
  \fill [\KROOF] (-5.75,-4.25) rectangle (5.75,-3.8);
  \end{scope}
  % 1948
  \node at (0,-6) [transform shape,\KROOF,inner sep=0pt,above] 
    {\KNUyearfont\fontsize{52pt}{52pt}\selectfont 1948};
  % help line
  %\IfBooleanT {#1}
  %  {\draw [help lines](-10,-10) grid (10,10);}
}

%% def: environment (basic)
%%-----------------------------------------------
%% \KNUfakelogo
% \usetikzlibrary{intersections,decorations.text}
% fonts: TeX Gyre Adventor, Oswald, KoPubWorldDottum
\NewDocumentEnvironment{KNUfakeLogoENV}{ s O{} m D(){8,6} d() }
{%
  \begin{tikzpicture}[scale=#3/2,#2]
  \def\KNUengsize{#3\KNUeng}
  \def\KNUkorsize{#3\KNUkor}
  \IfBooleanTF {#1}
    {%
      \def\KWHITE{white}
      \def\KCIRCLE{KNUcircle}
      \def\KTEXT{KNUtext}
      \def\KFILL{KNUfill}
      \def\KROOF{KNUbox}
      \def\KBOX{KNUbox}
      \IfNoValueTF {#5}
        {\fill [\KBOX] ($-2*(#4)$) rectangle ($2*(#4)$);}
        {\fill [\KBOX] ($2*(#4)$) rectangle ($2*(#5)$);}
    }
    {%
      \def\KWHITE{white}
      \def\KCIRCLE{KNUcircle}
      \def\KTEXT{KNUtext}
      \def\KFILL{KNUfill}
      \def\KROOF{KNUroof}
    }
  \KNUdef
}
{\end{tikzpicture}}

%% def: command (basic)
\NewDocumentCommand\KNUfakelogo{ s O{} m D(){8,6} d() }
{%
  \IfBooleanTF {#1}
    {%
      \IfNoValueTF {#5}
        {\begin{KNUfakeLogoENV}*[#2]{#3}(#4)}
        {\begin{KNUfakeLogoENV}*[#2]{#3}(#4)(#5)}
    }
    {\begin{KNUfakeLogoENV}[#2]{#3}(#4)}
  \end{KNUfakeLogoENV}%\endKNUfakelogo
}

%\let\knufakelogo\KNUfakelogo

%% def: environment (Blue)
%%-----------------------------------------------
%% \KNUfakelogoBlue
% \usetikzlibrary{intersections,decorations.text}
% fonts: TeX Gyre Adventor, Oswald, KoPubWorldDottum
\NewDocumentEnvironment{KNUfakeLogoBlueENV}{ s O{} m D(){8,6} d() }
{%
  \begin{tikzpicture}[scale=#3/2,#2]
  \def\KNUengsize{#3\KNUeng}
  \def\KNUkorsize{#3\KNUkor}
    \IfBooleanTF {#1}
    {%
      \def\KCIRCLE{KNUwhite}
      \def\KTEXT{KNUwhite}
      \def\KFILL{KNUwhite}
      \def\KROOF{KNUblue}
      \def\KBOX{KNUblue}
      \IfNoValueTF {#5}
        {\fill [\KBOX] ($-2*(#4)$) rectangle ($2*(#4)$);}
        {\fill [\KBOX] ($2*(#4)$) rectangle ($2*(#5)$);}
    }
    {%
      \def\KCIRCLE{KNUblue}
      \def\KTEXT{KNUblue}
      \def\KFILL{KNUblue}
      \def\KROOF{KNUwhite}
    }
  \KNUdef
}
{\end{tikzpicture}}

%% def: command (Blue)
\NewDocumentCommand\KNUfakelogoBlue{ s O{} m D(){8,6} d() }
{%
  \IfBooleanTF {#1}
    {%
      \IfNoValueTF {#5}
        {\begin{KNUfakeLogoBlueENV}*[#2]{#3}(#4)}
        {\begin{KNUfakeLogoBlueENV}*[#2]{#3}(#4)(#5)}
    }
    {\begin{KNUfakeLogoBlueENV}[#2]{#3}(#4)}
  \end{KNUfakeLogoBlueENV}%\endKNUfakelogoBlue
}

%\let\knufakelogoBlue\KNUfakelogoBlue

%% def: environment (Green)
%%-----------------------------------------------
%% \KNUfakelogoGreen
% \usetikzlibrary{intersections,decorations.text}
% fonts: TeX Gyre Adventor, Oswald, KoPubWorldDottum
\NewDocumentEnvironment{KNUfakeLogoGreenENV}{s O{} m D(){8,6} d() }
{%
  \begin{tikzpicture}[scale=#3/2,#2]
  \def\KNUengsize{#3\KNUeng}
  \def\KNUkorsize{#3\KNUkor}
  \IfBooleanTF {#1}
    {%
      \def\KCIRCLE{KNUwhite}
      \def\KTEXT{KNUwhite}
      \def\KFILL{KNUwhite}
      \def\KROOF{KNUgreen}
      \def\KBOX{KNUgreen}
      \IfNoValueTF {#5}
        {\fill [\KBOX] ($-2*(#4)$) rectangle ($2*(#4)$);}
        {\fill [\KBOX] ($2*(#4)$) rectangle ($2*(#5)$);}
    }
    {%
      \def\KCIRCLE{KNUgreen}
      \def\KTEXT{KNUgreen}
      \def\KFILL{KNUgreen}
      \def\KROOF{KNUwhite}
    }
  \KNUdef
}
{\end{tikzpicture}}

%% def: command (Green)
\NewDocumentCommand\KNUfakelogoGreen{ s O{} m D(){8,6} d() }
{%
  \IfBooleanTF {#1}
    {%
      \IfNoValueTF {#5}
        {\begin{KNUfakeLogoGreenENV}*[#2]{#3}(#4)}
        {\begin{KNUfakeLogoGreenENV}*[#2]{#3}(#4)(#5)}
    }
    {\begin{KNUfakeLogoGreenENV}[#2]{#3}(#4)}
  \end{KNUfakeLogoGreenENV}%\endKNUfakelogoGreen
}

%\let\knufakelogoGreen\KNUfakelogoGreen

%% def: environment (Black)
%%-----------------------------------------------
%% \KNUfakelogoBlack
% \usetikzlibrary{intersections,decorations.text}
% fonts: TeX Gyre Adventor, Oswald, KoPubWorldDottum
\NewDocumentEnvironment{KNUfakeLogoBlackENV}{ s O{} m D(){8,6} d() }
{%
  \begin{tikzpicture}[scale=#3/2,#2]
  \def\KNUengsize{#3\KNUeng}
  \def\KNUkorsize{#3\KNUkor}
    \IfBooleanTF {#1}
    {%
      \def\KCIRCLE{KNUwhite}
      \def\KTEXT{KNUwhite}
      \def\KFILL{KNUwhite}
      \def\KROOF{KNUblack}
      \def\KBOX{KNUblack}
      \IfNoValueTF {#5}
        {\fill [\KBOX] ($-2*(#4)$) rectangle ($2*(#4)$);}
        {\fill [\KBOX] ($2*(#4)$) rectangle ($2*(#5)$);}
    }
    {%
      \def\KCIRCLE{KNUblack}
      \def\KTEXT{KNUblack}
      \def\KFILL{KNUblack}
      \def\KROOF{KNUwhite}
    }
  \KNUdef
}
{\end{tikzpicture}}

% def: command (Black)
\NewDocumentCommand\KNUfakelogoBlack{ s O{} m D(){8,6} d() }
{%
  \IfBooleanTF {#1}
    {%
      \IfNoValueTF {#5}
      {\begin{KNUfakeLogoBlackENV}*[#2]{#3}(#4)}
      {\begin{KNUfakeLogoBlackENV}*[#2]{#3}(#4)(#5)}
    }
    {\begin{KNUfakeLogoBlackENV}[#2]{#3}(#4)}
  \end{KNUfakeLogoBlackENV}%\endKNUfakelogoBlack
}

%\let\knufakelogoBlack\KNUfakelogoBlack

%% def: environment (Color}
%%-----------------------------------------------
%% \KNUfakelogoColor
% \usetikzlibrary{intersections,decorations.text}
% fonts: TeX Gyre Adventor, Oswald, KoPubWorldDottum
\NewDocumentEnvironment{KNUfakeLogoColorENV}{ s O{} m G{black} O{white} O{black} G{#4} D(){8,6} d() }
{%
  \begin{tikzpicture}[scale=#3/2,#2]
  \def\KNUengsize{#3\KNUeng}
  \def\KNUkorsize{#3\KNUkor}
  \IfBooleanTF {#1}
    {%
      \def\KFILL{#5}
      \def\KROOF{#4}
      \def\KTEXT{#5}
      \def\KCIRCLE{#5}
      \def\KBOX{#4}
      \IfNoValueTF {#9}
        {\fill [\KBOX] ($-2*(#8)$) rectangle ($2*(#8)$);}
        {\fill [\KBOX] ($2*(#8)$) rectangle ($2*(#9)$);}
    }
    {%
      \def\KFILL{#4}
      \def\KROOF{#5}
      \def\KTEXT{#6}
      \def\KCIRCLE{#7}
    }
  \KNUdef
}
{\end{tikzpicture}}

%% def: command (Color)
\NewDocumentCommand\KNUfakelogoColor{ s O{} m G{black} O{white} O{black} G{#4} D(){8,6} d() }
{%
  \IfBooleanTF {#1}
    {%
      \IfNoValueTF {#9}
        {\begin{KNUfakeLogoColorENV}*[#2]{#3}{#4}[#5](#8) }
        {\begin{KNUfakeLogoColorENV}*[#2]{#3}{#4}[#5](#8)(#9) }
    }
    {\begin{KNUfakeLogoColorENV}[#2]{#3}{#4}[#5][#6]{#7}}
  \end{KNUfakeLogoColorENV}%\endKNUfakelogoColor
}

%\let\knufakelogoColor\KNUfakelogoColor

\endinput