ntg-context - mailing list for ConTeXt users
 help / color / mirror / Atom feed
From: Hans Hagen <pragma@wxs.nl>
To: mailing list for ConTeXt users <ntg-context@ntg.nl>,
	Aditya Mahajan <adityam@umich.edu>
Subject: Re: Metafun: setting pen size in properties
Date: Mon, 24 Jul 2017 10:26:25 +0200	[thread overview]
Message-ID: <66846094-ca3a-4e8d-89a2-f7423893f0a9@wxs.nl> (raw)
In-Reply-To: <alpine.OSX.2.02.1707231931440.36563@nqv-znpobbx>

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
___________________________________________________________________________________

  parent reply	other threads:[~2017-07-24  8:26 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2017-07-23 23:40 Aditya Mahajan
2017-07-24  0:13 ` Alan Braslau
2017-07-24  8:26 ` Hans Hagen [this message]
2017-07-24 16:58   ` Alan Braslau
2017-07-25 17:34     ` Aditya Mahajan

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=66846094-ca3a-4e8d-89a2-f7423893f0a9@wxs.nl \
    --to=pragma@wxs.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).