ntg-context - mailing list for ConTeXt users
 help / color / mirror / Atom feed
* lmtx update / teaser
@ 2021-03-01 14:44 Hans Hagen
  2021-03-01 17:27 ` Otared Kavian
  2021-03-02 10:15 ` mf
  0 siblings, 2 replies; 6+ messages in thread
From: Hans Hagen @ 2021-03-01 14:44 UTC (permalink / raw)
  To: mailing list for ConTeXt users

Hi,

I uploaded a new lmtx. As I'm currently going through the metafun todo 
files I ended up at the fancy shape part (parshapes) running over 
multiple paragraphs and decided to provide a (kind of low level) 
interface that integrates that. The example code is a few decades old 
but still works ok (i might try to improve them a bit some day). Anyway, 
here is a teaser:

\starttext

\startuseMPgraphic{circle}
     lmt_parshape [
         path       = fullcircle scaled 136mm,
         offset     = 2mm,
         bottomskip = - 1.5LineHeight,
     ] ;
\stopuseMPgraphic

\start
\startshapedparagraph[list=circle,mp=circle,repeat=yes,method=cycle]%
     \setupalign[verytolerant,stretch,last]\dontcomplain
     {\darkred     \samplefile{tufte}}\par
     {\darkgreen   \samplefile{tufte}}\par
     {\darkblue    \samplefile{tufte}}\par
     {\darkcyan    \samplefile{tufte}}\par
     {\darkmagenta \samplefile{tufte}}\par
\stopshapedparagraph
\stop

\page

\start
\startshapedparagraph[list=circle,mp=circle,repeat=yes,method=repeat]%
     \setupalign[verytolerant,stretch,last]\dontcomplain
     {\darkred     \samplefile{tufte}}
     {\darkgreen   \samplefile{tufte}}
     {\darkblue    \samplefile{tufte}}
     {\darkcyan    \samplefile{tufte}}
     {\darkmagenta \samplefile{tufte}}
\stopshapedparagraph
\stop

\stoptext

The interface is still somewhat rough (no grouping for instance, not a 
real envrionment so that might change) but seems to work ok. One can 
also go the tex route and say:

\startparagraphshape[test]
     left 1mm right 1mm
     left 2mm right 2mm
     left 3mm right 3mm
     copy 8
     left 4mm right 4mm
     left 5mm right 5mm
     left 5mm hsize 10cm
\stopparagraphshape

or

\startparagraphshape[test]
     left 1mm right 1mm
     right 3mm
     left 5mm right 5mm
     repeat
\stopparagraphshape

or

\startparagraphshape[test]
     both 1mm both 2mm both 3mm both 4mm both 5mm both 6mm
     both 7mm both 6mm both 5mm both 4mm both 3mm both 2mm
\stopparagraphshape

or

\startparagraphshape[test-repeat]
     both 1mm both 2mm both 3mm both 4mm both 5mm both 6mm
     both 7mm both 6mm both 5mm both 4mm both 3mm both 2mm
     repeat
\stopparagraphshape

and use that with:

\startshapedparagraph[list=test]
     \dorecurse{8}{\showparagraphshape\samplefile{tufte} \par}
\stopshapedparagraph

or

\startshapedparagraph[list=test-repeat]
     \dorecurse{8}{\showparagraphshape\samplefile{tufte} \par}
\stopshapedparagraph

Some more info is in the lowlevel-paragrsph document (part of the low 
level series).

This kind of features falls into the category 'fancy' (no one reqtested 
it), nice for posters and covers. It might evolve depending on needs for 
fancy features, but as said, it's currently a side track of metafun, so 
it's also in the category 'fun'. It's code for 'controlled' usage.

Hans

-----------------------------------------------------------------
                                           Hans Hagen | PRAGMA ADE
               Ridderstraat 27 | 8061 GH Hasselt | The Netherlands
        tel: 038 477 53 69 | www.pragma-ade.nl | www.pragma-pod.nl
-----------------------------------------------------------------
___________________________________________________________________________________
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://context.aanhet.net
archive  : https://bitbucket.org/phg/context-mirror/commits/
wiki     : http://contextgarden.net
___________________________________________________________________________________

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

