ntg-context - mailing list for ConTeXt users
 help / color / mirror / Atom feed
* Metafun: setting pen size in properties
@ 2017-07-23 23:40 Aditya Mahajan
  2017-07-24  0:13 ` Alan Braslau
  2017-07-24  8:26 ` Hans Hagen
  0 siblings, 2 replies; 5+ messages in thread
From: Aditya Mahajan @ 2017-07-23 23:40 UTC (permalink / raw)
  To: mailing list for ConTeXt users

Hi,

Is it possible to set pen width using properties(...)? The following does 
not work (the color is set, but not the pen width):

\starttext
\startMPcode
property p[] ;
p[1] := properties(withcolor red  withpen pencircle scaled 1bp);
p[2] := properties(withcolor blue withpen pencircle scaled 10bp);

draw fullcircle scaled 1cm withproperties p[1];
draw fullcircle scaled 2cm withproperties p[2];
\stopMPcode
\stoptext

Also, what is the advantage of using properties over a simple def? (except 
that I cannot def a suffixed variable). For example:

\starttext
\startMPcode
def qA = withcolor red  withpen pencircle scaled 1bp enddef;
def qB = withcolor blue withpen pencircle scaled 10bp enddef;

draw fullcircle scaled 1cm qA;
draw fullcircle scaled 2cm qB;

\stopMPcode
\stoptext

Thanks,
Aditya
___________________________________________________________________________________
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] 5+ messages in thread

* Re: Metafun: setting pen size in properties
  2017-07-23 23:40 Metafun: setting pen size in properties Aditya Mahajan
@ 2017-07-24  0:13 ` Alan Braslau
  2017-07-24  8:26 ` Hans Hagen
  1 sibling, 0 replies; 5+ messages in thread
From: Alan Braslau @ 2017-07-24  0:13 UTC (permalink / raw)
  To: Aditya Mahajan; +Cc: mailing list for ConTeXt users

withproperties is an experimental, metafun extension that appears to
cover color and pre/postscripts. It could be extended to cover withpen,
etc.

Look at mp-mplib.mkiv. properties() returns an image object that can
hold many things. The graph package does similar tricks.

Alan




On Sun, 23 Jul 2017 19:40:03 -0400 (EDT)
Aditya Mahajan <adityam@umich.edu> wrote:

> Hi,
> 
> Is it possible to set pen width using properties(...)? The following
> does not work (the color is set, but not the pen width):
> 
> \starttext
> \startMPcode
> property p[] ;
> p[1] := properties(withcolor red  withpen pencircle scaled 1bp);
> p[2] := properties(withcolor blue withpen pencircle scaled 10bp);
> 
> draw fullcircle scaled 1cm withproperties p[1];
> draw fullcircle scaled 2cm withproperties p[2];
> \stopMPcode
> \stoptext
> 
> Also, what is the advantage of using properties over a simple def?
> (except that I cannot def a suffixed variable). For example:
> 
> \starttext
> \startMPcode
> def qA = withcolor red  withpen pencircle scaled 1bp enddef;
> def qB = withcolor blue withpen pencircle scaled 10bp enddef;
> 
> draw fullcircle scaled 1cm qA;
> draw fullcircle scaled 2cm qB;
> 
> \stopMPcode
> \stoptext
> 
> Thanks,
> Aditya
> ___________________________________________________________________________________
> 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] 5+ messages in thread

* Re: Metafun: setting pen size in properties
  2017-07-23 23:40 Metafun: setting pen size in properties Aditya Mahajan
  2017-07-24  0:13 ` Alan Braslau
@ 2017-07-24  8:26 ` Hans Hagen
  2017-07-24 16:58   ` Alan Braslau
  1 sibling, 1 reply; 5+ messages in thread
From: Hans Hagen @ 2017-07-24  8:26 UTC (permalink / raw)
  To: mailing list for ConTeXt users, Aditya Mahajan

On 7/24/2017 1:40 AM, Aditya Mahajan wrote:
> Hi,
> 
> Is it possible to set pen width using properties(...)? The following 
> does not work (the color is set, but not the pen width):
> 
> \starttext
> \startMPcode
> property p[] ;
> p[1] := properties(withcolor red  withpen pencircle scaled 1bp);
> p[2] := properties(withcolor blue withpen pencircle scaled 10bp);
> 
> draw fullcircle scaled 1cm withproperties p[1];
> draw fullcircle scaled 2cm withproperties p[2];
> \stopMPcode
> \stoptext

def withproperties expr p =
     if colormodel p = 3 :
         withcolor greypart p
     elseif colormodel p = 5 :
         withcolor (redpart p,greenpart p,bluepart p)
     elseif colormodel p = 7 :
         withcolor (cyanpart p,magentapart p,yellowpart p,blackpart p)
     fi
     withpen penpart p
     withprescript prescriptpart p
     withpostscript postscriptpart p
enddef ;



> Also, what is the advantage of using properties over a simple def? 
> (except that I cannot def a suffixed variable). For example:
> 
> \starttext
> \startMPcode
> def qA = withcolor red  withpen pencircle scaled 1bp enddef;
> def qB = withcolor blue withpen pencircle scaled 10bp enddef;
> 
> draw fullcircle scaled 1cm qA;
> draw fullcircle scaled 2cm qB;
> 
> \stopMPcode
> \stoptext
abstraction ..

-----------------------------------------------------------------
                                           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] 5+ messages in thread

* Re: Metafun: setting pen size in properties
  2017-07-24  8:26 ` Hans Hagen
