summaryrefslogtreecommitdiff
path: root/Master/texmf-dist/tex/latex/chordbars
diff options
context:
space:
mode:
authorKarl Berry <karl@freefriends.org>2019-01-01 22:50:09 +0000
committerKarl Berry <karl@freefriends.org>2019-01-01 22:50:09 +0000
commit360b2217b3fb6cbf371c80bd9c4ed3352dc9a60c (patch)
tree9f837d11a1488c17705d192b328d730981bd8d32 /Master/texmf-dist/tex/latex/chordbars
parent06201beeeeb22aeb1ff0de4e620deb1f1693612a (diff)
chordbars (1jan19)
git-svn-id: svn://tug.org/texlive/trunk@49569 c570f23f-e606-0410-a88d-b1316a301751
Diffstat (limited to 'Master/texmf-dist/tex/latex/chordbars')
-rw-r--r--Master/texmf-dist/tex/latex/chordbars/chordbars.sty119
1 files changed, 103 insertions, 16 deletions
diff --git a/Master/texmf-dist/tex/latex/chordbars/chordbars.sty b/Master/texmf-dist/tex/latex/chordbars/chordbars.sty
index 13e4f49642b..4064cf14c8e 100644
--- a/Master/texmf-dist/tex/latex/chordbars/chordbars.sty
+++ b/Master/texmf-dist/tex/latex/chordbars/chordbars.sty
@@ -1,8 +1,8 @@
-%% chordbars.sty
+%% file: chordbars.sty
%% Copyright 2018 M. Sebastien Kramm
%
% This work may be distributed and/or modified under the
-% conditions of the LaTeX Project Public License, either version 1.3
+% 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
@@ -17,8 +17,12 @@
% Home page: https://github.com/skramm/chordbars
+
+% TODO define command to have 1 chord per beat
+
+
\NeedsTeXFormat{LaTeX2e}
-\ProvidesPackage{chordbars}[2017-12-28 version 1.0]
+\ProvidesPackage{chordbars}[2017-12-29 version 1.1]
\RequirePackage{tikz}
\RequirePackage{pgfmath}
@@ -38,7 +42,7 @@
\begin{center}%
\begin{tikzpicture}[line width=1.5pt]
\tikzstyle{block} = [rectangle, draw, text width=20em, text centered, minimum height=4em]
- \node [block,font=\fontsize{20}{28}\selectfont\bfseries] (init) { \@title~-~\@author };
+ \node [block,font=\fontsize{20}{28}\selectfont\bfseries] (init) { \@title\\ \@author };
\end{tikzpicture}
\end{center}%
\par
@@ -98,14 +102,69 @@
}
\def\barsize{1.6}%
+\def\delta{0.36}
+\def\chordFontSize{\normalsize \bfseries}
+\def\titleFontSize{\large \bfseries}
\xdef\NumberOfBarsPerLine{4}
+% arg1: chord
+% arg2: number of bars
+% arg3: title
+\newcommand{\chordline}[3]
+{
+ {\fontfamily{phv}\selectfont
+ \noindent\ignorespaces %
+ \vspace{\vspacebefore}
+ \refstepcounter{NumMesure}%
+ \refstepcounter{NumPart}%
+ \begin{tikzpicture}[line width=1pt,x=1cm,y=-1cm]
+
+% draw part title
+ \ifthenelse
+ {\boolean{printBarNumber}}
+ {
+ \draw (0,-\barsize*.2) node [anchor=west, align=left,font=\titleFontSize] {Part \theNumPart: #3};
+ \draw (-.3,.5*\barsize) node{\bf \theNumMesure};
+ }
+ {
+ \draw (0,-\barsize*.2) node [anchor=west, align=left,font=\titleFontSize] {#3};
+ }
+
+ \draw (0,0) -- (#2*\barsize,0); % horizontal lines
+ \draw (0,\barsize) -- (#2*\barsize,\barsize);
+
+ \draw (0,0) -- (0,\barsize); % first vertical line
+ \draw (\barsize,0) -- (\barsize,\barsize); % second vertical line
+ \draw (\barsize/2,\barsize/2) node [font=\chordFontSize]{#1}; % chord name
+
+ \foreach \k in {2,...,{#2}}
+ {
+ \draw (\k*\barsize,0) -- (\k*\barsize,\barsize);
+
+ \pgfmathsetmacro{\Axa}{(\k-1)*\barsize+\delta*\barsize}
+ \pgfmathsetmacro{\Axb}{\k*\barsize-\delta*\barsize}
+ \pgfmathsetmacro{\Aya}{(1-\delta)*\barsize}
+ \pgfmathsetmacro{\Ayb}{\delta*\barsize}
+
+ \coordinate (A) at (\Axa,\Ayb);
+ \coordinate (B) at (\Axb,\Aya);
+
+ \fill (A) circle[radius=2pt];
+ \fill (B) circle[radius=2pt];
+ \draw [thick] (\Axa,\Aya) -- (\Axb,\Ayb); % Draw "repeat" symbol
+ }
+
+ \end{tikzpicture}
+ }
+ \addtocounter{NumMesure}{#2}
+}
+
%==========================================================================
% main environment, has 2 mandatory arguments
-% arg 1: total number of 4 beat bars (4, 8, ...)
-% arg 2: part name (can be empty)
+% arg 1 (#2 inside): total number of 4 beat bars (4, 8, ...)
+% arg 2 {#3 inside}: part name (can be empty)
% optional arg: nb of repetitions (default is 1)
\newenvironment{chordbar}[3][1]
@@ -128,7 +187,7 @@
\refstepcounter{CurrentBarInLine}%
\pgfmathsetmacro{\x}{-\barsize/2+\theCurrentBarInLine*\barsize}
\pgfmathsetmacro{\y}{\value{CurrentLine})*\barsize+\barsize/2}
- \draw (\x,\y) node {##1};%
+ \draw (\x,\y) node [font=\chordFontSize]{##1};%
}%
\newcommand{\chordh}[2]%
@@ -154,11 +213,11 @@
\draw (
{-3*\barsize/4+\theCurrentBarInLine*\barsize},
{\theCurrentLine*\barsize+1*\barsize/4}
- ) node {##1};
+ ) node [font=\chordFontSize]{##1};
\draw (
{-\barsize/4+\theCurrentBarInLine*\barsize},
{\theCurrentLine*\barsize+3*\barsize/4}
- ) node {##2};%
+ ) node [font=\chordFontSize]{##2};%
}
@@ -173,7 +232,6 @@
{}
\refstepcounter{CurrentBarInLine}%
- \def\delta{0.36}
\pgfmathsetmacro{\Axa}{(\theCurrentBarInLine-1)*\barsize+\delta*\barsize}
\pgfmathsetmacro{\Axb}{\theCurrentBarInLine*\barsize-\delta*\barsize}
\pgfmathsetmacro{\Aya}{(1-\delta)*\barsize+\theCurrentLine*\barsize}
@@ -189,7 +247,6 @@
\newcommand{\repeatBarPair}%
{ %
- \def\delta{0.36}
\pgfmathsetmacro{\Axa}{\theCurrentBarInLine*\barsize+\delta*\barsize}
\pgfmathsetmacro{\Axb}{(\theCurrentBarInLine+2)*\barsize-\delta*\barsize}
\pgfmathsetmacro{\Aya}{(1-\delta)*\barsize+\theCurrentLine*\barsize}
@@ -211,8 +268,39 @@
}
\fi
}%
+
+ \newcommand{\addHalfBar}[1]%
+ {
+ \refstepcounter{NumMesure}%
+ \refstepcounter{CurrentBarInLine}%
+
+% \pgfmathsetmacro{\xa}{(\theCurrentBarInLine-1)*\barsize}
+% \pgfmathsetmacro{\xb}{\theCurrentBarInLine*\barsize}
+%
+% \pgfmathsetmacro{\ya}{\theCurrentLine*\barsize}
+% \pgfmathsetmacro{\ya}{(\theCurrentLine+1)*\barsize}
+
+% diagonal line
+% \draw (\xa,\ya) -- (\xb,\yb); A BUG HERE: investigate
+ \draw
+ (\theCurrentBarInLine*\barsize,{\theCurrentLine*\barsize})
+ --
+ ({(\theCurrentBarInLine-1)*\barsize},{(\theCurrentLine+1)*\barsize});
+
+% horizontal line
+ \draw
+ (\theCurrentBarInLine*\barsize,{\theCurrentLine*\barsize})
+ --
+ ({(\theCurrentBarInLine-1)*\barsize},{(\theCurrentLine)*\barsize});
+
+
+ \pgfmathsetmacro{\x}{-3*\barsize/4+\theCurrentBarInLine*\barsize}
+ \pgfmathsetmacro{\y}{\value{CurrentLine})*\barsize+\barsize/4}
+ \draw (\x,\y) node [font=\chordFontSize]{##1};%
- \typeout{chordbarl: START #2}
+ }
+
+ \typeout{chordbar: START #3}
\fontfamily{phv}\selectfont
\setcounter{CurrentLine}{0}
@@ -236,7 +324,7 @@
\xdef\NbBarsInitialLine{\NumberOfBarsPerLine}
\ifthenelse
{#2<\NumberOfBarsPerLine}
- {\xdef\NbBarsInitialLine{#1}}
+ {\xdef\NbBarsInitialLine{#2}}
{}
% initial horizontal line
@@ -245,8 +333,8 @@
% draw part title
\ifthenelse
{\boolean{printBarNumber}}
- {\draw (0,-\barsize*.2) node [anchor=west, align=left] {\bf Part \theNumPart: #3};}
- {\draw (0,-\barsize*.2) node [anchor=west, align=left] {\bf #3};}
+ {\draw (0,-\barsize*.2) node [anchor=west, align=left,font=\titleFontSize] {Part \theNumPart: #3};}
+ {\draw (0,-\barsize*.2) node [anchor=west, align=left,font=\titleFontSize] {#3};}
\pgfmathtruncatemacro{\nblines}{(#2-1)/\NumberOfBarsPerLine+1}
\typeout{chordbarl: nblines=\nblines}
@@ -301,6 +389,5 @@
\let\OLDflat\flat
\renewcommand{\flat}{\ensuremath{\OLDflat}}
-
\endinput