* Re: lmtx update / teaser
  2021-03-01 14:44 lmtx update / teaser Hans Hagen
@ 2021-03-01 17:27 ` Otared Kavian
  2021-03-01 18:13   ` Hans Hagen
  2021-03-02 10:15 ` mf
  1 sibling, 1 reply; 6+ messages in thread
From: Otared Kavian @ 2021-03-01 17:27 UTC (permalink / raw)
  To: mailing list for ConTeXt users

Hi Hans,

Thank you for the new upload.

The teaser examples work fine, many thanks !
I have a question though: how can one center within a page a text, for example typeset in a circular shape? I tried with \startalignment, and also with \startplacefigure but none of these gives a centered circular shape.

Also I noticed that if one removes the comment at the end of \startshapedparagraph, or add a blank line after that, then the circular shape is destroyed: is this on purpose ?

Best regards: Otared

% begin example-circular-shape.tex
\starttext

%\startuseMPgraphic{circle}
%	lmt_parshape [
%		path       = fullcircle scaled 136mm,
%		offset     = 2mm,
%		bottomskip = - 1.5LineHeight,
%	] ;
%\stopuseMPgraphic

\startuseMPgraphic{circleBis}
	lmt_parshape [
		path       = fullcircle scaled 90mm,
		offset     = 2mm,
		bottomskip = - 1.5LineHeight,
	] ;
\stopuseMPgraphic

\startalignment[middle]
%\startplacefigure[align=middle,number=no]
\start
\startshapedparagraph[list=circle,mp=circleBis,repeat=yes,method=repeat]%
	\setupalign[verytolerant,stretch,last]
	\dontcomplain
		{\darkred     \samplefile{thuan}}
\stopshapedparagraph
\stop
%\stopplacefigure
\stopalignment 

\stoptext
% end example-circular-shape.tex

> On 1 Mar 2021, at 15:44, Hans Hagen <j.hagen@xs4all.nl> wrote:
> 
> Hi,
> 
> I uploaded a new lmtx. As I'm currently going through the metafun todo files I ended up at the fancy shape part (parshapes) running over multiple paragraphs and decided to provide a (kind of low level) interface that integrates that. The example code is a few decades old but still works ok (i might try to improve them a bit some day). Anyway, here is a teaser:
> 
> \starttext
> 
> \startuseMPgraphic{circle}
>    lmt_parshape [
>        path       = fullcircle scaled 136mm,
>        offset     = 2mm,
>        bottomskip = - 1.5LineHeight,
>    ] ;
> \stopuseMPgraphic
> 
> \start
> \startshapedparagraph[list=circle,mp=circle,repeat=yes,method=cycle]%
>    \setupalign[verytolerant,stretch,last]\dontcomplain
>    {\darkred     \samplefile{tufte}}\par
>    {\darkgreen   \samplefile{tufte}}\par
>    {\darkblue    \samplefile{tufte}}\par
>    {\darkcyan    \samplefile{tufte}}\par
>    {\darkmagenta \samplefile{tufte}}\par
> \stopshapedparagraph
> \stop
> 
> \page
> 
> \start
> \startshapedparagraph[list=circle,mp=circle,repeat=yes,method=repeat]%
>    \setupalign[verytolerant,stretch,last]\dontcomplain
>    {\darkred     \samplefile{tufte}}
>    {\darkgreen   \samplefile{tufte}}
>    {\darkblue    \samplefile{tufte}}
>    {\darkcyan    \samplefile{tufte}}
>    {\darkmagenta \samplefile{tufte}}
> \stopshapedparagraph
> \stop
> 
> \stoptext
> 
> The interface is still somewhat rough (no grouping for instance, not a real envrionment so that might change) but seems to work ok. One can also go the tex route and say:
> 
> \startparagraphshape[test]
>    left 1mm right 1mm
>    left 2mm right 2mm
>    left 3mm right 3mm
>    copy 8
>    left 4mm right 4mm
>    left 5mm right 5mm
>    left 5mm hsize 10cm
> \stopparagraphshape
> 
> or
> 
> \startparagraphshape[test]
>    left 1mm right 1mm
>    right 3mm
>    left 5mm right 5mm
>    repeat
> \stopparagraphshape
> 
> or
> 
> \startparagraphshape[test]
>    both 1mm both 2mm both 3mm both 4mm both 5mm both 6mm
>    both 7mm both 6mm both 5mm both 4mm both 3mm both 2mm
> \stopparagraphshape
> 
> or
> 
> \startparagraphshape[test-repeat]
>    both 1mm both 2mm both 3mm both 4mm both 5mm both 6mm
>    both 7mm both 6mm both 5mm both 4mm both 3mm both 2mm
>    repeat
> \stopparagraphshape
> 
> and use that with:
> 
> \startshapedparagraph[list=test]
>    \dorecurse{8}{\showparagraphshape\samplefile{tufte} \par}
> \stopshapedparagraph
> 
> or
> 
> \startshapedparagraph[list=test-repeat]
>    \dorecurse{8}{\showparagraphshape\samplefile{tufte} \par}
> \stopshapedparagraph
> 
> Some more info is in the lowlevel-paragrsph document (part of the low level series).
> 
> This kind of features falls into the category 'fancy' (no one reqtested it), nice for posters and covers. It might evolve depending on needs for fancy features, but as said, it's currently a side track of metafun, so it's also in the category 'fun'. It's code for 'controlled' usage.
> 
> Hans
> 
> -----------------------------------------------------------------
>                                          Hans Hagen | PRAGMA ADE
>              Ridderstraat 27 | 8061 GH Hasselt | The Netherlands
>       tel: 038 477 53 69 | www.pragma-ade.nl | www.pragma-pod.nl
> -----------------------------------------------------------------
> ___________________________________________________________________________________
> 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://context.aanhet.net
> archive  : https://bitbucket.org/phg/context-mirror/commits/
> wiki     : http://contextgarden.net
> ___________________________________________________________________________________

___________________________________________________________________________________
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://context.aanhet.net
archive  : https://bitbucket.org/phg/context-mirror/commits/
wiki     : http://contextgarden.net
___________________________________________________________________________________

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

* Re: lmtx update / teaser
  2021-03-01 17:27 ` Otared Kavian
