ntg-context - mailing list for ConTeXt users
 help / color / mirror / Atom feed
* tweaking underlining
@ 2005-07-08 22:49 Stuart Jansen
  2005-07-09  9:19 ` Hans Hagen
  2005-07-11 21:33 ` Mojca Miklavec
  0 siblings, 2 replies; 4+ messages in thread
From: Stuart Jansen @ 2005-07-08 22:49 UTC (permalink / raw)



[-- Attachment #1.1: Type: text/plain, Size: 1164 bytes --]

Reading the list archives, it looks like there are certain advantages,
to performing underlining according to my example below:

=====
\setupcolors[state=start]
\definetextbackground[underline][location=text,alternative=1,background=,frame=off]
\definestartstop
  [underline]
  [before={\starttextbackground[underline]},
   after=\stoptextbackground]
\starttext
\startunderline{}http://gurulabs.com/\stopunderline
\stoptext
=====

I would like to tweak this a little however. Specifically, I'd like to
change the color of the line and move it down a point or two.

In one thread, Hans hinted how to do this:

> you can redefine the metapost graphic, the main thing there is that
> you draw/fill something related to the multipar paths; it takes a bit
> of experimenting, but after a while you start seeing possibilities. 
> See plus-rul.tex for an example of such a graphic.

I think I've tracked this reference down to the definition of
mpos:par:columnset, but at this point am lost as to how to proceed.
Metapost is still beyond me. Any hints would be much appreciated.


-- 
Stuart Jansen <sjansen@gurulabs.com>
Guru Labs, L.C.

[-- Attachment #1.2: This is a digitally signed message part --]
[-- Type: application/pgp-signature, Size: 189 bytes --]

[-- Attachment #2: Type: text/plain, Size: 139 bytes --]

_______________________________________________
ntg-context mailing list
ntg-context@ntg.nl
http://www.ntg.nl/mailman/listinfo/ntg-context

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: tweaking underlining
  2005-07-08 22:49 tweaking underlining Stuart Jansen
@ 2005-07-09  9:19 ` Hans Hagen
  2005-07-15 23:04   ` Stuart Jansen
  2005-07-11 21:33 ` Mojca Miklavec
  1 sibling, 1 reply; 4+ messages in thread
From: Hans Hagen @ 2005-07-09  9:19 UTC (permalink / raw)


Stuart Jansen wrote:
> Reading the list archives, it looks like there are certain advantages,
> to performing underlining according to my example below:
> 
> =====
> \setupcolors[state=start]
> \definetextbackground[underline][location=text,alternative=1,background=,frame=off]
> \definestartstop
>   [underline]
>   [before={\starttextbackground[underline]},
>    after=\stoptextbackground]
> \starttext
> \startunderline{}http://gurulabs.com/\stopunderline
> \stoptext
> =====
> 
> I would like to tweak this a little however. Specifically, I'd like to
> change the color of the line and move it down a point or two.
> 
> In one thread, Hans hinted how to do this:
> 
> 
>>you can redefine the metapost graphic, the main thing there is that
>>you draw/fill something related to the multipar paths; it takes a bit
>>of experimenting, but after a while you start seeing possibilities. 
>>See plus-rul.tex for an example of such a graphic.
> 
> 
> I think I've tracked this reference down to the definition of
> mpos:par:columnset, but at this point am lost as to how to proceed.
> Metapost is still beyond me. Any hints would be much appreciated.

ok, a quick hack (no time today):

the one ou need to tweak is:

\startuseMPgraphic{mpos:par:columnset}
   \iftracepositions show_multi_pars \else draw_multi_pars \fi ;
\stopuseMPgraphic

so one option is to provide your own draw macro (the draw macro is in 
mp-core.mp); however, here you can check a bit:

\startuseMPgraphic{mpos:par:columnset}
   \iftracepositions show_multi_pars \else draw_multi_pars \fi ;
   path p ; p := boundingbox currentpicture ;
   currentpicture := currentpicture shifted (0,-3pt) ;
   setbounds currentpicture to p ;
\stopuseMPgraphic

or better:

\startuseMPgraphic{mpos:par:columnset}
   \iftracepositions show_multi_pars \else draw_multi_pars \fi ;
   path p ; p := boundingbox currentpicture ;
   currentpicture := currentpicture shifted (0,-StrutDepth/2) ;
   setbounds currentpicture to p ;
\stopuseMPgraphic

(remind me some time later to add an option to shift the thing down by keyword 
control)

[this is wikiable]

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
-----------------------------------------------------------------

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: tweaking underlining
  2005-07-08 22:49 tweaking underlining Stuart Jansen
  2005-07-09  9:19 ` Hans Hagen
@ 2005-07-11 21:33 ` Mojca Miklavec
  1 sibling, 0 replies; 4+ messages in thread
From: Mojca Miklavec @ 2005-07-11 21:33 UTC (permalink / raw)


[-- Attachment #1: Type: text/plain, Size: 4082 bytes --]

Stuart Jansen wrote:
> Reading the list archives, it looks like there are certain advantages,
> to performing underlining according to my example below:
> 
> =====
> \setupcolors[state=start]
> \definetextbackground[underline][location=text,alternative=1,background=,frame=off]
> \definestartstop
>   [underline]
>   [before={\starttextbackground[underline]},
>    after=\stoptextbackground]
> \starttext
> \startunderline{}http://gurulabs.com/\stopunderline
> \stoptext
> =====
> 
> I would like to tweak this a little however. Specifically, I'd like to
> change the color of the line and move it down a point or two.

The quick way to do it (but probably not the one you would really like):

\definetextbackground
   [underline]
   [location=text,
    alternative=2,
    frame=off,
    bottomframe=on,
    framecolor=red,
    rulethickness=1pt]

Even if you're satisfied with it, there's one problem. In every line
there are two lines drawn: above and below the text. This leads to the
(probably undesired) result: the first and the last rule are only half
so thick as the rest.

> In one thread, Hans hinted how to do this:
> 
> > you can redefine the metapost graphic, the main thing there is that
> > you draw/fill something related to the multipar paths; it takes a bit
> > of experimenting, but after a while you start seeing possibilities.
> > See plus-rul.tex for an example of such a graphic.
> 
> I think I've tracked this reference down to the definition of
> mpos:par:columnset, but at this point am lost as to how to proceed.
> Metapost is still beyond me. Any hints would be much appreciated.

Metapost graphics for backgrounds are doable once you understand some
basics about metapost (MetaFun tutorial, Learning metapost by doing,
Metapost manual, ...). Here's an example:

\startuniqueMPgraphic{MyGraphic1}
	draw unitsquare xscaled \overlaywidth yscaled \overlayheight withcolor red;
\stopuniqueMPgraphic
\startuniqueMPgraphic{MyGraphic2}
	save r, dist, offset;
	numeric r, dist, offset;
	% circle radius
	r := 3pt;
	% distance between two circles
	dist := 1cm;
	% distance between the bottom frame margin and the center of my pattern
	offset := 5pt;
	
	for i=0 upto floor((\overlaywidth-2r)/dist):
		draw fullcircle scaled 2r shifted (i*dist+r,-offset) withcolor blue;
	endfor;
	setbounds currentpicture to unitsquare xscaled \overlaywidth yscaled
\overlayheight;
\stopuniqueMPgraphic

\defineoverlay
  [myframe1]
  [\uniqueMPgraphic{MyGraphic1}]
\defineoverlay
  [myframe2]
  [\uniqueMPgraphic{MyGraphic2}]

\framed[background=myframe1,frame=off]{abc}
% what does a linebreak after \framed[...]{...} do?
\framed[background=myframe2,frame=on]{\dorecurse{15}{bla }}abc\crlf
\framed[background=myframe2,frame=off]{\dorecurse{17}{bla }}

However, I have no idea how to apply the same to the underlining
scheme of paragraphs. Saying

\definetextbackground
   [underline]
   [location=text,
    alternative=2,
    background=myframe2]

has absolutely no influence on how the frames are drawn.

mpos:par:columnset is a name of a metapost graphic, defined in
core-pos.tex. However, I tried to play with

\definetextbackground
   [underline]
   [... mp=oneofmygraphics ...]

which should change the background graphic, but also without any success.

I thought also that perhaps making something like
\setupMPvariables
  [mpos:par:columnset]
  [linecolor=red,
   linewidth=10pt]

would have any influence of how the frames are drawn, but it doesn't.

My other try was trying to change the example on page 43/44 of
columns.pdf. I replaced the whole body of  {mpos:par:columnset:shade}
graphic by a single statement,
    draw multipars[1] withcolor green;
This works (it draws a frame around the whole paragraph in the first
column), but I didn't find out how to access the variable with the
bounding box of one line only.

An interesting observation (feature/bug or maybe just a stupid
usage?): Try to compile the example attached in the file.

Mojca

[-- Attachment #2: test4.tex --]
[-- Type: application/x-tex, Size: 960 bytes --]

[-- Attachment #3: Type: text/plain, Size: 139 bytes --]

_______________________________________________
ntg-context mailing list
ntg-context@ntg.nl
http://www.ntg.nl/mailman/listinfo/ntg-context

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: tweaking underlining
  2005-07-09  9:19 ` Hans Hagen
@ 2005-07-15 23:04   ` Stuart Jansen
  0 siblings, 0 replies; 4+ messages in thread
From: Stuart Jansen @ 2005-07-15 23:04 UTC (permalink / raw)



[-- Attachment #1.1: Type: text/plain, Size: 492 bytes --]

On Sat, 2005-07-09 at 11:19 +0200, Hans Hagen wrote:
> Stuart Jansen wrote:
> > I would like to tweak this a little however. Specifically, I'd like to
> > change the color of the line and move it down a point or two.
> 
> ok, a quick hack (no time today):

Thanks again!

> (remind me some time later to add an option to shift the thing down by keyword 
> control)

Not problem. ;-)

> [this is wikiable]

Done. 

-- 
Stuart Jansen <sjansen@gurulabs.com>
Guru Labs, L.C.

[-- Attachment #1.2: This is a digitally signed message part --]
[-- Type: application/pgp-signature, Size: 189 bytes --]

[-- Attachment #2: Type: text/plain, Size: 139 bytes --]

_______________________________________________
ntg-context mailing list
ntg-context@ntg.nl
http://www.ntg.nl/mailman/listinfo/ntg-context

^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2005-07-15 23:04 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2005-07-08 22:49 tweaking underlining Stuart Jansen
2005-07-09  9:19 ` Hans Hagen
2005-07-15 23:04   ` Stuart Jansen
2005-07-11 21:33 ` Mojca Miklavec

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).