Skip to content

Commit

Permalink
byrne.mp and byrne.sty updated
Browse files Browse the repository at this point in the history
  • Loading branch information
jemmybutton committed Sep 16, 2024
1 parent b6a2971 commit ce04fe3
Show file tree
Hide file tree
Showing 2 changed files with 40 additions and 3 deletions.
31 changes: 29 additions & 2 deletions byrne.mp
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
% byrne-euclid 0.2.4
% byrne-euclid 0.2.5
% MetaPost library that implements most of the graphical
% features present in Oliver Byrne's version of Euclid's "Elements"
% Copyright 2023 Sergey Slyusarev
% Copyright 2024 Sergey Slyusarev
%
% This program is free software: you can redistribute it and/or modify
% it under the terms of the GNU General Public License as published by
Expand Down Expand Up @@ -1211,6 +1211,33 @@ vardef byNamedLineSeq (expr s)(text linesListRaw) =
)
enddef;

vardef byNamedLineSeqByPoints(expr s, cyc)(text pointsList) =
save constLinesList, lastPoint, firstPoint, i;
string constLinesList, lastPoint, firstPoint;
numeric i;
constLinesList := "";
lastPoint := "";
i := 0;
forsuffixes pN=pointsList:
i := i + 1;
if (lastPoint <> ""):
if (str pN <> "noPoint"):
if (i > 2):
constLinesList := constLinesList & ", ";
fi;
constLinesList := constLinesList & lastPoint & str pN;
fi;
else:
firstPoint := str pN;
fi;
lastPoint := str pN;
endfor;
if (cyc) and (i <> 2) and (lastPoint <> "noPoint"):
constLinesList := constLinesList & ", " & lastPoint & firstPoint;
fi;
byNamedLineSeq(s)(scantokens(constLinesList))
enddef;

vardef byMarkLine(expr pos, col)(suffix lineName) =
setAttribute("mark", "Position", str lineName, pos);
setAttribute("mark", "Color", str lineName, col);
Expand Down
12 changes: 11 additions & 1 deletion byrne.sty
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
\NeedsTeXFormat{LaTeX2e}
\ProvidesPackage{byrne}[2023/04/22 Byrne]
\ProvidesPackage{byrne}[2024/09/16 Byrne]

\RequirePackage{xparse}
\RequirePackage{ifmtarg}
Expand Down Expand Up @@ -272,6 +272,16 @@ end
{\drawFromCurrentPicture[\plal][line#3]{startAutoLabeling;draw byNamedLineSeq(0)(#3);stopAutoLabeling;}}%
{\drawFromCurrentPicture[\plal][#2]{startAutoLabeling;draw byNamedLineSeq(0)(#3);stopAutoLabeling;}}%
}

\DeclareDocumentCommand{\drawLineByPoints}{o o m}{%
\IfNoValueTF{#1}%
{\global\def\plal{middle}}%
{\global\def\plal{#1}}%
\IfNoValueTF{#2}%
{\drawFromCurrentPicture[\plal][line#3]{startAutoLabeling;draw byNamedLineSeqByPoints(0,true)(#3);stopAutoLabeling;}}%
{\drawFromCurrentPicture[\plal][#2]{startAutoLabeling;draw byNamedLineSeqByPoints(0,true)(#3);stopAutoLabeling;}}%
}


\def\drawPointM#1{\drawFromCurrentPicture[middle][pointm#1]{startAutoLabeling; draw byNamedPointMark(#1); stopAutoLabeling;}}

Expand Down

0 comments on commit ce04fe3

Please sign in to comment.