@ 2021-03-01 18:13   ` Hans Hagen
  0 siblings, 0 replies; 6+ messages in thread
From: Hans Hagen @ 2021-03-01 18:13 UTC (permalink / raw)
  To: mailing list for ConTeXt users, Otared Kavian

On 3/1/2021 6:27 PM, Otared Kavian wrote:
> Hi Hans,
> 
> Thank you for the new upload.
> 
> The teaser examples work fine, many thanks !
> I have a question though: how can one center within a page a text, for example typeset in a circular shape? I tried with \startalignment, and also with \startplacefigure but none of these gives a centered circular shape.
> 
> Also I noticed that if one removes the comment at the end of \startshapedparagraph, or add a blank line after that, then the circular shape is destroyed: is this on purpose ?
\starttext

\startuseMPgraphic{circleBis}
     lmt_parshape [
         path       = fullcircle scaled 90mm,
         offset     = 2mm,
         bottomskip = - 1.5LineHeight,
     ] ;
\stopuseMPgraphic

\startplacefigure[align=middle,number=no]
     \framed[width=90mm,offset=2mm,align=normal]\bgroup
         \startshapedparagraph
             [list=circle,mp=circleBis,repeat=yes,method=repeat]%
             \setupalign[verytolerant,stretch,last]\dontcomplain
             {\darkred \samplefile{thuan}}
         \stopshapedparagraph
     \egroup
\stopplacefigure

\stoptext

We're talking parshapes here, think of

\parshape 2
   2mm 10cm
   4mm 12cm

or

\parshape 2
   options 1 % force a repeat
   2mm 10cm
   4mm 12cm

but then nicely wrapped in a macro. The circle is (cf metafun manual) 
converted into such a parshape. A parshape is forgotten when a new 
paragraph is started, but ... we have extra magic that revives them 
which is why the multi-page-par examples work too. The cycle and repeat 
methods do that (using abit diufferent tricks than the 20 year old one 
but not that different); these methods are independent of the parshape's 
repeat option itself, which is an engine feature.

Messing with left/right 'align' will also bring left/rightskip into the 
game so normally you will not do that. I admit it take a bit of 
imagination to get the picture. The 'last' keyword is some old context 
feature that centers the last line (which looks nicer in a circle) which
is using some parfillskip magic.

Hans


-----------------------------------------------------------------
                                           Hans Hagen | PRAGMA ADE
               Ridderstraat 27 | 8061 GH Hasselt | The Netherlands
        tel: 038 477 53 69 | www.pragma-ade.nl | www.pragma-pod.nl
-----------------------------------------------------------------
___________________________________________________________________________________
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://context.aanhet.net
archive  : https://bitbucket.org/phg/context-mirror/commits/
wiki     : http://contextgarden.net
___________________________________________________________________________________

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

* Re: lmtx update / teaser
  2021-03-01 14:44 lmtx update / teaser Hans Hagen
  2021-03-01 17:27 ` Otared Kavian
