ntg-context - mailing list for ConTeXt users
 help / color / mirror / Atom feed
* Unexpected result when using PaperHeight and MetaFUun
@ 2020-04-19 11:15 Keith McKay
  2020-04-19 12:04 ` Wolfgang Schuster
  0 siblings, 1 reply; 3+ messages in thread
From: Keith McKay @ 2020-04-19 11:15 UTC (permalink / raw)
  To: mailing list for ConTeXt users


[-- Attachment #1.1: Type: text/plain, Size: 1974 bytes --]

Dear All

I have problem understanding what is happening in the MWE below which is 
different from what I expected.

I have created a shaded background using MetaFun with dimensions 
PaperWidth by PaperHeight which mimics \setuppapersize[A4,landscape} as 
expected.  I then within \starttext \startMPpage... \stopMPpage 
\stoptext created a stripe of the shaded background, xscaled 2cm y 
scaled PaperHeight, but reversed, expecting it to cover the background 
top to bottom. However the top of the stripe seems to start at 10.5cm 
which is suspiciously half the height of A4, Landscape i.e. 21cm. I 
confirmed this by changing the shifted command to, shifted 
(19cm,10.5cm), and the stripe is positioned as expected.

Am I missing something obvious in how MetaFun handles coordinates? I 
have asumed that in MetaFun, (0,0) is the bottom left corner. Or is it 
how I applied the shifted command?

I'm using LuaMetaTex Version 2.05.01 ConTeXt ver: 2020.04.03 10:31 MKIV 
beta fmt: 2020.4.6 int: english/english

Thanks and stay safe.

Best Wishes

Keith McKay

%%%%%%%%%%% MWE %%%%%%%%%%%%%%% \setuppapersize[A4,landscape]

\definelayer[mybg]

[x=0mm, y=0mm,

width=\paperwidth, height=\paperheight] % let the layer cover the full paper

\startuniqueMPgraphic{blueShade}

draw lmt_shade [

path = fullsquare xyscaled(PaperWidth,PaperHeight),

direction = "up",

alternative = "linear",

colors = { "red", "blue" },

];

\stopuniqueMPgraphic

\setlayer[mybg]{\uniqueMPgraphic{blueShade}}

\setupbackgrounds[page][background={mybg}]

\starttext

\startMPpage

StartPage ;

%Result Left

draw lmt_shade [

path = fullsquare xscaled 2cm yscaled PaperHeight,

direction = "down",

alternative = "linear",

colors = { "red", "blue" },

]shifted (12cm,0cm);

%Result Right

draw lmt_shade [

path = fullsquare xscaled 2cm yscaled PaperHeight,

direction = "down",

alternative = "linear",

colors = { "red", "blue" },

] shifted (19cm,10.5cm);

StopPage ;

\stopMPpage

\stoptext


[-- Attachment #1.2: Type: text/html, Size: 7052 bytes --]

[-- Attachment #2: Type: text/plain, Size: 493 bytes --]

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

* Re: Unexpected result when using PaperHeight and MetaFUun
  2020-04-19 11:15 Unexpected result when using PaperHeight and MetaFUun Keith McKay
@ 2020-04-19 12:04 ` Wolfgang Schuster
  2020-04-19 12:21   ` Keith McKay
  0 siblings, 1 reply; 3+ messages in thread
From: Wolfgang Schuster @ 2020-04-19 12:04 UTC (permalink / raw)
  To: mailing list for ConTeXt users, Keith McKay

Keith McKay schrieb am 19.04.2020 um 13:15:
> Dear All
> 
> I have problem understanding what is happening in the MWE below which is 
> different from what I expected.
> 
> I have created a shaded background using MetaFun with dimensions 
> PaperWidth by PaperHeight which mimics \setuppapersize[A4,landscape} as 
> expected.  I then within \starttext \startMPpage... \stopMPpage 
> \stoptext created a stripe of the shaded background, xscaled 2cm y 
> scaled PaperHeight, but reversed, expecting it to cover the background 
> top to bottom. However the top of the stripe seems to start at 10.5cm 
> which is suspiciously half the height of A4, Landscape i.e. 21cm. I 
> confirmed this by changing the shifted command to, shifted 
> (19cm,10.5cm), and the stripe is positioned as expected.
> 
> Am I missing something obvious in how MetaFun handles coordinates? I 
> have asumed that in MetaFun, (0,0) is the bottom left corner. Or is it 
> how I applied the shifted command?

1. When you need page backgrounds you can use a overlay and don't have 
to create a layer for it.

2. Use unitsquare for your bars which has the origin in the lower left 
corner because fullsquare has the origin in the center (look at page 383 
in the metafun manual).

\setuppapersize [A4,landscape]

\startuniqueMPgraphic{blueShade}
draw lmt_shade [
     path        = fullsquare xyscaled (OverlayWidth,OverlayHeight) ,
     direction   = "up",
     alternative = "linear",
     colors      = { "red", "blue" },
] ;
\stopuniqueMPgraphic

\defineoverlay [mybg] [\uniqueMPgraphic{blueShade}]

\setupbackgrounds [page] [background=mybg]

\starttext

\startMPpage
StartPage ;
     % Result Left
     draw lmt_shade [
         path        = unitsquare xscaled 2cm yscaled PaperHeight,
         direction   = "down",
         alternative = "linear",
         colors      = { "red", "blue" },
     ] shifted (12cm,0) ;
     % Result Right
     draw lmt_shade [
         path        = unitsquare xscaled 2cm yscaled PaperHeight,
         direction   = "down",
         alternative = "linear",
         colors      = { "red", "blue" },
     ] shifted (19cm,0cm) ;
StopPage ;
\stopMPpage

\stoptext

Wolfgang
___________________________________________________________________________________
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] 3+ messages in thread

* Re: Unexpected result when using PaperHeight and MetaFUun
  2020-04-19 12:04 ` Wolfgang Schuster
