ntg-context - mailing list for ConTeXt users
 help / color / mirror / Atom feed
* [NTG-context] How can I use a variable for a MetaPost coordinate ?
@ 2023-10-05  3:54 peter.hopcroft--- via ntg-context
  2023-10-05  6:05 ` [NTG-context] " Thomas A. Schmitz
  0 siblings, 1 reply; 3+ messages in thread
From: peter.hopcroft--- via ntg-context @ 2023-10-05  3:54 UTC (permalink / raw)
  To: mailing list for ConTeXt users; +Cc: peter.hopcroft

Hello list,

I want to draw lines on a page. I want to pass my line coordinates as a percent of \width or \textheight, rather than as millimetres. So that if I change the page size I don't need to change the coordinates. 

The MWE below compiles but the pdf does not have any lines drawn on it. 

Is there a way of doing calculations on the coordinates for the draw using ConTexT variables like \textheight?

Thank you,
Peter Hopcroft

------

\starttext
Some text

\startMPcode
	pickup pensquare scaled 1pt;
	draw (0mm,0mm)--(0mm,\textheight) withcolor red 
\stopMPcode

More text

\startMPcode
	pickup pensquare scaled 1pt;
	draw (0mm,0mm)--(0mm,50mm) scaled \numexpr\textheight/50mm\relax
\stopMPcode

\stoptext


------

___________________________________________________________________________________
If your question is of interest to others as well, please add an entry to the Wiki!

maillist : {listname} / https://mailman.ntg.nl/mailman3/lists/{list_id}
webpage  : https://www.pragma-ade.nl / https://context.aanhet.net (mirror)
archive  : https://github.com/contextgarden/context 
wiki     : https://wiki.contextgarden.net
___________________________________________________________________________________

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

* [NTG-context] Re: How can I use a variable for a MetaPost coordinate ?
  2023-10-05  3:54 [NTG-context] How can I use a variable for a MetaPost coordinate ? peter.hopcroft--- via ntg-context
@ 2023-10-05  6:05 ` Thomas A. Schmitz
  2023-10-06  3:03   ` peter.hopcroft--- via ntg-context
  0 siblings, 1 reply; 3+ messages in thread
From: Thomas A. Schmitz @ 2023-10-05  6:05 UTC (permalink / raw)
  To: mailing list for ConTeXt users

Have a look at chapter 6.4 of the metafun manual. You need StartPage ... 
StopPage in your MPcode, then you can knock yourself out by using 
variables such as PaperHeight or TextHeight and do all sorts of 
calculations.

All best

Thomas

On 10/5/23 05:54, peter.hopcroft--- via ntg-context wrote:
> Hello list, I want to draw lines on a page. I want to pass my line 
> coordinates as a percent of \width or \textheight, rather than as 
> millimetres. So that if I change the page size I don't need to change 
> the coordinates. The MWE below compiles but the pdf does not have any 
> lines drawn on it. Is there a way of doing calculations on the 
> coordinates for the draw using ConTexT variables like \textheight? Thank 
> you, Peter Hopcroft


___________________________________________________________________________________
If your question is of interest to others as well, please add an entry to the Wiki!

maillist : {listname} / https://mailman.ntg.nl/mailman3/lists/{list_id}
webpage  : https://www.pragma-ade.nl / https://context.aanhet.net (mirror)
archive  : https://github.com/contextgarden/context 
wiki     : https://wiki.contextgarden.net
___________________________________________________________________________________

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

* [NTG-context] Re: How can I use a variable for a MetaPost coordinate ?
  2023-10-05  6:05 ` [NTG-context] " Thomas A. Schmitz
@ 2023-10-06  3:03   ` peter.hopcroft--- via ntg-context
  0 siblings, 0 replies; 3+ messages in thread
From: peter.hopcroft--- via ntg-context @ 2023-10-06  3:03 UTC (permalink / raw)
  To: mailing list for ConTeXt users; +Cc: peter.hopcroft

Yes, indeed. The metafun manual also explains things about overlays and layers I hadn't known. I'd previously ignored that manual.

Thank you,
Peter

> On 5/10/2023, at 7:05 PM, Thomas A. Schmitz <thomas.schmitz@uni-bonn.de> wrote:
> 
> Have a look at chapter 6.4 of the metafun manual. You need StartPage ... StopPage in your MPcode, then you can knock yourself out by using variables such as PaperHeight or TextHeight and do all sorts of calculations.
> 
> All best
> 
> Thomas
> 
> On 10/5/23 05:54, peter.hopcroft--- via ntg-context wrote:
>> Hello list, I want to draw lines on a page. I want to pass my line coordinates as a percent of \width or \textheight, rather than as millimetres. So that if I change the page size I don't need to change the coordinates. The MWE below compiles but the pdf does not have any lines drawn on it. Is there a way of doing calculations on the coordinates for the draw using ConTexT variables like \textheight? Thank you, Peter Hopcroft
> 
> 
> ___________________________________________________________________________________
> If your question is of interest to others as well, please add an entry to the Wiki!
> 
> maillist : {listname} / https://mailman.ntg.nl/mailman3/lists/{list_id}
> webpage  : https://www.pragma-ade.nl / https://context.aanhet.net(mirror)
> archive  : https://github.com/contextgarden/context wiki     : https://wiki.contextgarden.net
> ___________________________________________________________________________________


___________________________________________________________________________________
If your question is of interest to others as well, please add an entry to the Wiki!

maillist : {listname} / https://mailman.ntg.nl/mailman3/lists/{list_id}
webpage  : https://www.pragma-ade.nl / https://context.aanhet.net (mirror)
archive  : https://github.com/contextgarden/context 
wiki     : https://wiki.contextgarden.net
___________________________________________________________________________________

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

end of thread, other threads:[~2023-10-06  3:13 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2023-10-05  3:54 [NTG-context] How can I use a variable for a MetaPost coordinate ? peter.hopcroft--- via ntg-context
2023-10-05  6:05 ` [NTG-context] " Thomas A. Schmitz
2023-10-06  3:03   ` peter.hopcroft--- via ntg-context

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