@ 2021-03-02 10:15 ` mf
  2021-03-02 10:33   ` Hans Hagen
  2021-03-02 10:47   ` Hans Hagen
  1 sibling, 2 replies; 6+ messages in thread
From: mf @ 2021-03-02 10:15 UTC (permalink / raw)
  To: ntg-context

Il 01/03/21 15:44, Hans Hagen ha scritto:
> 
> \starttext
> 
> \startuseMPgraphic{circle}
>      lmt_parshape [
>          path       = fullcircle scaled 136mm,
>          offset     = 2mm,
>          bottomskip = - 1.5LineHeight,
>      ] ;
> \stopuseMPgraphic
> 
> \start
> \startshapedparagraph[list=circle,mp=circle,repeat=yes,method=cycle]%

list=... refers to a previous \startparagraphshape definition, so mp=... 
tells ConTeXt that the definition is derived from MetaPost code instead.

Just mp=... could be enough, but maybe "list=xyz,mp=xyz" makes it clear 
that mp is used to get a parshape from MetaPost instead of a 
\startparagraphshape definition.

>      \setupalign[verytolerant,stretch,last]\dontcomplain

What's the meaning of \dontcomplain? Why is it needed there?

BTW, \startparagraphshape, \stopparagraphshape, \startshapedparagraph, 
\stopshapedparagraph should be added to the .xml documentation files.

The "right", "left", "both", "copy", "repeat" syntax in 
\startparagraphshape is really handy.

Thanks,
Massi
___________________________________________________________________________________
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://context.aanhet.net
archive  : https://bitbucket.org/phg/context-mirror/commits/
wiki     : http://contextgarden.net
___________________________________________________________________________________

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

* Re: lmtx update / teaser
  2021-03-02 10:15 ` mf
@ 2021-03-02 10:33   ` Hans Hagen
  2021-03-02 10:47   ` Hans Hagen
  1 sibling, 0 replies; 6+ messages in thread
From: Hans Hagen @ 2021-03-02 10:33 UTC (permalink / raw)
  To: mailing list for ConTeXt users, mf

On 3/2/2021 11:15 AM, mf wrote:
> Il 01/03/21 15:44, Hans Hagen ha scritto:
>>
>> \starttext
>>
>> \startuseMPgraphic{circle}
>>      lmt_parshape [
>>          path       = fullcircle scaled 136mm,
>>          offset     = 2mm,
>>          bottomskip = - 1.5LineHeight,
>>      ] ;
>> \stopuseMPgraphic
>>
>> \start
>> \startshapedparagraph[list=circle,mp=circle,repeat=yes,method=cycle]%
> 
> list=... refers to a previous \startparagraphshape definition, so mp=... 
> tells ConTeXt that the definition is derived from MetaPost code instead.

you're right, the list= can be removed (you can do that and see that it 
still works)

> Just mp=... could be enough, but maybe "list=xyz,mp=xyz" makes it clear 
> that mp is used to get a parshape from MetaPost instead of a 
> \startparagraphshape definition.
> 
>>      \setupalign[verytolerant,stretch,last]\dontcomplain
> 
> What's the meaning of \dontcomplain? Why is it needed there?

I don't want to see messages about underful boxes cluttering my log (and 
such shapes tend to produce them).