@ 2020-04-19 12:21   ` Keith McKay
  0 siblings, 0 replies; 3+ messages in thread
From: Keith McKay @ 2020-04-19 12:21 UTC (permalink / raw)
  To: Wolfgang Schuster, mailing list for ConTeXt users

Thank you Wolfgang!

I thought it must be simple! And if I had stayed the course and got to 
the end of the MetaFun manual I would have found it.

Thanks for your help.

Keith

On 19/04/2020 13:04, Wolfgang Schuster wrote:
> Keith McKay schrieb am 19.04.2020 um 13:15:
>> Dear All
>>
>> I have problem understanding what is happening in the MWE below which 
>> is different from what I expected.
>>
>> I have created a shaded background using MetaFun with dimensions 
>> PaperWidth by PaperHeight which mimics \setuppapersize[A4,landscape} 
>> as expected.  I then within \starttext \startMPpage... \stopMPpage 
>> \stoptext created a stripe of the shaded background, xscaled 2cm y 
>> scaled PaperHeight, but reversed, expecting it to cover the 
>> background top to bottom. However the top of the stripe seems to 
>> start at 10.5cm which is suspiciously half the height of A4, 
>> Landscape i.e. 21cm. I confirmed this by changing the shifted command 
>> to, shifted (19cm,10.5cm), and the stripe is positioned as expected.
>>
>> Am I missing something obvious in how MetaFun handles coordinates? I 
>> have asumed that in MetaFun, (0,0) is the bottom left corner. Or is 
>> it how I applied the shifted command?
>
> 1. When you need page backgrounds you can use a overlay and don't have 
> to create a layer for it.
>
> 2. Use unitsquare for your bars which has the origin in the lower left 
> corner because fullsquare has the origin in the center (look at page 
> 383 in the metafun manual).
>
> \setuppapersize [A4,landscape]
>
> \startuniqueMPgraphic{blueShade}
> draw lmt_shade [
>     path        = fullsquare xyscaled (OverlayWidth,OverlayHeight) ,
>     direction   = "up",
>     alternative = "linear",
>     colors      = { "red", "blue" },
> ] ;
> \stopuniqueMPgraphic
>
> \defineoverlay [mybg] [\uniqueMPgraphic{blueShade}]
>
> \setupbackgrounds [page] [background=mybg]
>
> \starttext
>
> \startMPpage
> StartPage ;
>     % Result Left
>     draw lmt_shade [
>         path        = unitsquare xscaled 2cm yscaled PaperHeight,
>         direction   = "down",
>         alternative = "linear",
>         colors      = { "red", "blue" },
>     ] shifted (12cm,0) ;
>     % Result Right
>     draw lmt_shade [
>         path        = unitsquare xscaled 2cm yscaled PaperHeight,
>         direction   = "down",
>         alternative = "linear",
>         colors      = { "red", "blue" },
>     ] shifted (19cm,0cm) ;
> StopPage ;
> \stopMPpage
>
> \stoptext
>
> Wolfgang
___________________________________________________________________________________
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] 3+ messages in thread

end of thread, other threads:[~2020-04-19 12:21 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-04-19 11:15 Unexpected result when using PaperHeight and MetaFUun Keith McKay
2020-04-19 12:04 ` Wolfgang Schuster
2020-04-19 12:21   ` Keith McKay

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