From: Hans Hagen <pragma@wxs.nl>
Subject: Re: Problems with uniqueMPgraphic
Date: Fri, 17 Dec 2004 12:14:06 +0100 [thread overview]
Message-ID: <41C2BF7E.4070300@wxs.nl> (raw)
In-Reply-To: <41C2B9B5.9030203@wxs.nl>
Here is another approach
% small extension to underbar, accepts [settings]
\unprotected \def\underbarparameter#1{\getvalue{\??on#1}}
\unexpanded\def\dounderbar#1%
{\let\betweenisolatedwords#1%
\dosingleempty\redounderbar}
\unexpanded\def\redounderbar[#1]#2%
{\iffirstargument\setupunderbar[#1]\fi
\processisolatedwords{#2}\dodounderbar
\egroup}
% roughly the same
\startuniqueMPgraphic{underline}{color,width,height,depth}
numeric w,h; w := \MPvar{width} ; h := \MPvar{height} ; d := \MPvar{depth} ;
path p; p := (0, -h)..(w/2,0 + (h/3 randomized h/3))..(w, -h);
p := p shifted (0,-d) ;
draw p withpen pencircle scaled 1 withcolor \MPvar{color} ;
setbounds currentpicture to unitsquare xyscaled
(OverlayWidth,OverlayHeight); \stopuniqueMPgraphic
hook into underbar:
\unprotect
\def\underbarmethodx#1#2#3% mp
{\hbox to #1{\uniqueMPgraphic
{underline}{width=#1,height=#2,depth=\underbarparameter\c!bottomoffset,color=\underbarparameter\c!color}}}
\protect
% usage:
\setupunderbar[alternative=x,bottomoffset=1ex,color=red]
\startitemize
\item test: \underbars[color=blue]{how are you?}
\item test: \underbars{how are you?}
\item test: \underbars{how are you?}
\stopitemize
\stoptext
in your case, in order to make the graphic unique, you need to pass the second
arg in order to make them unique (uniqueness is determined by dimensions and a
few more things; another option would be to use the backgroundcolor of inframed
which is accessible by \OverlayColor and also determines uniqueness
\startuniqueMPgraphic{underline}{color}
alternative
\startuniqueMPgraphic{underline}
numeric w,h; w := OverlayWidth; h := ExHeight/6;
path p; p := (0, -h)..(w/2,0 + (h/3 randomized h/3))..(w, -h);
draw p withpen pencircle scaled 1 withcolor OverlayColor ;
setbounds currentpicture to unitsquare xyscaled
(OverlayWidth,OverlayHeight); \stopuniqueMPgraphic
\defineoverlay[underline][\uniqueMPgraphic{underline}]
\def\aidul{\dosingleempty\doaidul}
\def\doaidul[#1]{\inframed[background=underline,frame=off,#1]}
\setupcolors[state=start]
\startitemize
\item test: \aidul[backgroundcolor=red]{how} \aidul[color=green]{are}
\aidul[color=blue]{you?}
\item test:\aidul[backgroundcolor=blue]{how} \aidul[color=green]{how}
\aidul[color=red]{how}
\stopitemize
Hans
-----------------------------------------------------------------
Hans Hagen | PRAGMA ADE
Ridderstraat 27 | 8061 GH Hasselt | The Netherlands
tel: 038 477 53 69 | fax: 038 477 53 74 | www.pragma-ade.com
| www.pragma-pod.nl
-----------------------------------------------------------------
next prev parent reply other threads:[~2004-12-17 11:14 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
2004-12-16 15:51 Adam Duck
2004-12-17 10:49 ` Hans Hagen
2004-12-17 11:14 ` Hans Hagen [this message]
2004-12-18 0:40 ` Adam Duck
2004-12-18 22:35 ` h h extern
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=41C2BF7E.4070300@wxs.nl \
--to=pragma@wxs.nl \
--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).