> BTW, \startparagraphshape, \stopparagraphshape, \startshapedparagraph, 
> \stopshapedparagraph should be added to the .xml documentation files.

WOlfgang normally picks up these new thinsg and adds them but we update 
the xml files only periodically.

> The "right", "left", "both", "copy", "repeat" syntax in 
> \startparagraphshape is really handy.
I might actually add "metapost {name}" too and "delete n" to wipe out 
some previous ones. Rather trivial but we need to be able to say that we 
'added a new feature' occasionally. I couldn't yet think of more than 
'cycle' and 'repeat' but who knows what users want ... (like some 
autofit loop).

Hans

-----------------------------------------------------------------
                                           Hans Hagen | PRAGMA ADE
               Ridderstraat 27 | 8061 GH Hasselt | The Netherlands
        tel: 038 477 53 69 | www.pragma-ade.nl | www.pragma-pod.nl
-----------------------------------------------------------------
___________________________________________________________________________________
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://context.aanhet.net
archive  : https://bitbucket.org/phg/context-mirror/commits/
wiki     : http://contextgarden.net
___________________________________________________________________________________

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

* Re: lmtx update / teaser
  2021-03-02 10:15 ` mf
  2021-03-02 10:33   ` Hans Hagen
@ 2021-03-02 10:47   ` Hans Hagen
  1 sibling, 0 replies; 6+ messages in thread
From: Hans Hagen @ 2021-03-02 10:47 UTC (permalink / raw)
  To: mailing list for ConTeXt users, mf

On 3/2/2021 11:15 AM, mf wrote:
> Il 01/03/21 15:44, Hans Hagen ha scritto:
>>
>> \starttext
>>
>> \startuseMPgraphic{circle}
>>      lmt_parshape [
>>          path       = fullcircle scaled 136mm,
>>          offset     = 2mm,
>>          bottomskip = - 1.5LineHeight,
>>      ] ;
>> \stopuseMPgraphic
>>
>> \start
>> \startshapedparagraph[list=circle,mp=circle,repeat=yes,method=cycle]%
> 
> list=... refers to a previous \startparagraphshape definition, so mp=... 
> tells ConTeXt that the definition is derived from MetaPost code instead.
You can go completely crazy with this:

\setupbodyfont[pagella,10pt]

\showframe

\setuplayout[width=middle,height=middle,footer=0pt]

\startuseMPgraphic{circle}
     lmt_parshape [
      %  path       = fullcircle scaled 136mm,
         path       = fullcircle scaled TextWidth randomized 2cm,
      %  offset     = 2mm,
         bottomskip = - 1.5LineHeight,
     ] ;
\stopuseMPgraphic

\starttext

\startshapedparagraph[mp=circle,repeat=yes,method=cycle]%
     \setupalign[verytolerant,stretch,last]\dontcomplain
     \dorecurse{100}{
         {\darkred                          \samplefile{tufte}}
         {\darkgreen   \kerncharacters[.125]\samplefile{ward}}
         {\darkblue    \it                  \samplefile{thuan}}
         {\darkcyan    \bf                  \samplefile{zapf}}
         {\darkmagenta \bi                  \samplefile{sapolsky}}
         {\darkyellow  \smallcaps           \samplefile{davis}}
         \par % \blank
     }
\stopshapedparagraph

\stoptext

It might work for a children book or so,

Hans


-----------------------------------------------------------------
                                           Hans Hagen | PRAGMA ADE
               Ridderstraat 27 | 8061 GH Hasselt | The Netherlands
        tel: 038 477 53 69 | www.pragma-ade.nl | www.pragma-pod.nl
-----------------------------------------------------------------
___________________________________________________________________________________
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://context.aanhet.net
archive  : https://bitbucket.org/phg/context-mirror/commits/
wiki     : http://contextgarden.net
___________________________________________________________________________________

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

end of thread, other threads:[~2021-03-02 10:47 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-03-01 14:44 lmtx update / teaser Hans Hagen
2021-03-01 17:27 ` Otared Kavian
2021-03-01 18:13   ` Hans Hagen
2021-03-02 10:15 ` mf
2021-03-02 10:33   ` Hans Hagen
2021-03-02 10:47   ` Hans Hagen

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