From: Vyatcheslav Yatskovsky <yatskovsky@gmail.com>
To: ntg-context@ntg.nl
Subject: Re: Building a guitar chord using MP
Date: Tue, 13 Apr 2010 00:57:03 +0300 [thread overview]
Message-ID: <4BC3972F.30501@gmail.com> (raw)
In-Reply-To: <mailman.501.1271102166.4277.ntg-context@ntg.nl>
Hurray!
I've got first draft version of guitar chord building macro. (With the
help of this excellent manual http://www.tug.org/docs/metapost/mpman.pdf )
% -- working version ---
\startuseMPgraphic{chordgrid}{e,B,G,D,A,E}
def fretmark(expr a,b) =
% a = string number
% b = fret number
pickup pencircle scaled 3pt;
drawdot(b*7-3, a*4.5-4.5);
enddef;
drawoptions(withpen pencircle scaled 0.4pt withcolor black) ;
draw hlingrid(0, 5, 1, 0.8cm, 1cm) ;
draw vlingrid(0, 4, 1, 1cm, 0.8cm) ;
fretmark(1,\MPvar{e});
fretmark(2,\MPvar{B});
fretmark(3,\MPvar{G});
fretmark(4,\MPvar{D});
fretmark(5,\MPvar{A});
fretmark(6,\MPvar{E});
\stopuseMPgraphic
\define[6]\Ch
{\dontleavehmode
\useMPgraphic{chordgrid}{e={#1},B={#2},G={#3},D={#4},A={#5},E={#6}}%
\hskip2mm}
\starttext
\Ch{1}{3}{1}{2}{1}{4}
\stoptext
However, my current trouble is chord caption (like Am). Except wrong
placement of the label, adding seventh non-numerical argument to the
macro throws an error.
% -- does not work ---
\startuseMPgraphic{chordgrid}{e,B,G,D,A,E,Cptn}
def fretmark(expr a,b) =
% a = string number
% b = fret number
pickup pencircle scaled 3pt;
drawdot(b*7-3, a*4.5-4.5);
enddef;
drawoptions(withpen pencircle scaled 0.4pt withcolor black) ;
draw hlingrid(0, 5, 1, 0.8cm, 1cm) ;
draw vlingrid(0, 4, 1, 1cm, 0.8cm) ;
fretmark(1,\MPvar{e});
fretmark(2,\MPvar{B});
fretmark(3,\MPvar{G});
fretmark(4,\MPvar{D});
fretmark(5,\MPvar{A});
fretmark(6,\MPvar{E});
label.top(\MPvar{Cptn}, (2,0));
\stopuseMPgraphic
\define[7]\Ch
{\dontleavehmode
\useMPgraphic{chordgrid}{e={#1},B={#2},G={#3},D={#4},A={#5},E={#6},Cptn={#7}}%
\hskip2mm}
\starttext
\Ch{1}{3}{1}{2}{1}{4}{Am}
\stoptext
! Missing number, treated as zero.
<to be read again>
A
\theMPvariable ->A
m
<argument> ...\hbox {\scratchdimen \theMPvariable
sp}\ifdim \wd
\scratchbox ...
\secondoftwoarguments #1#2->#2
\prepareMPvariable ...epareMPvariable {\@@meta #1}
\fi
\next1 #1,->\prepareMPvariable {#1}
\doprocesscommaitem
...
l.29 \Ch{1}{3}{1}{2}{1}{4}{Am}
?
Regards,
Vyatcheslav
___________________________________________________________________________________
If your question is of interest to others as well, please add an entry to the Wiki!
maillist : ntg-context@ntg.nl / http://www.ntg.nl/mailman/listinfo/ntg-context
webpage : http://www.pragma-ade.nl / http://tex.aanhet.net
archive : http://foundry.supelec.fr/projects/contextrev/
wiki : http://contextgarden.net
___________________________________________________________________________________
next parent reply other threads:[~2010-04-12 21:57 UTC|newest]
Thread overview: 9+ messages / expand[flat|nested] mbox.gz Atom feed top
[not found] <mailman.501.1271102166.4277.ntg-context@ntg.nl>
2010-04-12 21:57 ` Vyatcheslav Yatskovsky [this message]
[not found] <mailman.466.1270861320.4277.ntg-context@ntg.nl>
2010-04-10 9:56 ` Vyatcheslav Yatskovsky
2010-04-10 12:30 ` Taco Hoekwater
2010-04-10 10:01 ` Vyatcheslav Yatskovsky
2010-04-10 20:26 ` Henning Hraban Ramm
[not found] <mailman.459.1270827309.4277.ntg-context@ntg.nl>
2010-04-09 18:05 ` Vyatcheslav Yatskovsky
2010-04-09 18:30 ` Taco Hoekwater
2010-04-09 20:55 ` Henning Hraban Ramm
2010-04-10 8:35 ` R. Bastian
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=4BC3972F.30501@gmail.com \
--to=yatskovsky@gmail.com \
--cc=ntg-context@ntg.nl \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).