[NTG-context] code 139

2021-01-29 Thread Thomas A. Schmitz


Hi all,

a complex file with a metafun background does not compile anymore with 
lmtx. It compiles fine with mkiv. Compilation breaks off after 10 pages 
(maybe that's significant) with this message:


pages   > flushing realpage 10, userpage 10, subpage 10
mtx-context | fatal error: return code: 139

What is code: 139? Where should I start looking for the culprit?

All best

Thomas
___
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
___


Re: [NTG-context] possible problem with MPinstance or MPinclusions? works in 20200920 but not in the current 20210124 ...

2021-01-28 Thread Hans Hagen

On 1/27/2021 3:08 PM, Rudd, Kevin wrote:

thanks, Hans---

with the only change being the lmtx release, I get:

in 2020.09.20:

resolvers       > tex > 'file' closer:

'/local/Software/lmtx/tex/texmf-context/metapost/context/base/mpiv/metafun.mpxl'
closed
metapost        > log >
resolvers       > methods > resolving, method 'finders', how 'uri',
handler 'file', argument 'boxrow.mp'

in 2021.01.24:

resolvers       > tex > 'file' closer:

'/local/Software/lmtx/tex/texmf-context/metapost/context/base/mpxl/metafun.mpxl'
closed
metafun         > log >
metafun         > log > error: Not implemented: (unknown
numeric)=(string)

thus the MPincludes block doesn't seem to be processed in the latest 
release so the option block doesn't get grokked properly. the log files 
are attached with all of the gory details; if they don't make it, I can 
send separately.
but how does the tex/.mp file look ... in the log you can see that there 
is no attempt to read boxrow.mp at all


-
  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
___


Re: [NTG-context] possible problem with MPinstance or MPinclusions? works in 20200920 but not in the current 20210124 ...

2021-01-26 Thread Rudd, Kevin
argh. the problem with multiple versions of lmtx

  - running mtxrun --generate then mtxrun --find finds the file
  - running context with the document doesn't find the file and gives the same 
error
. but i haven't changed my environment usepath/usesubpath file

so:

20200920: mtxrun --generate .. mtxrun --find boxrow.mp works; context 
 works w/ or w/o putting the file in .../lmtx/tex/texmf-local/metapost
20210124: mtxrun --generate .. mtxrun --find boxrow.mp works; context 
 doesn't work w/ or w/o putting the file in 
.../lmtx/tex/texmf-local/metapost

 ---K

Kevin W. Rudd, Ph.D.
CAPT, USN (Ret)

Computer Architecture & Computer Engineering
Advanced Computing Systems (ACS) Research Program
Laboratory for Physical Sciences (LPS)

443-654-7878
ke...@lps.umd.edu<mailto:ke...@lps.umd.edu>

Visiting Research Professor
United States Naval Academy

r...@usna.edu<mailto:r...@usna.edu>


On Jan 26, 2021, at 12:32, Rudd, Kevin 
mailto:ke...@lps.umd.edu>> wrote:

hi, Hans---

putting boxrow.mp in the lmtx tree and running "mtxrun --generate"  worked, so 
it appears that my old path settings in the environment file isn't working any 
more. and i'd rather not mangle the distribution tree as that's 
out-of-sight/out-of-mind and likely to get replaced sometime after i've 
forgotten that i mangled it

  - does that mean that the usepath/usesubpath feature or environment scoping 
is now different?
=> if so, where do i find the new rules/syntax so i can regenerate my path 
code/environment file?
=> is there a hook to generate/append the file paths dynamically using a 
lua script in the top-level setup file (seems easier than the manual csh 
script=>environment file that i'm using now)

  - is it possible to configure lmtx to add my local tree to the search path? i 
seem to recall it was possible when i was fiddling with kpse many many years 
ago.
=> if so, where do i find the info to set that up in my *shrc files?

thanks,
 ---K

Kevin W. Rudd, Ph.D.
CAPT, USN (Ret)

Computer Architecture & Computer Engineering
Advanced Computing Systems (ACS) Research Program
Laboratory for Physical Sciences (LPS)

443-654-7878
ke...@lps.umd.edu<mailto:ke...@lps.umd.edu>

Visiting Research Professor
United States Naval Academy

r...@usna.edu<mailto:r...@usna.edu>


On Jan 26, 2021, at 12:00, Hans Hagen 
mailto:j.ha...@xs4all.nl>> wrote:

On 1/26/2021 1:19 PM, Rudd, Kevin wrote:
Hi---
I have a number of included figures that work in 20200920 but not in the 
current 20210124 version. There's a project structure that sets everything up 
but after that they are input as a figure:
\startplacefigure[title={NS Hierarchy},
  reference={f:ns-hierarchy}]
\input ns_hierarchy
\stopplacefigure
and generate the error:
metafun > log > error: Not implemented: (unknown numeric)=(string)
metafun > log >
metapost> log >
metapost> log > 
metapost> log >,
metapost> log > <*>  make_BoxRow [ name = "Parent",
metafun > log >
metafun > log > I'm afraid I don't know how to apply that operation to 
that combination of types.
Continue, and I'll return the second argument (see above) as the result of 
theoperation.
metafun > log >
metapost> log > label = "Parent 
Root Namespace", ]; ;
>From triaging, it looks like the "boxrow.mp" file isn't being input by the 
>current version from within the MPinclusions block associated with the 
>MPinstance; the error appears to be spurious as a result of make_BoxRow not 
>being defined and doesn't occur in the old version where the file is input. 
>"boxrow.mp" is not in the same directory as the document but is in the 
>configured through the usepath/usesubpath interface from an environment file.
I can put together and share a runnable MWE set of files if this information is 
not complete enough to identify the problem.
Here is the MWE that I used for the input figure file that demonstrates the 
problem.
\defineMPinstance[ns_hier]
[
format=metafun,
extensions=yes,
initializations=yes,
method=double,
]
\startMPinclusions{ns_hier}
input boxrow
\stopMPinclusions
\startMPdefinitions{ns_hier}
% nothing to see here
\stopMPdefinitions
\startMPcode{ns_hier}
make_BoxRow
[
name   = "Parent",
label  = "Parent Root Namespace",
];
\stopMPcode
What if you put it in your tree? Someplace under

texmf-local/metapost/...

(run mtxrun --generate afterdpimng that)

Hans



-

Re: [NTG-context] possible problem with MPinstance or MPinclusions? works in 20200920 but not in the current 20210124 ...

2021-01-26 Thread Rudd, Kevin
hi, Hans---

putting boxrow.mp in the lmtx tree and running "mtxrun --generate"  worked, so 
it appears that my old path settings in the environment file isn't working any 
more. and i'd rather not mangle the distribution tree as that's 
out-of-sight/out-of-mind and likely to get replaced sometime after i've 
forgotten that i mangled it

  - does that mean that the usepath/usesubpath feature or environment scoping 
is now different?
=> if so, where do i find the new rules/syntax so i can regenerate my path 
code/environment file?
=> is there a hook to generate/append the file paths dynamically using a 
lua script in the top-level setup file (seems easier than the manual csh 
script=>environment file that i'm using now)

  - is it possible to configure lmtx to add my local tree to the search path? i 
seem to recall it was possible when i was fiddling with kpse many many years 
ago.
=> if so, where do i find the info to set that up in my *shrc files?

thanks,
 ---K

Kevin W. Rudd, Ph.D.
CAPT, USN (Ret)

Computer Architecture & Computer Engineering
Advanced Computing Systems (ACS) Research Program
Laboratory for Physical Sciences (LPS)

443-654-7878
ke...@lps.umd.edu<mailto:ke...@lps.umd.edu>

Visiting Research Professor
United States Naval Academy

r...@usna.edu<mailto:r...@usna.edu>


On Jan 26, 2021, at 12:00, Hans Hagen 
mailto:j.ha...@xs4all.nl>> wrote:

On 1/26/2021 1:19 PM, Rudd, Kevin wrote:
Hi---
I have a number of included figures that work in 20200920 but not in the 
current 20210124 version. There's a project structure that sets everything up 
but after that they are input as a figure:
\startplacefigure[title={NS Hierarchy},
  reference={f:ns-hierarchy}]
    \input ns_hierarchy
\stopplacefigure
and generate the error:
metafun > log > error: Not implemented: (unknown numeric)=(string)
metafun > log >
metapost> log >
metapost> log > 
metapost    > log >        ,
metapost> log > <*>  make_BoxRow [ name = "Parent",
metafun > log >
metafun > log > I'm afraid I don't know how to apply that operation to 
that combination of types.
Continue, and I'll return the second argument (see above) as the result of 
theoperation.
metafun > log >
metapost> log > label = "Parent 
Root Namespace", ]; ;
>From triaging, it looks like the "boxrow.mp" file isn't being input by the 
>current version from within the MPinclusions block associated with the 
>MPinstance; the error appears to be spurious as a result of make_BoxRow not 
>being defined and doesn't occur in the old version where the file is input. 
>"boxrow.mp" is not in the same directory as the document but is in the 
>configured through the usepath/usesubpath interface from an environment file.
I can put together and share a runnable MWE set of files if this information is 
not complete enough to identify the problem.
Here is the MWE that I used for the input figure file that demonstrates the 
problem.
\defineMPinstance[ns_hier]
[
format=metafun,
extensions=yes,
initializations=yes,
method=double,
]
\startMPinclusions{ns_hier}
input boxrow
\stopMPinclusions
\startMPdefinitions{ns_hier}
% nothing to see here
\stopMPdefinitions
\startMPcode{ns_hier}
make_BoxRow
[
name   = "Parent",
label  = "Parent Root Namespace",
];
\stopMPcode
What if you put it in your tree? Someplace under

texmf-local/metapost/...

(run mtxrun --generate afterdpimng that)

Hans



-
 Hans Hagen | PRAGMA ADE
 Ridderstraat 27 | 8061 GH Hasselt | The Netherlands
  tel: 038 477 53 69 | www.pragma-ade.nl<http://www.pragma-ade.nl> | 
www.pragma-pod.nl<http://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
___


Re: [NTG-context] possible problem with MPinstance or MPinclusions? works in 20200920 but not in the current 20210124 ...

2021-01-26 Thread Hans Hagen

On 1/26/2021 1:19 PM, Rudd, Kevin wrote:

Hi---

I have a number of included figures that work in 20200920 but not in the 
current 20210124 version. There's a project structure that sets 
everything up but after that they are input as a figure:


             \startplacefigure[title={NS Hierarchy},
                               reference={f:ns-hierarchy}]
                 \input ns_hierarchy
             \stopplacefigure

and generate the error:

metafun         > log > error: Not implemented: (unknown numeric)=(string)
metafun         > log >
metapost        > log >
metapost        > log > 
metapost        > log >                    ,
metapost        > log > <*>  make_BoxRow [ name = "Parent",
metafun         > log >
metafun         > log > I'm afraid I don't know how to apply that 
operation to that combination of types.
Continue, and I'll return the second argument (see above) as the result 
of theoperation.

metafun         > log >
metapost        > log >                                     label = 
"Parent Root Namespace", ]; ;


 From triaging, it looks like the "boxrow.mp" file isn't being input by 
the current version from within the MPinclusions block associated with 
the MPinstance; the error appears to be spurious as a result of 
make_BoxRow not being defined and doesn't occur in the old version where 
the file is input. "boxrow.mp" is not in the same directory as the 
document but is in the configured through the usepath/usesubpath 
interface from an environment file.


I can put together and share a runnable MWE set of files if this 
information is not complete enough to identify the problem.


Here is the MWE that I used for the input figure file that demonstrates 
the problem.


\defineMPinstance[ns_hier]
[
     format=metafun,
     extensions=yes,
     initializations=yes,
     method=double,
]

\startMPinclusions{ns_hier}
     input boxrow
\stopMPinclusions

\startMPdefinitions{ns_hier}
     % nothing to see here
\stopMPdefinitions

\startMPcode{ns_hier}

     make_BoxRow
     [
         name           = "Parent",
         label          = "Parent Root Namespace",
     ];

\stopMPcode

What if you put it in your tree? Someplace under

texmf-local/metapost/...

(run mtxrun --generate afterdpimng that)

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
___


[NTG-context] possible problem with MPinstance or MPinclusions? works in 20200920 but not in the current 20210124 ...

2021-01-26 Thread Rudd, Kevin
Hi---

I have a number of included figures that work in 20200920 but not in the 
current 20210124 version. There's a project structure that sets everything up 
but after that they are input as a figure:

\startplacefigure[title={NS Hierarchy},
  reference={f:ns-hierarchy}]
\input ns_hierarchy
\stopplacefigure

and generate the error:

metafun > log > error: Not implemented: (unknown numeric)=(string)
metafun > log >
metapost> log >
metapost> log > 
metapost> log >,
metapost> log > <*>  make_BoxRow [ name = "Parent",
metafun > log >
metafun > log > I'm afraid I don't know how to apply that operation to 
that combination of types.
Continue, and I'll return the second argument (see above) as the result of 
theoperation.
metafun > log >
metapost> log > label = "Parent 
Root Namespace", ]; ;

>From triaging, it looks like the "boxrow.mp" file isn't being input by the 
>current version from within the MPinclusions block associated with the 
>MPinstance; the error appears to be spurious as a result of make_BoxRow not 
>being defined and doesn't occur in the old version where the file is input. 
>"boxrow.mp" is not in the same directory as the document but is in the 
>configured through the usepath/usesubpath interface from an environment file.

I can put together and share a runnable MWE set of files if this information is 
not complete enough to identify the problem.

Here is the MWE that I used for the input figure file that demonstrates the 
problem.

\defineMPinstance[ns_hier]
[
format=metafun,
extensions=yes,
initializations=yes,
method=double,
]

\startMPinclusions{ns_hier}
input boxrow
\stopMPinclusions

\startMPdefinitions{ns_hier}
% nothing to see here
\stopMPdefinitions

\startMPcode{ns_hier}

make_BoxRow
[
name   = "Parent",
label  = "Parent Root Namespace",
];

\stopMPcode

Thanks for any feedback,
 ---K

Kevin W. Rudd, Ph.D.
CAPT, USN (Ret)

Computer Architecture & Computer Engineering
Advanced Computing Systems (ACS) Research Program
Laboratory for Physical Sciences (LPS)

443-654-7878
ke...@lps.umd.edu<mailto:ke...@lps.umd.edu>

Visiting Research Professor
United States Naval Academy

r...@usna.edu<mailto:r...@usna.edu>


___
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
___


Re: [NTG-context] Using \overloaded

2021-01-24 Thread Hans Hagen

On 1/24/2021 10:16 PM, Rik Kabel wrote:

I can find no information on \aliased and the push/pop for overloademode 
and such, so will leave documenting that in the wiki to somebody with a 
few more clues.
it will be (and often is) in documentation and manuals in the 
distribution and in articles in user group journals and so


but anyway it's kind of new and i still need to flag all visible (low 
level) macros and variables (still some 700 to go)


the same is also done for metafun (mostly done but also some to go)

it roughly works as follows:

- primitives are marked as 'primitive' (already by the engine)
- we mark all registers we allocate as 'permanent'
- most constants are marked as 'immutable'
- if we don't care (or can't) we mark something as 'mutable'
- user defined instances are 'frozen' (can be \overloaded)
- \aliased just means: take the properties (applies to \let cs)
- \enforced (in the body of a macro) does just that

the last one is special because it gets internalized in ini mode (when 
the format is made)


there are (and might be some more) flags (like \noaligned)

the other large effort is removing some indirectness (using the extended 
lightweight macro argument parsing features) (mostly done, but it can 
introduce issues due to the rather large amount of tiny adptions but 
luckily these are reported here by users)


anyway, what happens after that depends on \overloadmode (th ehigher the 
more strict, odd a warning, even an error)


it is not (and can never be) complete in terms of protection (too many 
macro definitions, also runtime) but good enough for what i have in 
mind: help users to keep their run working by not redefining essential 
macros


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
___


Re: [NTG-context] question about vardef variables

2021-01-18 Thread Taco Hoekwater


> On 17 Jan 2021, at 11:17, Damien Thiriet  wrote:
> 
> Hi,
> 
> 
> I have some troubles with understanding metafun's macro mechanism.
> 
> Given this MWE:
> 
> \starttext
> \startMPpage
> 
> vardef Test (expr ab,cd)=
>   %numeric ab;
>   %numeric cd;
>   draw unitsquare scaled 10 xshifted ab;
>   draw unitsquare scaled 10 yshifted cd;
> enddef;
> 
> Test (50,100);
> \stopMPpage
> \stoptext
> 
> Uncommenting the two declarations makes me run intro a silent error. I was 
> lucky enough yesterday to get an explicit error message with a more 
> complex macro.  It made me figure out where my problems came from.
> 
> So here are my two questions:
> - Why shouldn't we tell metafun if expr is a path, a pair or so on?

You were (attempting to) redefine the macro’s arguments, but they are read-only.

A somewhat longer answer: the type of macro arguments in this case is “expr”. 
Metapost argument types are based solely on what the internal language parser 
needs to interpret the code; the language is not strongly typed.

Also, during macro expansion, your code is replaced by:

  %numeric (READONLY TEMP VALUE 1);
  %numeric (READONLY TEMP VALUE 2);
  draw unitsquare scaled 10 xshifted (READONLY TEMP VALUE 1);
  draw unitsquare scaled 10 yshifted (READONLY TEMP VALUE 2);

Best wishes,
Taco

— 
Taco Hoekwater  E: t...@bittext.nl
genderfluid (all pronouns)







___
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
___


Re: [NTG-context] question about vardef variables

2021-01-17 Thread Jeong Dal
Dear Damien Thiriet,

If you change ‘vardef’ to ‘def’, you will get the figure.
There is a difference between ‘vardef’ and ‘def’.
AFAIK, vardef returns the value of the last statement in the macro.
Please see  the examples in Metafun manual from page 32 ~ .
I hope that you find your answer there.

I am sorry that I am not good enough to explain the variables.

Best regards,

Dalyoung

> 2021. 1. 17. 오후 8:00, ntg-context-requ...@ntg.nl 작성:
> 
> \starttext
> \startMPpage
> 
> vardef Test (expr ab,cd)=
>   %numeric ab;
>   %numeric cd;
>   draw unitsquare scaled 10 xshifted ab;
>   draw unitsquare scaled 10 yshifted cd;
> enddef;
> 
> Test (50,100);
> \stopMPpage
> \stoptext

___
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
___


[NTG-context] question about vardef variables

2021-01-17 Thread Damien Thiriet
Hi,


I have some troubles with understanding metafun's macro mechanism.

Given this MWE:

\starttext
\startMPpage

vardef Test (expr ab,cd)=
   %numeric ab;
   %numeric cd;
   draw unitsquare scaled 10 xshifted ab;
   draw unitsquare scaled 10 yshifted cd;
enddef;

Test (50,100);
\stopMPpage
\stoptext

Uncommenting the two declarations makes me run intro a silent error. I was 
lucky enough yesterday to get an explicit error message with a more 
complex macro.  It made me figure out where my problems came from.

So here are my two questions:
- Why shouldn't we tell metafun if expr is a path, a pair or so on?
- Would it be possible to issue an error message each time this wrong
declaration is made?

Thanks,


Damien Thiriet 
___
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
___


Re: [NTG-context] Hatch a cell : meta:hash:left

2021-01-16 Thread Wolfgang Schuster

Fabrice Couvreur schrieb am 16.01.2021 um 16:58:

Hi,
I seem to have seen a method for hatching the cell of a table, but 
maybe it's my imagination.The following code does not work.

Thanks for your help.


Look into section 7.4 (Shape libraries) of the metafun manual.

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
___


Re: [NTG-context] odd behaviour of mp odd function in lmtx

2021-01-07 Thread Hans Hagen

On 1/7/2021 8:03 PM, Damien Thiriet wrote:

Hi,


I may have found the bug that broke my metafun
file. Looks like it is connected to odd function.

This snippet of code:

\starttext

\startMPpage
path p;p:=origin--(20,20);
draw p;
draw p reflectedabout ((10,10),(10,-10)) withcolor red;
for i=1 upto 2:
if odd i:
   draw p yshifted 20 withcolor green;
else:
   draw p xshifted 20 withcolor blue;
fi;
endfor;


\stopMPpage

\stoptext

does not compile as I would expect (no green
line drawn). I noticed such behaviour in
2020.12.30 16:45
version. I updated a few minutes ago and have
the same output.

for now use this:

 let odd = relax;
 vardef odd expr n = ((abs(n) mod 2) == 1) enddef ;

I got it fixed (scaled, double and decimal) but no upload now

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
___


[NTG-context] odd behaviour of mp odd function in lmtx

2021-01-07 Thread Damien Thiriet
Hi,


I may have found the bug that broke my metafun 
file. Looks like it is connected to odd function. 

This snippet of code:

\starttext

\startMPpage
path p;p:=origin--(20,20);
draw p;
draw p reflectedabout ((10,10),(10,-10)) withcolor red;
for i=1 upto 2:
   if odd i:
  draw p yshifted 20 withcolor green; 
   else:
  draw p xshifted 20 withcolor blue;
   fi;
endfor;


\stopMPpage

\stoptext

does not compile as I would expect (no green
line drawn). I noticed such behaviour in
2020.12.30 16:45
version. I updated a few minutes ago and have
the same output.

I hope I didn't miss anything.
Best regards,

Damien Thiriet 
___
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
___


[NTG-context] odd seems to be broken in lmtx-metafun

2021-01-07 Thread Damien Thiriet
Hi,

I think I found the bug that made me send a
"false positive" a few days ago.
Looks like something messes up with metafun odd function.

This snippet of code:

\starttext

\startMPpage
path p;p:=origin--(20,20);
draw p;
draw p reflectedabout ((10,10),(10,-10)) withcolor red;
for i=1 upto 2:
   if odd i:
  draw p yshifted 20 withcolor green; 
   else:
  draw p xshifted 20 withcolor blue;
   fi;
endfor;

%draw (0,0)--(20,20) withcolor red;
\stopMPpage

\stoptext
does not compile as I would expect it: no green line
is drawn (but there is an output). I hope I did not miss 
something and won't waste your time.

This appeared at least in 
2020.12.30 16:45 
version (I don't update often enough to give better hints)

Best regards,

Damien Thiriet


___
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
___


Re: [NTG-context] Problem with show command in MetaFun

2021-01-07 Thread Keith McKay

Thanks Hans!

I had forgotten about \enabletrackers[metapost.tracingall].

Best Wishes

Keith

On 07/01/2021 15:35, Hans Hagen wrote:

On 1/7/2021 4:11 PM, Keith McKay wrote:
In the MWE below I would expect the "show" command to print the value 
of p in the console output (I use Texworks), however this does not 
seem to be happening. I haven't used "show" in MetaFun for a while, 
am I implementing it correctly?


Best Wishes

Keith McKay

 MWE %

\setuppapersize[A4, portrait]

\starttext

\startMPpage

StartPage;

width := PaperWidth ; height := PaperHeight ; unit := cm ;

numeric p;

p := 0;

for q = 0 step 1 until 10:

show p;

p := p + 1;

fill fullcircle xyscaled(3cm,4cm) shifted ((p +2)*cm, (p + 2)*cm) 
withcolor red ;


endfor;

StopPage;

\stopMPpage

\stoptext


\enabletrackers[metapost.tracingall]


but best use:

message(p);

-
  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
___


Re: [NTG-context] Problem with show command in MetaFun

2021-01-07 Thread Hans Hagen

On 1/7/2021 4:11 PM, Keith McKay wrote:
In the MWE below I would expect the "show" command to print the value of 
p in the console output (I use Texworks), however this does not seem to 
be happening. I haven't used "show" in MetaFun for a while, am I 
implementing it correctly?


Best Wishes

Keith McKay

 MWE %

\setuppapersize[A4, portrait]

\starttext

\startMPpage

StartPage;

width := PaperWidth ; height := PaperHeight ; unit := cm ;

numeric p;

p := 0;

for q = 0 step 1 until 10:

show p;

p := p + 1;

fill fullcircle xyscaled(3cm,4cm) shifted ((p +2)*cm, (p + 2)*cm) 
withcolor red ;


endfor;

StopPage;

\stopMPpage

\stoptext


\enabletrackers[metapost.tracingall]


but best use:

message(p);

-
  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
___


[NTG-context] Problem with show command in MetaFun

2021-01-07 Thread Keith McKay
In the MWE below I would expect the "show" command to print the value of 
p in the console output (I use Texworks), however this does not seem to 
be happening. I haven't used "show" in MetaFun for a while, am I 
implementing it correctly?


Best Wishes

Keith McKay

 MWE %

\setuppapersize[A4, portrait]

\starttext

\startMPpage

StartPage;

width := PaperWidth ; height := PaperHeight ; unit := cm ;

numeric p;

p := 0;

for q = 0 step 1 until 10:

show p;

p := p + 1;

fill fullcircle xyscaled(3cm,4cm) shifted ((p +2)*cm, (p + 2)*cm) 
withcolor red ;


endfor;

StopPage;

\stopMPpage

\stoptext

___
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
___


[NTG-context] lmtx upload

2021-01-05 Thread Hans Hagen

Hi,

A new version has been uploaded. This one has:

  \enableexperiments[fonts.compact]

for the brave to test.

As a reminder, as this has been around for a while now, if you really 
want to stress your test, run with (top of file):


  \overloadmode 4 % error
  \overloadmode 3 % warning

in order to see if you (re)define primitives, core functionality, 
instances and whatever can lead to conflicts. There are still some 
commands to be tagged (and for some the category might change) but it's 
a bit of a tedious job.


Btw, for metafun the warnings are enabled by default (for now), but 
users might have noticed that already.


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
___


[NTG-context] MP reflectedabout broken?

2021-01-04 Thread Damien Thiriet
Hi,

I updated ConTeXt yesterday and went through
troubles with reflectedabout.

This snippet of code

\starttext
\startMPpage
path p[];
p1:= unitcircle scaled 10;
p2:= p1 reflectedabout ((15u,-15u),(15u,15));
draw p1;
draw p2;


\stopMPpage
\stoptext

doesn't compile with the following error message
metafun > log > I'm unable to apply a partially specified
transformation except to a fully known
pair or transform. Proceed, and I'll omit the transformation.

metafun > log > error: Transform components aren't all known
metafun > log >
metapost> log >
metapost> log > 
metapost> log >=
metapost> log >
reflectedabout->transformed.begingroup.transform.temp_transform;(EXPR0)transformed.temp_transform=
metapost> log >
(EXPR0);(EXPR1)transformed.temp_transform=(EXPR1);xxpart.temp_transform=-yypart.temp_transform;xypa...
metapost> log > <*> path p[]; p1:= unitcircle scaled 10; p2:= p1
reflectedabout ((15u,-15u),(15u,15))
metafun > log >
metafun > log > I'm unable to apply a partially specified
transformation except to a fully known
pair or transform. Proceed, and I'll omit the transformation.

My version:
current version: 2020.12.30 16:45

Did I missused this function before?

Best regards, 

Damien Thiriet 
___
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
___


Re: [NTG-context] metapost graph and ConTeXt LMTX

2021-01-03 Thread Jean-Philippe Rey
Le 3 janv. 2021 à 19:21, Hans Hagen <j.ha...@xs4all.nl> a écrit :On 1/3/2021 7:12 PM, Jean-Philippe Rey wrote:Dear List,I have used TikZ and pgfplots for a few years and I am considering switching to metapost/metafun which appears more efficient with LMTX. I have already designed several figures with metapost/metafun and some with the help of metaobj and I am fully satisfied with the result.Alan rewrote graph in a more context way ... so, there is the m-grapph.mkiv module (I admit, not tested for a while).Thank you Hans for pointing to this module.I took a look at m-graph.mkiv and wrote the following ==\usemodule[graph]\starttext\startMPcode{graph}draw begingraph(150mm, 100mm);	gdraw "test-mpgraph.txt";	endgraph;\stopMPcode\stoptext==which fails with "error: Improper type" (see attached log file). Maybe I don't understand how to use the graph module.
-- Jean-Philippe Reyjean-philippe@centralesupelec.fr91192 Gif-sur-Yvette Cedex - FranceEmpreinte PGP : 807A 5B2C 69E4 D4B5 783A 428A 1B5E E83E 261B BF51



test-mpgraph.log
Description: Binary data
___
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
___


Re: [NTG-context] metapost graph and ConTeXt LMTX

2021-01-03 Thread Hans Hagen

On 1/3/2021 7:12 PM, Jean-Philippe Rey wrote:

Dear List,

I have used TikZ and pgfplots for a few years and I am considering switching to 
metapost/metafun which appears more efficient with LMTX. I have already 
designed several figures with metapost/metafun and some with the help of 
metaobj and I am fully satisfied with the result.


Alan rewrote graph in a more context way ... so, there is the 
m-grapph.mkiv module (I admit, not tested for a while).


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
___


[NTG-context] metapost graph and ConTeXt LMTX

2021-01-03 Thread Jean-Philippe Rey
Dear List,

I have used TikZ and pgfplots for a few years and I am considering switching to 
metapost/metafun which appears more efficient with LMTX. I have already 
designed several figures with metapost/metafun and some with the help of 
metaobj and I am fully satisfied with the result.

I am now trying to draw graphs with the metapost graph module, but I haven't 
been integrated to my ConTeXt LMTX document. The following example works 
perfectly well when compiled directly with metapost (from TeXlive 2020).

= mpost example =
beginfig(1)
input graph

draw begingraph(150mm, 100mm);
gdraw "test-mpgraph.txt";
endgraph;
endfig;
end
=

Here is my demo data file

 test-mpgraph.txt 
0 0
1 1
2 2
3 1
4 3
5 2
6 1
==

I tried the following to draw directly from a ConTeXt document

 LMTX example =
\starttext
\startMPcode
troffmode:=0;
prologues:=0;
input graph

draw begingraph(150mm, 100mm);
gdraw "test-mpgraph.txt";
endgraph;
\stopMPcode
\stoptext
===

I had to define troffmode and prologues, otherwise I get error messages about 
undecidable expressions and now I get an error that I don't understand (see 
attached log file).

I also tried \usemodule[graph] as documented on the wiki 
(https://wiki.contextgarden.net/MPgraph) but without success.

I guess I am doing something wrong. Could someone help me see my error?

Thanks,

-- 
Jean-Philippe Rey
jean-philippe@centralesupelec.fr
91192 Gif-sur-Yvette Cedex - France
Empreinte PGP : 807A 5B2C 69E4 D4B5 783A 428A 1B5E E83E 261B BF51


test-mpgraph.log
Description: Binary data
___
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
___


Re: [NTG-context] drop shadows with metapost/ metafun

2021-01-02 Thread Henning Hraban Ramm


> Am 29.12.2020 um 22:56 schrieb Garulfo :
> 
> Which process would you advice to add « drop shadows » to any kind of metafun 
> / metapost figures like:
> picture p;
> p := textext("MetaPost is fun!") shifted (10cm,10cm);
> 
> 
> My current understanding of the required steps :
> 
> 
> 1- fill p with the shadow color
> 
> 2- write it to an external metapost file (with savebuffer ?) ready for png 
> export (outputformat := "png »;)
> 
> 3- with lua, os.execute, and imagemagick prepare the shadow
>   - extent the png file with a transparent background, to have room for 
> blurring 
>   - blur it
> 
> 4- import this png in context / Metapost (externalfigure), and center it with 
> p figure
> 
> 5- shift it according to the desired shadows distance and angle
> 
> 6- apply the initial bounding box of p to the shadow, draw the shadow, draw 
> the p picture 
> 
> 
> Actually, all this seems long and tedious, and contrasts with the already 
> existing links between MetaPost / MetaFun and cairo + libpng.

I don’t know if that helps, but I’m using a stack of transparent objects to 
simulate drop shadows:
https://wiki.contextgarden.net/Drop_shadows

No pixel images required. But I’d like to have a real text shadow instead of 
that box shadow.


Happy New Year!
Hraban
___
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
___


Re: [NTG-context] drop shadows with metapost/ metafun

2020-12-31 Thread Aditya Mahajan
On Fri, 1 Jan 2021, Aditya Mahajan wrote:

> On Tue, 29 Dec 2020, Garulfo wrote:
> 
> > Which process would you advice to add « drop shadows » to any kind of 
> > metafun / metapost figures like:
>
> > Actually, all this seems long and tedious, and contrasts with the already 
> > existing links between MetaPost / MetaFun and cairo + libpng.
> 
> There was a drops module by Peter Rolf, which provides exactly these features:
> 
> https://mailman.ntg.nl/pipermail/ntg-context/2016/084242.html
> 
> It is not part of modules.contextgarden.net and the url in the previous post 
> is no longer valid. 
> 
> I am CC:ing Peter and perhaps he can point to the updated location for the 
> module. 

Also, if you don't want the shadows to be too nice, you can also translate the 
fake shadows used by tikz to metapost:

https://adityam.github.io/context-blog/post/drop-shadow-with-lifted-corners/

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
___


Re: [NTG-context] drop shadows with metapost/ metafun

2020-12-31 Thread Aditya Mahajan
On Tue, 29 Dec 2020, Garulfo wrote:

> Which process would you advice to add « drop shadows » to any kind of metafun 
> / metapost figures like:
> picture p;
> p := textext("MetaPost is fun!") shifted (10cm,10cm);
> 
> My current understanding of the required steps :
> 
> 
> 1- fill p with the shadow color
> 
> 2- write it to an external metapost file (with savebuffer ?) ready for png 
> export (outputformat := "png »;)
> 
> 3- with lua, os.execute, and imagemagick prepare the shadow
>   - extent the png file with a transparent background, to have room for 
> blurring 
>   - blur it
> 
> 4- import this png in context / Metapost (externalfigure), and center it with 
> p figure
> 
> 5- shift it according to the desired shadows distance and angle
> 
> 6- apply the initial bounding box of p to the shadow, draw the shadow, draw 
> the p picture 
> 
> 
> Actually, all this seems long and tedious, and contrasts with the already 
> existing links between MetaPost / MetaFun and cairo + libpng.

There was a drops module by Peter Rolf, which provides exactly these features:

https://mailman.ntg.nl/pipermail/ntg-context/2016/084242.html

It is not part of modules.contextgarden.net and the url in the previous post is 
no longer valid. 

I am CC:ing Peter and perhaps he can point to the updated location for the 
module. 

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
___


[NTG-context] drop shadows with metapost/ metafun

2020-12-29 Thread Garulfo
Which process would you advice to add « drop shadows » to any kind of metafun / 
metapost figures like:
picture p;
p := textext("MetaPost is fun!") shifted (10cm,10cm);

My current understanding of the required steps :


1- fill p with the shadow color

2- write it to an external metapost file (with savebuffer ?) ready for png 
export (outputformat := "png »;)

3- with lua, os.execute, and imagemagick prepare the shadow
  - extent the png file with a transparent background, to have room for 
blurring 
  - blur it

4- import this png in context / Metapost (externalfigure), and center it with p 
figure

5- shift it according to the desired shadows distance and angle

6- apply the initial bounding box of p to the shadow, draw the shadow, draw the 
p picture 


Actually, all this seems long and tedious, and contrasts with the already 
existing links between MetaPost / MetaFun and cairo + libpng.

Thanks again for your help.___
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
___


[NTG-context] Metafun: dotlabel issue in latest LMTX

2020-12-27 Thread Otared Kavian
Hi Hans,

The following (due to you and Aditya, discussed a few days ago) used to work 
with LMTX until version 2020-12-10, but it does not work anymore with LMTX 
version 2020-12-24 17:30. I wonder whether this is due to some changes you have 
made recently.

%% begin squaredot-test.tex
\startMPdefinitions
newpath mydotlabelshape ;
mydotlabelshape := fullcircle ;
mydotlabeldiam := 12 pt ;

vardef mydotlabel@#(expr s,z) text t_ =
label@#(s,z) t_ ;
fill (mydotlabelshape scaled 2mydotlabeldiam) shifted z t_;
enddef ;
\stopMPdefinitions

\starttext
\startMPcode
newpath p ; 
p := (2cm, 3cm) -- (3cm, 5cm);

mydotlabeldiam := 15pt;
mydotlabelshape := fullsquare ;

draw p ;

mydotlabel(textext("\switchtobodyfont[8pt]" & "A"), point 0 of p) 
withcolor transparent("exclusion",.5,red) ;
mydotlabel(textext("\switchtobodyfont[8pt]" & "B"), point 1 of p) 
withcolor transparent("exclusion",.5,red) ;

\stopMPcode
\stoptext
%% end squaredot-test.tex

I get an error message, which is obscure to me, saying:

%-- begin error message excerpt

metafun > log > error: Isolated expression
metafun > log >
metapost> log > 
metapost> log >  
metapost    > log >        ;
metapost> log > <*> newpath mydotlabelshape ;
metafun > log >
metafun > log > I couldn't find an '=' or ':=' after the expression 
that is shown above this
error message, so I guess I'll just ignore it and carry on.
metafun > log >
metapost> log >   mydotlabelshape := 
fullcircle ; mydotlabeldiam := 12 pt ; vardef mydotlabel@##(expr s,z) text t_ = 
label@##(s,z) t_ ; fill (mydotlabelshape scaled 2mydotlabeldiam) shi...

%-- end error message excerpt

Best regards: Otared

___
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
___


Re: [NTG-context] freedotlabel not defined in LMTX ?

2020-12-26 Thread Hans Hagen

On 12/26/2020 11:28 AM, Otared Kavian wrote:

Hi Hans,

When I was testing your example with freelabel in another thread, I noticed 
that freedotlabel does not work in LMTX.
Here is the code from the Metafun manual which works with ConTeXt version 
2020.06.25 10:55 MKIV, but not with ConTeXt version 2020.12.24 17:30 LMTX.

%% begin freedotlabel.tex
\setupbodyfont[pagella]

\starttext

\startMPcode
pair destination ;
for whereto = "up", "down", "left", "right" :
destination := scantokens(whereto) * 1cm ;
freedotlabel(whereto, destination, origin) ;
drawarrow origin -- destination
withpen pencircle scaled .25mm withcolor .625 red ;
endfor ;
\stopMPcode

\stoptext
%% end freedotlabel.tex

a renamed variable ...

vardef freedotlabel (expr asked_text, asked_location, asked_origin) =
interim linecap := rounded ;
draw asked_location withpen pencircle scaled freedotlabelsize ;
draw thefreelabel(asked_text,asked_location,asked_origin) ;
enddef ;

-
  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
___


[NTG-context] freedotlabel not defined in LMTX ?

2020-12-26 Thread Otared Kavian
Hi Hans,

When I was testing your example with freelabel in another thread, I noticed 
that freedotlabel does not work in LMTX.
Here is the code from the Metafun manual which works with ConTeXt version 
2020.06.25 10:55 MKIV, but not with ConTeXt version 2020.12.24 17:30 LMTX.

%% begin freedotlabel.tex
\setupbodyfont[pagella]

\starttext

\startMPcode
pair destination ;
for whereto = "up", "down", "left", "right" :
destination := scantokens(whereto) * 1cm ;
freedotlabel(whereto, destination, origin) ;
drawarrow origin -- destination
withpen pencircle scaled .25mm withcolor .625 red ;
endfor ;
\stopMPcode

\stoptext
%% end freedotlabel.tex

Best regards: Otared
___
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
___


Re: [NTG-context] MetaFun labels and xsized

2020-12-25 Thread Pablo Rodriguez
On 12/25/20 10:09 PM, Hans Hagen wrote:
>> [...]
> \startMPcode
>  path p ; p := (
>  ( 1,  1) --
>  ( 1,  5) --
>  (10, 10) --
>  (14,  4) --
>  cycle) xsized .75TextWidth;
>
>  draw p ;
>
>  freelabel("\strut α",point 0 of p,center p) ;
>  freelabel("\strut β",point 1 of p,center p) ;
>  freelabel("\strut γ",point 2 of p,center p) ;
>  freelabel("\strut δ",point 3 of p,center p) ;
> \stopMPcode

Many thanks for your code, Hans.

This is exactly what I need.

Pablo
--
http://www.ousia.tk
___
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
___


Re: [NTG-context] MetaFun labels and xsized

2020-12-25 Thread Hans Hagen

On 12/25/2020 6:36 PM, Fabrice L wrote:

Hi,


Le 25 déc. 2020 à 12:30, Pablo Rodriguez  a écrit :

Dear list,

I have this minimal MetaFun sample (the only one in my real document):

  \setupbodyfont[pagella]
  \starttext
  \startMPcode
  pair a ; a := (1, 1) ;
  pair b ; b := (1, 10) ;
  pair c ; c := (10, 10) ;
  pair d ; d := (10, 1) ;
  draw (a--b--c--d--a) xsized .75TextWidth;

  draw thelabel.lft("α",a) ;
  draw thelabel.lft("β",b) ;
  draw thelabel.top("γ",c) ;
  draw thelabel.rt("δ",d) ;
  \stopMPcode
  \stoptext

Is there a way to relate adapt the labels to the xsized positions used?


I’m sure somebody could find a more elegant solution, but here is a simple one:

  \setupbodyfont[pagella]
  \starttext
  \startMPcode
  pair a ; a := (1, 1) ;
  pair b ; b := (1, 10) ;
  pair c ; c := (10, 10) ;
  pair d ; d := (10, 1) ;
  path square ;
  square := (a--b--c--d--cycle) xsized .75TextWidth ;
  
  draw square xsized .75TextWidth;


  draw thelabel.lft("α",point 0 of square) ;
  draw thelabel.lft("β",point 1 of square) ;
  draw thelabel.top("γ",point 2 of square) ;
  draw thelabel.rt("δ",point 3 of square) ;
  \stopMPcode
  \stoptext

Fabrice.


\startMPcode
path p ; p := (
( 1,  1) --
( 1,  5) --
(10, 10) --
(14,  4) --
cycle) xsized .75TextWidth;

draw p ;

freelabel("\strut α",point 0 of p,center p) ;
freelabel("\strut β",point 1 of p,center p) ;
freelabel("\strut γ",point 2 of p,center p) ;
freelabel("\strut δ",point 3 of p,center p) ;
\stopMPcode


-
  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
___


Re: [NTG-context] MetaFun labels and xsized

2020-12-25 Thread Pablo Rodriguez
On 12/25/20 6:36 PM, Fabrice L wrote:
>> I have this minimal MetaFun sample (the only one in my real document):
>> [...]
>> Is there a way to relate adapt the labels to the xsized positions used?
>
> I’m sure somebody could find a more elegant solution, but here is a simple 
> one:
>
>  \setupbodyfont[pagella]
>  \starttext
>  \startMPcode
>  pair a ; a := (1, 1) ;
>  pair b ; b := (1, 10) ;
>  pair c ; c := (10, 10) ;
>  pair d ; d := (10, 1) ;
>  path square ;
>  square := (a--b--c--d--cycle) xsized .75TextWidth ;
>
>  draw square xsized .75TextWidth;
>
>  draw thelabel.lft("α",point 0 of square) ;
>  draw thelabel.lft("β",point 1 of square) ;
>  draw thelabel.top("γ",point 2 of square) ;
>  draw thelabel.rt("δ",point 3 of square) ;
>  \stopMPcode
>  \stoptext

Many thanks for your ultra-fast reply, Fabrice.

I didn’t know that paths could be also defined (MP is all Greek to me).

I realized that drawing doesn’t require resizing again (once the path
definition contains resizing).

Many thanks for your help,

Pablo
--
http://www.ousia.tk
___
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
___


Re: [NTG-context] MetaFun labels and xsized

2020-12-25 Thread Fabrice L
Hi,

> Le 25 déc. 2020 à 12:30, Pablo Rodriguez  a écrit :
> 
> Dear list,
> 
> I have this minimal MetaFun sample (the only one in my real document):
> 
>  \setupbodyfont[pagella]
>  \starttext
>  \startMPcode
>  pair a ; a := (1, 1) ;
>  pair b ; b := (1, 10) ;
>  pair c ; c := (10, 10) ;
>  pair d ; d := (10, 1) ;
>  draw (a--b--c--d--a) xsized .75TextWidth;
> 
>  draw thelabel.lft("α",a) ;
>  draw thelabel.lft("β",b) ;
>  draw thelabel.top("γ",c) ;
>  draw thelabel.rt("δ",d) ;
>  \stopMPcode
>  \stoptext
> 
> Is there a way to relate adapt the labels to the xsized positions used?

I’m sure somebody could find a more elegant solution, but here is a simple one:

 \setupbodyfont[pagella]
 \starttext
 \startMPcode
 pair a ; a := (1, 1) ;
 pair b ; b := (1, 10) ;
 pair c ; c := (10, 10) ;
 pair d ; d := (10, 1) ;
 path square ; 
 square := (a--b--c--d--cycle) xsized .75TextWidth ;
 
 draw square xsized .75TextWidth;

 draw thelabel.lft("α",point 0 of square) ;
 draw thelabel.lft("β",point 1 of square) ;
 draw thelabel.top("γ",point 2 of square) ;
 draw thelabel.rt("δ",point 3 of square) ;
 \stopMPcode
 \stoptext

Fabrice.

> 
> Many thanks for your help,
> 
> Pablo
> --
> http://www.ousia.tk
> ___
> 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
___


[NTG-context] MetaFun labels and xsized

2020-12-25 Thread Pablo Rodriguez
Dear list,

I have this minimal MetaFun sample (the only one in my real document):

  \setupbodyfont[pagella]
  \starttext
  \startMPcode
  pair a ; a := (1, 1) ;
  pair b ; b := (1, 10) ;
  pair c ; c := (10, 10) ;
  pair d ; d := (10, 1) ;
  draw (a--b--c--d--a) xsized .75TextWidth;

  draw thelabel.lft("α",a) ;
  draw thelabel.lft("β",b) ;
  draw thelabel.top("γ",c) ;
  draw thelabel.rt("δ",d) ;
  \stopMPcode
  \stoptext

Is there a way to relate adapt the labels to the xsized positions used?

Many thanks for your help,

Pablo
--
http://www.ousia.tk
___
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
___


Re: [NTG-context] Check if two paths intersect in Metafun

2020-12-25 Thread Fabrice L
Hi,

> Le 25 déc. 2020 à 08:48, Jairo A. del Rio  a écrit :
> 
> Hi, list. I've got a question about paths and intersections. The following:
> 
> \starttext 
> \startMPpage
> path p[];
> 
> p[1] = fullcircle scaled 2cm;
> p[2] = unitsquare shifted (4cm,6cm);
> 
> if (known (p[1] intersectionpoint p[2])):
> 
> draw textext("yes");
> 
> else:
> 
> draw textext("no");
> fi;
> 
> \stopMPpage
> \stoptext
> 
> yields an error message: "The paths don't intersect". Is there a way to 
> intercept this error message and trigger an action instead? Thank you in 
> advance.

Instead of using « intersectionpoint » use « Intersectiontimes », this will 
give you the « time » of the intersection of the two paths. If the paths do not 
intersect, than the value is (-1,-1). So you could do something like:

pair checkintersec ;
checkintersec := p[1] intersectiontimes p[2] ;
If xpart(checkintersec) <> -1 : 
draw textext("yes »);
else: 
draw textext(« non »);
fi;

Fabrice.

> 
> Best regards,
> 
> Jairo
> ___
> 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
___


[NTG-context] Check if two paths intersect in Metafun

2020-12-25 Thread Jairo A. del Rio
Hi, list. I've got a question about paths and intersections. The following:


\starttext

\startMPpage

path p[];


p[1] = fullcircle scaled 2cm;

p[2] = unitsquare shifted (4cm,6cm);


if (known (p[1] intersectionpoint p[2])):


draw textext("yes");


else:


draw textext("no");

fi;


\stopMPpage

\stoptext

yields an error message: "The paths don't intersect". Is there a way to
intercept this error message and trigger an action instead? Thank you in
advance.

Best regards,

Jairo
___
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
___


Re: [NTG-context] MetaFun - "remove the paths of text" from a rectangle to let the background visible

2020-12-24 Thread Garulfo

Much more lean now thanks to your feedbacks.

I prefered to "remove the shapes of the letter"
rather than doubling the shading.


Wikified https://wiki.contextgarden.net/Cover_Pages#.22Empty.22_letters





\definecolor [ColorHighA] [h=c4a000]
\definecolor [ColorHighB] [h=602217]
\definecolor [ColorLow] [0.8(white)]

\startMPpage

%-- 



  picture tt ;
  tt := lmt_outline [
kind = "fillup",
text = "\definedfont[name:texgyrepagellabold*default]%
\framed[frame=off,offset=3mm,align=middle,strut=none]
{MetaPost\\is Fun !\\Aujourd'hui\\Today\\*§ 2020 §*}",
] xsized 12cm ;

  path bb ; bb := boundingbox tt;

%-- 



  path pp ; pp := bb enlarged 2cm ;
  fill pp
   withshademethod "linear"
   withshadedirection (2.,0.)
   withshadecolors (\MPcolor{ColorHighA}, \MPcolor{ColorHighB});

%-- 



  picture Paddmissing; Paddmissing := nullpicture;
  picture Pwoletters; Pwoletters := nullpicture;
  numeric testwithin ;

%-- 



  for i within tt :

if stroked i or filled i :
  testwithin :=0;

  for j within tt :
if stroked j or filled j:
  if (((xpart llcorner i) > (xpart llcorner j)) and
  ((ypart llcorner i) > (ypart llcorner j)) and
  ((xpart urcorner i) < (xpart urcorner j)) and
  ((ypart urcorner i) < (ypart urcorner j))) :
  testwithin :=1;
  fi;
fi;
  endfor;

  if testwithin == 1:
addto Paddmissing contour
  (pathpart i)
  withcolor \MPcolor{ColorLow};
  else:
addto Pwoletters contour
  (pathpart i)
  withpostscript "collect";
  fi;

fi ;
  endfor ;

%-- 



  addto Pwoletters contour
bb
withpostscript "evenodd"
withcolor \MPcolor{ColorLow};
  draw Pwoletters ;
  draw Paddmissing ;

\stopMPpage
___
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
___


Re: [NTG-context] MetaFun - "remove the paths of text" from a rectangle to let the background visible

2020-12-24 Thread Taco Hoekwater


> On 24 Dec 2020, at 00:14, Garulfo  wrote:
> 
> Thanks Taco,
> 
> I made some progress :
> https://wiki.contextgarden.net/Talk:Cover_Pages
> 
> I now have two additional questions ... ;-)
> 
> - How can I deal with "space" characters (because current solution
>  requires to explicitly add the ~ character)

Here’s what I would do (which is probably not the nicest way of doing it). Just
enable \obeyspaces while reading the argument to \EmptyLetters, then disable
it again immediately (that is needed if you have to go back to TeX from Lua):

\def\EmptyLetters
 {\obeyspaces\doEmptyLetters}

\def\doEmptyLetters#1%
  {\normalspaces
   ...
  }

and in \whatever you then need \doifinstringelse{ }{#1}

Best wishes,
Taco

___
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
___


Re: [NTG-context] MetaFun - "remove the paths of text" from a rectangle to let the background visible

2020-12-23 Thread Hans Hagen

On 12/24/2020 12:46 AM, Otared Kavian wrote:

Hi Garulfo,

Thank you for sharing your nice example: it typesets correctly with mkiv, but 
it seems to me that with LMTX the text does not appear (at least on my 
installation of the latest LMTX).

I admit that I had to trial and error this:

\startMPpage
picture tt ; tt := lmt_outline [
kind  = "fillup",
text  = "\strut foo f o o",
drawcolor = "white",
rulethickness = .2
] ysized 5cm ;

path bb ; bb := boundingbox tt;
path pp ; pp := bb enlarged 3cm ;

fill pp
withshademethod "linear"
withshadedirection down
withshadecolors (red, blue)
;

fill bb withcolor "darkgray" ;

for i within tt :
if stroked i :
nofill (pathpart i)
;
fi ;
dofill bb
withshademethod "linear"
withshadedirection down
withshadecolors (red, blue)
;
endfor ;
\stopMPpage

-
  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
___


Re: [NTG-context] MetaFun - "remove the paths of text" from a rectangle to let the background visible

2020-12-23 Thread Hans Hagen

On 12/24/2020 12:14 AM, Garulfo wrote:

Thanks Taco,

I made some progress :
https://wiki.contextgarden.net/Talk:Cover_Pages

I now have two additional questions ... ;-)

- How can I deal with "space" characters (because current solution
   requires to explicitly add the ~ character)

- What would be the work to do in order to make this mechanism directly
   usable in metapost / metafun, within \startMPpage \stopMPpage,
   - to avoid switching between \start\stopMPdrawing and TeX
   - to have something like "draw followtext" in mp-blob.mpiv ?



Maybe pickup some tricks from this:

\starttext

\startMPpage
StartPage;

fill Page
   withshademethod "linear"
   withshadedirection(0,1)
   withshadecolors (red, blue) ;

picture p ; p := lmt_outline [
text  = "\strut foo f o o",
drawcolor = "white",
rulethickness = .2
] ysized 5cm ;

draw (p shifted - center p) shifted center Page;

StopPage;
\stopMPpage

\startuseMPgraphic{MyShade}
fill OverlayBox
   withshademethod "linear"
   withshadedirection(0,1)
   withshadecolors (red, blue) ;
\stopuseMPgraphic

\defineoverlay[MyShade][\useMPgraphic{MyShade}]

\setupbackgrounds[page][background=MyShade]

\startmakeup

\definedfont[SerifBold*default @ 50pt] \setupinterlinespace

\defineeffect[MyOutline][alternative=outer,rulethickness=1pt]

\startcolor[white]
\starteffect[MyOutline]
\input jojomayer
\stopeffect
\stopcolor

\stopmakeup

\stoptext

%-- 



\setuppapersize  [A4]

%-- 



\def\MyFont{\definedfont[name:%
texgyrepagellabold%
%exo2black%
%agaramondprobold%
*default at 55pt]}

%-- 



\startluacode

function document.outlinepaths(character)
     local chardata  = fonts.hashes.characters[true] -- by unicode
     local shapedata = fonts.hashes.shapes[true] -- by index
     local c = chardata[character]
     if c and c.index and shapedata then
     local shapeglyphs = shapedata.glyphs or { }
     local glyph   = shapeglyphs[c.index]
     if glyph and (glyph.segments or glyph.sequence) then
     local units  = shapedata.units or 1000
     local factor = 100/units
     return fonts.metapost.paths(glyph,factor)
     end
     end
     return { }
end

function document.defineoutline(char,target)
     local outlines = document.outlinepaths(char)
     local nofpaths = #outlines
     context("\\startMPdrawing") -- ADDED by 
garulfo

     context("path %s[] ;",target)
     context("numeric %sn ; %sn := %s ;",target,target,nofpaths)
     for i=1,nofpaths do
     context("%s[%i] := %s ; ",target,i,outlines[i])
     end
     context("\\stopMPdrawing")  -- ADDED by 
garulfo

end

\stopluacode

%-- 



\def\mpdefineoutlines#1#2{\ctxlua{document.defineoutline(\number`#1,"#2")}}

%-- 



\def\EmptyLetters#1%
{%
\resetMPdrawing
\MPtoks={}
%
\startMPdrawing
   picture pic[], pictA ;
   numeric wid[], len[], pos[], n ;
   wid[0] := len[0] := pos[0] := n := 0 ;
   numeric scaling;
   path pictB , frame ;
   pair shiftB ;
   picture monImageA; monImageA := nullpicture;
   picture monImageB; monImageB := nullpicture;
   color colorframe;  colorframe := 0.6white;
%
\stopMPdrawing
%
\MyFont\handletokens#1\with\whatever
%
\startMPdrawing
   frame :=  unitsquare
   xscaled ( (xpart urcorner monImageB - xpart llcorner 
monImageB) + 5mm )
   yscaled ( (ypart urcorner monImageB - ypart llcorner 
monImageB) + 5mm );

   frame := frame shifted (center monImageB - center frame);
   addto monImageB contour
     frame
     withpostscript "evenodd"
     withcolor transparent (1,1.,colorframe);
   draw monImageB ;
   draw monImageA ;
\stopMPdrawing
%
\MPdrawingdonetrue
\getMPdrawing}

%-- 



\def\whatever#1%
   {\appendtoks#1\to\MPtoks
    \setbox\MPbox=\hbox{\MyFont\the\MPtoks}%
    %
    \startMPdrawing
  n := n + 1 ; len[n] := \the\wd\MPbox ;
    \stopMPdrawing
    %
    \mpdefineoutlines{M}{MaLettre}
    %
    \startMPdrawing
    pictA := textext.drt("\MyFont M") ;
    pictB := MaLettre[1];
    scaling := bbheight pictA / bbheight pictB;
    \stopMPdrawing
    %
    \doifinstringelse{~}{#1}{}{%    HOW TO PROPERLY COPE 
WITH SPACES ?

    \mpdefineoutlines{#1}{MyGlyph}
    %
    \s

Re: [NTG-context] MetaFun - "remove the paths of text" from a rectangle to let the background visible

2020-12-23 Thread Otared Kavian
Hi Garulfo,

Thank you for sharing your nice example: it typesets correctly with mkiv, but 
it seems to me that with LMTX the text does not appear (at least on my 
installation of the latest LMTX).

Best regards: Otared

> On 24 Dec 2020, at 00:14, Garulfo  wrote:
> 
> Thanks Taco,
> 
> I made some progress :
> https://wiki.contextgarden.net/Talk:Cover_Pages
> 
> I now have two additional questions ... ;-)
> 
> - How can I deal with "space" characters (because current solution
>  requires to explicitly add the ~ character)
> 
> - What would be the work to do in order to make this mechanism directly
>  usable in metapost / metafun, within \startMPpage \stopMPpage,
>  - to avoid switching between \start\stopMPdrawing and TeX
>  - to have something like "draw followtext" in mp-blob.mpiv ?
> 
> 
> 
> %--
> 
> \setuppapersize  [A4]
> 
> %--
> 
> \def\MyFont{\definedfont[name:%
> texgyrepagellabold%
> %exo2black%
> %agaramondprobold%
> *default at 55pt]}
> 
> %--
> 
> \startluacode
> 
> function document.outlinepaths(character)
>local chardata  = fonts.hashes.characters[true] -- by unicode
>local shapedata = fonts.hashes.shapes[true] -- by index
>local c = chardata[character]
>if c and c.index and shapedata then
>local shapeglyphs = shapedata.glyphs or { }
>local glyph   = shapeglyphs[c.index]
>if glyph and (glyph.segments or glyph.sequence) then
>local units  = shapedata.units or 1000
>local factor = 100/units
>return fonts.metapost.paths(glyph,factor)
>end
>end
>return { }
> end
> 
> function document.defineoutline(char,target)
>local outlines = document.outlinepaths(char)
>local nofpaths = #outlines
>context("\\startMPdrawing") -- ADDED by garulfo
>context("path %s[] ;",target)
>context("numeric %sn ; %sn := %s ;",target,target,nofpaths)
>for i=1,nofpaths do
>context("%s[%i] := %s ; ",target,i,outlines[i])
>end
>context("\\stopMPdrawing")  -- ADDED by garulfo
> end
> 
> \stopluacode
> 
> %--
> 
> \def\mpdefineoutlines#1#2{\ctxlua{document.defineoutline(\number`#1,"#2")}}
> 
> %--
> 
> \def\EmptyLetters#1%
> {%
> \resetMPdrawing
> \MPtoks={}
> %
> \startMPdrawing
>  picture pic[], pictA ;
>  numeric wid[], len[], pos[], n ;
>  wid[0] := len[0] := pos[0] := n := 0 ;
>  numeric scaling;
>  path pictB , frame ;
>  pair shiftB ;
>  picture monImageA; monImageA := nullpicture;
>  picture monImageB; monImageB := nullpicture;
>  color colorframe;  colorframe := 0.6white;
> %
> \stopMPdrawing
> %
> \MyFont\handletokens#1\with\whatever
> %
> \startMPdrawing
>  frame :=  unitsquare
>  xscaled ( (xpart urcorner monImageB - xpart llcorner monImageB) + 
> 5mm )
>  yscaled ( (ypart urcorner monImageB - ypart llcorner monImageB) + 
> 5mm );
>  frame := frame shifted (center monImageB - center frame);
>  addto monImageB contour
>frame
>withpostscript "evenodd"
>withcolor transparent (1,1.,colorframe);
>  draw monImageB ;
>  draw monImageA ;
> \stopMPdrawing
> %
> \MPdrawingdonetrue
> \getMPdrawing}
> 
> %--
> 
> \def\whatever#1%
>  {\appendtoks#1\to\MPtoks
>   \setbox\MPbox=\hbox{\MyFont\the\MPtoks}%
>   %
>   \startMPdrawing
> n := n + 1 ; len[n] := \the\wd\MPbox ;
>   \stopMPdrawing
>   %
>   \mpdefineoutlines{M}{MaLettre}
>   %
>   \startMPdrawing
>   pictA := textext.drt("\MyFont M") ;
>   pictB := MaLettre[1];
>   scaling := bbheight pictA / bbheight pictB;
>   \stopMPdrawing
>   %
>   \doifinstringelse{~}{#1}{}{%HOW TO PROPERLY COPE WITH 
> SPACES ?
>   \mpdefineoutlines{#1}{MyGlyph}
>   %
>   \startMPdrawing
> string sb; sb := "i";
> pic[n] := textext.drt("\MyFont\setstrut\strut#1") ;
> %
> shiftB := - llcorner pic[n];
> pic[n] := pic[n] shifted shiftB ;
> %
> wid[n] := abs(xpart urcorner pic[n] - xpart llcorner pic[n]) ;
> pos[n] := len[n]-wid[n] ;
>

Re: [NTG-context] MetaFun - "remove the paths of text" from a rectangle to let the background visible

2020-12-23 Thread Garulfo

Thanks Taco,

I made some progress :
https://wiki.contextgarden.net/Talk:Cover_Pages

I now have two additional questions ... ;-)

- How can I deal with "space" characters (because current solution
  requires to explicitly add the ~ character)

- What would be the work to do in order to make this mechanism directly
  usable in metapost / metafun, within \startMPpage \stopMPpage,
  - to avoid switching between \start\stopMPdrawing and TeX
  - to have something like "draw followtext" in mp-blob.mpiv ?



%--

\setuppapersize  [A4]

%--

\def\MyFont{\definedfont[name:%
texgyrepagellabold%
%exo2black%
%agaramondprobold%
*default at 55pt]}

%--

\startluacode

function document.outlinepaths(character)
local chardata  = fonts.hashes.characters[true] -- by unicode
local shapedata = fonts.hashes.shapes[true] -- by index
local c = chardata[character]
if c and c.index and shapedata then
local shapeglyphs = shapedata.glyphs or { }
local glyph   = shapeglyphs[c.index]
if glyph and (glyph.segments or glyph.sequence) then
local units  = shapedata.units or 1000
local factor = 100/units
return fonts.metapost.paths(glyph,factor)
end
end
return { }
end

function document.defineoutline(char,target)
local outlines = document.outlinepaths(char)
local nofpaths = #outlines
context("\\startMPdrawing") -- ADDED by 
garulfo

context("path %s[] ;",target)
context("numeric %sn ; %sn := %s ;",target,target,nofpaths)
for i=1,nofpaths do
context("%s[%i] := %s ; ",target,i,outlines[i])
end
context("\\stopMPdrawing")  -- ADDED by 
garulfo

end

\stopluacode

%--

\def\mpdefineoutlines#1#2{\ctxlua{document.defineoutline(\number`#1,"#2")}}

%--

\def\EmptyLetters#1%
{%
\resetMPdrawing
\MPtoks={}
%
\startMPdrawing
  picture pic[], pictA ;
  numeric wid[], len[], pos[], n ;
  wid[0] := len[0] := pos[0] := n := 0 ;
  numeric scaling;
  path pictB , frame ;
  pair shiftB ;
  picture monImageA; monImageA := nullpicture;
  picture monImageB; monImageB := nullpicture;
  color colorframe;  colorframe := 0.6white;
%
\stopMPdrawing
%
\MyFont\handletokens#1\with\whatever
%
\startMPdrawing
  frame :=  unitsquare
  xscaled ( (xpart urcorner monImageB - xpart llcorner 
monImageB) + 5mm )
  yscaled ( (ypart urcorner monImageB - ypart llcorner 
monImageB) + 5mm );

  frame := frame shifted (center monImageB - center frame);
  addto monImageB contour
frame
withpostscript "evenodd"
withcolor transparent (1,1.,colorframe);
  draw monImageB ;
  draw monImageA ;
\stopMPdrawing
%
\MPdrawingdonetrue
\getMPdrawing}

%--

\def\whatever#1%
  {\appendtoks#1\to\MPtoks
   \setbox\MPbox=\hbox{\MyFont\the\MPtoks}%
   %
   \startMPdrawing
 n := n + 1 ; len[n] := \the\wd\MPbox ;
   \stopMPdrawing
   %
   \mpdefineoutlines{M}{MaLettre}
   %
   \startMPdrawing
   pictA := textext.drt("\MyFont M") ;
   pictB := MaLettre[1];
   scaling := bbheight pictA / bbheight pictB;
   \stopMPdrawing
   %
   \doifinstringelse{~}{#1}{}{%HOW TO PROPERLY COPE 
WITH SPACES ?

   \mpdefineoutlines{#1}{MyGlyph}
   %
   \startMPdrawing
 string sb; sb := "i";
 pic[n] := textext.drt("\MyFont\setstrut\strut#1") ;
 %
 shiftB := - llcorner pic[n];
 pic[n] := pic[n] shifted shiftB ;
 %
 wid[n] := abs(xpart urcorner pic[n] - xpart llcorner pic[n]) ;
 pos[n] := len[n]-wid[n] ;
 %
 addto monImageB contour
   ((MyGlyph[1] scaled scaling)
   shifted ( (pos[n],0) +  shiftB))
   withpostscript "collect";
 %
 if MyGlyphn > 1 :
for ind=2 upto MyGlyphn :
if (((xpart llcorner MyGlyph[ind]) > (xpart llcorner 
MyGlyph[1])) and
((ypart llcorner MyGlyph[ind]) > (ypart llcorner 
MyGlyph[1])) and
((xpart urcorner MyGlyph[ind]) < (xpart urcorner 
MyGlyph[1])) and
((ypart urcorner MyGlyph[ind]) < (ypart urcorner 
MyGlyph[1]))) :

%
addto monImageA contour
  (MyGlyph[ind] scaled scaling)
  shifted ( (pos[n],0) +  shiftB)
  withcolor transparent (1,1.,colorframe);
else :
addto monImageB contour
  (

Re: [NTG-context] MetaFun - "remove the paths of text" from a rectangle to let the background visible

2020-12-21 Thread Taco Hoekwater


> On 21 Dec 2020, at 16:09, Garulfo  wrote:
> 
> Hi,
> 
> 
> * I try to "remove the paths of text" from a metapost pictures to let
>  the background visible.
> 
> * Using
>  https://mailman.ntg.nl/pipermail/ntg-context/2018/thread.html#92725
> 
> * I was able to get the following with one glyph (MVE code below)
> 
>  https://wiki.contextgarden.net/images/d/d2/test_extract_glyphs.pdf
> 
> 
> 2 questions:
> 
> 1/ for some fonts (e.g. dejavu vs latin modern) the "encompassing" path
>   of the B glyph can switch from B[1] to B[Bn]. Is there a trick to
>   identify which id match with "the encompassing" path ?

What you get is the order of the paths as defined in the font, which is 
arbitrary, as you discovered.

A quick trick (that will not always work, but should work quite well for font 
variations of alphabetics) is to check the actual arclength of the paths. The 
longest one will typically be the outer one. 

But much depends on the font, so a generic solution is likely quite 
complicated. Consider an outline font’s colon glyph ;)


> 
> 2/ now, I would like to do the same, but for text... a kind of
>   derivative of "textext" or "outlinetext".
>   Would you please give me some guidelines ?
>   does it already exist ?
>   should I use something like \handletokens, \scantokens ?
>   do you have examples where I can get inspiration ?
> 
> 
> Thanks again for your help,
> Garulfo
> 
> 
> %==
> 
> 
> 
> 
> \starttext
> 
> %--
> 
> \startluacode
> 
> function document.outlinepaths(character)
>local chardata  = fonts.hashes.characters[true] -- by unicode
>local shapedata = fonts.hashes.shapes[true] -- by index
>local c = chardata[character]
>if c and c.index and shapedata then
>local shapeglyphs = shapedata.glyphs or { }
>local glyph   = shapeglyphs[c.index]
>if glyph and (glyph.segments or glyph.sequence) then
>local units  = shapedata.units or 1000
>local factor = 100/units
>return fonts.metapost.paths(glyph,factor)
>end
>end
>return { }
> end
> 
> function document.defineoutline(char,target)
>local outlines = document.outlinepaths(char)
>local nofpaths = #outlines
>context("path %s[] ;",target)
>context("numeric %sn ; %sn := %s ;",target,target,nofpaths)
>for i=1,nofpaths do
>context("%s[%i] := %s ; ",target,i,outlines[i])
>end
> end
> 
> \stopluacode
> 
> %--
> 
> \def\mpdefineoutlines#1#2{\ctxlua{document.defineoutline(\number`#1,"#2")}}
> 
> %--
> 
> \startMPpage
> 
> numeric dimA ; dimA := 20cm;
> 
> path pathbackground ;
> pathbackground :=  unitsquare scaled dimA ;
> fill pathbackground withshademethod "linear" withshadedirection(0,1) 
> withshadecolors (red,blue);
> 
> %--
> 
> \mpdefineoutlines{B}{B}
> 
> %--
> 
> numeric dimB  ; dimB := 2cm;
> numeric vratio ; vratio := 2;
> 
> path frame ;
> frame :=  unitsquare
>  xscaled (dimA - 2 * dimB)
>  yscaled (dimA / vratio)
>  shifted (dimB , (dimA - (dimA / vratio))/2 );
> 
> %--
> 
> pair shift ; shift := center frame;
> numeric scal ; scal := (0.9) * (10cm / (bbheight B[1])) ;
> 
> picture monImageB; monImageB := nullpicture;
> addto monImageB contour
>  (B[1] shifted (- center B[1]) scaled scal)
>  shifted shift
>  withpostscript "collect";
> 
> addto monImageB contour
>  frame
>  withpostscript "evenodd";
> 
> for i=2 upto Bn :
>  addto monImageB contour
>(B[i] shifted (- center B[1]) scaled scal)
>shifted shift;
> endfor ;
> 
> %--
> 
> draw monImageB withcolor white;
> 
> \stopMPpage
> 
> \stoptext
> ___
> 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
> ___

Taco Hoekwater
Elvenkind BV




___
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

[NTG-context] MetaFun - "remove the paths of text" from a rectangle to let the background visible

2020-12-21 Thread Garulfo

Hi,


* I try to "remove the paths of text" from a metapost pictures to let
  the background visible.

* Using
  https://mailman.ntg.nl/pipermail/ntg-context/2018/thread.html#92725

* I was able to get the following with one glyph (MVE code below)

  https://wiki.contextgarden.net/images/d/d2/test_extract_glyphs.pdf


2 questions:

1/ for some fonts (e.g. dejavu vs latin modern) the "encompassing" path
   of the B glyph can switch from B[1] to B[Bn]. Is there a trick to
   identify which id match with "the encompassing" path ?

2/ now, I would like to do the same, but for text... a kind of
   derivative of "textext" or "outlinetext".
   Would you please give me some guidelines ?
does it already exist ?
should I use something like \handletokens, \scantokens ?
do you have examples where I can get inspiration ?


Thanks again for your help,
Garulfo


%==




\starttext

%--

\startluacode

function document.outlinepaths(character)
local chardata  = fonts.hashes.characters[true] -- by unicode
local shapedata = fonts.hashes.shapes[true] -- by index
local c = chardata[character]
if c and c.index and shapedata then
local shapeglyphs = shapedata.glyphs or { }
local glyph   = shapeglyphs[c.index]
if glyph and (glyph.segments or glyph.sequence) then
local units  = shapedata.units or 1000
local factor = 100/units
return fonts.metapost.paths(glyph,factor)
end
end
return { }
end

function document.defineoutline(char,target)
local outlines = document.outlinepaths(char)
local nofpaths = #outlines
context("path %s[] ;",target)
context("numeric %sn ; %sn := %s ;",target,target,nofpaths)
for i=1,nofpaths do
context("%s[%i] := %s ; ",target,i,outlines[i])
end
end

\stopluacode

%--

\def\mpdefineoutlines#1#2{\ctxlua{document.defineoutline(\number`#1,"#2")}}

%--

\startMPpage

numeric dimA ; dimA := 20cm;

path pathbackground ;
pathbackground :=  unitsquare scaled dimA ;
fill pathbackground withshademethod "linear" withshadedirection(0,1) 
withshadecolors (red,blue);


%--

\mpdefineoutlines{B}{B}

%--

numeric dimB  ; dimB := 2cm;
numeric vratio ; vratio := 2;

path frame ;
frame :=  unitsquare
  xscaled (dimA - 2 * dimB)
  yscaled (dimA / vratio)
  shifted (dimB , (dimA - (dimA / vratio))/2 );

%--

pair shift ; shift := center frame;
numeric scal ; scal := (0.9) * (10cm / (bbheight B[1])) ;

picture monImageB; monImageB := nullpicture;
addto monImageB contour
  (B[1] shifted (- center B[1]) scaled scal)
  shifted shift
  withpostscript "collect";

addto monImageB contour
  frame
  withpostscript "evenodd";

for i=2 upto Bn :
  addto monImageB contour
(B[i] shifted (- center B[1]) scaled scal)
shifted shift;
endfor ;

%--

draw monImageB withcolor white;

\stopMPpage

\stoptext
___
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
___


Re: [NTG-context] Problem with shading in Metafun (LMTX)

2020-12-21 Thread Jairo A. del Rio
Nice. It works again. Thank you very much!

Cordially,

Jairo

El lun., 21 de dic. de 2020 2:45 a. m., Hans Hagen 
escribió:

> On 12/21/2020 4:46 AM, Jairo A. del Rio wrote:
> > While shading works with MkIV, with LMTX the following breaks:
> >
> >
> > \startMPpage
> >
> > comment("two shades with named colors");
> >
> > fill fullcircle scaled 5cm
> >
> > withshademethod "circular"
> >
> > withshadecolors ((1,0,0),(0,0,1,0))
> >
> > ;
> >
> > fill fullcircle scaled 5cm shifted (6cm,0)
> >
> > withshademethod "circular"
> >
> > withcolor (1,0,0,0) shadedinto "blue"
> >
> > ;
> >
> > \stopMPpage
>
> in mp-base.mpxl there is a ; missing
>
>  temp_any_u = u
>
> must be:
>
>  temp_any_u := u ;
>
> (in the min and max macros)
>
> (i replaced some internal names as part of a cleanup)
>
> (there will be a new upload later that will also fix this)
>
> 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
___


Re: [NTG-context] Problem with shading in Metafun (LMTX)

2020-12-20 Thread Hans Hagen

On 12/21/2020 4:46 AM, Jairo A. del Rio wrote:

While shading works with MkIV, with LMTX the following breaks:


\startMPpage

comment("two shades with named colors");

fill fullcircle scaled 5cm

withshademethod "circular"

withshadecolors ((1,0,0),(0,0,1,0))

;

fill fullcircle scaled 5cm shifted (6cm,0)

withshademethod "circular"

withcolor (1,0,0,0) shadedinto "blue"

;

\stopMPpage


in mp-base.mpxl there is a ; missing

temp_any_u = u

must be:

temp_any_u := u ;

(in the min and max macros)

(i replaced some internal names as part of a cleanup)

(there will be a new upload later that will also fix this)

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
___


[NTG-context] Problem with shading in Metafun (LMTX)

2020-12-20 Thread Jairo A. del Rio
While shading works with MkIV, with LMTX the following breaks:


\startMPpage

comment("two shades with named colors");

fill fullcircle scaled 5cm

withshademethod "circular"

withshadecolors ((1,0,0),(0,0,1,0))

;

fill fullcircle scaled 5cm shifted (6cm,0)

withshademethod "circular"

withcolor (1,0,0,0) shadedinto "blue"

;

\stopMPpage

The log says:

metafun > log >

metafun > log > error: Unknown relation will be considered false

metafun > log >

metapost > log >

metapost > log > 

metapost > log > :

metapost > log >  if(EXPR0)>temp_any_u:

metapost > log > temp_any_u:=(EXPR0);fi ENDFOR

metapost > log >
max->begingroup.save.temp_any_u;if.pair(EXPR2):pair.temp_any_u.elseif.string(EXPR2):
string.temp_any_u.fi
;temp_any_u=(EXPR2)for.i=(TEXT3):if.i>temp_any_u:temp_any_u:=i;fi.endfor

metapost > log > .temp_any_u.endgroup

metapost > log >
mfun_max_radius->...er(EXPR2)-xpart.center(EXPR2))++(ypart.center(EXPR2)-ypart.lrcorner(EXPR2)),(xpart.urcorner(EXPR2)-xpart.center(EXPR2))++(ypart.urcorner(EXPR2)-ypart.center(EXPR2)))

metapost > log > endgroup

metapost > log >
withshademethod->...cimal.center(EXPR0)withprescript"sh_center_b="&ddecimal.center(EXPR0)withprescript"sh_radius_a="&decimal0withprescript"sh_radius_b="&decimal.mfun_max_radius((EXPR0))

metapost > log > fi

metapost > log > 

metapost > log > withprescript

metapost > log >
withshadecolors->...hprescript"sh_color_a_"&decimal.mfun_shade_step&"="&colordecimals(EXPR0)withprescript"sh_color_b_"&decimal.mfun_shade_step&"="&colordecimals(EXPR1)else:withprescript

metapost > log > "sh_color=in...

metapost > log > <*> comment("two shades with named colors"); fill
fullcircle scaled 5cm withshademethod "circular" withshadecolors
((1,0,0),(0,0,1,0))

metafun > log >

metafun > log > Oh dear. I can't decide if the expression above is
positive, negative, or zero.

So this comparison test won't be 'true'.

metafun > log >

metapost > log > ; fill fullcircle scaled 5cm shifted (6cm,0)
withshademethod "...

metapost > log >


Hans told me not to use the B tag, so I'm asking first in case I've missed
something. Thank you in advance.

Best regards,


Jairo
___
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
___


[NTG-context] A link to an example of poster build with ConTeXt

2020-12-19 Thread Garulfo

Hi,

it's really fun to play with ConTeXt and MetaPost / Metafun to build 
posters (color, fonts, alignment, scaling, randomized geometry).


Thanks to the ConTeXt team to make it easy.

PDF:

https://salsa.debian.org/zleap-guest/libreplanet2021/-/raw/master/ConTeXt_version/poster_libreplanet_2021.pdf

Source code:

https://salsa.debian.org/zleap-guest/libreplanet2021/-/blob/master/README.md
___
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
___


Re: [NTG-context] LMTX MetaFun SVG trouble, a portion of the SVG is cut of in the PDF

2020-12-18 Thread Hans Hagen

On 12/17/2020 3:03 PM, Neven Sajko wrote:

Hello all,

I am completely new to TeX, ConTeXt, MetaPost, etc. (Except for some
MathJax snippets and the like.)

I am using Aditya's LMTX package from AUR on Archlinux.

I have some SVGs (generated by the Julia Gadfly package) that
represent 2D plots of some functions, and I would like to include the
SVGs in a ConTeXt document so it ends up as PDF. I started creating
the document by including the SVGs using the new LMTX MetaPost SVG
feature, however at this point I don't know how to proceed...

This is the situation: the source SVGs look fine, but after including
them in the document with the new ConTeXt feature mentioned above, the
bottom-most part of the image is "cut off" (not visible). In the
attached ZIP I included all relevant files (.tex, .svg, .pdf, ...), as
well as PNG screenshots of the PDFs (in case the issue is
PDF-viewer-specific, I'm using Chromium as the PDF viewer).

I tried doing this in two different ways: using includesvgfile with
the offset option, and using startMPcode with setbounds in the MetaFun
code. In both cases I just get blank space instead of the cut-off
content

How can I fix this?

Related question: is it possible to get the MetaPost code that (I
think) the SVG gets translated to? I'm interested in how it looks
like.

\enabletrackers[metapost.svg.result]

but i have a fix that does clipping different


-
  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
___


Re: [NTG-context] LMTX MetaFun SVG trouble, a portion of the SVG is cut of in the PDF

2020-12-17 Thread Pablo Rodriguez
On 12/17/20 6:45 PM, Pablo Rodriguez wrote:
> On 12/17/20 5:08 PM, Neven Sajko wrote:
>> On Thu, 17 Dec 2020 at 15:27, Aditya Mahajan  wrote:
>> [...]
>>> Can you check with a desktop pdf viewer as well.
>>
>> It looks the same with MuPDF.
>
> Hi Neven,
>
> it seems to be an issue with the conversion of the SVG file.

Hans,

I thought it was an issue with the MP conversion of the SVG file.

I was wrong: it is an issue on how LMTX deals with the SVG conversion in
MP. MkIV is totally fine respecting image dimensions.

Many thanks for your help,

Pablo
--
http://www.ousia.tk
___
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
___


Re: [NTG-context] LMTX MetaFun SVG trouble, a portion of the SVG is cut of in the PDF

2020-12-17 Thread Pablo Rodriguez
On 12/17/20 5:08 PM, Neven Sajko wrote:
> On Thu, 17 Dec 2020 at 15:27, Aditya Mahajan  wrote:
> [...]
>> Can you check with a desktop pdf viewer as well.
>
> It looks the same with MuPDF.

Hi Neven,

it seems to be an issue with the conversion of the SVG file.

> This is a combined TeX file containing two different ways I took to
> try to accomplish the same thing:

How about a much simpler approach?

  \starttext
  \framed[offset=overlay]

{\externalfigure[hammingCoderStopwatch-hammingCoder-gcc-RowsSparse-1023-1013.svg]
  [width=\textwidth, offset=20pt]}
  \stoptext

In that case, if you use \externalfigure, ConTeXt will invoke Inkscape
to convert the file. The output is way better.

Just in case it may help,

Pablo
--
http://www.ousia.tk
___
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
___


Re: [NTG-context] LMTX MetaFun SVG trouble, a portion of the SVG is cut of in the PDF

2020-12-17 Thread Neven Sajko
On Thu, 17 Dec 2020 at 15:27, Aditya Mahajan  wrote:
> OT but can Gadfly directly produce PDFs? [...]

Yes it can. Going to try that route if this doesn't work out.

> [..] Depending on how complicated plots you want to generate, you can also 
> use metapost graph module or pdfplots package for drawing 2D plots.

OT, but that wouldn't work for me easily, because I don't actually
know what function I'm plotting - it's a probability density function
estimation (which is similar to a histogram, but continuous), where I
only provide the data points and Gadfly takes care of everything else.

> Can you check with a desktop pdf viewer as well.

It looks the same with MuPDF.

> The mailing list has a size limit for attachments, so I think that your zip 
> file did not get included in your message. Could you just include the tex 
> file and maybe upload the svg somewhere and include a link.

This is a combined TeX file containing two different ways I took to
try to accomplish the same thing:

\starttext
{\switchtobodyfont[2pt]

{\framed[offset=overlay]{\includesvgfile[../hammingCoderStopwatch-hammingCoder-gcc-RowsSparse-1023-1013.svg][offset=20pt]}}
{some offset}

\startMPcode
draw lmt_svg [
filename =
"../hammingCoderStopwatch-hammingCoder-gcc-RowsSparse-1023-1013.svg"
];
setbounds currentpicture to
  boundingbox currentpicture
  enlarged 20pt;
\stopMPcode
}
\stoptext

The SVG: 
https://drive.google.com/file/d/1_JsIfA9cgEs5_x7FFJrUWPPe3Ht8JnIm/view?usp=sharing

To be specific, what gets cut off is the bottom half of each number on
the x-axis and the entire x-axis label.

Thanks,
Neven
___
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
___


Re: [NTG-context] LMTX MetaFun SVG trouble, a portion of the SVG is cut of in the PDF

2020-12-17 Thread Aditya Mahajan
On Thu, 17 Dec 2020, Neven Sajko wrote:

> Hello all,
> 
> I am completely new to TeX, ConTeXt, MetaPost, etc. (Except for some
> MathJax snippets and the like.)
> 
> I am using Aditya's LMTX package from AUR on Archlinux.
> 
> I have some SVGs (generated by the Julia Gadfly package) that
> represent 2D plots of some functions, and I would like to include the
> SVGs in a ConTeXt document so it ends up as PDF. 

OT but can Gadfly directly produce PDFs? Depending on how complicated plots you 
want to generate, you can also use metapost graph module or pdfplots package 
for drawing 2D plots.

> I started creating
> the document by including the SVGs using the new LMTX MetaPost SVG
> feature, however at this point I don't know how to proceed...
> 
> This is the situation: the source SVGs look fine, but after including
> them in the document with the new ConTeXt feature mentioned above, the
> bottom-most part of the image is "cut off" (not visible). In the
> attached ZIP I included all relevant files (.tex, .svg, .pdf, ...), as
> well as PNG screenshots of the PDFs (in case the issue is
> PDF-viewer-specific, I'm using Chromium as the PDF viewer).

Can you check with a desktop pdf viewer as well.

> I tried doing this in two different ways: using includesvgfile with
> the offset option, and using startMPcode with setbounds in the MetaFun
> code. In both cases I just get blank space instead of the cut-off
> content
> 
> How can I fix this?

The mailing list has a size limit for attachments, so I think that your zip 
file did not get included in your message. Could you just include the tex file 
and maybe upload the svg somewhere and include a link.

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
___


[NTG-context] LMTX MetaFun SVG trouble, a portion of the SVG is cut of in the PDF

2020-12-17 Thread Neven Sajko
Hello all,

I am completely new to TeX, ConTeXt, MetaPost, etc. (Except for some
MathJax snippets and the like.)

I am using Aditya's LMTX package from AUR on Archlinux.

I have some SVGs (generated by the Julia Gadfly package) that
represent 2D plots of some functions, and I would like to include the
SVGs in a ConTeXt document so it ends up as PDF. I started creating
the document by including the SVGs using the new LMTX MetaPost SVG
feature, however at this point I don't know how to proceed...

This is the situation: the source SVGs look fine, but after including
them in the document with the new ConTeXt feature mentioned above, the
bottom-most part of the image is "cut off" (not visible). In the
attached ZIP I included all relevant files (.tex, .svg, .pdf, ...), as
well as PNG screenshots of the PDFs (in case the issue is
PDF-viewer-specific, I'm using Chromium as the PDF viewer).

I tried doing this in two different ways: using includesvgfile with
the offset option, and using startMPcode with setbounds in the MetaFun
code. In both cases I just get blank space instead of the cut-off
content

How can I fix this?

Related question: is it possible to get the MetaPost code that (I
think) the SVG gets translated to? I'm interested in how it looks
like.

Thanks,
Neven
___
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
___


Re: [NTG-context] upload / metafun

2020-12-16 Thread Hans Hagen

On 12/15/2020 9:18 PM, Pablo Rodriguez wrote:

On 12/15/20 8:24 PM, Otared Kavian wrote:

[...]
However after running install. sh on MacOS, I still get current
version: 2020.12.10 22:26, even after removing the .tma files.> So I guess I 
have to wait a little bit for the new version to be
upoaded.

Hans,

I’m afraid I’m having the same issue as Otared.

   $ curl I http://lmtx.pragma-ade.com/install-lmtx/texmf-context.zip
 Last-Modified: Thu, 10 Dec 2020 21:30:45 GMT

   $ curl -I http://lmtx.pragma-ade.com/install-lmtx/texmf.zip
 Last-Modified: Thu, 10 Dec 2020 21:30:47 GMT

This is from some minute ago (Date: Tue, 15 Dec 2020 20:15:33 GMT).

I guess this might be the reason for an oudated brand new install.

I think there might be an issue here.

I'll check it when I've finished what I'm doing now (some more mp stuff).

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
___


Re: [NTG-context] upload / metafun

2020-12-15 Thread Pablo Rodriguez
On 12/15/20 8:24 PM, Otared Kavian wrote:
> [...]
> However after running install. sh on MacOS, I still get current
> version: 2020.12.10 22:26, even after removing the .tma files.> So I guess I 
> have to wait a little bit for the new version to be
> upoaded.
Hans,

I’m afraid I’m having the same issue as Otared.

  $ curl I http://lmtx.pragma-ade.com/install-lmtx/texmf-context.zip
Last-Modified: Thu, 10 Dec 2020 21:30:45 GMT

  $ curl -I http://lmtx.pragma-ade.com/install-lmtx/texmf.zip
Last-Modified: Thu, 10 Dec 2020 21:30:47 GMT

This is from some minute ago (Date: Tue, 15 Dec 2020 20:15:33 GMT).

I guess this might be the reason for an oudated brand new install.

I think there might be an issue here.

Many thanks for your help,

Pablo
--
http://www.ousia.tk
___
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
___


Re: [NTG-context] upload / metafun

2020-12-15 Thread Otared Kavian
Hi Hans,

Thanks for the new upload. 
With your comments, I understand that, following the discussion with Aditya, 
when using the new version I should not define in Metafun a new function named
dotlabel
in order to have a square dot… Actually I called it mydotlabel in order to be 
able to change the shape of the dot, so I will be on the safe side when I can 
download the new version.

However after running install. sh on MacOS, I still get current version: 
2020.12.10 22:26, even after removing the .tma files.
So I guess I have to wait a little bit for the new version to be upoaded.

Best regards: Otared



> On 15 Dec 2020, at 10:35, Hans Hagen  wrote:
> 
> Hi,
> 
> I uploaded a new lmtx. This time some work has been done at the metafun end.
> 
> At the tex end we're working on some overload protection mechanism which 
> involves tagging many macro so that will take a while (most tagging is done 
> but checking left over cases take time).
> 
> So, I wondered if we can do something similar in metapost: flag macros and 
> variables in order to issue a warnings when a dangerous overload happens.
> 
> The current lmtx has this as an experiment: primitives, permanent, immutable 
> and mutable (so far); you can look at the *.mpxl files to get an idea. If you 
> say for instance
> 
>path fullcircle;
> 
> there will be a warning
> 
>   metapost> overloading immutable 'fullcircle'
> 
> or when
> 
>   \enabledirectives[metapost.overloadmode=error]
> 
> has been given you get an error.
> 
> The implementation is rather simple and non intrusive and differs from
> the one in tex. There it is tightly integrated for all kind of reasons 
> (millions of macro definitions per run so efficiency matters). Also, in 
> metapost variables (tags) can have complex name constructions and we only 
> test the top level. When a overload happens (overloadmode internal <> 0) a 
> lua callback takes care of it.
> 
> A side effect is that we can query all hash entries and check for consistency 
> which is what i've done and am doing now. Of course that can introduce issues 
> ... just that you know.
> 
> 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
> ___

___
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
___


[NTG-context] RE : upload / metafun

2020-12-15 Thread Joseph
Hi, FYI, when running install.bat I see problem downloading exe mtx-install | changed  :   0 % :  2391552 : tex/texmf-win64/bin/luametatex.exemtx-install | tex/texmf-win64/bin/luametatex.exe, trying again: After several attempts, the install.bat run stops.Thanks Joseph De : Hans HagenEnvoyé le :mardi 15 décembre 2020 10:35À : mailing list for ConTeXt usersObjet :[NTG-context] upload / metafun Hi, I uploaded a new lmtx. This time some work has been done at the metafun end. At the tex end we're working on some overload protection mechanism which involves tagging many macro so that will take a while (most tagging is done but checking left over cases take time). So, I wondered if we can do something similar in metapost: flag macros and variables in order to issue a warnings when a dangerous overload happens. The current lmtx has this as an experiment: primitives, permanent, immutable and mutable (so far); you can look at the *.mpxl files to get an idea. If you say for instance  path fullcircle; there will be a warning metapost    > overloading immutable 'fullcircle' or when \enabledirectives[metapost.overloadmode=error] has been given you get an error. The implementation is rather simple and non intrusive and differs fromthe one in tex. There it is tightly integrated for all kind of reasons (millions of macro definitions per run so efficiency matters). Also, in metapost variables (tags) can have complex name constructions and we only test the top level. When a overload happens (overloadmode internal <> 0) a lua callback takes care of it. A side effect is that we can query all hash entries and check for consistency which is what i've done and am doing now. Of course that can introduce issues ... just that you know. 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-contextwebpage  : http://www.pragma-ade.nl / http://context.aanhet.netarchive  : 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
___


[NTG-context] upload / metafun

2020-12-15 Thread Hans Hagen

Hi,

I uploaded a new lmtx. This time some work has been done at the metafun end.

At the tex end we're working on some overload protection mechanism which 
involves tagging many macro so that will take a while (most tagging is 
done but checking left over cases take time).


So, I wondered if we can do something similar in metapost: flag macros 
and variables in order to issue a warnings when a dangerous overload 
happens.


The current lmtx has this as an experiment: primitives, permanent, 
immutable and mutable (so far); you can look at the *.mpxl files to get 
an idea. If you say for instance


path fullcircle;

there will be a warning

metapost> overloading immutable 'fullcircle'

or when

\enabledirectives[metapost.overloadmode=error]

has been given you get an error.

The implementation is rather simple and non intrusive and differs from
the one in tex. There it is tightly integrated for all kind of reasons 
(millions of macro definitions per run so efficiency matters). Also, in 
metapost variables (tags) can have complex name constructions and we 
only test the top level. When a overload happens (overloadmode internal 
<> 0) a lua callback takes care of it.


A side effect is that we can query all hash entries and check for 
consistency which is what i've done and am doing now. Of course that can 
introduce issues ... just that you know.


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
___


Re: [NTG-context] Metafun: is it possible to redefine dotlabel to draw a square ?

2020-12-10 Thread Hans Hagen

On 12/10/2020 8:37 PM, Aditya Mahajan wrote:

On Thu, 10 Dec 2020, Hans Hagen wrote:


dotlabel uses a pen to draw the dot, and I am not sure why it uses that rather
than a path. Here is a (to me) simpler definition, where you can change the
shape:


just look in the pdf ... in your case the dot is a n point path while otherwise
it uses the default postscript pen (which is a dot)


Ah, that makes sense.


it surprised me that a math guru like you doesn't do this:

vardef dotlabel@#(expr s,z) text t_ =
% draw textext("$\bullet$") scaled (1/2) shifted z ;
% draw textext("$\blacktriangle$") scaled (1/4) shifted z ;
 draw textext("$\blacksquare$") scaled (1/4) shifted z ;
 label@#(s,z) t_ ;
enddef ;
\stopMPdefinitions


Ha! I know that you said this as a joke, but as someone who did try to use the old 
font-based picture environment in LaTeX back in the day, I would never try to use fonts 
for "drawing". Especially, math fonts, where every designer has a different 
idea of what the shape should look like.

ah pictex memories ... drawing lines with cmr5 periods ...

but actually, we can define a stable font with symbols in metafun and 
use that (quite efficient too) and then one can even cut'n'paste those 
tiny symbols (don't worry ... not much of a challenge so low on my list)


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
___


Re: [NTG-context] Metafun: is it possible to redefine dotlabel to draw a square ?

2020-12-10 Thread Aditya Mahajan
On Thu, 10 Dec 2020, Hans Hagen wrote:

> > dotlabel uses a pen to draw the dot, and I am not sure why it uses that 
> > rather
> > than a path. Here is a (to me) simpler definition, where you can change the
> > shape:
> 
> just look in the pdf ... in your case the dot is a n point path while 
> otherwise
> it uses the default postscript pen (which is a dot)

Ah, that makes sense. 

> it surprised me that a math guru like you doesn't do this:
> 
> vardef dotlabel@#(expr s,z) text t_ =
> % draw textext("$\bullet$") scaled (1/2) shifted z ;
> % draw textext("$\blacktriangle$") scaled (1/4) shifted z ;
> draw textext("$\blacksquare$") scaled (1/4) shifted z ;
> label@#(s,z) t_ ;
> enddef ;
> \stopMPdefinitions

Ha! I know that you said this as a joke, but as someone who did try to use the 
old font-based picture environment in LaTeX back in the day, I would never try 
to use fonts for "drawing". Especially, math fonts, where every designer has a 
different idea of what the shape should look like. 

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
___


Re: [NTG-context] Metafun: is it possible to redefine dotlabel to draw a square ?

2020-12-10 Thread Hans Hagen

On 12/10/2020 7:04 PM, Aditya Mahajan wrote:

On Thu, 10 Dec 2020, Otared Kavian wrote:


Hi Aditya,
Thank you very much !
That's great indeed, you gave me an elegant solution.
  
One more question, in order for me to understand a little more: when defining a new dotlabel as you do, might it not conflict with the internal definitions of dotlabel in Metafun in some other place?

Maybe it is safer for me to call it something like  « dotshapelabel » ?


In general, I agree. Redefining internal macros has the advantage that your 
code doesn't have to change. See, for example:


it depends a bit ... redefing dotlabel in a compatible way is kind of 
ok, but using/redefining \foo_bar_something_internal is a real bad idea 
as that is not part of the interface (okay, i know that there are macro 
packages out there where it's part of the concept to redefine low level 
stuff for styles but in context we should try to avoid it ... we should 
then adapt the high level interface to suport something)


it also depends who does it ... i know that aditya knows the internals 
well enough to deal with it


(one of my concerns is always that while we try to come up with 
efficient solutions it's easy to make things inefficient but that's not 
the case here ... unless of course we want to nurture the 'context is 
slow' meme)


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
___


Re: [NTG-context] Metafun: is it possible to redefine dotlabel to draw a square ?

2020-12-10 Thread Hans Hagen

On 12/10/2020 6:44 PM, Aditya Mahajan wrote:

On Thu, 10 Dec 2020, Otared Kavian wrote:


Hi all,

In Metafun when representing a point I woul dlike to have some dots represented 
by a square (or even by another scalable symbol): for instance in the following 
I would like the dot at the point B to be a square:

\starttext
\startMPcode
draw (2cm,3cm) -- (3cm,5cm) ;
dotlabel(textext("\switchtobodyfont[8pt]" & "A"), (2cm,3cm))
withpen pencircle scaled 12pt
withcolor transparent("exclusion",.5,red) ;

dotlabel(textext("\switchtobodyfont[8pt]" & "B"), (3cm,5cm))
withpen pencircle scaled 12pt
withcolor transparent("exclusion",.5,red) ;
\stopMPcode
\stoptext

I wonder whether it is possible to define something like « drawsquaredot » or « 
squaredotlabel » in order to do this.


dotlabel uses a pen to draw the dot, and I am not sure why it uses that rather 
than a path. Here is a (to me) simpler definition, where you can change the 
shape:


just look in the pdf ... in your case the dot is a n point path while 
otherwise it uses the default postscript pen (which is a dot)


actually fullcircle is pencircle so you can ponder why that is the case -)


\startMPdefinitions
newpath dotlabelshape;

dotlabelshape := fullcircle;

vardef dotlabel@#(expr s,z) text t_ =
 label@#(s,z) t_ ;
 fill (dotlabelshape scaled 2dotlabeldiam) shifted z t_;
enddef ;
\stopMPdefinitions

\starttext
\startMPcode
newpath p ;
p := (2cm, 3cm) -- (3cm, 5cm);
dotlabeldiam := 12pt;

% Default
draw p;
dotlabel(textext("\switchtobodyfont[8pt]" & "A"), point 0 of p)
 withcolor transparent("exclusion",.5,red) ;

dotlabel(textext("\switchtobodyfont[8pt]" & "B"), point 1 of p)
 withcolor transparent("exclusion",.5,red) ;

% Using a square "dot"
p := p shifted (5cm, 0);
dotlabelshape := fullsquare;

draw p;
dotlabel(textext("\switchtobodyfont[8pt]" & "A"), point 0 of p)
 withcolor transparent("exclusion",.5,red) ;

dotlabel(textext("\switchtobodyfont[8pt]" & "B"), point 1 of p)
 withcolor transparent("exclusion",.5,red) ;
\stopMPcode
\stoptext

These types of macros are also a good candidate for the new LMTX syntax, where 
we can make all components configurable via a key-value interface 
(labeldistance etc. as well).

it surprised me that a math guru like you doesn't do this:

vardef dotlabel@#(expr s,z) text t_ =
% draw textext("$\bullet$") scaled (1/2) shifted z ;
% draw textext("$\blacktriangle$") scaled (1/4) shifted z ;
draw textext("$\blacksquare$") scaled (1/4) shifted z ;
label@#(s,z) t_ ;
enddef ;
\stopMPdefinitions



-
  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
___


Re: [NTG-context] Metafun: is it possible to redefine dotlabel to draw a square ?

2020-12-10 Thread Aditya Mahajan
On Thu, 10 Dec 2020, Otared Kavian wrote:

> Hi Aditya,
> Thank you very much !
> That's great indeed, you gave me an elegant solution.
>  
> One more question, in order for me to understand a little more: when defining 
> a new dotlabel as you do, might it not conflict with the internal definitions 
> of dotlabel in Metafun in some other place?
> Maybe it is safer for me to call it something like  « dotshapelabel » ?

In general, I agree. Redefining internal macros has the advantage that your 
code doesn't have to change. See, for example:

https://github.com/adityam/mp-sketch/blob/master/mp-sketch.mp

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
___


Re: [NTG-context] Metafun: is it possible to redefine dotlabel to draw a square ?

2020-12-10 Thread Otared Kavian
Hi Aditya,
Thank you very much !
That's great indeed, you gave me an elegant solution.
 
One more question, in order for me to understand a little more: when defining a 
new dotlabel as you do, might it not conflict with the internal definitions of 
dotlabel in Metafun in some other place?
Maybe it is safer for me to call it something like  « dotshapelabel » ?

Best regards and agin many thanks: Otared

> On 10 Dec 2020, at 18:44, Aditya Mahajan  wrote:
> 
> On Thu, 10 Dec 2020, Otared Kavian wrote:
> 
>> Hi all,
>> 
>> In Metafun when representing a point I woul dlike to have some dots 
>> represented by a square (or even by another scalable symbol): for instance 
>> in the following I would like the dot at the point B to be a square:
>> 
>> \starttext
>> \startMPcode
>> draw (2cm,3cm) -- (3cm,5cm) ;
>> dotlabel(textext("\switchtobodyfont[8pt]" & "A"), (2cm,3cm)) 
>>  withpen pencircle scaled 12pt 
>>  withcolor transparent("exclusion",.5,red) ;
>> 
>> dotlabel(textext("\switchtobodyfont[8pt]" & "B"), (3cm,5cm)) 
>>  withpen pencircle scaled 12pt 
>>  withcolor transparent("exclusion",.5,red) ;
>> \stopMPcode
>> \stoptext
>> 
>> I wonder whether it is possible to define something like « drawsquaredot » 
>> or « squaredotlabel » in order to do this.
> 
> dotlabel uses a pen to draw the dot, and I am not sure why it uses that 
> rather than a path. Here is a (to me) simpler definition, where you can 
> change the shape:
> 
> \startMPdefinitions
> newpath dotlabelshape;
> 
> dotlabelshape := fullcircle;
> 
> vardef dotlabel@#(expr s,z) text t_ =
>label@#(s,z) t_ ;
>fill (dotlabelshape scaled 2dotlabeldiam) shifted z t_;
> enddef ;
> \stopMPdefinitions
> 
> \starttext
> \startMPcode
> newpath p ; 
> p := (2cm, 3cm) -- (3cm, 5cm);
> dotlabeldiam := 12pt;
> 
> % Default
> draw p;
> dotlabel(textext("\switchtobodyfont[8pt]" & "A"), point 0 of p) 
>withcolor transparent("exclusion",.5,red) ;
> 
> dotlabel(textext("\switchtobodyfont[8pt]" & "B"), point 1 of p) 
>withcolor transparent("exclusion",.5,red) ;
> 
> % Using a square "dot"
> p := p shifted (5cm, 0);
> dotlabelshape := fullsquare;
> 
> draw p;
> dotlabel(textext("\switchtobodyfont[8pt]" & "A"), point 0 of p) 
>withcolor transparent("exclusion",.5,red) ;
> 
> dotlabel(textext("\switchtobodyfont[8pt]" & "B"), point 1 of p) 
>withcolor transparent("exclusion",.5,red) ;
> \stopMPcode
> \stoptext
> 
> These types of macros are also a good candidate for the new LMTX syntax, 
> where we can make all components configurable via a key-value interface 
> (labeldistance etc. as well).
> 
> 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
___


Re: [NTG-context] Metafun: is it possible to redefine dotlabel to draw a square ?

2020-12-10 Thread Aditya Mahajan
On Thu, 10 Dec 2020, Otared Kavian wrote:

> Hi all,
> 
> In Metafun when representing a point I woul dlike to have some dots 
> represented by a square (or even by another scalable symbol): for instance in 
> the following I would like the dot at the point B to be a square:
> 
> \starttext
> \startMPcode
> draw (2cm,3cm) -- (3cm,5cm) ;
> dotlabel(textext("\switchtobodyfont[8pt]" & "A"), (2cm,3cm)) 
>   withpen pencircle scaled 12pt 
>   withcolor transparent("exclusion",.5,red) ;
> 
> dotlabel(textext("\switchtobodyfont[8pt]" & "B"), (3cm,5cm)) 
>   withpen pencircle scaled 12pt 
>   withcolor transparent("exclusion",.5,red) ;
> \stopMPcode
> \stoptext
> 
> I wonder whether it is possible to define something like « drawsquaredot » or 
> « squaredotlabel » in order to do this.

dotlabel uses a pen to draw the dot, and I am not sure why it uses that rather 
than a path. Here is a (to me) simpler definition, where you can change the 
shape:

\startMPdefinitions
newpath dotlabelshape;

dotlabelshape := fullcircle;

vardef dotlabel@#(expr s,z) text t_ =
label@#(s,z) t_ ;
fill (dotlabelshape scaled 2dotlabeldiam) shifted z t_;
enddef ;
\stopMPdefinitions

\starttext
\startMPcode
newpath p ; 
p := (2cm, 3cm) -- (3cm, 5cm);
dotlabeldiam := 12pt;

% Default
draw p;
dotlabel(textext("\switchtobodyfont[8pt]" & "A"), point 0 of p) 
withcolor transparent("exclusion",.5,red) ;

dotlabel(textext("\switchtobodyfont[8pt]" & "B"), point 1 of p) 
withcolor transparent("exclusion",.5,red) ;

% Using a square "dot"
p := p shifted (5cm, 0);
dotlabelshape := fullsquare;

draw p;
dotlabel(textext("\switchtobodyfont[8pt]" & "A"), point 0 of p) 
withcolor transparent("exclusion",.5,red) ;

dotlabel(textext("\switchtobodyfont[8pt]" & "B"), point 1 of p) 
withcolor transparent("exclusion",.5,red) ;
\stopMPcode
\stoptext

These types of macros are also a good candidate for the new LMTX syntax, where 
we can make all components configurable via a key-value interface 
(labeldistance etc. as well).

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
___


[NTG-context] Metafun: is it possible to redefine dotlabel to draw a square ?

2020-12-10 Thread Otared Kavian
Hi all,

In Metafun when representing a point I woul dlike to have some dots represented 
by a square (or even by another scalable symbol): for instance in the following 
I would like the dot at the point B to be a square:

\starttext
\startMPcode
draw (2cm,3cm) -- (3cm,5cm) ;
dotlabel(textext("\switchtobodyfont[8pt]" & "A"), (2cm,3cm)) 
withpen pencircle scaled 12pt 
withcolor transparent("exclusion",.5,red) ;

dotlabel(textext("\switchtobodyfont[8pt]" & "B"), (3cm,5cm)) 
withpen pencircle scaled 12pt 
withcolor transparent("exclusion",.5,red) ;
\stopMPcode
\stoptext

I wonder whether it is possible to define something like « drawsquaredot » or « 
squaredotlabel » in order to do this.
If I use for B the command
withpen pensquare scaled 12pt
then the dot is a square, but the label B is drawn in a strange way.

Thanks for any help: Otared
___
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
___


Re: [NTG-context] Metafun: how to draw a straight line past the end points

2020-12-09 Thread Hans Hagen

On 12/9/2020 9:38 PM, Aditya Mahajan wrote:


Or just redefine shortened to accept a pair!

\startMPdefinitions
primarydef p shortened d =
 reverse ( ( reverse (p enlonged -xpart paired(d)) ) enlonged -ypart 
paired(d) )
enddef ;
\stopMPdefinitions


patched but then also:

primarydef p enlonged len =
begingroup
if len == 0 :
p
elseif pair p :
...

in order to save some energy when one is zero

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
___


Re: [NTG-context] Metafun: how to draw a straight line past the end points

2020-12-09 Thread Otared Kavian
Thanks Aditya!
One can learn a lot with your answers !
In the Metafun manual I see enlonged but I did not know to use it.

Best regards: Otared

> On 9 Dec 2020, at 21:38, Aditya Mahajan  wrote:
> 
> On Wed, 9 Dec 2020, Otared Kavian wrote:
> 
>> Hi Aditya,
>> 
>> Thanks for the alternative method, which comes handy if one wishes to extend 
>> the straight line by a different amount at either end:
>> 
>> \starttext
>> \startMPcode
>>   z1 = (1cm,3cm) ;
>>   z2 = (5cm, 9cm) ;
>>   z3 = 1cm * dir(angle (z2 - z1)) shifted z2 ;
>>   z4 = -.5cm*dir(angle(z2 - z1)) shifted z1 ;
>>   draw z1 -- z3 ; 
>>   draw z4 -- z1 ;
>>   draw z1 -- z2 withcolor red ;
>> \stopMPcode
>> \stoptext
> 
> Or just redefine shortened to accept a pair! 
> 
> \startMPdefinitions
> primarydef p shortened d =
>reverse ( ( reverse (p enlonged -xpart paired(d)) ) enlonged -ypart 
> paired(d) )
> enddef ;
> \stopMPdefinitions
> 
> 
> 
> \starttext
> \startMPpage
> z1 = (1cm,3cm) ;
> z2 = (5cm, 9cm) ;
> draw (z1--z2) shortened (-1cm,-2cm)  withcolor blue ;
> draw (z1--z2) withcolor red ;
> 
> \stopMPpage
> \stoptext
> 
> Now that if you really want to shorten a path, then cutends works better than 
> shortened
> 
> \startMPdefinitions
> primarydef p shortened d =
>reverse ( ( reverse (p enlonged -xpart paired(d)) ) enlonged -ypart 
> paired(d) )
> enddef ;
> \stopMPdefinitions
> 
> 
> \starttext
> \startMPpage
> z1 = (1cm,3cm) ;
> z2 = (5cm, 9cm) ;
> path p, q;
> p := z1 {up} .. {right} z2;
> q := p shifted (6cm, 0);
> 
> draw p withcolor red ;
> draw p shortened (1cm,2cm)  withcolor blue ;
> 
> draw q withcolor green ;
> draw q cutends (1cm,2cm)  withcolor blue ;
> 
> \stopMPpage
> \stoptext
> 
> 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
___


Re: [NTG-context] Metafun: how to draw a straight line past the end points

2020-12-09 Thread Aditya Mahajan
On Wed, 9 Dec 2020, Otared Kavian wrote:

> Hi Aditya,
> 
> Thanks for the alternative method, which comes handy if one wishes to extend 
> the straight line by a different amount at either end:
> 
> \starttext
> \startMPcode
>z1 = (1cm,3cm) ;
>z2 = (5cm, 9cm) ;
>z3 = 1cm * dir(angle (z2 - z1)) shifted z2 ;
>z4 = -.5cm*dir(angle(z2 - z1)) shifted z1 ;
>draw z1 -- z3 ; 
>draw z4 -- z1 ;
>draw z1 -- z2 withcolor red ;
> \stopMPcode
> \stoptext

Or just redefine shortened to accept a pair! 

\startMPdefinitions
primarydef p shortened d =
reverse ( ( reverse (p enlonged -xpart paired(d)) ) enlonged -ypart 
paired(d) )
enddef ;
\stopMPdefinitions



\starttext
\startMPpage
z1 = (1cm,3cm) ;
z2 = (5cm, 9cm) ;
draw (z1--z2) shortened (-1cm,-2cm)  withcolor blue ;
draw (z1--z2) withcolor red ;

\stopMPpage
\stoptext

Now that if you really want to shorten a path, then cutends works better than 
shortened

\startMPdefinitions
primarydef p shortened d =
reverse ( ( reverse (p enlonged -xpart paired(d)) ) enlonged -ypart 
paired(d) )
enddef ;
\stopMPdefinitions


\starttext
\startMPpage
z1 = (1cm,3cm) ;
z2 = (5cm, 9cm) ;
path p, q;
p := z1 {up} .. {right} z2;
q := p shifted (6cm, 0);

draw p withcolor red ;
draw p shortened (1cm,2cm)  withcolor blue ;

draw q withcolor green ;
draw q cutends (1cm,2cm)  withcolor blue ;

\stopMPpage
\stoptext

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
___


Re: [NTG-context] Metafun: how to draw a straight line past the end points

2020-12-09 Thread Otared Kavian
Hi Aditya,

Thanks for the alternative method, which comes handy if one wishes to extend 
the straight line by a different amount at either end:

\starttext
\startMPcode
   z1 = (1cm,3cm) ;
   z2 = (5cm, 9cm) ;
   z3 = 1cm * dir(angle (z2 - z1)) shifted z2 ;
   z4 = -.5cm*dir(angle(z2 - z1)) shifted z1 ;
   draw z1 -- z3 ; 
   draw z4 -- z1 ;
   draw z1 -- z2 withcolor red ;
\stopMPcode
\stoptext

Best regards: Otared

> On 9 Dec 2020, at 18:37, Aditya Mahajan  wrote:
> 
> On Wed, 9 Dec 2020, Otared Kavian wrote:
> 
>> Thanks a lot ! Indeed that does the job, which shows how wonderful Metafun 
>> is !
> 
> Or, if you want to use high school algebra:
> 
> \starttext
> \startMPcode
>z1 = (1cm,3cm) ;
>z2 = (5cm, 9cm) ;
>z3 = 1cm * dir(angle (z2 - z1)) shifted z2;
>draw z1 -- z3 ; 
>draw z1 -- z2 withcolor red;
> \stopMPcode
> \stoptext
> 
> 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
___


Re: [NTG-context] Metafun: how to draw a straight line past the end points

2020-12-09 Thread Aditya Mahajan
On Wed, 9 Dec 2020, Otared Kavian wrote:

> Thanks a lot ! Indeed that does the job, which shows how wonderful Metafun is 
> !

Or, if you want to use high school algebra:

\starttext
\startMPcode
z1 = (1cm,3cm) ;
z2 = (5cm, 9cm) ;
z3 = 1cm * dir(angle (z2 - z1)) shifted z2;
draw z1 -- z3 ; 
draw z1 -- z2 withcolor red;
\stopMPcode
\stoptext

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
___


Re: [NTG-context] Metafun: how to draw a straight line past the end points

2020-12-09 Thread Otared Kavian
Hi Fabrice,

Thanks a lot ! Indeed that does the job, which shows how wonderful Metafun is !

Best regards: Otared

> On 9 Dec 2020, at 17:19, Fabrice L  wrote:
> 
> Hi,
> 
>> Le 9 déc. 2020 à 10:57, Otared Kavian  a écrit :
>> 
>> Hi,
>> 
>> I have a silly question: given two points in the plane
>>  z1 = (1cm,3cm) ;
>>  z2 = (5cm, 9cm) ;
>> the command
>>  draw z1 -- z2 withpen pencircle scaled .5pt ;
>> draws the line segment joining z1 and z2. How could I draw the line segment 
>> which goes a little further (say 1cm) than both the end points of this 
>> segment (that is in this example, a point before z1 and a point after z2 on 
>> the straight line) .
>> Indeed it is possible to write the equation of the line and then compute by 
>> hand the coordinates of the new end points, but I think there is a simpler 
>> way in Metafun to do this.
> 
> The shortened operation is the solution ! See MetaFun manual section 1.18
> 
> \starttext
> \startMPpage
> z1 = (1cm,3cm) ;
> z2 = (5cm, 9cm) ;
> draw (z1--z2) shortened -1cm  withcolor blue ;
> draw (z1--z2) withcolor red ;
> 
> \stopMPpage
> \stoptext
>   
> Fabrice.
> 
>> 
>> Thanks for any help: Otared
>> 
>> 
>> ___
>> 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
> ___

___
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
___


Re: [NTG-context] Metafun: how to draw a straight line past the end points

2020-12-09 Thread Fabrice L
Hi,

> Le 9 déc. 2020 à 10:57, Otared Kavian  a écrit :
> 
> Hi,
> 
> I have a silly question: given two points in the plane
>   z1 = (1cm,3cm) ;
>   z2 = (5cm, 9cm) ;
> the command
>   draw z1 -- z2 withpen pencircle scaled .5pt ;
> draws the line segment joining z1 and z2. How could I draw the line segment 
> which goes a little further (say 1cm) than both the end points of this 
> segment (that is in this example, a point before z1 and a point after z2 on 
> the straight line) .
> Indeed it is possible to write the equation of the line and then compute by 
> hand the coordinates of the new end points, but I think there is a simpler 
> way in Metafun to do this.

The shortened operation is the solution ! See MetaFun manual section 1.18

\starttext
\startMPpage
z1 = (1cm,3cm) ;
z2 = (5cm, 9cm) ;
draw (z1--z2) shortened -1cm  withcolor blue ;
draw (z1--z2) withcolor red ;

\stopMPpage
\stoptext

Fabrice.

> 
> Thanks for any help: Otared
> 
> 
> ___
> 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
___


[NTG-context] Metafun: how to draw a straight line past the end points

2020-12-09 Thread Otared Kavian
Hi,

I have a silly question: given two points in the plane
z1 = (1cm,3cm) ;
z2 = (5cm, 9cm) ;
the command
draw z1 -- z2 withpen pencircle scaled .5pt ;
draws the line segment joining z1 and z2. How could I draw the line segment 
which goes a little further (say 1cm) than both the end points of this segment 
(that is in this example, a point before z1 and a point after z2 on the 
straight line) .
Indeed it is possible to write the equation of the line and then compute by 
hand the coordinates of the new end points, but I think there is a simpler way 
in Metafun to do this.

Thanks for any help: Otared


___
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
___


Re: [NTG-context] Parallelizing typesetting of large documents with lots of cross-references

2020-12-03 Thread Hans Hagen

On 12/3/2020 12:04 PM, Stephen Gaito wrote:


- very large (1,000+ pages),


not that large, literate code is often verbatim so that doesn't take 
much runtime either



- highly cross-referenced documents,


ok, that demands runs


- with embedded literate-programmed code (which needs
   concurrent compiling and execution),


you only need to process those snippets when something has changed and 
there are ways in context to deal with that (like \typesetbuffer and 
such which only processes when something changed between runs)



- containing multiple MetaFun graphics,


those don't take time assuming effecitne metapost code
 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
___


[NTG-context] Parallelizing typesetting of large documents with lots of cross-references

2020-12-03 Thread Stephen Gaito
Hello,

This email is largely a simple notification of one "Fool's" dream...

("Only Fools rush in where Angels fear to tread").

I am currently attempting to create "a" (crude) "tool" with which I can
typeset:

- very large (1,000+ pages),
- highly cross-referenced documents,
- with embedded literate-programmed code (which needs
  concurrent compiling and execution),
- containing multiple MetaFun graphics,

all based upon ConTeXt-LMTX.

"In theory", it should be possible to typeset individual "sub-documents"
(any section which is known to start on a page boundary rather than
inside a page), and then re-combine the individual PDFs back into one
single PDF for the whole document (complete with control over the page
numbering).

The inherent problem is that the *whole* of a ConTeXt document depends
upon cross-references from *everywhere* else in the document. TeX and
ConTeXt "solve" this problem by using a multi-pass approach (in, for
example, 5 passes for the `luametatex` document).

Between each pass, ConTeXt saves this multi-pass data (page
numbers and cross-references) in the `*.tuc` file.

Clearly any parallelization approach needs to have a process which
coordinates the update and re-distribution of any changes in this
multi-pass data obtained by typesetting each "sub-document".

My current approach is to have a federation of Docker/Podman "pods".
Each "pod" would have a number of ConTeXt workers, as well as
(somewhere in the federation) a Lua based Multi-Pass-Data-coordinator.

All work would be coordinated by messages sent and received over a
corresponding federation of [NATS servers](https://nats.io/). (Neither
[Podman](https://podman.io/) pods nor NATS message coordination are
problems at the moment).


**The real problem**, for typesetting a ConTeXt document, is the design
of the critical process which will act as a
"Multi-Pass-Data-coordinator".


All ConTeXt sub-documents would be typeset in "once" mode using the
latest complete set of "Multi-Pass-Data" obtained from the central
coordinator. Then, once each typesetting run is complete, the resulting
"Multi-Pass-Data" would be sent back to the coordinator to be used to
update the coordinator's complete set of "Multi-Pass-Data" ready for
any required next typesetting pass.

(From the `context --help`:
>mtx-context | --once only run once (no multipass data file is produced)
I will clearly have to patch(?) the mtx-context.lua script to allow
multipass data to be produced... this is probably not a problem).

(There would also be a number of additional processes/containers for
dependency analysis, build sequencing, compilation of code,
execution or interpretation of the code, stitching the PDFs back into
one PDF, etc -- these processes are also not the really critical
problem at the moment).


QUESTIONS:

1. Are there any other known attempts to parallelize context?

2. Are there any other obvious problems with my approach?

3. Is there any existing documentation on the contents of the `*.tuc`
   file?

4. If there is no such documentation, is there any naming pattern of
   the Lua functions which get/set this multi-pass information that I
   should be aware of?


Many thanks for all of the very useful comments so far...

Regards,

Stephen Gaito
___
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
___


Re: [NTG-context] Using ConTeXt-LMTX for modern Mathematically-Literate-Programming 1/2

2020-12-03 Thread Stephen Gaito
Hans,

As I said my desktop is elderly... it has a 2.8GHz processor, 16Gb of
DDR3 memory, and a couple of old SATA1 hard disks, and only 3Mb of CPU
cache...

... all well past its use by date for single threaded ConTeXt. ;-(

So one way to get better performance for ConTeXt is to invest in a new
ultra fast processor. Which will cost a lot, and use a lot of power
which has to be cooled, which uses even more power

Alternatively, for the same costs (or less), I can buy cheaper slower
processors but have lots of threads (a cluster of Raspberry Pi 4 8Gb
cards)...

Alas this requires finding some way to parallelize ConTeXt

(Fools rush in where Angels fear to tread ;-(

Regards,

Stephen Gaito 

On Wed, 2 Dec 2020 14:04:18 +0100
Hans Hagen  wrote:

> On 12/2/2020 10:40 AM, Stephen Gaito wrote:
> 
> > Many thanks for your swift and helpful comments.
> > 
> > After some *very crude* tests using the `luametatex` and
> > `luametafun` documents, I find that while I *can* stop effective
> > processing at various points in the LuaMetaTeX pipeline, the time
> > difference overall is not really significant enough to bother with
> > this approach.
> > 
> > The principle problem is, as you suggested below, "stopping" the
> > pipeline at the PDF stage (using for example the
> > `pre_output_filter`) corrupted the `*.tuc` data which is for my
> > purposes, critical.
> > 
> > Your comment was:
> >   
> >> but keep in mind that multipass data is flushed as part of the
> >> shipout (because it is often location and order bound)  
> > 
> > For the record, using the `append_to_vlist_filter` callback, I did
> > manage to drastically reduce the "pages" (which were all blank, not
> > surprisingly).
> > 
> > However, on my elderly desktop from 2008, both callbacks
> > essentially cut only 6-8 seconds out of 18 seconds, for the
> > `luametatex` document, and 190 seconds, for the `luametafun`
> > document.  
> 
> hm, on my 2013 laptop the luametatex manual needs 10 sec (i have all
> the fonts, so that includes a bunch) and a metafun manual should do
> about 20
> 
> a test on am M1 mini needs half those times as reported yesterday
> 
> i bet that on a modern desktop the luatex manual will do < 5 sec
> 
> > In the case of the `luametafun` document, it is the MetaFun/MetaPost
> > processing which, of course, is taking a long time (as it should,
> > the graphics computations represent important but complex
> > computations).  
> 
> One run or many due to xref? Maybe your machine has no significant
> cpu cache? Do you run from disk or ssd? How much memory?
> 
> > My ultimate goal is to parallelize the production of large, heavily
> > cross-referenced, ConTeXt documents... more on this in a future
> > email...  
> 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
___


Re: [NTG-context] Using ConTeXt-LMTX for modern Mathematically-Literate-Programming 2/2

2020-12-03 Thread Stephen Gaito
Hans,

If my only constraints were ease of programming and moderate
performance, I would completely agree that using mostly Lua plus
(possibly) some C code for some targeted stuff that is really slow in
Lua is the correct solution we are actually in agreement.

Unfortunately, I have the *non-functional* requirement to *prove* the
code's correctness this is the heart of what I have to write about.

There is no getting out of this requirement

So, some day it would be very useful to be able to directly embed a
Lua wrapped ANSI-C shared library inside the new LuaMetaTex

However, at the moment, as part of my parallelization attempts I can
interact with my ANSI-C code over a network so I will use this
approach for the near to medium time frames.

Regards,

Stephen Gaito



On Wed, 2 Dec 2020 14:17:54 +0100
Hans Hagen  wrote:

> On 12/2/2020 11:43 AM, Stephen Gaito wrote:
> 
> > Again, to my knowledge, Lua v5.4 has only one implementation (though
> > this implementation *can* be compiled for a very wide range of
> > CPU's).  
> 
> Lua has not many demands ... it can even run on tiny cpu's. It's all 
> rather plain C code. (And in luametatex we have no c++ ... all is
> just C.)
> 
> > Finally, the computational complexity of my proof engine, will be
> > comparable to MetaFun/MetaPost... which I suspect you would not
> > consider implementing in pure Lua. Some things are faster in C.  
> 
> Hard to say ... I think that the parser / expansion machinery in mp
> is the bottleneck here (no fun to do that in lua). Redoing it in Lua
> also is asking for compatibility issues. (btw, extensions are done in
> lua anyway, as is the mp backend)
> 
> > So yes I do need to implement it in ANSI-C wrapped in Lua (so that
> > it can be used from *inside* ConTeXt).  
> 
> I would have to see the 'kind of code involved' in order to comment
> on that.
> 
> An option is to do most in lua and maybe some helpers for crititical 
> code in C.
>   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
___


Re: [NTG-context] Using ConTeXt-LMTX for modern Mathematically-Literate-Programming 2/2

2020-12-02 Thread Hans Hagen

On 12/2/2020 11:43 AM, Stephen Gaito wrote:


Again, to my knowledge, Lua v5.4 has only one implementation (though
this implementation *can* be compiled for a very wide range of CPU's).


Lua has not many demands ... it can even run on tiny cpu's. It's all 
rather plain C code. (And in luametatex we have no c++ ... all is just C.)



Finally, the computational complexity of my proof engine, will be
comparable to MetaFun/MetaPost... which I suspect you would not
consider implementing in pure Lua. Some things are faster in C.


Hard to say ... I think that the parser / expansion machinery in mp is 
the bottleneck here (no fun to do that in lua). Redoing it in Lua also 
is asking for compatibility issues. (btw, extensions are done in lua 
anyway, as is the mp backend)



So yes I do need to implement it in ANSI-C wrapped in Lua (so that it
can be used from *inside* ConTeXt).


I would have to see the 'kind of code involved' in order to comment on 
that.


An option is to do most in lua and maybe some helpers for crititical 
code in C.

 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
___


Re: [NTG-context] Using ConTeXt-LMTX for modern Mathematically-Literate-Programming 1/2

2020-12-02 Thread Hans Hagen

On 12/2/2020 10:40 AM, Stephen Gaito wrote:


Many thanks for your swift and helpful comments.

After some *very crude* tests using the `luametatex` and `luametafun`
documents, I find that while I *can* stop effective processing at
various points in the LuaMetaTeX pipeline, the time difference overall
is not really significant enough to bother with this approach.

The principle problem is, as you suggested below, "stopping" the
pipeline at the PDF stage (using for example the `pre_output_filter`)
corrupted the `*.tuc` data which is for my purposes, critical.

Your comment was:


but keep in mind that multipass data is flushed as part of the
shipout (because it is often location and order bound)


For the record, using the `append_to_vlist_filter` callback, I did
manage to drastically reduce the "pages" (which were all blank, not
surprisingly).

However, on my elderly desktop from 2008, both callbacks essentially cut
only 6-8 seconds out of 18 seconds, for the `luametatex` document, and
190 seconds, for the `luametafun` document.


hm, on my 2013 laptop the luametatex manual needs 10 sec (i have all the 
fonts, so that includes a bunch) and a metafun manual should do about 20


a test on am M1 mini needs half those times as reported yesterday

i bet that on a modern desktop the luatex manual will do < 5 sec


In the case of the `luametafun` document, it is the MetaFun/MetaPost
processing which, of course, is taking a long time (as it should, the
graphics computations represent important but complex computations).


One run or many due to xref? Maybe your machine has no significant cpu 
cache? Do you run from disk or ssd? How much memory?



My ultimate goal is to parallelize the production of large, heavily
cross-referenced, ConTeXt documents... more on this in a future email...

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
___


Re: [NTG-context] Using ConTeXt-LMTX for modern Mathematically-Literate-Programming 2/2

2020-12-02 Thread Stephen Gaito
Hans,

Many thanks for your comments... see below.

On Mon, 30 Nov 2020 19:31:55 +0100
Hans Hagen  wrote:

> On 11/30/2020 10:51 AM, Stephen Gaito wrote:
> > Hello (again),
> > 
> > This email is further to my previous "Using ConTeXt-LMTX for modern
> > Mathematically-Literate-Programming 1/2" email...
> > 
> > My ultimate goal in using ConTeXt-LMTX as a
> > Mathematically-Literate-Programming tool, is to actually write a
> > kernel "Mathematical Language" in ANSI-C (wrapped in Lua) which is
> > then imported back into ConTeXt-LMTX as a standard Lua module (with
> > an ANSI-C shared library).
> 
> Just curious: do you think that using c instead of lua for that has 
> advantages?

This is a very good and important question. One I have asked myself
repeatedly.

My ultimate goal is to write a small mathematical kernel in ANSI-C,
which is, using [Frama-C](https://frama-c.com/), proven *correct*.

To my knowledge, Lua has no similar tool for correctness proofs.

Equally importantly, there are a very wide range of very different
compilers which compile ANSI-C for an equally very wide range of CPU's. 

Again, to my knowledge, Lua v5.4 has only one implementation (though
this implementation *can* be compiled for a very wide range of CPU's).

The problem here is that Mathematicians are inherently very
conservative about the concept of "proof" (it has taken well over 2,000
hard years to develop our current understanding). My kernel will be an
extensible "proof" engine. For mathematicians to trust it, this proof
engine must itself be proven correct (or as correct as currently
possible). It must also be simple enough to *see* that it is correct
(hence the Literate-Programming approach), *and* (since I can not even
hope to prove the compilers are *correct*), there must be many
*different* compiler implementations (to show that the results are not
artefacts of one particular implementation).

Finally, the computational complexity of my proof engine, will be
comparable to MetaFun/MetaPost... which I suspect you would not
consider implementing in pure Lua. Some things are faster in C.

So yes I do need to implement it in ANSI-C wrapped in Lua (so that it
can be used from *inside* ConTeXt).

Since this is a mathematical tool, "embedding" it in ConTeXt is ideal.

As a mathematician writes, what they write gets proof-checked
automatically... in the document they are writing, and by the
typesetting tool they are using for the finished PDF. :-)

ConTeXt (via LuaMetaTex) makes this possible in a way native TeX/LaTeX
never could.

So once again, many many thanks for the vision to create such a
flexible tool!

> 
> > This would allow the output of "code" in my "Mathematical Language"
> > to be directly embedded/typeset in the output of my Mathematical
> > document.
> > 
> > (The ultimate goal is to ensure that there is NO wishful thinking
> > that the code is "correct" ("just trust me")... all results would be
> > directly visible in the PDF).
> > 
> > Alas, while, for other reasons, trying to use the Lua-CJSON Lua
> > module from within ConTeXt-LMTX (which also makes use of a shared
> > library written in C), I find that the current ConTeXt-LMTX is
> > missing (among potentially others) the `lua_checkstack` symbol:
> 
> could be .. we dont' use it
> 
> >> ...Xt/tex/texmf-context/tex/context/base/mkiv/l-package.lua:333:
> >> error loading module 'cjson' from file
> >> '/usr/local/lib/lua/5.4/cjson.so':
> >> /usr/local/lib/lua/5.4/cjson.so: undefined symbol: lua_checkstack
> > 
> > even when using the ConTeXt/LuaMetaTeX `--permiteloadlib` switch.
> > 
> > (Note that this Lua-CJSON module does work with the native 5.4 Lua).
> 
> why not use the build in helpers

The test, which triggered the error message (above), was to prove that
I could send [NATS](https://nats.io/) messages from *inside* ConTeXt.

"Out of the box", the [Lua-NATS](https://github.com/DawnAngel/lua-nats)
requires:

- luasocket (which LuaMetaTex provides, many many thanks!)

- lua-cjson (which is an external shared library and is what I was
  testing)

Fortunately, I found a couple of pure Lua JSON tools which I could get
Lua-NATS to use with a one line change. (And, for the record, I *can*
send and receive messages from a NATS server from inside ConTeXt :-)  

If I find I need to make changes to the Lua-NATS code, I will probably
use LuaMetaTeX's internal JSON implementation as you suggest below
(again many thanks for embedding a JSON implementation).

Using Lua-NATS is part of my larger goal to parallelize the typesetting
of large documents using ConTeXt (more on this in another email).

> 
> \usemodu

Re: [NTG-context] Using ConTeXt-LMTX for modern Mathematically-Literate-Programming 1/2

2020-12-02 Thread Stephen Gaito
Hans,

Many thanks for your swift and helpful comments.

After some *very crude* tests using the `luametatex` and `luametafun`
documents, I find that while I *can* stop effective processing at
various points in the LuaMetaTeX pipeline, the time difference overall
is not really significant enough to bother with this approach.

The principle problem is, as you suggested below, "stopping" the
pipeline at the PDF stage (using for example the `pre_output_filter`)
corrupted the `*.tuc` data which is for my purposes, critical.

Your comment was: 

> but keep in mind that multipass data is flushed as part of the
> shipout (because it is often location and order bound)

For the record, using the `append_to_vlist_filter` callback, I did
manage to drastically reduce the "pages" (which were all blank, not
surprisingly).

However, on my elderly desktop from 2008, both callbacks essentially cut
only 6-8 seconds out of 18 seconds, for the `luametatex` document, and
190 seconds, for the `luametafun` document.

In the case of the `luametafun` document, it is the MetaFun/MetaPost
processing which, of course, is taking a long time (as it should, the
graphics computations represent important but complex computations).

My ultimate goal is to parallelize the production of large, heavily
cross-referenced, ConTeXt documents... more on this in a future email...

Again, many thanks for your comments!

Regards,

Stephen Gaito

On Mon, 30 Nov 2020 19:59:07 +0100
Hans Hagen  wrote:

> On 11/30/2020 10:51 AM, Stephen Gaito wrote:
> > Hello,
> > 
> > I am slowly working on a Mathematical problem requiring underlying
> > computation.
> > 
> > As Mathematicians (myself included) are rather "conservative", I
> > need to discuss each "chunk" of code with the full set of
> > Mathematical notation.
> > 
> > A couple of years ago I started using ConTeXt-MKIV as a
> > Mathematically-Literate-Programming tool by using its excellent Lua
> > interface to capture the code and dump it to disk for external
> > compilation.
> > 
> > I am now revisiting my original design and want to redo my tools
> > using ConTeXt-LMTX.
> > 
> > I would *like* to be able to "stop" the ConTeXt typesetting at
> > various points for differing purposes:
> > 
> > 1. After all macro expansions (and hence after *my* calls into Lua)
> > but before line/paragraph/page layout begins.
> 
> maybe something
> 
> \startmystuff
> 
> \stopmystuff
> 
> and then you can hook something into startmystuff and \stopmystuff
> 
> > 2. After line/paragraph/page layout but before PDF generation.
> 
> pdf is generated per page, if needed one can kick in a shipout
> overload
> 
> but keep in mind that multipass data is flushed as part of the
> shipout (because it is often location and order bound)
> 
> > 3. After all PDF generated (ie. a "normal" "full" ConTeXt run).
> > 
> > Stopping after all macro expansions would allow my code generation
> > builds to proceed without the un-needed page setting or PDF
> > generation.
> 
> hm, the problem is always in the 'state' of all kind of variables
> 
> > Stopping after the line/paragraph/page layout would allow multiple
> > "faster(?)" ConTeXt runs while the "*.tuc" file converges to a
> > complete set of page numbers and cross references (etc). Then, once
> > the "*.tuc" file has converged, a full ConTeXt run with PDF output
> > could be done.
> 
> not sure what you mean here ... what is fast? or: how slow is it now? 
> what is the bottleneck? can you cache data that didn't change?
> 
> a large document is normally split up in sections that can be
> processed independent
> 
> \starttext
>  \dorecurse{1}{\samplefile{ward}\par}
> \stoptext
> 
> runs on my 2013 laptop at over 65 pages per second
> 
> quite often performance is hit by inefficient styling and such ..
> it's no problem to bring a tex system a grinding halt
> 
> > I am very aware that *internally* ConTeXt is probably structured as
> > a tight pipeline with each of the "traditional" TeX stages "Mouth",
> > "Stomach", "page setting", PDF generation tightly "chained"...
> > This means that there is no "one" place in the code where all macro
> > expansions have completed but before the page setting "starts", or
> > similarly, after the page setting has finished but before the PDF
> > generation "starts".
> 
> yes and often something is left over for a next page so it's kind of
> fluid
> 
> > 
> > QUES

Re: [NTG-context] Units of xpart and ypart of a pair in MetaFun

2020-11-27 Thread Keith McKay
Thanks Taco!
I understand much better now. I think it's best to leave the units out
until the drawing stage as you suggest.
Thanks again
Keith McKay

On Fri, 27 Nov 2020, 08:30 Taco Hoekwater,  wrote:

>
>
> > On 26 Nov 2020, at 16:09, Keith McKay  wrote:
> >
> > Hi,
> >
> > I have been using xpart and ypart to extract these values from pairs of
> points in a path but I wasn't getting the correct result. I was expecting:
> >
> > pair (2cm, 11cm) to give xpart 2 and ypart 11
>
> As explained by various people, Metapost does not have dimensions. All
> lengths are implicit Postscript big points
> (72/inch). Variables like “cm” just add a multiplication factor to your
> expressions, at no point is a dimension stored inside Metapost.
>
> Your equation:
>
>   a0 = (2cm,11cm)
>
> first expands into
>
>   a0 = (2*28.34645,11*28.34645)
>
> because “cm” is a variable with a value (Its definition in plain.mp is
> "cm = 28.34645”)
>
> Then, the two expressions in the a0 equation are resolved before the
> assignment, so what you actually wrote at the statement level is
>
>   a0 = (56.6929, 311.8096);
>
> At no point is there a “cm”-sized dimension.
>
> ===
>
> Perhaps another option would be for you to do all your work without units,
> e.g.
>
>   a0 = (2,11) % assume scaling will happen later
>
> and then in the end do the drawing on a scaled path:
>
>   draw (pp scaled cm) …
>
> as that may be less confusing? If the precision is an issue, you could
> counter the loss of precision you could use implied millimeters instead of
> centimeters.
>
> Best wishes,
> Taco
>
>
>
>
>
>
> ___
> 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
___


Re: [NTG-context] Units of xpart and ypart of a pair in MetaFun

2020-11-27 Thread Taco Hoekwater


> On 26 Nov 2020, at 16:09, Keith McKay  wrote:
> 
> Hi,
> 
> I have been using xpart and ypart to extract these values from pairs of 
> points in a path but I wasn't getting the correct result. I was expecting:
> 
> pair (2cm, 11cm) to give xpart 2 and ypart 11

As explained by various people, Metapost does not have dimensions. All lengths 
are implicit Postscript big points
(72/inch). Variables like “cm” just add a multiplication factor to your 
expressions, at no point is a dimension stored inside Metapost. 

Your equation:

  a0 = (2cm,11cm)

first expands into 
  
  a0 = (2*28.34645,11*28.34645)

because “cm” is a variable with a value (Its definition in plain.mp is "cm = 
28.34645”)

Then, the two expressions in the a0 equation are resolved before the 
assignment, so what you actually wrote at the statement level is

  a0 = (56.6929, 311.8096);

At no point is there a “cm”-sized dimension.

===

Perhaps another option would be for you to do all your work without units, e.g. 

  a0 = (2,11) % assume scaling will happen later

and then in the end do the drawing on a scaled path:

  draw (pp scaled cm) …

as that may be less confusing? If the precision is an issue, you could counter 
the loss of precision you could use implied millimeters instead of centimeters.

Best wishes,
Taco





___
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
___


Re: [NTG-context] Units of xpart and ypart of a pair in MetaFun

2020-11-26 Thread Keith McKay
/First « //uniformdeviate(1) - 0.5// » could be modified to « 
//uniformdeviate(0.5)//»./

/
/
/To add noise, you can use the randomized function of Metafun. For 
exemple, you can write:/

/
/
/draw pp randomized 1cm ;/
/
/
That's true Fabrice but in this use case I wanted a random number 
between -0.5 and +0.5, and I wasn't sure I would get that with randomized.

Thanks again
Keith McKay/
/
On 26/11/2020 17:20, Fabrice L wrote:

Keith,

Le 26 nov. 2020 à 12:12, Keith McKay <mailto:mckaymeis...@gmail.com>> a écrit :


Thanks Fabrice and Hans.

I now see I can simplify some lines of the code:

pp := ((xpart a[i])/cf*cm, (ypart a[i])/cf*cm); now becomes pp:= a[i];

and

pp := pp --- ((xpart a[i+1]/cf)*cm, (ypart a[i+1])/cf*cm); now 
becomes pp := pp --- a[i +1] ;


However I still have the problem in the calculation of xcoord and 
ycoord which are used in the creation of path pp:

for squig = 1 step 1 until 15:
xcoord := uniformdeviate(1) - 0.5 + (xpart a[i]/cf);
ycoord := uniformdeviate(1) - 0.5+ (ypart a[i]/cf);
pp := pp .. {curl 100}(xcoord*cm, ycoord*cm);
endfor;
I'm adding a small random amount to the x and ypart of the pair a[i] 
to produce a path that is like a squiggle (gribouiller in French, 
according to Google). I have to use cf to convert to the x and yparts 
to centimeters since they seem to loose the centimeter units on 
separation. I can't see anyway round this, or am I missing something?

Thanks
Keith McKay


First « uniformdeviate(1) - 0.5 » could be modified to « 
uniformdeviate(0.5)».


To add noise, you can use the randomized function of Metafun. For 
exemple, you can write:


draw pp randomized 1cm ;

Fabrice.




On 26/11/2020 15:19, Fabrice L wrote:

Hi keith,

Le 26 nov. 2020 à 10:09, Keith McKay <mailto:mckaymeis...@gmail.com>> a écrit :


Hi,

I have been using xpart and ypart to extract these values from 
pairs of points in a path but I wasn't getting the correct result. 
I was expecting:


pair (2cm, 11cm) to give xpart 2 and ypart 11

However I was getting:

pair (2cm, 11cm) -> xpart 56.6929 and ypart 311.8096

After much head scratching and reading the MetaPost and MetaFun 
manuals, I realised that the units of xpart or ypart are in 
Postcript points or Big Points (bp), and 1 bp is 1/72 of an inch, 
and thus to get the values of xpart or ypart in cm I would have to 
use a correction factor. I had made the assumption that since the x 
and ypart in the pair was in cm that the result would be in cm, but 
I see now that this is not the case. Will I have to continue doing 
this or is there some magic within MetaFun which takes account of 
the units in a pair and outputs the result of x and ypart in the 
same units?


The MWE belows shows what I have been doing.

Thanks

Keith McKay

%%% MWE %%%
\setuppapersize [A5, landscape][A4, portrait]
\usecolors[crayola]
\starttext
\startMPpage
StartPage;
width := PaperWidth ; height := PaperHeight ; unit := cm ;
numeric squig;
pair a[]; a0 = (2cm,11cm); a1 = (4cm,10cm); a2 = (6cm,9cm); a3 = 
(8cm,8cm);
show xpart a[0], ypart a[0]; %Example of result from x and ypart 
before applying correction factor (cf) %

cf := 72/2.54; %Converts points/in to points/cm%
path pp;
for i = 0 step 1 until 3:
pp := ((xpart a[i])/cf*cm, (ypart a[i])/cf*cm);
for squig = 1 step 1 until 15:
xcoord := uniformdeviate(1) - 0.5 + (xpart a[i]/cf);
ycoord := uniformdeviate(1) - 0.5+ (ypart a[i]/cf);
pp := pp .. {curl 100}(xcoord*cm, ycoord*cm);
endfor;
pp := pp --- cycle;
if i < 3 :
pp := pp --- ((xpart a[i+1]/cf)*cm, (ypart a[i+1])/cf*cm);
fi;
f :=((1.4 - 0.6) * uniformdeviate(1)) + 0.8; % Factor to 
lighten/darken colour %
draw pp withpen pencircle xscaled 0.5mm yscaled .1mm rotated 45 
withcolor (f[white,\MPcolor{BurntSienna}]);

endfor;
StopPage;
\stopMPpage
\stoptext
%%



MetaPost (MetaFun) is taking care of everything regarding units. As 
you ave discovered, everything is translated to a unique internal 
dimension. So you can write:


 a := (1cm,2in) ;

with no problem. The « cm » and « in » parts of the expression will 
become numbers to translate this number on the right unit.

Fabrice.


___ 
If your question is of interest to others as well, please add an 
entry to the Wiki! maillist :ntg-context@ntg.nl 
<mailto:ntg-context@ntg.nl>/http://www.ntg.nl/mailman/listinfo/ntg-context 
<http://www.ntg.nl/mailman/listinfo/ntg-context> webpage 
 :http://www.pragma-ade.nl 
<http://www.pragma-ade.nl/>/http://context.aanhet.net 
<http://context.aanhet.net/> archive 
 :https://bitbucket.org/phg/context-mirror/commits/ 
<https://bitbucket.org/phg/context-mirror/commits/> wiki 
:http://contextgarden.net <http://contextgarden.net/> 
___





Re: [NTG-context] Units of xpart and ypart of a pair in MetaFun

2020-11-26 Thread Keith McKay
Thanks again Hans and Fabrice, for the time you have both taken with my 
question and thanks for the code snippet Hans. Just one last 
confirmation from the snippet. Hans uses the correction factor cf on the 
x and yparts of a[i]. I taking this as meaning that this has to be done 
because the x and yparts of a[i] are returned as postscript points units 
and not as centimeters as in the pair. I maybe didn't make this clear in 
my original query.


Thanks for your patience.

Keith McKay

On 26/11/2020 17:25, Hans Hagen wrote:

On 11/26/2020 6:12 PM, Keith McKay wrote:

Thanks Fabrice and Hans.

I now see I can simplify some lines of the code:

pp := ((xpart a[i])/cf*cm, (ypart a[i])/cf*cm); now becomes pp:= a[i];

and

pp := pp --- ((xpart a[i+1]/cf)*cm, (ypart a[i+1])/cf*cm); now 
becomes pp := pp --- a[i +1] ;


However I still have the problem in the calculation of xcoord and 
ycoord which are used in the creation of path pp:


for squig = 1 step 1 until 15:
xcoord := uniformdeviate(1) - 0.5 + (xpart a[i]/cf);
ycoord := uniformdeviate(1) - 0.5+ (ypart a[i]/cf);
pp := pp .. {curl 100}(xcoord*cm, ycoord*cm);
endfor;
I'm adding a small random amount to the x and ypart of the pair a[i] 
to produce a path that is like a squiggle (gribouiller in French, 
according to Google). I have to use cf to convert to the x and yparts 
to centimeters since they seem to loose the centimeter units on 
separation. I can't see anyway round this, or am I missing something?



for squig = 1 step 1 until 15:
    xcoord := (xpart a[i]/cf);
    ycoord := (ypart a[i]/cf);
    xcoord := xcoord randomized (xcoord/50);
    ycoord := ycoord randomized (ycoord/50);
    pp := pp  .. { curl 100 } (xcoord*cm, ycoord*cm);
endfor;



Thanks
Keith McKay

On 26/11/2020 15:19, Fabrice L wrote:

Hi keith,

Le 26 nov. 2020 à 10:09, Keith McKay <mailto:mckaymeis...@gmail.com>> a écrit :


Hi,

I have been using xpart and ypart to extract these values from 
pairs of points in a path but I wasn't getting the correct result. 
I was expecting:


pair (2cm, 11cm) to give xpart 2 and ypart 11

However I was getting:

pair (2cm, 11cm) -> xpart 56.6929 and ypart 311.8096

After much head scratching and reading the MetaPost and MetaFun 
manuals, I realised that the units of xpart or ypart are in 
Postcript points or Big Points (bp), and 1 bp is 1/72 of an inch, 
and thus to get the values of xpart or ypart in cm I would have to 
use a correction factor. I had made the assumption that since the x 
and ypart in the pair was in cm that the result would be in cm, but 
I see now that this is not the case. Will I have to continue doing 
this or is there some magic within MetaFun which takes account of 
the units in a pair and outputs the result of x and ypart in the 
same units?


The MWE belows shows what I have been doing.

Thanks

Keith McKay

%%% MWE %%%
\setuppapersize [A5, landscape][A4, portrait]
\usecolors[crayola]
\starttext
\startMPpage
StartPage;
width := PaperWidth ; height := PaperHeight ; unit := cm ;
numeric squig;
pair a[]; a0 = (2cm,11cm); a1 = (4cm,10cm); a2 = (6cm,9cm); a3 = 
(8cm,8cm);
show xpart a[0], ypart a[0]; %Example of result from x and ypart 
before applying correction factor (cf) %

cf := 72/2.54; %Converts points/in to points/cm%
path pp;
for i = 0 step 1 until 3:
pp := ((xpart a[i])/cf*cm, (ypart a[i])/cf*cm);
for squig = 1 step 1 until 15:
xcoord := uniformdeviate(1) - 0.5 + (xpart a[i]/cf);
ycoord := uniformdeviate(1) - 0.5+ (ypart a[i]/cf);
pp := pp .. {curl 100}(xcoord*cm, ycoord*cm);
endfor;
pp := pp --- cycle;
if i < 3 :
pp := pp --- ((xpart a[i+1]/cf)*cm, (ypart a[i+1])/cf*cm);
fi;
f :=((1.4 - 0.6) * uniformdeviate(1)) + 0.8; % Factor to 
lighten/darken colour %
draw pp withpen pencircle xscaled 0.5mm yscaled .1mm rotated 45 
withcolor (f[white,\MPcolor{BurntSienna}]);

endfor;
StopPage;
\stopMPpage
\stoptext
%%



MetaPost (MetaFun) is taking care of everything regarding units. As 
you ave discovered, everything is translated to a unique internal 
dimension. So you can write:


 a := (1cm,2in) ;

with no problem. The « cm » and « in » parts of the expression will 
become numbers to translate this number on the right unit.

Fabrice.


___ 
If your question is of interest to others as well, please add an 
entry to the Wiki! maillist :ntg-context@ntg.nl 
<mailto:ntg-context@ntg.nl>/http://www.ntg.nl/mailman/listinfo/ntg-context 
<http://www.ntg.nl/mailman/listinfo/ntg-context> webpage 
 :http://www.pragma-ade.nl 
<http://www.pragma-ade.nl/>/http://context.aanhet.net 
<http://context.aanhet.net/> archive 
 :https://bitbucket.org/phg/context-mirror/commits/ 
<https://bitbucket.org/phg/context-mirror/commits/&

Re: [NTG-context] Units of xpart and ypart of a pair in MetaFun

2020-11-26 Thread Fabrice L
Keith,

> Le 26 nov. 2020 à 12:12, Keith McKay  a écrit :
> Thanks Fabrice and Hans.
> 
> I now see I can simplify some lines of the code:
> 
> pp := ((xpart a[i])/cf*cm, (ypart a[i])/cf*cm); now becomes pp:= a[i];
> 
> and
> 
> pp := pp --- ((xpart a[i+1]/cf)*cm, (ypart a[i+1])/cf*cm); now becomes pp := 
> pp --- a[i +1] ;
> 
> However I still have the problem in the calculation of xcoord and ycoord 
> which are used in the creation of path pp:
>   
>   for squig = 1 step 1 until 15:
> 
>   xcoord := uniformdeviate(1) - 0.5 + (xpart a[i]/cf);
> 
>   ycoord := uniformdeviate(1) - 0.5+ (ypart a[i]/cf);
> 
>   pp := pp  .. {curl 100}(xcoord*cm, ycoord*cm);
> 
>   endfor;
> 
> I'm adding a small random amount to the x and ypart of the pair a[i] to 
> produce a path that is like a squiggle (gribouiller in French, according to 
> Google). I have to use cf to convert to the x and yparts to centimeters since 
> they seem to loose the centimeter units on separation. I can't see anyway 
> round this, or am I missing something?
> 
> Thanks
> Keith McKay

First « uniformdeviate(1) - 0.5 » could be modified to « uniformdeviate(0.5)».

To add noise, you can use the randomized function of Metafun. For exemple, you 
can write:

draw pp randomized 1cm ;

Fabrice.



> 
> On 26/11/2020 15:19, Fabrice L wrote:
>> Hi keith,
>> 
>>> Le 26 nov. 2020 à 10:09, Keith McKay >> <mailto:mckaymeis...@gmail.com>> a écrit :
>>> 
>>> Hi,
>>> 
>>> I have been using xpart and ypart to extract these values from pairs of 
>>> points in a path but I wasn't getting the correct result. I was expecting:
>>> 
>>> pair (2cm, 11cm) to give xpart 2 and ypart 11
>>> 
>>> However I was getting:
>>> 
>>> pair (2cm, 11cm) -> xpart 56.6929 and ypart 311.8096
>>> 
>>> After much head scratching and reading the MetaPost and MetaFun manuals, I 
>>> realised that the units of xpart or ypart are in Postcript points or Big 
>>> Points (bp), and 1 bp is 1/72 of an inch, and thus to get the values of 
>>> xpart or ypart in cm I would have to use a correction factor. I had made 
>>> the assumption that since the x and ypart in the pair was in cm that the 
>>> result would be in cm, but I see now that this is not the case. Will I have 
>>> to continue doing this or is there some magic within MetaFun which takes 
>>> account of the units in a pair and outputs the result of x and ypart in the 
>>> same units?
>>> 
>>> The MWE belows shows what I have been doing.
>>> 
>>> Thanks
>>> 
>>> Keith McKay
>>> 
>>> %%% MWE %%%
>>> \setuppapersize [A5, landscape][A4, portrait]
>>> \usecolors[crayola]
>>> \starttext
>>> \startMPpage
>>> StartPage;
>>> width := PaperWidth ; height := PaperHeight ; unit := cm ;
>>> numeric squig;
>>> pair a[]; a0 = (2cm,11cm);  a1 = (4cm,10cm);  a2 = (6cm,9cm);  a3 = 
>>> (8cm,8cm);
>>> show xpart a[0], ypart a[0]; %Example of result from x and ypart before 
>>> applying correction factor (cf) %
>>> cf := 72/2.54; %Converts points/in to points/cm%
>>> path pp;
>>> for i = 0 step 1 until 3:
>>> pp := ((xpart a[i])/cf*cm, (ypart a[i])/cf*cm);
>>> for squig = 1 step 1 until 15:
>>> xcoord := uniformdeviate(1) - 0.5 + (xpart a[i]/cf);
>>> ycoord := uniformdeviate(1) - 0.5+ (ypart a[i]/cf);
>>> pp := pp  .. {curl 100}(xcoord*cm, ycoord*cm);
>>> endfor;
>>> pp := pp --- cycle;
>>> if i < 3 :
>>> pp := pp --- ((xpart a[i+1]/cf)*cm, (ypart a[i+1])/cf*cm);
>>> fi; 
>>> f :=((1.4 - 0.6) * uniformdeviate(1)) + 0.8; % Factor to lighten/darken 
>>> colour %
>>> draw pp withpen pencircle xscaled 0.5mm yscaled .1mm rotated 45 
>>> withcolor (f[white,\MPcolor{BurntSienna}]);
>>> endfor;
>>> StopPage;
>>> \stopMPpage
>>> \stoptext
>>> %%
>>> 
>> 
>> MetaPost (MetaFun) is taking care of everything regarding units. As you ave 
>> discovered, everything is translated to a unique internal dimension. So you 
>> can write:
>> 
>>  a := (1cm,2in) ;
>> 
>> with no problem. The « cm » and « in » p

Re: [NTG-context] Units of xpart and ypart of a pair in MetaFun

2020-11-26 Thread Hans Hagen

On 11/26/2020 6:12 PM, Keith McKay wrote:

Thanks Fabrice and Hans.

I now see I can simplify some lines of the code:

pp := ((xpart a[i])/cf*cm, (ypart a[i])/cf*cm); now becomes pp:= a[i];

and

pp := pp --- ((xpart a[i+1]/cf)*cm, (ypart a[i+1])/cf*cm); now becomes 
pp := pp --- a[i +1] ;


However I still have the problem in the calculation of xcoord and ycoord 
which are used in the creation of path pp:


for squig = 1 step 1 until 15:
xcoord := uniformdeviate(1) - 0.5 + (xpart a[i]/cf);
ycoord := uniformdeviate(1) - 0.5+ (ypart a[i]/cf);
pp := pp .. {curl 100}(xcoord*cm, ycoord*cm);
endfor;
I'm adding a small random amount to the x and ypart of the pair a[i] to 
produce a path that is like a squiggle (gribouiller in French, according 
to Google). I have to use cf to convert to the x and yparts to 
centimeters since they seem to loose the centimeter units on separation. 
I can't see anyway round this, or am I missing something?



for squig = 1 step 1 until 15:
xcoord := (xpart a[i]/cf);
ycoord := (ypart a[i]/cf);
xcoord := xcoord randomized (xcoord/50);
ycoord := ycoord randomized (ycoord/50);
pp := pp  .. { curl 100 } (xcoord*cm, ycoord*cm);
endfor;



Thanks
Keith McKay

On 26/11/2020 15:19, Fabrice L wrote:

Hi keith,

Le 26 nov. 2020 à 10:09, Keith McKay <mailto:mckaymeis...@gmail.com>> a écrit :


Hi,

I have been using xpart and ypart to extract these values from pairs 
of points in a path but I wasn't getting the correct result. I was 
expecting:


pair (2cm, 11cm) to give xpart 2 and ypart 11

However I was getting:

pair (2cm, 11cm) -> xpart 56.6929 and ypart 311.8096

After much head scratching and reading the MetaPost and MetaFun 
manuals, I realised that the units of xpart or ypart are in Postcript 
points or Big Points (bp), and 1 bp is 1/72 of an inch, and thus to 
get the values of xpart or ypart in cm I would have to use a 
correction factor. I had made the assumption that since the x and 
ypart in the pair was in cm that the result would be in cm, but I see 
now that this is not the case. Will I have to continue doing this or 
is there some magic within MetaFun which takes account of the units 
in a pair and outputs the result of x and ypart in the same units?


The MWE belows shows what I have been doing.

Thanks

Keith McKay

%%% MWE %%%
\setuppapersize [A5, landscape][A4, portrait]
\usecolors[crayola]
\starttext
\startMPpage
StartPage;
width := PaperWidth ; height := PaperHeight ; unit := cm ;
numeric squig;
pair a[]; a0 = (2cm,11cm); a1 = (4cm,10cm); a2 = (6cm,9cm); a3 = 
(8cm,8cm);
show xpart a[0], ypart a[0]; %Example of result from x and ypart 
before applying correction factor (cf) %

cf := 72/2.54; %Converts points/in to points/cm%
path pp;
for i = 0 step 1 until 3:
pp := ((xpart a[i])/cf*cm, (ypart a[i])/cf*cm);
for squig = 1 step 1 until 15:
xcoord := uniformdeviate(1) - 0.5 + (xpart a[i]/cf);
ycoord := uniformdeviate(1) - 0.5+ (ypart a[i]/cf);
pp := pp .. {curl 100}(xcoord*cm, ycoord*cm);
endfor;
pp := pp --- cycle;
if i < 3 :
pp := pp --- ((xpart a[i+1]/cf)*cm, (ypart a[i+1])/cf*cm);
fi;
f :=((1.4 - 0.6) * uniformdeviate(1)) + 0.8; % Factor to 
lighten/darken colour %
draw pp withpen pencircle xscaled 0.5mm yscaled .1mm rotated 45 
withcolor (f[white,\MPcolor{BurntSienna}]);

endfor;
StopPage;
\stopMPpage
\stoptext
%%



MetaPost (MetaFun) is taking care of everything regarding units. As 
you ave discovered, everything is translated to a unique internal 
dimension. So you can write:


 a := (1cm,2in) ;

with no problem. The « cm » and « in » parts of the expression will 
become numbers to translate this number on the right unit.

Fabrice.


___ 
If your question is of interest to others as well, please add an 
entry to the Wiki! maillist :ntg-context@ntg.nl 
<mailto:ntg-context@ntg.nl>/http://www.ntg.nl/mailman/listinfo/ntg-context 
<http://www.ntg.nl/mailman/listinfo/ntg-context> webpage 
 :http://www.pragma-ade.nl 
<http://www.pragma-ade.nl/>/http://context.aanhet.net 
<http://context.aanhet.net/> archive 
 :https://bitbucket.org/phg/context-mirror/commits/ 
<https://bitbucket.org/phg/context-mirror/commits/> wiki 
:http://contextgarden.net <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.o

Re: [NTG-context] Units of xpart and ypart of a pair in MetaFun

2020-11-26 Thread Keith McKay

Thanks Fabrice and Hans.

I now see I can simplify some lines of the code:

pp := ((xpart a[i])/cf*cm, (ypart a[i])/cf*cm); now becomes pp:= a[i];

and

pp := pp --- ((xpart a[i+1]/cf)*cm, (ypart a[i+1])/cf*cm); now becomes 
pp := pp --- a[i +1] ;


However I still have the problem in the calculation of xcoord and ycoord 
which are used in the creation of path pp:


for squig = 1 step 1 until 15:
xcoord := uniformdeviate(1) - 0.5 + (xpart a[i]/cf);
ycoord := uniformdeviate(1) - 0.5+ (ypart a[i]/cf);
pp := pp .. {curl 100}(xcoord*cm, ycoord*cm);
endfor;
I'm adding a small random amount to the x and ypart of the pair a[i] to 
produce a path that is like a squiggle (gribouiller in French, according 
to Google). I have to use cf to convert to the x and yparts to 
centimeters since they seem to loose the centimeter units on separation. 
I can't see anyway round this, or am I missing something?

Thanks
Keith McKay

On 26/11/2020 15:19, Fabrice L wrote:

Hi keith,

Le 26 nov. 2020 à 10:09, Keith McKay <mailto:mckaymeis...@gmail.com>> a écrit :


Hi,

I have been using xpart and ypart to extract these values from pairs 
of points in a path but I wasn't getting the correct result. I was 
expecting:


pair (2cm, 11cm) to give xpart 2 and ypart 11

However I was getting:

pair (2cm, 11cm) -> xpart 56.6929 and ypart 311.8096

After much head scratching and reading the MetaPost and MetaFun 
manuals, I realised that the units of xpart or ypart are in Postcript 
points or Big Points (bp), and 1 bp is 1/72 of an inch, and thus to 
get the values of xpart or ypart in cm I would have to use a 
correction factor. I had made the assumption that since the x and 
ypart in the pair was in cm that the result would be in cm, but I see 
now that this is not the case. Will I have to continue doing this or 
is there some magic within MetaFun which takes account of the units 
in a pair and outputs the result of x and ypart in the same units?


The MWE belows shows what I have been doing.

Thanks

Keith McKay

%%% MWE %%%
\setuppapersize [A5, landscape][A4, portrait]
\usecolors[crayola]
\starttext
\startMPpage
StartPage;
width := PaperWidth ; height := PaperHeight ; unit := cm ;
numeric squig;
pair a[]; a0 = (2cm,11cm); a1 = (4cm,10cm); a2 = (6cm,9cm); a3 = 
(8cm,8cm);
show xpart a[0], ypart a[0]; %Example of result from x and ypart 
before applying correction factor (cf) %

cf := 72/2.54; %Converts points/in to points/cm%
path pp;
for i = 0 step 1 until 3:
pp := ((xpart a[i])/cf*cm, (ypart a[i])/cf*cm);
for squig = 1 step 1 until 15:
xcoord := uniformdeviate(1) - 0.5 + (xpart a[i]/cf);
ycoord := uniformdeviate(1) - 0.5+ (ypart a[i]/cf);
pp := pp .. {curl 100}(xcoord*cm, ycoord*cm);
endfor;
pp := pp --- cycle;
if i < 3 :
pp := pp --- ((xpart a[i+1]/cf)*cm, (ypart a[i+1])/cf*cm);
fi;
f :=((1.4 - 0.6) * uniformdeviate(1)) + 0.8; % Factor to 
lighten/darken colour %
draw pp withpen pencircle xscaled 0.5mm yscaled .1mm rotated 45 
withcolor (f[white,\MPcolor{BurntSienna}]);

endfor;
StopPage;
\stopMPpage
\stoptext
%%



MetaPost (MetaFun) is taking care of everything regarding units. As 
you ave discovered, everything is translated to a unique internal 
dimension. So you can write:


 a := (1cm,2in) ;

with no problem. The « cm » and « in » parts of the expression will 
become numbers to translate this number on the right unit.

Fabrice.


___ 
If your question is of interest to others as well, please add an 
entry to the Wiki! maillist :ntg-context@ntg.nl 
<mailto:ntg-context@ntg.nl>/http://www.ntg.nl/mailman/listinfo/ntg-context 
<http://www.ntg.nl/mailman/listinfo/ntg-context> webpage 
 :http://www.pragma-ade.nl 
<http://www.pragma-ade.nl/>/http://context.aanhet.net 
<http://context.aanhet.net/> archive 
 :https://bitbucket.org/phg/context-mirror/commits/ 
<https://bitbucket.org/phg/context-mirror/commits/> wiki 
:http://contextgarden.net <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
___


Re: [NTG-context] Units of xpart and ypart of a pair in MetaFun

2020-11-26 Thread Hans Hagen

On 11/26/2020 4:09 PM, Keith McKay wrote:

Hi,

I have been using xpart and ypart to extract these values from pairs of 
points in a path but I wasn't getting the correct result. I was expecting:


pair (2cm, 11cm) to give xpart 2 and ypart 11

However I was getting:

pair (2cm, 11cm) -> xpart 56.6929 and ypart 311.8096

After much head scratching and reading the MetaPost and MetaFun manuals, 
I realised that the units of xpart or ypart are in Postcript points or 
Big Points (bp), and 1 bp is 1/72 of an inch, and thus to get the values 
of xpart or ypart in cm I would have to use a correction factor. I had 
made the assumption that since the x and ypart in the pair was in cm 
that the result would be in cm, but I see now that this is not the case. 
Will I have to continue doing this or is there some magic within MetaFun 
which takes account of the units in a pair and outputs the result of x 
and ypart in the same units?


The MWE belows shows what I have been doing.


cm is not really a unit but a multiplier

cf := 72/2.54; %Converts points/in to points/cm%

message(cm);
message(cf);




Thanks

Keith McKay

%%% MWE %%%

\setuppapersize [A5, landscape][A4, portrait]

\usecolors[crayola]

\starttext

\startMPpage

StartPage;

width := PaperWidth ; height := PaperHeight ; unit := cm ;

numeric squig;

pair a[]; a0 = (2cm,11cm); a1 = (4cm,10cm); a2 = (6cm,9cm); a3 = (8cm,8cm);

show xpart a[0], ypart a[0]; %Example of result from x and ypart before 
applying correction factor (cf) %


cf := 72/2.54; %Converts points/in to points/cm%

path pp;

for i = 0 step 1 until 3:

pp := ((xpart a[i])/cf*cm, (ypart a[i])/cf*cm);

for squig = 1 step 1 until 15:

xcoord := uniformdeviate(1) - 0.5 + (xpart a[i]/cf);

ycoord := uniformdeviate(1) - 0.5+ (ypart a[i]/cf);

pp := pp .. {curl 100}(xcoord*cm, ycoord*cm);

endfor;

pp := pp --- cycle;

if i < 3 :

pp := pp --- ((xpart a[i+1]/cf)*cm, (ypart a[i+1])/cf*cm);

fi;

f :=((1.4 - 0.6) * uniformdeviate(1)) + 0.8; % Factor to lighten/darken 
colour %


draw pp withpen pencircle xscaled 0.5mm yscaled .1mm rotated 45 
withcolor (f[white,\MPcolor{BurntSienna}]);


endfor;

StopPage;

\stopMPpage

\stoptext

%%


___
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
___




--

-
  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
___


Re: [NTG-context] Units of xpart and ypart of a pair in MetaFun

2020-11-26 Thread Fabrice L
Hi keith,

> Le 26 nov. 2020 à 10:09, Keith McKay  a écrit :
> 
> Hi,
> 
> I have been using xpart and ypart to extract these values from pairs of 
> points in a path but I wasn't getting the correct result. I was expecting:
> 
> pair (2cm, 11cm) to give xpart 2 and ypart 11
> 
> However I was getting:
> 
> pair (2cm, 11cm) -> xpart 56.6929 and ypart 311.8096
> 
> After much head scratching and reading the MetaPost and MetaFun manuals, I 
> realised that the units of xpart or ypart are in Postcript points or Big 
> Points (bp), and 1 bp is 1/72 of an inch, and thus to get the values of xpart 
> or ypart in cm I would have to use a correction factor. I had made the 
> assumption that since the x and ypart in the pair was in cm that the result 
> would be in cm, but I see now that this is not the case. Will I have to 
> continue doing this or is there some magic within MetaFun which takes account 
> of the units in a pair and outputs the result of x and ypart in the same 
> units?
> 
> The MWE belows shows what I have been doing.
> 
> Thanks
> 
> Keith McKay
> 
> %%% MWE %%%
> \setuppapersize [A5, landscape][A4, portrait]
> \usecolors[crayola]
> \starttext
> \startMPpage
> StartPage;
> width := PaperWidth ; height := PaperHeight ; unit := cm ;
> numeric squig;
> pair a[]; a0 = (2cm,11cm);  a1 = (4cm,10cm);  a2 = (6cm,9cm);  a3 = (8cm,8cm);
> show xpart a[0], ypart a[0]; %Example of result from x and ypart before 
> applying correction factor (cf) %
> cf := 72/2.54; %Converts points/in to points/cm%
> path pp;
> for i = 0 step 1 until 3:
>   pp := ((xpart a[i])/cf*cm, (ypart a[i])/cf*cm);
>   for squig = 1 step 1 until 15:
>   xcoord := uniformdeviate(1) - 0.5 + (xpart a[i]/cf);
>   ycoord := uniformdeviate(1) - 0.5+ (ypart a[i]/cf);
>   pp := pp  .. {curl 100}(xcoord*cm, ycoord*cm);
>   endfor;
>   pp := pp --- cycle;
>   if i < 3 :
>   pp := pp --- ((xpart a[i+1]/cf)*cm, (ypart a[i+1])/cf*cm);
>   fi; 
>   f :=((1.4 - 0.6) * uniformdeviate(1)) + 0.8; % Factor to lighten/darken 
> colour %
>   draw pp withpen pencircle xscaled 0.5mm yscaled .1mm rotated 45 
> withcolor (f[white,\MPcolor{BurntSienna}]);
> endfor;
> StopPage;
> \stopMPpage
> \stoptext
> %%
> 

MetaPost (MetaFun) is taking care of everything regarding units. As you ave 
discovered, everything is translated to a unique internal dimension. So you can 
write:

 a := (1cm,2in) ;

with no problem. The « cm » and « in » parts of the expression will become 
numbers to translate this number on the right unit. 
Fabrice.
> ___
> If your question is of interest to others as well, please add an entry to the 
> Wiki!
> 
> maillist : ntg-context@ntg.nl <mailto:ntg-context@ntg.nl> / 
> http://www.ntg.nl/mailman/listinfo/ntg-context 
> <http://www.ntg.nl/mailman/listinfo/ntg-context>
> webpage  : http://www.pragma-ade.nl <http://www.pragma-ade.nl/> / 
> http://context.aanhet.net <http://context.aanhet.net/>
> archive  : https://bitbucket.org/phg/context-mirror/commits/ 
> <https://bitbucket.org/phg/context-mirror/commits/>
> wiki : http://contextgarden.net <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
___


[NTG-context] Units of xpart and ypart of a pair in MetaFun

2020-11-26 Thread Keith McKay

Hi,

I have been using xpart and ypart to extract these values from pairs of 
points in a path but I wasn't getting the correct result. I was expecting:


pair (2cm, 11cm) to give xpart 2 and ypart 11

However I was getting:

pair (2cm, 11cm) -> xpart 56.6929 and ypart 311.8096

After much head scratching and reading the MetaPost and MetaFun manuals, 
I realised that the units of xpart or ypart are in Postcript points or 
Big Points (bp), and 1 bp is 1/72 of an inch, and thus to get the values 
of xpart or ypart in cm I would have to use a correction factor. I had 
made the assumption that since the x and ypart in the pair was in cm 
that the result would be in cm, but I see now that this is not the case. 
Will I have to continue doing this or is there some magic within MetaFun 
which takes account of the units in a pair and outputs the result of x 
and ypart in the same units?


The MWE belows shows what I have been doing.

Thanks

Keith McKay

%%% MWE %%%

\setuppapersize [A5, landscape][A4, portrait]

\usecolors[crayola]

\starttext

\startMPpage

StartPage;

width := PaperWidth ; height := PaperHeight ; unit := cm ;

numeric squig;

pair a[]; a0 = (2cm,11cm); a1 = (4cm,10cm); a2 = (6cm,9cm); a3 = (8cm,8cm);

show xpart a[0], ypart a[0]; %Example of result from x and ypart before 
applying correction factor (cf) %


cf := 72/2.54; %Converts points/in to points/cm%

path pp;

for i = 0 step 1 until 3:

pp := ((xpart a[i])/cf*cm, (ypart a[i])/cf*cm);

for squig = 1 step 1 until 15:

xcoord := uniformdeviate(1) - 0.5 + (xpart a[i]/cf);

ycoord := uniformdeviate(1) - 0.5+ (ypart a[i]/cf);

pp := pp .. {curl 100}(xcoord*cm, ycoord*cm);

endfor;

pp := pp --- cycle;

if i < 3 :

pp := pp --- ((xpart a[i+1]/cf)*cm, (ypart a[i+1])/cf*cm);

fi;

f :=((1.4 - 0.6) * uniformdeviate(1)) + 0.8; % Factor to lighten/darken 
colour %


draw pp withpen pencircle xscaled 0.5mm yscaled .1mm rotated 45 
withcolor (f[white,\MPcolor{BurntSienna}]);


endfor;

StopPage;

\stopMPpage

\stoptext

%%

___
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
___


Re: [NTG-context] new upload

2020-11-25 Thread Hans Hagen

On 11/25/2020 10:12 AM, Giulio Bertellini wrote:


Great. Made a clean install from scratch and now metafun manual compiles 
great at first run:


mkiv lua stats  > used engine:*luametatex version: 2.0803, functionality 
level: 20201123*, format id: 547, compiler: gcc
mkiv lua stats  > tex properties: 740024 hash slots used of 2097152, 
approximate memory usage: 44 MB
mkiv lua stats  > lua properties: engine: lua 5.4, used memory: 140 MB, 
ctx: 123 MB, max: 123 MB, hash chars: min(64,40), symbol mask: utf (τεχ)
mkiv lua stats  > runtime: 20.182 seconds, 396 processed pages, 396 
shipped pages, 19.621 pages/second
Looks ok to me given the thousands of graphics. What are the specs of 
the machine?


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
___


Re: [NTG-context] new upload

2020-11-25 Thread Giulio Bertellini
Great. Made a clean install from scratch and now metafun manual compiles
great at first run:

mkiv lua stats  > used engine:* luametatex version: 2.0803, functionality
level: 20201123*, format id: 547, compiler: gcc
mkiv lua stats  > tex properties: 740024 hash slots used of 2097152,
approximate memory usage: 44 MB
mkiv lua stats  > lua properties: engine: lua 5.4, used memory: 140 MB,
ctx: 123 MB, max: 123 MB, hash chars: min(64,40), symbol mask: utf (τεχ)
mkiv lua stats  > runtime: 20.182 seconds, 396 processed pages, 396 shipped
pages, 19.621 pages/second

giulio b.


On Tue, Nov 24, 2020 at 8:07 PM Hans Hagen  wrote:

> Hi,
>
> A new upload. Mojca upgraded the build manager and we also updated some
> machines so all binaries (platforms) should be in sync now. (No binaries
> for apples M1 and microsofts SQ2 as we don't have these machines, so
> just good old intel and arm it is.)
>
> On my rusty laptop the luametatex manual takes between 10 and 10.5 sec
> (depending on load). On the raspberry pi 64 bit it takes 32.5 sec
> (ubuntu, ssd on usb 3). The Windows Linux Subsystem (version 1) takes
> some 11.5 seconds and the domotica fitlet with a low power AMD A10 needs
> 27.5 sec.) The ratios match measurements of a while ago. In the meantime
> the format file got smaller, memory more dynamic and the mem footprint
> also smaller. I expect a modern intel laptop cpu to need some 5 seconds
> and a decent desktop less but who knows. It's not easy to squeeze out
> more (the bottleneck is in the lua code as the (con)tex(t) code is
> pretty efficient so we pay a price for flexibility).
>
> (In the process I saw that I bugged the xetex logo but that has to wait
> for a next upload. Hardly critital I suspect.)
>
> 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
>
> ___
>
___
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
___


Re: [NTG-context] Current LMTX unable to compile file metafun-positioning.tex - error on line 240

2020-11-23 Thread Giulio Bertellini
Dear All
 Unable to compile metafun manual with current release of LMTX for linux
 X86_64 and  RPI 4 (both Raspberry PI OS 32 bit and Manjaro Linux ARM 64).
engine: luametatex version: 2.0802, functionality level: 20201118

tex error   > tex error on line 240 in file metafun-positioning.tex:
Missing number, treated as zero.   This problem never occurred in earlier
compilations with LMTX.

Commenting out  file metafun-positioning.tex  metafun  manual compiles
successfully.  Same problem is exhibited in different version of ubuntu and
arch linux X86_64  ,

Thank you all for your feedback.

Giulio B.


234 \startsection[title={A more detailed view}]

235

236 As we know, a decent portion of \TEX's attention is focused on
breaking

237 paragraphs into lines and determining the optimal point to split
off the page.

238 Trying to locate the optimal points to break lines is a dynamic
process. The

239 space between words is flexible and we don't know in advance when a
\hpos {A-1}

240 >>  {word} or piece of a word |<|maybe it's best to talk of typographic
\hpos {A-2}

241 {globs} instead|>| will end up on the page. It might even cross the
page

242 boundary.

243



A number should have been here; I inserted '0'. (If you can't figure out
why I

needed to see a number, look up 'weird error' in the index to The TeXbook.)


  mtx-context | fatal error: return code: 256

>
>
___
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
___


Re: [NTG-context] reusableMPgraphic not working

2020-11-18 Thread Bruce Horrocks


> On 18 Nov 2020, at 13:28, Rik Kabel  wrote:
> 
> 
> On 11/18/2020 08:11, Bruce Horrocks wrote:
>> Just working through the Metafun manual and have hit a problem. In the 
>> following MWE the green circle appears but the blue one doesn't. Surely 
>> reusable graphics must be so commonly used that it has to be me that's doing 
>> something wrong?
>> 
>> (Context version is: 2020.11.05 23:01)
>> 
>> \starttext
>> \startuseMPgraphic{name1}
>>  fill fullcircle scaled 100pt withcolor green ;
>> \stopuseMPgraphic
>> Green circle: \useMPgraphic{name1}
>> 
>> \startreusableMPgraphic{name2}
>>  fill fullcircle scaled 100pt withcolor blue ;
>> \stopreusableMPgraphic
>> Blue circle:\reuseMPgraphic{name2}
>> \stoptext
>> 
> 
> Works as expected here, producing both circles. I am using 2020.11.17 12:39, 
> both LMTX and MkIV.

Thanks. A complete wipe and reinstall of TeX Live and ConTeXt has fixed it for 
me. No idea what was corrupted though.

--
Bruce Horrocks
Hampshire, UK

___
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
___


Re: [NTG-context] reusableMPgraphic not working

2020-11-18 Thread Rik Kabel


On 11/18/2020 08:11, Bruce Horrocks wrote:

Just working through the Metafun manual and have hit a problem. In the 
following MWE the green circle appears but the blue one doesn't. Surely 
reusable graphics must be so commonly used that it has to be me that's doing 
something wrong?

(Context version is: 2020.11.05 23:01)

\starttext
\startuseMPgraphic{name1}
  fill fullcircle scaled 100pt withcolor green ;
\stopuseMPgraphic
Green circle: \useMPgraphic{name1}

\startreusableMPgraphic{name2}
  fill fullcircle scaled 100pt withcolor blue ;
\stopreusableMPgraphic
Blue circle:\reuseMPgraphic{name2}
\stoptext



Works as expected here, producing both circles. I am using 2020.11.17 12:39, 
both LMTX and MkIV.

--
RIk


___
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
___


[NTG-context] reusableMPgraphic not working

2020-11-18 Thread Bruce Horrocks
Just working through the Metafun manual and have hit a problem. In the 
following MWE the green circle appears but the blue one doesn't. Surely 
reusable graphics must be so commonly used that it has to be me that's doing 
something wrong?

(Context version is: 2020.11.05 23:01)

\starttext
\startuseMPgraphic{name1}
 fill fullcircle scaled 100pt withcolor green ;
\stopuseMPgraphic
Green circle: \useMPgraphic{name1}

\startreusableMPgraphic{name2}
 fill fullcircle scaled 100pt withcolor blue ;
\stopreusableMPgraphic
Blue circle:\reuseMPgraphic{name2}
\stoptext

--
Bruce Horrocks
Hampshire, UK

___
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
___


Re: [NTG-context] embed metapost figure into document

2020-11-09 Thread Jairo A. del Rio
Hi, Sylvain.

LuaMetaTeX and LuaTeX, the engines used by ConTeXt nowadays, use an
embedded library, so external compilations/files are not necessary. Just
out of curiosity, wouldn't it be easier to use a ConTeXt environment? E.g.:

\starttext
\startMPcode %\startuseMPgraphic{} if you want to reuse your graphic
with \useMPgraphic{}
draw fullcircle scaled cm
%withcolor black % black is default
;
\stopMPcode %\stopuseMPgraphic
\stoptext

More info here: https://wiki.contextgarden.net/MetaFun_-_MetaPost_in_ConTeXt
To actually answer your question, if you actually want to load a Metapost
graphic externally generated, you should have something like:

%nice.mp
%"begin ... endfig", as well as "end" are important
beginfig (1);
draw fullcircle scaled cm
%withcolor black
;
endfig;
end

so when you compile it via

mpost nice.mp

(obviously supposing you have Metapost installed) you'll get a file called
nice.1 and

\starttext

\externalfigure[nice.1][width=4cm]

\stoptext

will work. However, as you can see, ConTeXt deals with such minutiae for
you and extends Metapost capabilities too, so the second alternative is not
the ConTeXt way to go.

I hope it helps.

Jairo :)

El lun., 9 de nov. de 2020 a la(s) 16:59, Sylvain Hubert (
champign...@gmail.com) escribió:

> Dear List,
>
> I'm trying to embed a metapost image into the document. According the MetaFun
> manual <http://www.pragma-ade.com/general/manuals/metafun-p.pdf>,
> "embedding such a graphic is done by:
> \externalfigure[graphic.123][width=4cm]", but the following example
> produces an empty page:
>
> % test.mkxl
> \starttext
> \externalfigure[test.123][width=4cm]
> \stoptext
>
> % test.123
> draw fullcircle scaled cm withcolor black;
>
> Does anyone know how to properly embed a metapost image into a context
> document?
>
> Thanks!
>
> Best,
> Sylvain
>
> ___
> 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
___


<    1   2   3   4   5   6   7   8   9   10   >