ntg-context - mailing list for ConTeXt users
 help / color / mirror / Atom feed
From: Hans Hagen <j.hagen@xs4all.nl>
To: mailing list for ConTeXt users <ntg-context@ntg.nl>,
	Aditya Mahajan <adityam@umich.edu>
Subject: Re: weekend upload
Date: Sat, 10 Jul 2021 22:44:59 +0200	[thread overview]
Message-ID: <b402265d-0a0c-4284-6a14-949a974014da@xs4all.nl> (raw)
In-Reply-To: <nycvar.YAK.7.78.908.2107091731360.837077@nqv-guvaxcnq>

On 7/9/2021 11:33 PM, Aditya Mahajan wrote:
> 
> 
> On Fri, 9 Jul 2021, Hans Hagen wrote:
> 
>> Hi,
>>
>> This weekend upload has something new for metapost animation lovers:
>>
>> \starttext
>>
>> \startuseMPgraphic{demo}
>>       stacking := 6;
>>       fill fullcircle scaled 10cm
>>           withcolor "red" ;
>>     % stacking := 3;
>>       stacking := 9;
>>       fill fullcircle scaled 10cm shifted (3cm,0)
>>           withcolor "green" ;
>>       interim stacking := 4;
>>       fill fullcircle scaled 10cm shifted (3cm,3cm)
>>           withcolor "blue" ;
>>       for i=1 upto 10 :
>>           draw fullcircle scaled (i*cm)
>>               withstacking 8
>>               withpen      pencircle scaled 1mm
>>               withcolor    "gray" ;
>>       endfor ;
>>       for i=1 upto 20 :
>>           draw fullcircle scaled (i*cm/2)
>>               withstacking (if odd(i) : i else : 5 fi)
>>               withpen      pencircle scaled 2mm ;
>>       endfor ;
>>       draw boundingbox currentpicture
>>           withpen      pencircle scaled 1pt
>>           withstacking 0 ;
>>       currentpicture := currentpicture xsized 15mm;
>> \stopuseMPgraphic
>>
>> \setupMPvariables[demo]
>>
>> \startTEXpage
>>       \vskip1ex
>>       \hbox{\space\dorecurse{10}{\useMPgraphic{demo}{list={0,#1}}\space}}
>>       \vskip1ex \nointerlineskip
>>       \hbox{\space\dorecurse{10}{\useMPgraphic{demo}{list={0,1-#1}}\space}}
>>       \vskip1ex
>> \stopTEXpage
>>
>> \stoptext
>>
>> I have some more ideas but want to approach it stepwise. It bpils down
>> to the fact that one can put stuff on different 'layers' and optionally
>> flush these (by default all are flushed but the stackling order is
>> honored). An advantage is that one doesn't have to set up a graphic in
>> order (read: save pictures, flush them later on) and it is actually a
>> rather cheap extension in terms of runtime and overhead. Although I
>> could emulate it in mkiv, it is currently an LMTX only feature.
>>
>> The (optional) list accepts the usual {1,2,5,7-9} kind of specification.
> 
> Very interesting. What will be the syntax to use this with \processMPbuffer and \startMPcode?
In order to avoid a slash I went for the 'stacking' key:

  \startMPcode[instance=doublefun,stacking=0] % 4
      draw (fullcircle scaled 5cm shifted (0cm,0cm)) withstacking 4;
      draw (fullcircle scaled 5cm shifted (0cm,0cm))
          withpattern image (fill fullcircle scaled 1cm withcolor 
"darkred" ;)
          withpatternscale (1/10,1/10)
      ;
  \stopMPcode

  \startMPpage[offset=1cm,instance=doublefun,stacking=0] % 4
      draw (fullcircle scaled 5cm shifted (0cm,0cm)) withstacking 4;
      draw (fullcircle scaled 5cm shifted (0cm,0cm))
          withpattern image (fill fullcircle scaled 1cm withcolor 
"darkblue";)
          withpatternscale (1/10,1/10)
      ;
  \stopMPpage

we also have optionals to \use.., \reuse.. and \unique..

\startTEXpage
     \vskip1ex
     \hbox{\space\dorecurse{10}{\useMPgraphic
        {demo}{stacking={0,#1}}\space}}
     \vskip1ex \nointerlineskip
     \hbox{\space\dorecurse{10}{\useMPgraphic
        {demo}{stacking={0,1-#1}}\space}}
     \vskip1ex \nointerlineskip
     \hbox{\space\dorecurse{10}{\useMPgraphic
        [instance=doublefun,stacking={0,1-#1}]{demo}\space}}
     \vskip1ex
\stopTEXpage

work in progress (new upload anyway, also with clipping fixed wrt stacking)

(i was wondering for a moment if "undergraphic removal" makes sense but 
it is a somewhat costly operation)

(an other feature to explore is not to rerun but use some wrapper that 
keeps the image for as long as we flush ... it might save some runtime 
but first i need to run into a case where it pays off)

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
___________________________________________________________________________________

  parent reply	other threads:[~2021-07-10 20:44 UTC|newest]

Thread overview: 15+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-07-09 16:29 Hans Hagen
2021-07-09 17:19 ` Hans Hagen
2021-07-09 21:33 ` Aditya Mahajan
2021-07-09 22:24   ` Hans Hagen
2021-07-10 20:44   ` Hans Hagen [this message]
2021-07-11 13:04 ` Bruce Horrocks
2021-07-11 15:00   ` Hans Hagen
2021-07-12  3:31   ` Aditya Mahajan
2021-07-12  8:07     ` Hans Hagen
2021-07-12 10:12       ` Floris van Manen
2021-07-12 16:47         ` Hans Hagen
2021-07-12  9:07     ` Hans Hagen
     [not found] <mailman.580.1626060721.1143.ntg-context@ntg.nl>
2021-07-12 19:29 ` Jeong Dal
2021-07-12 20:00   ` Aditya Mahajan
     [not found] <mailman.1.1626170401.2795.ntg-context@ntg.nl>
2021-07-13 10:29 ` Jeong Dal

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=b402265d-0a0c-4284-6a14-949a974014da@xs4all.nl \
    --to=j.hagen@xs4all.nl \
    --cc=adityam@umich.edu \
    --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).