@ 2017-07-24 16:58   ` Alan Braslau
  2017-07-25 17:34     ` Aditya Mahajan
  0 siblings, 1 reply; 5+ messages in thread
From: Alan Braslau @ 2017-07-24 16:58 UTC (permalink / raw)
  To: Hans Hagen; +Cc: mailing list for ConTeXt users

On Mon, 24 Jul 2017 10:26:25 +0200
Hans Hagen <pragma@wxs.nl> wrote:

> On 7/24/2017 1:40 AM, Aditya Mahajan wrote:
> > Hi,
> > 
> > Is it possible to set pen width using properties(...)? The
> > following does not work (the color is set, but not the pen width):
> > 
> > \starttext
> > \startMPcode
> > property p[] ;
> > p[1] := properties(withcolor red  withpen pencircle scaled 1bp);
> > p[2] := properties(withcolor blue withpen pencircle scaled 10bp);
> > 
> > draw fullcircle scaled 1cm withproperties p[1];
> > draw fullcircle scaled 2cm withproperties p[2];
> > \stopMPcode
> > \stoptext  
> 
> def withproperties expr p =
>      if colormodel p = 3 :
>          withcolor greypart p
>      elseif colormodel p = 5 :
>          withcolor (redpart p,greenpart p,bluepart p)
>      elseif colormodel p = 7 :
>          withcolor (cyanpart p,magentapart p,yellowpart p,blackpart p)
>      fi
>      withpen penpart p

       if dashpart p <> nullpicture :
         dashed dashpart p
       fi

>      withprescript prescriptpart p
>      withpostscript postscriptpart p
> enddef ;
> 
> 
> 
> > Also, what is the advantage of using properties over a simple def? 
> > (except that I cannot def a suffixed variable). For example:
> > 
> > \starttext
> > \startMPcode
> > def qA = withcolor red  withpen pencircle scaled 1bp enddef;
> > def qB = withcolor blue withpen pencircle scaled 10bp enddef;
> > 
> > draw fullcircle scaled 1cm qA;
> > draw fullcircle scaled 2cm qB;
> > 
> > \stopMPcode
> > \stoptext  
> abstraction ..
> 
> -----------------------------------------------------------------
>                                            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] 5+ messages in thread

* Re: Metafun: setting pen size in properties
  2017-07-24 16:58   ` Alan Braslau
@ 2017-07-25 17:34     ` Aditya Mahajan
  0 siblings, 0 replies; 5+ messages in thread
From: Aditya Mahajan @ 2017-07-25 17:34 UTC (permalink / raw)
  To: mailing list for ConTeXt users

On Mon, 24 Jul 2017, Alan Braslau wrote:

> On Mon, 24 Jul 2017 10:26:25 +0200
> Hans Hagen <pragma@wxs.nl> wrote:
>
>> On 7/24/2017 1:40 AM, Aditya Mahajan wrote:
>>> Hi,
>>>
>>> Is it possible to set pen width using properties(...)? The
>>> following does not work (the color is set, but not the pen width):
>>>
>>> \starttext
>>> \startMPcode
>>> property p[] ;
>>> p[1] := properties(withcolor red  withpen pencircle scaled 1bp);
>>> p[2] := properties(withcolor blue withpen pencircle scaled 10bp);
>>>
>>> draw fullcircle scaled 1cm withproperties p[1];
>>> draw fullcircle scaled 2cm withproperties p[2];
>>> \stopMPcode
>>> \stoptext
>>
>> def withproperties expr p =
>>      if colormodel p = 3 :
>>          withcolor greypart p
>>      elseif colormodel p = 5 :
>>          withcolor (redpart p,greenpart p,bluepart p)
>>      elseif colormodel p = 7 :
>>          withcolor (cyanpart p,magentapart p,yellowpart p,blackpart p)
>>      fi
>>      withpen penpart p
>
>       if dashpart p <> nullpicture :
>         dashed dashpart p
>       fi
>
>>      withprescript prescriptpart p
>>      withpostscript postscriptpart p
>> enddef ;

Thanks!

Aditya
___________________________________________________________________________________
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] 5+ messages in thread

end of thread, other threads:[~2017-07-25 17:34 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2017-07-23 23:40 Metafun: setting pen size in properties Aditya Mahajan
2017-07-24  0:13 ` Alan Braslau
2017-07-24  8:26 ` Hans Hagen
2017-07-24 16:58   ` Alan Braslau
2017-07-25 17:34     ` Aditya Mahajan

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