Re: [NTG-context] Compiling a large metapost document

2022-06-01 Thread Thomas A. Schmitz via ntg-context



On 6/1/22 19:35, Stefan Nedeljkovic via ntg-context wrote:
Sorry, i just updated the file, should now compile, but fail due to 
resources. Are the configuration options to context that would enable 
this file to be compiled?
The question still stands: what do you expect us to do? Hunt for a 
problem through a huge file? What have you done to identify this 
problem? Is there a minimal example?


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] Compiling a large metapost document

2022-06-01 Thread Stefan Nedeljkovic via ntg-context
Sorry, i just updated the file, should now compile, but fail due to
resources. Are the configuration options to context that would enable this
file to be compiled?

On Wed, Jun 1, 2022 at 7:24 PM Bruce Horrocks  wrote:

> Hi Stefan,
>
> What exactly are you asking for help with?
>
> The previous file was 12MB and simply ran out of resource when compiled.
> The new file is 812KB and compiles provided you remove the references to
> \setxheight[...] because \setxheight generates an error.
>
>
> > On 1 Jun 2022, at 17:43, Stefan Nedeljkovic via ntg-context <
> ntg-context@ntg.nl> wrote:
> >
> > Just fixed the file, here is the new link:
> https://drive.google.com/file/d/16jTzHbaqxPmhgmNaDOBRijlhlmUCnH4j/view?usp=sharing
> >
> > On Wed, Jun 1, 2022 at 4:48 PM Stefan Nedeljkovic 
> wrote:
> > Dear list,
> >
> > I have a large .tex file with metapost embedded in it and want to
> compile it, but it fails. Here is a link to the file (~12MB):
> https://drive.google.com/file/d/1t-6mxFmGp-nzpl0RrPgNFq8KRvpplgDv/view?usp=sharing
> >
> > Do you know of a way to compile it?
> > BTW, the file is automatically generated by a Python script.
> >
> > Sincerely,
> > Stefan
>
> —
> 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] Compiling a large metapost document

2022-06-01 Thread Bruce Horrocks via ntg-context
Hi Stefan,

What exactly are you asking for help with?

The previous file was 12MB and simply ran out of resource when compiled. The 
new file is 812KB and compiles provided you remove the references to 
\setxheight[...] because \setxheight generates an error.


> On 1 Jun 2022, at 17:43, Stefan Nedeljkovic via ntg-context 
>  wrote:
> 
> Just fixed the file, here is the new link: 
> https://drive.google.com/file/d/16jTzHbaqxPmhgmNaDOBRijlhlmUCnH4j/view?usp=sharing
> 
> On Wed, Jun 1, 2022 at 4:48 PM Stefan Nedeljkovic  wrote:
> Dear list,
> 
> I have a large .tex file with metapost embedded in it and want to compile it, 
> but it fails. Here is a link to the file (~12MB): 
> https://drive.google.com/file/d/1t-6mxFmGp-nzpl0RrPgNFq8KRvpplgDv/view?usp=sharing
> 
> Do you know of a way to compile it?
> BTW, the file is automatically generated by a Python script.
> 
> Sincerely,
> Stefan

—
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] Compiling a large metapost document

2022-06-01 Thread Stefan Nedeljkovic via ntg-context
Just fixed the file, here is the new link:
https://drive.google.com/file/d/16jTzHbaqxPmhgmNaDOBRijlhlmUCnH4j/view?usp=sharing

On Wed, Jun 1, 2022 at 4:48 PM Stefan Nedeljkovic 
wrote:

> Dear list,
>
> I have a large .tex file with metapost embedded in it and want to compile
> it, but it fails. Here is a link to the file (~12MB):
> https://drive.google.com/file/d/1t-6mxFmGp-nzpl0RrPgNFq8KRvpplgDv/view?usp=sharing
>
> Do you know of a way to compile it?
> BTW, the file is automatically generated by a Python script.
>
> Sincerely,
> Stefan
>
___
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] Compiling a large metapost document

2022-06-01 Thread Stefan Nedeljkovic via ntg-context
Dear list,

I have a large .tex file with metapost embedded in it and want to compile
it, but it fails. Here is a link to the file (~12MB):
https://drive.google.com/file/d/1t-6mxFmGp-nzpl0RrPgNFq8KRvpplgDv/view?usp=sharing

Do you know of a way to compile it?
BTW, the file is automatically generated by a Python script.

Sincerely,
Stefan
___
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] How to add margin around standalone MetaPost?

2022-05-24 Thread Vincent Hennebert via ntg-context
On Sat, 2022-05-21 at 07:39 +0530, śrīrāma wrote:
> On 5/20/22 10:26 PM Vincent Hennebert via ntg-context wrote:
> > Take the following MetaPost file:
> > 
> > beginfig(0)
> >   ahlength := 20;
> >   linejoin := mitered;
> >   drawarrow origin--(40,0) withpen pencircle scaled 5;
> > endfig;
> > 
> > Render it into PDF with ConTeXt. Witness the cut out ends of the
> > arrow.
> > How to fix that?
> > 
> > Being able to add some margin would be a solution, which may be
> > desirable anyway in some cases. Is that possible?
> 
> Enlarge the bounds of your picture – 
> 
>   beginfig(0);
>     ahlength := 20;
>     linejoin := mitered;
>     drawarrow origin--(40,0) withpen pencircle scaled 5;
> 
>     setbounds currentpicture to boundingbox currentpicture enlarged
> 5mm;
>   endfig;

Exactly what I was looking for. Thanks!

(I did find out about \startMPpage[offset=3pt], but that requires me to
include my MetaPost file into an additional, somewhat superfluous TeX
file. And for better editor support I prefer to edit the MetaPost in a
.mp file, rather than embedded in a .tex.)


Vincent
___
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 examples seems broken

2022-05-22 Thread Bruce Horrocks via ntg-context
It's archived here
<https://web.archive.org/web/20210815171931/https://tex.loria.fr/prod-graph/zoonekynd/metapost/metapost.html>

which might suffice until the author gets his certificates sorted out?


> On 22 May 2022, at 09:41, Jan-Erik Hägglöf via ntg-context 
>  wrote:
> 
> HI!
> 
> I have issues to access the very most useful place to get inspiration to 
> write MetaFun code.
> 
> Google Chrome reports security issues
> 
> Maybe this could be off topic in this forum, if so, My apologize in advance. 
> But maybe someone knows the author of this site
> 
> https://tex.loria.fr/prod-graph/zoonekynd/metapost/metapost.html
> 

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


[NTG-context] Metapost examples seems broken

2022-05-22 Thread Jan-Erik Hägglöf via ntg-context
HI!

I have issues to access the very most useful place to get inspiration to write 
MetaFun code.

Google Chrome reports security issues

Maybe this could be off topic in this forum, if so, My apologize in advance. 
But maybe someone knows the author of this site

https://tex.loria.fr/prod-graph/zoonekynd/metapost/metapost.html 
<https://tex.loria.fr/prod-graph/zoonekynd/metapost/metapost.html>



/Jan-Erik___
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] How to add margin around standalone MetaPost?

2022-05-20 Thread śrīrāma via ntg-context
On 5/20/22 10:26 PM Vincent Hennebert via ntg-context wrote:
> Take the following MetaPost file:
> 
> beginfig(0)
>   ahlength := 20;
>   linejoin := mitered;
>   drawarrow origin--(40,0) withpen pencircle scaled 5;
> endfig;
> 
> Render it into PDF with ConTeXt. Witness the cut out ends of the arrow.
> How to fix that?
> 
> Being able to add some margin would be a solution, which may be
> desirable anyway in some cases. Is that possible?

Enlarge the bounds of your picture – 

  beginfig(0);
ahlength := 20;
linejoin := mitered;
drawarrow origin--(40,0) withpen pencircle scaled 5;

setbounds currentpicture to boundingbox currentpicture enlarged 5mm;
  endfig;

  Sreeram


___
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] How to add margin around standalone MetaPost?

2022-05-20 Thread Mikael Sundqvist via ntg-context
Hi,

Not sure if I understand the problem correctly. You could try

\starttext
\startMPpage[offset=3pt]
  ahlength := 20;
  linejoin := mitered;
  drawarrow origin--(40,0) withpen pencircle scaled 5;
\stopMPpage

\startMPpage[offset=1cm]
  ahlength := 20;
  linejoin := mitered;
  drawarrow origin--(40,0) withpen pencircle scaled 5;
\stopMPpage
\stoptext

Compile with context.

/Mikael

On Fri, May 20, 2022 at 7:07 PM Bruce Horrocks via ntg-context
 wrote:
>
> The arrow looks fine to me in ConTeXt ver: 2022.01.10 08:36 LMTX. (See 
> attached PDF)
>
> > On 20 May 2022, at 17:56, Vincent Hennebert via ntg-context 
> >  wrote:
> >
> > Take the following MetaPost file:
> >
> > beginfig(0)
> >  ahlength := 20;
> >  linejoin := mitered;
> >  drawarrow origin--(40,0) withpen pencircle scaled 5;
> > endfig;
> >
> > Render it into PDF with ConTeXt. Witness the cut out ends of the arrow.
> > How to fix that?
> >
> > Being able to add some margin would be a solution, which may be
> > desirable anyway in some cases. Is that possible?
> >
> > Thanks,
> > Vincent
>
> —
> 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
> ___
___
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] How to add margin around standalone MetaPost?

2022-05-20 Thread Bruce Horrocks via ntg-context
The arrow looks fine to me in ConTeXt ver: 2022.01.10 08:36 LMTX. (See attached 
PDF)

> On 20 May 2022, at 17:56, Vincent Hennebert via ntg-context 
>  wrote:
> 
> Take the following MetaPost file:
> 
> beginfig(0)
>  ahlength := 20;
>  linejoin := mitered;
>  drawarrow origin--(40,0) withpen pencircle scaled 5;
> endfig;
> 
> Render it into PDF with ConTeXt. Witness the cut out ends of the arrow.
> How to fix that?
> 
> Being able to add some margin would be a solution, which may be
> desirable anyway in some cases. Is that possible?
> 
> Thanks,
> Vincent

—
Bruce Horrocks
Hampshire, UK


tt.pdf
Description: Adobe PDF document
___
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] How to add margin around standalone MetaPost?

2022-05-20 Thread Vincent Hennebert via ntg-context
Take the following MetaPost file:

beginfig(0)
  ahlength := 20;
  linejoin := mitered;
  drawarrow origin--(40,0) withpen pencircle scaled 5;
endfig;

Render it into PDF with ConTeXt. Witness the cut out ends of the arrow.
How to fix that?

Being able to add some margin would be a solution, which may be
desirable anyway in some cases. Is that possible?

Thanks,
Vincent
___
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] Rendering Standalone MetaPost Graphics with ConTeXt

2022-05-19 Thread Vincent Hennebert via ntg-context
On Thu, 2022-05-19 at 14:23 +0530, śrīrāma wrote:
> On 5/19/22 1:53 PM Vincent Hennebert via ntg-context wrote:
> > Looking at the wiki, it seems that \startMPinclusions is not meant
> > to
> > actually render any content, just to include MetaPost code like
> > function definitions. I guess I would have expected \startMPpage
> > instead.
> > 
> > Am I doing something wrong, or is that an error in ConTeXt?
> 
> The MP statements should be inside a beginfig() .. endfig.

Oh, I see. Not super fan of enclosing each and every of my graphics in
a beginfig...endfig statement, but it does the job indeed.

Although in my case I must give a number parameter to beginfig,
otherwise I get an error.

Thanks Sreeram!
Vincent
___
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] Rendering Standalone MetaPost Graphics with ConTeXt

2022-05-19 Thread śrīrāma via ntg-context
On 5/19/22 1:53 PM Vincent Hennebert via ntg-context wrote:
> Looking at the wiki, it seems that \startMPinclusions is not meant to
> actually render any content, just to include MetaPost code like
> function definitions. I guess I would have expected \startMPpage
> instead.
> 
> Am I doing something wrong, or is that an error in ConTeXt?

The MP statements should be inside a beginfig() .. endfig.
With metapost.mp containing – 

  beginfig();
  draw fullcircle scaled 10cm;
  endfig;

the temporary file from mptopdf will have (\start...\stop)MPpage as required.

  Sreeram


___
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] Rendering Standalone MetaPost Graphics with ConTeXt

2022-05-19 Thread Vincent Hennebert via ntg-context
I’d like to use MetaPost to generate all sorts of standalone graphics
(ultimately converted to SVG). For various reasons (among others,
MetaFun and advanced text processing) I want to use MetaPost as
embedded in ConTeXt rather than a standalone installation.

 metapost.mp 
fill fullcircle scaled 10cm;


Whether I run
  context metapost.mp
or
  mtxrun --script metapost metapost.mp
I get a PDF document that contains no page.

The mtxrun version generates the following temp file:
 mptopdf-temp.tex 
\starttext
\startMPinclusions
fill fullcircle scaled 10cm;
\stopMPinclusions
\stoptext


Looking at the wiki, it seems that \startMPinclusions is not meant to
actually render any content, just to include MetaPost code like
function definitions. I guess I would have expected \startMPpage
instead.

Am I doing something wrong, or is that an error in ConTeXt?

Thanks,
Vincent
___
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] Math functions not typeset inside MetaPost

2022-04-19 Thread śrīrāma via ntg-context
On 4/19/22 8:22 PM Mikael Sundqvist via ntg-context wrote:
> Thanks, this will be fixed in the next upload (that will take place
> soon as far as I've heard).

Thanks very much for the quick reply. Yes: it is fixed in the latest upload 
just now.

Thanks,
  Sreeram


___
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] Math functions not typeset inside MetaPost

2022-04-19 Thread Mikael Sundqvist via ntg-context
On Tue, Apr 19, 2022 at 3:59 PM śrīrāma via ntg-context
 wrote:
>
> Hi Hans,
>
> [I am sending this again since the previous mails regarding were sent during
> the weekend].
>
> I am on the most recent upload of LMTX [2022.04.15 20:20]. However, when I try
> to use math functions inside MetaPost strings, the function is not typeset
> correctly. Please consider the following MWE:
>
>   \starttext
> \startMPcode
> draw textext("\m{\max_i x_i}");
> \stopMPcode
>   \stoptext
>
> which produces the output attached here as an image. Instead of the mfunction
> maxᵢ xᵢ
> some form of the string mathfunctionhandlelabel is typeset.
>
> I tried to inspect \math_function_handle_label [math-ini] and also mp-mlib and
> mlib-pps but could not figure out what is going wrong. I wonder if there is a
> backslash missing somewhere. I am a little worried since I use MetaFun in
> conjunction with maths and could not figure out what the issue is.
>
> Please see the original post by Dalyoung here:
>   https://mailman.ntg.nl/pipermail/ntg-context/2022/105462.html
>
> Please advise.
>
> Thank you,
>   
> Sreeram___

Thanks, this will be fixed in the next upload (that will take place
soon as far as I've heard).

Best regards, Mikael
___
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] Math functions not typeset inside MetaPost

2022-04-19 Thread śrīrāma via ntg-context
Hi Hans,

[I am sending this again since the previous mails regarding were sent during 
the weekend].

I am on the most recent upload of LMTX [2022.04.15 20:20]. However, when I try 
to use math functions inside MetaPost strings, the function is not typeset 
correctly. Please consider the following MWE:

  \starttext
\startMPcode
draw textext("\m{\max_i x_i}");
\stopMPcode
  \stoptext

which produces the output attached here as an image. Instead of the mfunction 
maxᵢ xᵢ 
some form of the string mathfunctionhandlelabel is typeset.

I tried to inspect \math_function_handle_label [math-ini] and also mp-mlib and 
mlib-pps but could not figure out what is going wrong. I wonder if there is a 
backslash missing somewhere. I am a little worried since I use MetaFun in 
conjunction with maths and could not figure out what the issue is.

Please see the original post by Dalyoung here:
  https://mailman.ntg.nl/pipermail/ntg-context/2022/105462.html

Please advise.

Thank you,
  Sreeram___
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] \asciimode and MetaPost in LMTX result in “Isolated expression”

2022-03-12 Thread Marco Patzer via ntg-context
On Sat, 12 Mar 2022 22:27:38 +0100
Henning Hraban Ramm via ntg-context  wrote:

> My current and most MP-heavy project so far, fails in asciimode with
> "Extra }, or forgotten \endgroup"

You can't just run “normal” projects with \asciimode. Chances are,
constructs are being used that are invalid in asciimode.

But as far as I understand, it should be sufficient running it
without asciimode just with the \ctxcatcodes snippet in place to
test if that breaks something.

> No time to investigate why, ATM.

No problem. Thanks for checking.

Marco
___
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] \asciimode and MetaPost in LMTX result in “Isolated expression”

2022-03-12 Thread Henning Hraban Ramm via ntg-context

Am 12.03.22 um 18:08 schrieb Marco Patzer via ntg-context:


Maybe someone else with more MetaPost-heavy workflows¹ can test
this, too?

Marco

¹ Hraban? nudge, nudge…


My use of MetaPost is very simple, I still don’t understand much...

My current and most MP-heavy project so far, fails in asciimode with
"Extra }, or forgotten \endgroup"
No time to investigate why, ATM.

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] \asciimode and MetaPost in LMTX result in “Isolated expression”

2022-03-12 Thread Marco Patzer via ntg-context
On Sat, 12 Mar 2022 15:51:16 +0100
Hans Hagen  wrote:

> you can try this
> (in cont-new.tex):
> 
> \prependtoks
>  \setcatcodetable\ctxcatcodes
> \to \everyMPgraphic
> 
> and then do lots of tests with and without asciimode so see if this 
> doesn't interfere

I run almost every document with \asciimode, so I can surely test
that aspect, but I'm not using MetaPost a lot these days. I ran a
few projects and it seems to work fine. But that's not what I'd call
extensive testing.

I think compiling the MetaPost manual would be a good test. But on
my machine this fails even without the \ctxcatcode fix in place.

Maybe someone else with more MetaPost-heavy workflows¹ can test
this, too?

Marco

¹ Hraban? nudge, nudge…
___
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] \asciimode and MetaPost in LMTX result in “Isolated expression”

2022-03-12 Thread Hans Hagen via ntg-context

On 3/12/2022 3:35 PM, Marco Patzer via ntg-context wrote:

On Mon, 31 Jan 2022 20:02:42 +0100
Marco Patzer via ntg-context  wrote:


LMTX seems to have an issue with \asciimode and MetaPost:

\asciimode
\starttext
   \startMPcode
 fill unitsquare scaled 2cm;
   \stopMPcode
\stoptext

Results in:

metafun > log > error: Isolated expression


This is still an issue with today's ver: 2022.03.12 11:27 LMTX.
that's because ascimode messes up some catcodes .. you can try this (in 
cont-new.tex):


\prependtoks
\setcatcodetable\ctxcatcodes
\to \everyMPgraphic

and then do lots of tests with and without asciimode so see if this 
doesn't interfere


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] \asciimode and MetaPost in LMTX result in “Isolated expression”

2022-03-12 Thread Marco Patzer via ntg-context
On Mon, 31 Jan 2022 20:02:42 +0100
Marco Patzer via ntg-context  wrote:

> LMTX seems to have an issue with \asciimode and MetaPost:
> 
> \asciimode
> \starttext
>   \startMPcode
> fill unitsquare scaled 2cm;
>   \stopMPcode
> \stoptext
> 
> Results in:
> 
> metafun > log > error: Isolated expression

This is still an issue with today's ver: 2022.03.12 11:27 LMTX.

Marco
___
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] \asciimode and MetaPost in LMTX result in “Isolated expression”

2022-01-31 Thread Marco Patzer via ntg-context
Hi!

LMTX seems to have an issue with \asciimode and MetaPost:

\asciimode
\starttext
  \startMPcode
fill unitsquare scaled 2cm;
  \stopMPcode
\stoptext

Results in:

metafun > log > error: Isolated expression
metafun > log >
metapost> trace >  E.dash.patterns
metapost> trace >  vardef
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> trace >  vardef dashpattern(text t) =

Marco

ConTeXt  ver: 2022.01.21 20:13 LMTX  fmt: 2022.1.21
___
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] Reset environment between MetaPost graphics?

2022-01-21 Thread Vincent Hennebert via ntg-context
On Thu, 2022-01-20 at 15:47 +0100, Hans Hagen via ntg-context wrote:
> On 1/20/2022 3:26 PM, Aditya Mahajan via ntg-context wrote:
> 
> > AFAIK, there is no in-built support for this.
> 
> FYEO:
> 
> \starttext
> 
> \startMPcode
>  u = 123;
> \stopMPcode
> 
> \ctxlua{metapost.reset("metafun:1")}
> 
> \startMPcode
>  u = 123;
> \stopMPcode
> 
> \stoptext
> 
> (the instance is reported on the console)

Thanks Aditya and Hans! Glad to hear I wasn’t missing anything obvious.

Vincent
___
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] Reset environment between MetaPost graphics?

2022-01-20 Thread Hans Hagen via ntg-context

On 1/20/2022 3:42 PM, Hans Hagen via ntg-context wrote:

next upload:

\resetMPinstance[metafun:1]

but try to avoid this because reloading takes time

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] Reset environment between MetaPost graphics?

2022-01-20 Thread Hans Hagen via ntg-context

On 1/20/2022 3:26 PM, Aditya Mahajan via ntg-context wrote:


AFAIK, there is no in-built support for this.


FYEO:

\starttext

\startMPcode
u = 123;
\stopMPcode

\ctxlua{metapost.reset("metafun:1")}

\startMPcode
u = 123;
\stopMPcode

\stoptext

(the instance is reported on the console)

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] Reset environment between MetaPost graphics?

2022-01-20 Thread Hans Hagen via ntg-context

On 1/20/2022 2:59 PM, Vincent Hennebert via ntg-context wrote:

Hi,

Say I’m writing a document containing many independent MetaPost
figures. I don’t want to bother with enclosing each and every graphics
in a ‘begingroup...endgroup’ with the appropriate ‘save’ statement. But
I don’t want variables from previous graphics to leak into following
ones either.

Like this:

% SOF
\starttext

Text about some topic.

\startMPcode
u=1cm;
draw (-u, u)--origin--(u ,u);
\stopMPcode

Now on to another topic.

\startMPcode
u=2cm; % Triggers an error: Inconsistent equation (off by 28.34645)
draw (-u, u)..origin..(u ,u);
\stopMPcode

\stoptext
% EOF

Is that achievable?

you could do

  save u; u = 1cm;

or

  u := 1cm;

or

  numeric u; u := 1cm;

or you could use a dedicated instance (normally not needed)

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] Reset environment between MetaPost graphics?

2022-01-20 Thread Aditya Mahajan via ntg-context
On Thu, 20 Jan 2022, Vincent Hennebert via ntg-context wrote:

> Hi,
> 
> Say I’m writing a document containing many independent MetaPost
> figures. I don’t want to bother with enclosing each and every graphics
> in a ‘begingroup...endgroup’ with the appropriate ‘save’ statement. But
> I don’t want variables from previous graphics to leak into following
> ones either.
> 
> Like this:
> 
> % SOF
> \starttext
> 
> Text about some topic.
> 
> \startMPcode
> u=1cm;
> draw (-u, u)--origin--(u ,u);
> \stopMPcode
> 
> Now on to another topic.
> 
> \startMPcode
> u=2cm; % Triggers an error: Inconsistent equation (off by 28.34645)
> draw (-u, u)..origin..(u ,u);
> \stopMPcode
> 
> \stoptext
> % EOF
> 
> Is that achievable?

AFAIK, there is no in-built support for this. 

I workaround this as follows. Instead of defining new variables using 

numeric u; pair p; path q; etc.

use:

newnumeric u; newpair p; newpath p; etc.

which automatically does a save beforehand. The only place where the 
abstraction leaks is arrays. You cannot do, 

newpair p[];

but need save p; pair p[] instead. 

Another option is to use assignment rather than equality:

  u := 2cm;

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] Reset environment between MetaPost graphics?

2022-01-20 Thread Vincent Hennebert via ntg-context
Hi,

Say I’m writing a document containing many independent MetaPost
figures. I don’t want to bother with enclosing each and every graphics
in a ‘begingroup...endgroup’ with the appropriate ‘save’ statement. But
I don’t want variables from previous graphics to leak into following
ones either.

Like this:

% SOF
\starttext

Text about some topic.

\startMPcode
u=1cm;
draw (-u, u)--origin--(u ,u);
\stopMPcode

Now on to another topic.

\startMPcode
u=2cm; % Triggers an error: Inconsistent equation (off by 28.34645)
draw (-u, u)..origin..(u ,u);
\stopMPcode

\stoptext
% EOF

Is that achievable?

Thanks,
Vincent

___
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] mp-geo Metapost package with ConTeXt

2021-10-22 Thread Hans Hagen via ntg-context

On 10/22/2021 4:16 PM, Henning Hraban Ramm via ntg-context wrote:



Am 22.10.2021 um 11:31 schrieb Henning Hraban Ramm via ntg-context 
:



Am 17.07.2021 um 12:45 schrieb Hans Hagen :


\startMPpage
   draw lmt_openstreetmap [
   filename = "hasselt.osm"
   grid = "dots",
   ] ;
\stopMPpage

The hasselt osm file is sime 12 MB, the colorful hasselt pdf file just below 1 
MB so that's okay (3.7 sec processing time on my machine so if all claims are 
right sub seconds on a fast new apple).


I finally tried this, hoping to replace my Maperitive workflow.

With a Bonn map from https://download.bbbike.org/osm/bbbike/ of 724 MB I 
started it last night (~13 h before), and it still didn’t finish. No messages 
after:

openstreetmap   > processing file '/Users/hraban/Downloads/ConTeXt/Bonn.osm'
openstreetmap   > original size 713811948 bytes, stripped down to 603309215 
bytes


Maybe I should try smaller files ;)


Indeed:

openstreetmap   > processing file '/Users/hraban/Downloads/ConTeXt/Limburg.osm'
openstreetmap   > original size 12431810 bytes, stripped down to 8768209 bytes
openstreetmap   > xml data loaded
openstreetmap   > 859154 characters metapost code, preprocessing time 3.165 
seconds
...
pdfview | command: open "osm-test.pdf" 1>/dev/null 2>/dev/null &
mtx-context | pdfview overhead: 0.005 seconds
system  | total runtime: 9.211 seconds of 9.328 seconds

The PDF is 488 kB.


Redefining color works, if you know what you’re looking for – and it’s partly 
really strange what is marked how...
Seems like I should start to work on OSM again.


yes, and we need to add more heuristics (i already added some after 
rendering don knuths university site (apart from the many fast food 
venue research institutes are also marked 'interestingly')



Are there any plans for text labels, e.g. street names? (I guess these are 
really tricky.)

depends on how

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] mp-geo Metapost package with ConTeXt

2021-10-22 Thread Henning Hraban Ramm via ntg-context

> Am 22.10.2021 um 11:31 schrieb Henning Hraban Ramm via ntg-context 
> :
> 
> 
>> Am 17.07.2021 um 12:45 schrieb Hans Hagen :
>> 
>> 
>> \startMPpage
>>   draw lmt_openstreetmap [
>>   filename = "hasselt.osm"
>>   grid = "dots",
>>   ] ;
>> \stopMPpage
>> 
>> The hasselt osm file is sime 12 MB, the colorful hasselt pdf file just below 
>> 1 MB so that's okay (3.7 sec processing time on my machine so if all claims 
>> are right sub seconds on a fast new apple).
> 
> I finally tried this, hoping to replace my Maperitive workflow.
> 
> With a Bonn map from https://download.bbbike.org/osm/bbbike/ of 724 MB I 
> started it last night (~13 h before), and it still didn’t finish. No messages 
> after:
> 
> openstreetmap   > processing file '/Users/hraban/Downloads/ConTeXt/Bonn.osm'
> openstreetmap   > original size 713811948 bytes, stripped down to 603309215 
> bytes
> 
> 
> Maybe I should try smaller files ;)

Indeed:

openstreetmap   > processing file '/Users/hraban/Downloads/ConTeXt/Limburg.osm'
openstreetmap   > original size 12431810 bytes, stripped down to 8768209 bytes
openstreetmap   > xml data loaded
openstreetmap   > 859154 characters metapost code, preprocessing time 3.165 
seconds
...
pdfview | command: open "osm-test.pdf" 1>/dev/null 2>/dev/null &
mtx-context | pdfview overhead: 0.005 seconds
system  | total runtime: 9.211 seconds of 9.328 seconds

The PDF is 488 kB.


Redefining color works, if you know what you’re looking for – and it’s partly 
really strange what is marked how...
Seems like I should start to work on OSM again.

Are there any plans for text labels, e.g. street names? (I guess these are 
really tricky.)

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] mp-geo Metapost package with ConTeXt

2021-10-22 Thread Hans Hagen via ntg-context

On 10/22/2021 11:31 AM, Henning Hraban Ramm via ntg-context wrote:



Am 17.07.2021 um 12:45 schrieb Hans Hagen :


\startMPpage
draw lmt_openstreetmap [
filename = "hasselt.osm"
grid = "dots",
] ;
\stopMPpage

The hasselt osm file is sime 12 MB, the colorful hasselt pdf file just below 1 
MB so that's okay (3.7 sec processing time on my machine so if all claims are 
right sub seconds on a fast new apple).


I finally tried this, hoping to replace my Maperitive workflow.

With a Bonn map from https://download.bbbike.org/osm/bbbike/ of 724 MB I 
started it last night (~13 h before), and it still didn’t finish. No messages 
after:

openstreetmap   > processing file '/Users/hraban/Downloads/ConTeXt/Bonn.osm'
openstreetmap   > original size 713811948 bytes, stripped down to 603309215 
bytes

Maybe I should try smaller files ;)


We hit a limti in lpeg that allocates memory by duplicating the size 
which then hits a top and falls back in allocating by + 1 every capture 
which then kind of stalls the xml interpretation. I can hack that to 
work (and need to check that with every lpeg update), but as we enter a 
next stage in th econversion mem starts going virtual anyway and I see 
my SSD being tortured so I aborted. More testing has to wait till I (if 
ever) have a faster machine, with (say) 64GB super fast memory.


On my machine the still ok size is some 200MB.

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] mp-geo Metapost package with ConTeXt

2021-10-22 Thread Henning Hraban Ramm via ntg-context

> Am 17.07.2021 um 12:45 schrieb Hans Hagen :
> 
> 
> \startMPpage
>draw lmt_openstreetmap [
>filename = "hasselt.osm"
>grid = "dots",
>] ;
> \stopMPpage
> 
> The hasselt osm file is sime 12 MB, the colorful hasselt pdf file just below 
> 1 MB so that's okay (3.7 sec processing time on my machine so if all claims 
> are right sub seconds on a fast new apple).

I finally tried this, hoping to replace my Maperitive workflow.

With a Bonn map from https://download.bbbike.org/osm/bbbike/ of 724 MB I 
started it last night (~13 h before), and it still didn’t finish. No messages 
after:

openstreetmap   > processing file '/Users/hraban/Downloads/ConTeXt/Bonn.osm'
openstreetmap   > original size 713811948 bytes, stripped down to 603309215 
bytes


Maybe I should try smaller files ;)


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] positioning of metapost figure

2021-09-12 Thread Sylvain Hubert via ntg-context
Thanks Hans!

On Sun, 12 Sept 2021 at 19:02, Hans Hagen  wrote:

> On 9/12/2021 6:54 PM, Sylvain Hubert via ntg-context wrote:
> > Dear List,
> >
> > The following code draws a circle at the center of the page, ignoring
> > the "shifted" part.
> >
> > \startuniqueMPgraphic{concept}
> > draw fullcircle scaled 1cm shifted (10cm,10cm);
> > \stopuniqueMPgraphic
> > \defineoverlay[concept][\uniqueMPgraphic{concept}]
> > \setupbackgrounds[page][background=concept]
> > \starttext
> > .
> > \stoptext
> >
> > How should the metapost background figure be positioned correctly?
>
> \startuniqueMPgraphic{concept}
>  StartPage;
>  draw fullcircle scaled 1cm shifted (10cm,10cm);
>  draw Page withpen pencircle scaled 5mm;
>  StopPage;
> \stopuniqueMPgraphic
>
> -
>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] positioning of metapost figure

2021-09-12 Thread Hans Hagen via ntg-context

On 9/12/2021 6:54 PM, Sylvain Hubert via ntg-context wrote:

Dear List,

The following code draws a circle at the center of the page, ignoring 
the "shifted" part.


\startuniqueMPgraphic{concept}
draw fullcircle scaled 1cm shifted (10cm,10cm);
\stopuniqueMPgraphic
\defineoverlay[concept][\uniqueMPgraphic{concept}]
\setupbackgrounds[page][background=concept]
\starttext
.
\stoptext

How should the metapost background figure be positioned correctly?


\startuniqueMPgraphic{concept}
StartPage;
draw fullcircle scaled 1cm shifted (10cm,10cm);
draw Page withpen pencircle scaled 5mm;
StopPage;
\stopuniqueMPgraphic

-
  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] positioning of metapost figure

2021-09-12 Thread Sylvain Hubert via ntg-context
Dear List,

The following code draws a circle at the center of the page, ignoring the
"shifted" part.

\startuniqueMPgraphic{concept}
draw fullcircle scaled 1cm shifted (10cm,10cm);
\stopuniqueMPgraphic
\defineoverlay[concept][\uniqueMPgraphic{concept}]
\setupbackgrounds[page][background=concept]
\starttext
.
\stoptext

How should the metapost background figure be positioned correctly?

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
___


Re: [NTG-context] Use MetaPost to distort images?

2021-09-06 Thread Henning Hraban Ramm via ntg-context

> Am 06.09.2021 um 04:13 schrieb Aditya Mahajan via ntg-context 
> :
> 
> On Sun, 5 Sep 2021, Henning Hraban Ramm via ntg-context wrote:
> 
>> 
>>> Am 05.09.2021 um 10:10 schrieb Hans Hagen :
 BTW, here’s my script:
 Here are some results:
>>> 
>>> Did you try that with the filter module? It would make it more portable
>> 
>> I completely forgot I could do that (and I even know how).
> 
> See attached. Basically, you can just copy-paste your script as the value of 
> the filtercommand, and that's it. 

Thank you! I could have done it myself...

But Hans was in a generous and experimenting mood and wrote 
- Lua code interfacing GraphicsMagick to manipulate bitmap data
- a MP interface to ImageMagick

I just need to test them and will report.


> PS: I realized that there is a regression, and \externalfilterbasefile does 
> not remove the file extension. So, the output is named mill.png-taped.png 
> rather than mill-taped.png. I'll look into it later

Oh, thank you. I need to check in my LilyPond setup.


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] Use MetaPost to distort images?

2021-09-05 Thread Aditya Mahajan via ntg-context
On Sun, 5 Sep 2021, Henning Hraban Ramm via ntg-context wrote:

> 
> > Am 05.09.2021 um 10:10 schrieb Hans Hagen :
> >> BTW, here’s my script:
> >> Here are some results:
> > 
> > Did you try that with the filter module? It would make it more portable
> 
> I completely forgot I could do that (and I even know how).

See attached. Basically, you can just copy-paste your script as the value of 
the filtercommand, and that's it. 

Aditya

PS: I realized that there is a regression, and \externalfilterbasefile does not 
remove the file extension. So, the output is named mill.png-taped.png rather 
than mill-taped.png. I'll look into it later

rotate.tex
Description: TeX document
___
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] Use MetaPost to distort images?

2021-09-05 Thread Henning Hraban Ramm via ntg-context

> Am 05.09.2021 um 10:10 schrieb Hans Hagen :
> 
> On 9/5/2021 9:40 AM, Henning Hraban Ramm via ntg-context wrote:
>>> Am 04.09.2021 um 19:06 schrieb Hans Hagen :
>>> 
>>> On 9/4/2021 2:18 PM, Henning Hraban Ramm via ntg-context wrote:
>>> 
 I guess it’s on me to write a wiki page about GM.
>>> 
>>> you can then also add some comparison with im (i.e. what does it offer more 
>>> than gm)
>> Oh no...
>> IM and GM have a history, and I don’t want to get involved.
>> GM accuses IM of security issues, feature and dependency bloat, bad code 
>> quality, inefficiency, frequent API changes, license changes and whatnot.
> 
> ah, i think i remember ... i switched to gm just because im didn't run well 
> at that time on windows
> 
> personally i think that "accuses of .." show that down side of the open 
> source community (which includes the tex community btw) ... it gets even 
> worse when something sells itself for big money and then after a few years 
> spins off again attacking those who paid them ... i suppose that 
> unconstrianed social media also play a role in this (one reason why i'm not 
> really interested in discussions around this in public)

I hear you. Of course there are reasons to be opinionated and to fork some open 
source projects if they move into a direction that you don’t like. But that 
doesn’t mean you can’t be polite about it. And the GM maintainers focus too 
much on their hate for IM’s developer(s) for my taste. Maybe it helps them to 
stay focused and write better code if they have an enemy...

> (what to think of: https://www.youtube.com/watch?v=BhTQyeEdnzs)

The video doesn’t run for me, just read the description: I’m sure the problem 
exists, but it’s maybe exaggerated?

>> Dependencies according to MacPorts:
>> Full Name: GraphicsMagick @1.3.36_1+q8
>> Library Dependencies: libxml2, bzip2, xz, zlib, libpng, tiff, freetype, 
>> libiconv, libtool, lcms2, jasper, libjpeg-turbo, webp
> 
> makes me wonder if there is some simple image manipulation lib that just 
> deals with the pixels .. we don't need xml, freetype, libiconv, ...

Maybe use these libs (libpng etc.) directly? I don’t know what they can do.

Is there a Lua lib that parallels Python’s Pillow?
It also has a lot of dependencies to support image formats or add features, but 
most of them are optional, see 
https://pillow.readthedocs.io/en/latest/installation.html#building-from-source

>> Full Name: ImageMagick @6.9.11-60_1+x11
>> Library Dependencies: bzip2, djvulibre, xz, jbigkit, libjpeg-turbo, lcms2, 
>> libpng, libraw, tiff, webp, zlib, fftw-3, freetype, fontconfig, ghostscript, 
>> libiconv, libtool, openjpeg, openexr, expat, libxml2, libheif, pkgconfig, 
>> xorg-libX11, xorg-libXext, xorg-libXt
>> Runtime Dependencies: urw-fonts
> 
> hm, that looks bad ... maybe not have a look after all ... i get the 
> impression that many originally small programs get bloated by pulling in one 
> lib that then pulls in more,

Exactly. The criticism by the GM maintainers probably *is* justified.
(When I installed IM, actually all of the dependecies were already installed 
for other programs.)

> even if nothing of that is used or useful to the task (we sort of had that 
> when luatex used xpdf from which we only need the reading part but we could 
> not really complain about that because it has been so from the start but it 
> triggered quite a bit of updating)

It might make sense for some projects to dive into these libs and pull out and 
combine the parts that they really need. Even if that’s against the meaning of 
shared libraries and makes it harder to watch upstream for security fixes...

> keep in mind that we can just call them as programs using os.execute (or the 
> filter module or ...) ... no need to waste time in integration (apart from a 
> fun aspect)

Of course. I never wanted to suggest integrating GM, IM or whatever.

>> It’s probably not wise to run IM in a web server process for security and 
>> efficiency reasons, but if I run it only on my own computer there shouldn’t 
>> be a problem.
> 
> hm, why not? all it does in the end is "bits in - bits out"

Apparently there were bugs in IM that bite web developers – if you used IM via 
PHP and allowed users to upload arbitrary images (e.g. avatars), they could 
exploit buffer overflows or something like that to hack your system. Or at 
least stall it (DoS attack).

>> BTW, here’s my script:
>> Here are some results:
> 
> Did you try that with the filter module? It would make it more portable

I completely forgot I could do that (and I even know how).

Working on too many building sites at the same time...


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  : 

Re: [NTG-context] Use MetaPost to distort images?

2021-09-05 Thread Hans Hagen via ntg-context

On 9/5/2021 9:40 AM, Henning Hraban Ramm via ntg-context wrote:


OTOH IM offers much more features (e.g. the geometric transformations I 
inquired about), and you can find lots of interesting examples (including the 
scripts Bruce mentioned). I couldn’t find another CLI tool that can do most of 
these things, at least not with much more programming.


one thing the api offers is a way to pass 'command line like options' to 
the converter ... so i might cook up a variant for it in the end because 
it needs not much interfacing


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] Use MetaPost to distort images?

2021-09-05 Thread Hans Hagen via ntg-context

On 9/5/2021 9:40 AM, Henning Hraban Ramm via ntg-context wrote:




Am 04.09.2021 um 19:06 schrieb Hans Hagen :

On 9/4/2021 2:18 PM, Henning Hraban Ramm via ntg-context wrote:


I guess it’s on me to write a wiki page about GM.


you can then also add some comparison with im (i.e. what does it offer more 
than gm)


Oh no...

IM and GM have a history, and I don’t want to get involved.

GM accuses IM of security issues, feature and dependency bloat, bad code 
quality, inefficiency, frequent API changes, license changes and whatnot.


ah, i think i remember ... i switched to gm just because im didn't run 
well at that time on windows


personally i think that "accuses of .." show that down side of the open 
source community (which includes the tex community btw) ... it gets even 
worse when something sells itself for big money and then after a few 
years spins off again attacking those who paid them ... i suppose that 
unconstrianed social media also play a role in this (one reason why i'm 
not really interested in discussions around this in public)


like: what is bad code quality ... i bet one can find examples of bad, 
inefficient, etc in gm too (it would be quite a claim to say one can't), 
and the more people touch the code ... also, what about the code quality 
of libs then ... one bug in those could affect lots of programs using 
them ... most is about trust .. and even more in 'working with people 
you like working with'


btw, 'bug' and 'many bugs' and 'big bug' are popular in subject titles 
and mail bodies, even it's small bugs or side effects or something that 
has to be tested but it might make people feel good


'security fix' is another one, which often just means: programming error 
e.g. array out of bounds; nowadays for me the way an email is written 
determines the reading order, but there is no good filter for that yet; 
same for (tech) websites: bluffing and barking agianst a tree (like your 
mentioned 'accuses' makes me go away immediately and discard whatever 
would follow)


(what to think of: https://www.youtube.com/watch?v=BhTQyeEdnzs)


OTOH IM offers much more features (e.g. the geometric transformations I 
inquired about), and you can find lots of interesting examples (including the 
scripts Bruce mentioned). I couldn’t find another CLI tool that can do most of 
these things, at least not with much more programming.


ok, i'll have a look later, maybe it can be compiled lean-and-mean


Dependencies according to MacPorts:

Full Name: GraphicsMagick @1.3.36_1+q8
Library Dependencies: libxml2, bzip2, xz, zlib, libpng, tiff, freetype, 
libiconv, libtool, lcms2, jasper, libjpeg-turbo, webp


makes me wonder if there is some simple image manipulation lib that just 
deals with the pixels .. we don't need xml, freetype, libiconv, ...



Full Name: ImageMagick @6.9.11-60_1+x11
Library Dependencies: bzip2, djvulibre, xz, jbigkit, libjpeg-turbo, lcms2, 
libpng, libraw, tiff, webp, zlib, fftw-3, freetype, fontconfig, ghostscript, 
libiconv, libtool, openjpeg, openexr, expat, libxml2, libheif, pkgconfig, 
xorg-libX11, xorg-libXext, xorg-libXt
Runtime Dependencies: urw-fonts


hm, that looks bad ... maybe not have a look after all ... i get the 
impression that many originally small programs get bloated by pulling in 
one lib that then pulls in more, even if nothing of that is used or 
useful to the task (we sort of had that when luatex used xpdf from which 
we only need the reading part but we could not really complain about 
that because it has been so from the start but it triggered quite a bit 
of updating)


keep in mind that we can just call them as programs using os.execute (or 
the filter module or ...) ... no need to waste time in integration 
(apart from a fun aspect)



It’s probably not wise to run IM in a web server process for security and 
efficiency reasons, but if I run it only on my own computer there shouldn’t be 
a problem.


hm, why not? all it does in the end is "bits in - bits out"



BTW, here’s my script:


#!/bin/bash
#INPUT=$1

OUTPUT=${INPUT/.JPG/.png}
OUTPUT=${OUTPUT/.jpg/.png}
OUTPUT=${OUTPUT/in\//out\/}

# random rotation ±1.5˚
ROTATION=`jot -r 1 -1.5 1.5`
echo $OUTPUT ${ROTATION}˚

# downscale, add a white border and a shadow, rotate, move down, add a piece of 
tape (tesa1.png), grayscale
convert "$INPUT" \
-auto-orient \
-resize 800x800 \
-bordercolor white -border 10 \
\( +clone -background black -shadow 80x3+2+2 \) +swap \
-background transparent \
-layers merge \
-rotate ${ROTATION} \
+repage  \
-gravity north \
-splice 0x10 \
\( tesa1.png -resize 200x50! \) -compose Multiply -composite \
-colorspace Gray \
"$OUTPUT"


Here are some results:
https://sedna.fiee.net/d/2c3218730f8341aab1fa/


Did you try that with the filter module? It would make it more portable

Hans

ps. It is still on my todo list to see of we can add some of metafont's 
bit stuff.


-
 

Re: [NTG-context] Use MetaPost to distort images?

2021-09-05 Thread Henning Hraban Ramm via ntg-context


> Am 04.09.2021 um 19:06 schrieb Hans Hagen :
> 
> On 9/4/2021 2:18 PM, Henning Hraban Ramm via ntg-context wrote:
> 
>> I guess it’s on me to write a wiki page about GM.
> 
> you can then also add some comparison with im (i.e. what does it offer more 
> than gm)

Oh no...

IM and GM have a history, and I don’t want to get involved.

GM accuses IM of security issues, feature and dependency bloat, bad code 
quality, inefficiency, frequent API changes, license changes and whatnot.

OTOH IM offers much more features (e.g. the geometric transformations I 
inquired about), and you can find lots of interesting examples (including the 
scripts Bruce mentioned). I couldn’t find another CLI tool that can do most of 
these things, at least not with much more programming.


Dependencies according to MacPorts:

Full Name: GraphicsMagick @1.3.36_1+q8
Library Dependencies: libxml2, bzip2, xz, zlib, libpng, tiff, freetype, 
libiconv, libtool, lcms2, jasper, libjpeg-turbo, webp

Full Name: ImageMagick @6.9.11-60_1+x11
Library Dependencies: bzip2, djvulibre, xz, jbigkit, libjpeg-turbo, lcms2, 
libpng, libraw, tiff, webp, zlib, fftw-3, freetype, fontconfig, ghostscript, 
libiconv, libtool, openjpeg, openexr, expat, libxml2, libheif, pkgconfig, 
xorg-libX11, xorg-libXext, xorg-libXt
Runtime Dependencies: urw-fonts


It’s probably not wise to run IM in a web server process for security and 
efficiency reasons, but if I run it only on my own computer there shouldn’t be 
a problem.


BTW, here’s my script:


#!/bin/bash
#INPUT=$1

OUTPUT=${INPUT/.JPG/.png}
OUTPUT=${OUTPUT/.jpg/.png}
OUTPUT=${OUTPUT/in\//out\/}

# random rotation ±1.5˚
ROTATION=`jot -r 1 -1.5 1.5`
echo $OUTPUT ${ROTATION}˚

# downscale, add a white border and a shadow, rotate, move down, add a piece of 
tape (tesa1.png), grayscale
convert "$INPUT" \
-auto-orient \
-resize 800x800 \
-bordercolor white -border 10 \
\( +clone -background black -shadow 80x3+2+2 \) +swap \
-background transparent \
-layers merge \
-rotate ${ROTATION} \
+repage  \
-gravity north \
-splice 0x10 \
\( tesa1.png -resize 200x50! \) -compose Multiply -composite \
-colorspace Gray \
"$OUTPUT"


Here are some results:
https://sedna.fiee.net/d/2c3218730f8341aab1fa/


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] Use MetaPost to distort images?

2021-09-04 Thread Hans Hagen via ntg-context

On 9/4/2021 2:18 PM, Henning Hraban Ramm via ntg-context wrote:


I guess it’s on me to write a wiki page about GM.


you can then also add some comparison with im (i.e. what does it offer 
more than gm)


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] Use MetaPost to distort images?

2021-09-04 Thread Henning Hraban Ramm via ntg-context

> Am 03.09.2021 um 18:24 schrieb Hans Hagen via ntg-context 
> :
> 
> On 9/3/2021 12:28 PM, Henning Hraban Ramm via ntg-context wrote:
>> Hi, is it possible to apply geometric transformations to images using 
>> MetaPost?
>> This is again way over my head, but I’m still trying different methods to 
>> let a ConTeXt document look more “hand-made”.
>> In my example*, I added frame and shadow to a photo and _distorted_ it 
>> slightly to have it look like a postcard was glued on the page (with a piece 
>> of tape). I’d like to automate and randomize that process.
>> I guess I could achieve something similar with ImageMagick (not with 
>> GraphicsMagick), but if it would be possible inside LMTX that would be great.
> the question is not so much if it can be done but how far we should go in 
> doing things .. so, only as friday afternoon distraction, and because
> i wanted to upload anyway (not done yet) i'll meta-imp-magick that uses the 
> gm lib interface (that only does simple conversions, but i added bur and 
> noise an dcan add some more if needed as long as there is no weird stuff or 
> code bloat)
> 
> not in the core, just as 'imp' because we don't want library dependencies 
> (and the optional libs are lightweight delayed loading ones)
> 
> now, the drawback of course is that one needs gm installed (quite large) but 
> it does work on my windows box so ...

Thank you!

That’s interesting and I can probably use it for a different project, but for 
what I had in mind, GM wasn’t enough. IM has much more features (and probably 
also flaws), is even bigger, with more dependencies, but I could install both 
with MacPorts.

I guess it’s on me to write a wiki page about GM.
And maybe adapt your code to IM...

I just thought since MP is great for geometrical calculations it might also be 
able to use transformation matrices on images.
But since I don’t understand matrix calculations anyway, I’ll live without.

Generally, I’d like to delay image manipulation as long as possible – only 
ConTeXt knows the final size of the used images, and since I want to keep e.g. 
frames and shadows at the same size for all images I need to calculate with 
that final size. 


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] Use MetaPost to distort images?

2021-09-04 Thread Henning Hraban Ramm via ntg-context

> Am 04.09.2021 um 00:16 schrieb Bruce Horrocks via ntg-context 
> :
> 
> 
> 
>> On 3 Sep 2021, at 11:28, Henning Hraban Ramm via ntg-context 
>>  wrote:
>> 
>> Hi, is it possible to apply geometric transformations to images using 
>> MetaPost?
>> 
>> This is again way over my head, but I’m still trying different methods to 
>> let a ConTeXt document look more “hand-made”.
>> 
>> In my example*, I added frame and shadow to a photo and _distorted_ it 
>> slightly to have it look like a postcard was glued on the page (with a piece 
>> of tape). I’d like to automate and randomize that process.
>> 
>> I guess I could achieve something similar with ImageMagick (not with 
>> GraphicsMagick), but if it would be possible inside LMTX that would be great.
> 
> No idea about MetaPost but "Fred's ImageMagic Scripts" 
> <http://www.fmwconcepts.com/imagemagick/index.php> is a fantastic resource. 
> Start with "vintage" 1, 2 & 3 towards the bottom.
> 
> The site is a little idiosyncratic in that you click and nothing appears to 
> happen. This is because all the pages start with the same table of scripts at 
> the top so you have to scroll down to see an example of the effect achieved 
> by the script you just selected.

Thank you – I know that site. I just hoped to keep everything ”inside“.

I made my own (shell) script for Imagemagick now; since I didn’t understand the 
transformation matrix anyway, I went without that distortion. (Nobody will miss 
it...)

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] Use MetaPost to distort images?

2021-09-03 Thread Bruce Horrocks via ntg-context


> On 3 Sep 2021, at 11:28, Henning Hraban Ramm via ntg-context 
>  wrote:
> 
> Hi, is it possible to apply geometric transformations to images using 
> MetaPost?
> 
> This is again way over my head, but I’m still trying different methods to let 
> a ConTeXt document look more “hand-made”.
> 
> In my example*, I added frame and shadow to a photo and _distorted_ it 
> slightly to have it look like a postcard was glued on the page (with a piece 
> of tape). I’d like to automate and randomize that process.
> 
> I guess I could achieve something similar with ImageMagick (not with 
> GraphicsMagick), but if it would be possible inside LMTX that would be great.

No idea about MetaPost but "Fred's ImageMagic Scripts" 
<http://www.fmwconcepts.com/imagemagick/index.php> is a fantastic resource. 
Start with "vintage" 1, 2 & 3 towards the bottom.

The site is a little idiosyncratic in that you click and nothing appears to 
happen. This is because all the pages start with the same table of scripts at 
the top so you have to scroll down to see an example of the effect achieved by 
the script you just selected.

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


[NTG-context] Use MetaPost to distort images?

2021-09-03 Thread Henning Hraban Ramm via ntg-context
Hi, is it possible to apply geometric transformations to images using MetaPost?

This is again way over my head, but I’m still trying different methods to let a 
ConTeXt document look more “hand-made”.

In my example*, I added frame and shadow to a photo and _distorted_ it slightly 
to have it look like a postcard was glued on the page (with a piece of tape). 
I’d like to automate and randomize that process.

I guess I could achieve something similar with ImageMagick (not with 
GraphicsMagick), but if it would be possible inside LMTX that would be great.

Hraban


*) not small enough for the mailing list; see 
https://sedna.fiee.net/f/fb532dc85c784147a149/
___
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 Examples

2021-09-01 Thread Henning Hraban Ramm via ntg-context

> Am 01.09.2021 um 14:45 schrieb Hans Hagen via ntg-context 
> :
> 
> On 9/1/2021 2:19 PM, Henning Hraban Ramm via ntg-context wrote:
>> Hi, I’m trying to “translate” the documentation of “fiziko”* from LaTeX to 
>> ConTeXt and would like to avoid the doubling of MP code like:
>> \startMP
>> path p;
>> p := (0,0){dir(30)}..(5cm, 0)..{dir(30)}(10cm, 0);
>> draw brush (p)(2minStrokeWidth*sin(offsetPathLength*pi));
>> \stopMP
>> \startMPcode
>> path p;
>> p := (0,0){dir(30)}..(5cm, 0)..{dir(30)}(10cm, 0);
>> draw brush (p)(2minStrokeWidth*sin(offsetPathLength*pi));
>> \stopMPcode
>> I’m quite sure there’s a possibility with buffers, but how?
>> \startbuffer
>> path p;
>> p := (0,0){dir(30)}..(5cm, 0)..{dir(30)}(10cm, 0);
>> draw brush (p)(2minStrokeWidth*sin(offsetPathLength*pi));
>> \stopbuffer
>> \typebuffer
>> ... and then how do I get the MP graphic?
> \processMPbuffer

“of course”

Thank you!

Used here: https://github.com/fiee/fiziko/blob/master/fiziko.mkiv

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] MetaPost Examples

2021-09-01 Thread Hans Hagen via ntg-context

On 9/1/2021 2:19 PM, Henning Hraban Ramm via ntg-context wrote:

Hi, I’m trying to “translate” the documentation of “fiziko”* from LaTeX to 
ConTeXt and would like to avoid the doubling of MP code like:

\startMP
 path p;
 p := (0,0){dir(30)}..(5cm, 0)..{dir(30)}(10cm, 0);
 draw brush (p)(2minStrokeWidth*sin(offsetPathLength*pi));
\stopMP

\startMPcode
 path p;
 p := (0,0){dir(30)}..(5cm, 0)..{dir(30)}(10cm, 0);
 draw brush (p)(2minStrokeWidth*sin(offsetPathLength*pi));
\stopMPcode

I’m quite sure there’s a possibility with buffers, but how?

\startbuffer
 path p;
 p := (0,0){dir(30)}..(5cm, 0)..{dir(30)}(10cm, 0);
 draw brush (p)(2minStrokeWidth*sin(offsetPathLength*pi));
\stopbuffer

\typebuffer

... and then how do I get the MP graphic?

\processMPbuffer


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

2021-09-01 Thread Henning Hraban Ramm via ntg-context
Hi, I’m trying to “translate” the documentation of “fiziko”* from LaTeX to 
ConTeXt and would like to avoid the doubling of MP code like:

\startMP
path p;
p := (0,0){dir(30)}..(5cm, 0)..{dir(30)}(10cm, 0);
draw brush (p)(2minStrokeWidth*sin(offsetPathLength*pi));
\stopMP

\startMPcode
path p;
p := (0,0){dir(30)}..(5cm, 0)..{dir(30)}(10cm, 0);
draw brush (p)(2minStrokeWidth*sin(offsetPathLength*pi));
\stopMPcode

I’m quite sure there’s a possibility with buffers, but how?

\startbuffer
path p;
p := (0,0){dir(30)}..(5cm, 0)..{dir(30)}(10cm, 0);
draw brush (p)(2minStrokeWidth*sin(offsetPathLength*pi));
\stopbuffer

\typebuffer

... and then how do I get the MP graphic?


Hraban

*) https://github.com/jemmybutton/fiziko
___
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] mp-geo Metapost package with ConTeXt

2021-07-27 Thread Alan Braslau via ntg-context

On 27/07/21 08:12, Gavin via ntg-context wrote:

Hi All,

Getting Closer I asked:


2) While I’m having good luck with paths, colors are causing trouble. In the 
data set the color information is in strings with French names of the color, 
like “rouge.” If I hand this string to MetaPost, MetaPost doesn’t expand it 
into a color. It does work if it is a native color, like “red,” but not if it 
is a defined color and not if the color is in a Lua variable. Any suggestions?


Aditya suggested:


\definecolor[rouge][red] should work. A better option will be use color 
palettes.


This solves my problem of translating French colors into English, but not the 
problem of passing colors from Lua to MetaPost. If the string giving the color 
name is in a variable, it doesn’t go through. A path in a variable works.

I’ve reduced my MWE below – no French, no MPinclusions, no new colors. Both pie 
slices should be red, but one is black. Any ideas on getting the color “red” 
passed from Lua to MetaPost when mycolor=“red”?


I am not looking closely at the code, but in general we use

fill fullcircle scaled 1cm withcolor red ;

and this takes Metapost's knowledge of red, the rgb triplet (1,0,0).
One can also use

fill fullcircle scaled 1cm withcolor "red" ;

as a string (quotation) and this passes Context's definition of the color.

Alan



--
Alan
___
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] mp-geo Metapost package with ConTeXt

2021-07-27 Thread Gavin via ntg-context
Hi All,

Getting Closer I asked:

>> 2) While I’m having good luck with paths, colors are causing trouble. In the 
>> data set the color information is in strings with French names of the color, 
>> like “rouge.” If I hand this string to MetaPost, MetaPost doesn’t expand it 
>> into a color. It does work if it is a native color, like “red,” but not if 
>> it is a defined color and not if the color is in a Lua variable. Any 
>> suggestions?

Aditya suggested:

> \definecolor[rouge][red] should work. A better option will be use color 
> palettes. 

This solves my problem of translating French colors into English, but not the 
problem of passing colors from Lua to MetaPost. If the string giving the color 
name is in a variable, it doesn’t go through. A path in a variable works.

I’ve reduced my MWE below – no French, no MPinclusions, no new colors. Both pie 
slices should be red, but one is black. Any ideas on getting the color “red” 
passed from Lua to MetaPost when mycolor=“red”?

Thanks!
Gavin


\startluacode
  mypath = {{0,0}, {2,0,0,0,2,0.5}, {1.6,1.2,1.9,0.8}, cycle = true}
  mycolor = “red”   --% Data files are read by Lua, so the color of each 
object will be a string, like "red".
  
  function mp.getpath() --% Is there a way for the MetaPost code to grab the 
path directly from the table?
mp.inject.path(mypath)
  end
  
  function mp.getred() --% Returning a string works.
mp.inject.string("red")
  end

  function mp.getcolor() --% Putting the string in a variable does not work.
mp.inject.string(mycolor)
  end
\stopluacode

\starttext
  \startMPpage
   fill lua.mp.getpath() scaled 2.5cm withcolor lua.mp.getred(); % Returning a 
string works.
   fill lua.mp.getpath() scaled 2.5cm shifted (0, -4cm) withcolor 
lua.mp.getcolor(); % Putting the string in a variable does not work.
  \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] mp-geo Metapost package with ConTeXt

2021-07-26 Thread Aditya Mahajan via ntg-context
On Mon, 26 Jul 2021, Gavin via ntg-context wrote:

> 2) While I’m having good luck with paths, colors are causing trouble. In the 
> data set the color information is in strings with French names of the color, 
> like “rouge.” If I hand this string to MetaPost, MetaPost doesn’t expand it 
> into a color. It does work if it is a native color, like “red,” but not if it 
> is a defined color and not if the color is in a Lua variable. Any suggestions?

\definecolor[rouge][red] should work. A better option will be use color 
palettes. 

This is very old code, but will give an idea of how to use palettes:
https://github.com/adityam/visualcounter/blob/master/visualcounter.pdf 
Effectively all you need to do is add \setuppalet[name] at an appropriate 
place, and then the user can easily change the colors (rather than having them 
specified as part of data files).

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] mp-geo Metapost package with ConTeXt

2021-07-26 Thread Gavin via ntg-context
Hi everyone,

I’ve made great progress creating globes for my diagrams using the data in the 
mp-geo package and some ideas from Hans. I have a couple questions about moving 
information from Lua to MetaPost. Below is a MWE for illustration. I have two 
related questions:

1) Is there a way for MetaPost to grab information from a Lua table? Currently 
the MetaPost code calls a Lua function which has a single line returning the 
information from the table. Is this necessary, or is these something in 
MetaPost that can get a path or color from a Lua table? 

2) While I’m having good luck with paths, colors are causing trouble. In the 
data set the color information is in strings with French names of the color, 
like “rouge.” If I hand this string to MetaPost, MetaPost doesn’t expand it 
into a color. It does work if it is a native color, like “red,” but not if it 
is a defined color and not if the color is in a Lua variable. Any suggestions?

Thanks!
Gavin


The code below produces four pie shape wedges to show the different results of 
handling the color. They should all be red, but the last two are black.


\startMPinclusions
  color rouge;  % To avoid changing the data files, I need to define 
colors in French.
  rouge=(1,0,0);% For this MWE, I only define rouge.
  
  color mycolor;% Defining mycolor in MetaPost works great, as shown in 
the first shape.
  mycolor = rouge;
\stopMPinclusions

\startluacode
  myluapath = {{0,0}, {1,0,0,0,1,0.25}, {0.8,0.6,0.95,0.4}, cycle = true}
  myluacolor = “red”--% Data files are read by Lua, so the myluacolor will 
be a string (in French, but native colors don't work either).
  
  function mp.getpath() --% Is there a way for the MetaPost code to grab the 
path directly from the table?
mp.inject.path(myluapath)
  end
  
  function mp.getred() --% Returning a string work for native colors.
mp.inject.string("red")
  end

  function mp.getrouge() --% Returning a string does not work for defined
mp.inject.string("rouge")
  end

  function mp.getcolor() --% Putting the string in a variable does not work.
mp.inject.string(mycolor)
  end
\stopluacode

\starttext
  \startMPpage
   fill lua.mp.getpath() scaled 2.5cm withcolor mycolor; % MetaPost color 
definition works great.
   fill lua.mp.getpath() scaled 2.5cm shifted (0, -2cm) withcolor 
lua.mp.getred(); % Returning a string work for native colors.
   fill lua.mp.getpath() scaled 2.5cm shifted (0, -4cm) withcolor 
lua.mp.getrouge(); % Returning a string does not work for defined colors.
   fill lua.mp.getpath() scaled 2.5cm shifted (0, -6cm) withcolor 
lua.mp.getcolor(); % Putting the string in a variable does not work.
  \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] Metapost Animation of Sine

2021-07-22 Thread Otared Kavian
Hi Jeroen,

Unfortunately I am not familiar with Tikz, since all my documents use what is 
built-in ConTeXt and Metapost…
That being said I am sure someone on the list can help you with Tikz module.

Best regards: Otared

> On 22 Jul 2021, at 14:28, Jeroen  wrote:
> 
> Hi, both solutions are great! This is what I had in mind, a rolling sine. Is 
> there a way to get the same result with the Tikz module?
> 
> \usemodule[animation]
> \setupinteraction[state=start]
> 
> \starttext
> 
> \input tufte
> 
> \framed{
> \startanimation[menu=yes,framerate=40]
> \dorecurse{50}{\expanded
> {\startframe
> \startMPcode
> numeric u, omega, mylength, tt ;
> u := 2cm ;
> omega := 4 ;
> mylength := 3.141596 ;
> tt := \recurselevel ;
> path p ;
> p := (0u,sin(omega*(mylength/100)*tt)*u) for i = 1 upto 100 : 
> .. (((mylength/100)*i)*u,sin(omega*(mylength/100)*(i + tt))*u) 
> endfor ;
> draw p withpen pencircle scaled .5pt withcolor darkred ;
> \stopMPcode
> \stopframe}
> }
> \stopanimation
> }
> 
> \stoptext
> 
> Op wo 21 jul. 2021 om 23:26 schreef Otared Kavian  <mailto:ota...@gmail.com>>:
> Hi, 
> 
> I wonder whether something like the following is what you are looking for:
> 
> % begin wave-sine.tex
> \usemodule[animation]
> \setupinteraction[state=start]
> \starttext
> \startTEXpage[offset=2pt]
> \startanimation[menu=yes,framerate=10]
> \dorecurse{100}{\expanded
> {\startframe
> \startMPcode
> numeric u, omega, mylength, tt ;
> u := 2cm ;
> omega := 4 ;
> mylength := 3.141596 ;
> tt := \recurselevel ;
> path p ;
> p := (0u,sin(omega*(mylength/100)*tt)*u) for i = 1 
> upto 100 : 
> .. 
> (((mylength/100)*i)*u,sin(omega*(mylength/100)*(i + tt))*u) 
> endfor ;
> draw p withpen pencircle scaled .5pt withcolor 
> darkred ;
> \stopMPcode
> \stopframe}
> }
> \stopanimation
> \stopTEXpage
> \stoptext
> % end wave-sine.tex
> 
> Best regards: OK
> 
> > On 21 Jul 2021, at 19:44, Jeroen  > <mailto:context...@gmail.com>> wrote:
> > 
> > I am looking for a sine animation as the one file f.pdf on this site
> > 
> > http://www.12000.org/my_notes/Mathematica_animation_into_PDF_using_latex/index.htm
> >  
> > <http://www.12000.org/my_notes/Mathematica_animation_into_PDF_using_latex/index.htm>
> > 
> > Jeroen
> > 
> > Op wo 21 jul. 2021 om 17:54 schreef Fabrice L  > <mailto:fabrice.al...@gmail.com>>:
> > Hi,
> > 
> >> Le 21 juill. 2021 à 10:08, Jeroen  >> <mailto:context...@gmail.com>> a écrit :
> >> 
> >> I use this small animation to enlarge a circle
> >> 
> >> 
> >> \usemodule[animation]
> >> \setupinteraction[state=start]
> >> \starttext
> >> \startanimation[menu=yes,framerate=10]
> >> \dorecurse{7}{\expanded
> >>   {\startframe
> >> \startMPcode
> >> path p;
> >> numeric n, u;
> >> u := 1cm;
> >> n:=\recurselevel*u;
> >> p := fullcircle scaled n;
> >> draw p;
> >> \stopMPcode
> >>   \stopframe}}
> >> \stopanimation
> >> \stoptext
> >> 
> >> 
> >> This I use to draw a sine
> >> 
> >> 
> >> \starttext
> >> \startMPcode
> >>   draw(-90/360*1.5cm,-0.9cm) for i = -90 upto 630: .. 
> >> (i/360*1.5cm,0.9cm*(sind(i)))endfor;
> >> \stopMPcode
> >> \stoptext
> >> 
> >> 
> >> When I put it together to animate the sine as following, it does not 
> >> entirely create the sine animation I am looking for
> >> 
> >> 
> >> \usemodule[animation]
> >> \setupinteraction[state=start]
> >> \starttext
> >> \startanimation[menu=yes,framerate=10]
> >> \dorecurse{7}{\expanded
> >>   {\startframe
> >> \startMPcode
> >> path p;
> >> numeric n, u;
> >> u := 1cm;
> >> n:=\recurselevel*u;
> >> p := (-90/360*1.5cm,-0.9cm) for i = -90 upto 630: .. 
> >> (i/360*1.5cm,0.9cm*(sind(i))) endfor shifted (n,0);
> >> draw p;
> >> \stopMPcode
> >> \stopframe}}
> >> \stopanimation
> >> \stoptext

Re: [NTG-context] another MetaPost question (this time on ConTeXt->MetaPost

2021-07-22 Thread Hans Hagen

On 7/22/2021 2:59 PM, Rudd, Kevin wrote:


Hey---

There seems to be a change with color transfer from ConTeXt to MetaPost. 
Using string references to defined (spot?) colors seemed to work but now 
does not; all of my colorful figures are now rendered only in shades of 
gray when using defined (spot?) colors….


I need to catch that case (string spot) indeed but even then, you need 
in your case


 p & ":" & c;

you missed the colon. Anyway, fixed in next upload.
 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] another MetaPost question (this time on ConTeXt->MetaPost color transfer)

2021-07-22 Thread Rudd, Kevin
... fixed minor typo that actually produced new information! invalid color => 
black, valid color => transparent black!---it seems like the color disappears 
in the transfer but not the transparency.

Hey---

There seems to be a change with color transfer from ConTeXt to MetaPost. Using 
string references to defined (spot?) colors seemed to work but now does not; 
all of my colorful figures are now rendered only in shades of gray when using 
defined (spot?) colors….

The figure drawn by the MWE should have a dark orange border and a transparent 
(thin) orange fill. However, all colors of this sort seem to end up being a 
single shade of gray (e.g. black), rendering a box perfect for Halloween use 
but not for my current purposes. Is there a change to how colors defined in 
ConTeXt are referenced in MetaPost that I've missed or is there an issue with 
transferring color (name or parameter) information to MetaPost? Defined (spot?) 
colors work fine in ConTeXt but not in MetaPost.

Many thanks,
 ---K



% system  > ConTeXt  ver: 2021.07.21 19:54 LMTX  fmt: 2021.7.22  int: 
english/english

\startMPdefinitions

presetparameters "parameters_Test"
[
]

def Test =
applyparameters "parameters_Test" "do_Test"
enddef;

def do_Test =
pushparameters "parameters_Test";

string p;  p = getparameter "prefix";  show p;
string c;  c = getparameter "color";   show c;
path   s;  s = unitsquare scaled 10cm; show s;
path   t;  t = unitsquare scaled  5cm; show t;  % new

fill s   withcolor p&":" % tweaked
fill t   withcolor p % new (and 
old)
draw s  withpen pencircle scaled 5pt withcolor   c;
enddef;

\stopMPdefinitions

\starttext

\definespotcolor[Thin:orange][orange][p=1,a=normal,t=0.5]

\color[orange]{hello}

\startalignment[center]
\startplacefigure
\startMPcode
Test [ prefix = "Thin", color = "orange" ];
\stopMPcode
\stopplacefigure
\stopalignment

\color[Thin:orange]{goodbye}

\stoptext




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
___


[NTG-context] another MetaPost question (this time on ConTeXt->MetaPost

2021-07-22 Thread Rudd, Kevin

Hey---

There seems to be a change with color transfer from ConTeXt to MetaPost. Using 
string references to defined (spot?) colors seemed to work but now does not; 
all of my colorful figures are now rendered only in shades of gray when using 
defined (spot?) colors….

The figure drawn by the MWE should have a dark orange border and a transparent 
(thin) orange fill. However, all colors of this sort seem to end up being a 
single shade of gray (e.g. black), rendering a box perfect for Halloween use 
but not for my current purposes. Is there a change to how colors defined in 
ConTeXt are referenced in MetaPost that I've missed or is there an issue with 
transferring color (name or parameter) information to MetaPost? Defined (spot?) 
colors work fine in ConTeXt but not in MetaPost.

Many thanks,
 ---K



% system  > ConTeXt  ver: 2021.07.21 19:54 LMTX  fmt: 2021.7.22  int: 
english/english

\startMPdefinitions

presetparameters "parameters_Test"
[
]

def Test =
applyparameters "parameters_Test" "do_Test"
enddef;

def do_Test =
pushparameters "parameters_Test";

string p;  p = getparameter "prefix";  show p;
string c;  c = getparameter "color";   show c;
path   s;  s = unitsquare scaled 10cm; show s;

fill s withpen pencircle scaled 5pt withcolor p
draw s withpen pencircle scaled 5pt withcolor   c;
enddef;

\stopMPdefinitions

\starttext

\definespotcolor[Thin:orange][orange][p=1,a=normal,t=0.5]

\color[orange]{hello}

\startalignment[center]
\startplacefigure
\startMPcode
Test [ prefix = "Thin", color = "orange" ];
\stopMPcode
\stopplacefigure
\stopalignment

\color[Thin:orange]{goodbye}

\stoptext




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] Metapost Animation of Sine

2021-07-22 Thread Jeroen
Hi, both solutions are great! This is what I had in mind, a rolling sine.
Is there a way to get the same result with the Tikz module?

\usemodule[animation]
\setupinteraction[state=start]

\starttext

\input tufte

\framed{
\startanimation[menu=yes,framerate=40]
\dorecurse{50}{\expanded
{\startframe
\startMPcode
numeric u, omega, mylength, tt ;
u := 2cm ;
omega := 4 ;
mylength := 3.141596 ;
tt := \recurselevel ;
path p ;
p := (0u,sin(omega*(mylength/100)*tt)*u) for i = 1 upto 100 :
.. (((mylength/100)*i)*u,sin(omega*(mylength/100)*(i + tt))*u)
endfor ;
draw p withpen pencircle scaled .5pt withcolor darkred ;
\stopMPcode
\stopframe}
}
\stopanimation
}

\stoptext

Op wo 21 jul. 2021 om 23:26 schreef Otared Kavian :

> Hi,
>
> I wonder whether something like the following is what you are looking for:
>
> % begin wave-sine.tex
> \usemodule[animation]
> \setupinteraction[state=start]
> \starttext
> \startTEXpage[offset=2pt]
> \startanimation[menu=yes,framerate=10]
> \dorecurse{100}{\expanded
> {\startframe
> \startMPcode
> numeric u, omega, mylength, tt ;
> u := 2cm ;
> omega := 4 ;
> mylength := 3.141596 ;
> tt := \recurselevel ;
> path p ;
> p := (0u,sin(omega*(mylength/100)*tt)*u) for i = 1
> upto 100 :
> ..
> (((mylength/100)*i)*u,sin(omega*(mylength/100)*(i + tt))*u)
> endfor ;
> draw p withpen pencircle scaled .5pt withcolor
> darkred ;
> \stopMPcode
> \stopframe}
> }
> \stopanimation
> \stopTEXpage
> \stoptext
> % end wave-sine.tex
>
> Best regards: OK
>
> > On 21 Jul 2021, at 19:44, Jeroen  wrote:
> >
> > I am looking for a sine animation as the one file f.pdf on this site
> >
> >
> http://www.12000.org/my_notes/Mathematica_animation_into_PDF_using_latex/index.htm
> >
> > Jeroen
> >
> > Op wo 21 jul. 2021 om 17:54 schreef Fabrice L :
> > Hi,
> >
> >> Le 21 juill. 2021 à 10:08, Jeroen  a écrit :
> >>
> >> I use this small animation to enlarge a circle
> >>
> >>
> >> \usemodule[animation]
> >> \setupinteraction[state=start]
> >> \starttext
> >> \startanimation[menu=yes,framerate=10]
> >> \dorecurse{7}{\expanded
> >>   {\startframe
> >> \startMPcode
> >> path p;
> >> numeric n, u;
> >> u := 1cm;
> >> n:=\recurselevel*u;
> >> p := fullcircle scaled n;
> >> draw p;
> >> \stopMPcode
> >>   \stopframe}}
> >> \stopanimation
> >> \stoptext
> >>
> >>
> >> This I use to draw a sine
> >>
> >>
> >> \starttext
> >> \startMPcode
> >>   draw(-90/360*1.5cm,-0.9cm) for i = -90 upto 630: ..
> (i/360*1.5cm,0.9cm*(sind(i)))endfor;
> >> \stopMPcode
> >> \stoptext
> >>
> >>
> >> When I put it together to animate the sine as following, it does not
> entirely create the sine animation I am looking for
> >>
> >>
> >> \usemodule[animation]
> >> \setupinteraction[state=start]
> >> \starttext
> >> \startanimation[menu=yes,framerate=10]
> >> \dorecurse{7}{\expanded
> >>   {\startframe
> >> \startMPcode
> >> path p;
> >> numeric n, u;
> >> u := 1cm;
> >> n:=\recurselevel*u;
> >> p := (-90/360*1.5cm,-0.9cm) for i = -90 upto 630: ..
> (i/360*1.5cm,0.9cm*(sind(i))) endfor shifted (n,0);
> >> draw p;
> >> \stopMPcode
> >> \stopframe}}
> >> \stopanimation
> >> \stoptext
> >>
> >>
> >> What better way can I create a sine animation with Metapost?
> >>
> >>
> >
> > Here is another way to do your animation. This is doing something, but I
> guess not what you want. Could you describe what do you have in mind ?
> >
> > \starttext
> > \dorecurse{7}{ % 3180
> > \startMPpage
> >   myvariable := #1 ;
> >   path p;
> > numeric n, u;
> > u := 1cm;
> > n:=myvariable*u;
> > p := (-90/360*1.5cm,-0.9cm) for i = -90 upto 630: ..
> (i/360*1.5cm,0.9cm*(sind(i))) endfor shifted (n,0);
> > draw p;
> > \stopMPpage
> > }
> > \stoptext
> >
> > Fabrice.
> >
> >
>

Re: [NTG-context] Metapost Animation of Sine

2021-07-21 Thread Otared Kavian
Hi,

Adding to my previous message, if you are looking for an animation of the wave 
equation for a string with fixed endpoints, one has to use something like the 
following:

% begin wave-sine-string.tex
\usemodule[animation]
\setupinteraction[state=start]
\starttext
\startTEXpage[offset=2pt]
\startanimation[menu=yes,framerate=10]
\dorecurse{101}{\expanded
{\startframe
\startMPcode
numeric u, omega, mylength, tt, N ;
u := 2cm ;
omega := 4 ;
mylength := 3.141596 ;
tt := \recurselevel - 1 ;
N := 500 ; % number of steps
path p ;
p := (0u,0u) for i = 1 upto N : 
-- 
(((mylength/N)*i)*u,cos(omega*(mylength/N)*tt)*sin(omega*(mylength/N)*i)*u) 
endfor ;
draw p withpen pencircle scaled .5pt withcolor darkred ;
\stopMPcode
\stopframe}
}
\stopanimation
\stopTEXpage
\stoptext
% end wave-sine-string.tex

Best regards: OK

> On 21 Jul 2021, at 19:44, Jeroen  wrote:
> 
> I am looking for a sine animation as the one file f.pdf on this site
> 
> http://www.12000.org/my_notes/Mathematica_animation_into_PDF_using_latex/index.htm
> 
> Jeroen
> 
> Op wo 21 jul. 2021 om 17:54 schreef Fabrice L :
> Hi,
> 
>> Le 21 juill. 2021 à 10:08, Jeroen  a écrit :
>> 
>> I use this small animation to enlarge a circle
>> 
>> 
>> \usemodule[animation]
>> \setupinteraction[state=start]
>> \starttext
>> \startanimation[menu=yes,framerate=10]
>> \dorecurse{7}{\expanded
>>   {\startframe
>> \startMPcode
>> path p;
>> numeric n, u;
>> u := 1cm;
>> n:=\recurselevel*u;
>> p := fullcircle scaled n;
>> draw p;
>> \stopMPcode
>>   \stopframe}}
>> \stopanimation
>> \stoptext
>> 
>> 
>> This I use to draw a sine
>> 
>> 
>> \starttext
>> \startMPcode
>>   draw(-90/360*1.5cm,-0.9cm) for i = -90 upto 630: .. 
>> (i/360*1.5cm,0.9cm*(sind(i)))endfor;
>> \stopMPcode
>> \stoptext
>> 
>> 
>> When I put it together to animate the sine as following, it does not 
>> entirely create the sine animation I am looking for
>> 
>> 
>> \usemodule[animation]
>> \setupinteraction[state=start]
>> \starttext
>> \startanimation[menu=yes,framerate=10]
>> \dorecurse{7}{\expanded
>>   {\startframe
>> \startMPcode
>> path p;
>> numeric n, u;
>> u := 1cm;
>> n:=\recurselevel*u;
>> p := (-90/360*1.5cm,-0.9cm) for i = -90 upto 630: .. 
>> (i/360*1.5cm,0.9cm*(sind(i))) endfor shifted (n,0);
>> draw p;
>> \stopMPcode
>> \stopframe}}
>> \stopanimation
>> \stoptext
>> 
>> 
>> What better way can I create a sine animation with Metapost?
>>  
>> 
> 
> Here is another way to do your animation. This is doing something, but I 
> guess not what you want. Could you describe what do you have in mind ?
> 
> \starttext
> \dorecurse{7}{ % 3180
> \startMPpage
>   myvariable := #1 ;
>   path p;
> numeric n, u;
> u := 1cm;
> n:=myvariable*u;
> p := (-90/360*1.5cm,-0.9cm) for i = -90 upto 630: .. 
> (i/360*1.5cm,0.9cm*(sind(i))) endfor shifted (n,0);
> draw p;
> \stopMPpage
> }
> \stoptext
> 
> Fabrice.
> 
> 
> ___
> 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] Metapost Animation of Sine

2021-07-21 Thread Otared Kavian
Hi, 

I wonder whether something like the following is what you are looking for:

% begin wave-sine.tex
\usemodule[animation]
\setupinteraction[state=start]
\starttext
\startTEXpage[offset=2pt]
\startanimation[menu=yes,framerate=10]
\dorecurse{100}{\expanded
{\startframe
\startMPcode
numeric u, omega, mylength, tt ;
u := 2cm ;
omega := 4 ;
mylength := 3.141596 ;
tt := \recurselevel ;
path p ;
p := (0u,sin(omega*(mylength/100)*tt)*u) for i = 1 upto 
100 : 
.. 
(((mylength/100)*i)*u,sin(omega*(mylength/100)*(i + tt))*u) 
endfor ;
draw p withpen pencircle scaled .5pt withcolor darkred ;
\stopMPcode
\stopframe}
}
\stopanimation
\stopTEXpage
\stoptext
% end wave-sine.tex

Best regards: OK

> On 21 Jul 2021, at 19:44, Jeroen  wrote:
> 
> I am looking for a sine animation as the one file f.pdf on this site
> 
> http://www.12000.org/my_notes/Mathematica_animation_into_PDF_using_latex/index.htm
> 
> Jeroen
> 
> Op wo 21 jul. 2021 om 17:54 schreef Fabrice L :
> Hi,
> 
>> Le 21 juill. 2021 à 10:08, Jeroen  a écrit :
>> 
>> I use this small animation to enlarge a circle
>> 
>> 
>> \usemodule[animation]
>> \setupinteraction[state=start]
>> \starttext
>> \startanimation[menu=yes,framerate=10]
>> \dorecurse{7}{\expanded
>>   {\startframe
>> \startMPcode
>> path p;
>> numeric n, u;
>> u := 1cm;
>> n:=\recurselevel*u;
>> p := fullcircle scaled n;
>> draw p;
>> \stopMPcode
>>   \stopframe}}
>> \stopanimation
>> \stoptext
>> 
>> 
>> This I use to draw a sine
>> 
>> 
>> \starttext
>> \startMPcode
>>   draw(-90/360*1.5cm,-0.9cm) for i = -90 upto 630: .. 
>> (i/360*1.5cm,0.9cm*(sind(i)))endfor;
>> \stopMPcode
>> \stoptext
>> 
>> 
>> When I put it together to animate the sine as following, it does not 
>> entirely create the sine animation I am looking for
>> 
>> 
>> \usemodule[animation]
>> \setupinteraction[state=start]
>> \starttext
>> \startanimation[menu=yes,framerate=10]
>> \dorecurse{7}{\expanded
>>   {\startframe
>> \startMPcode
>> path p;
>> numeric n, u;
>> u := 1cm;
>> n:=\recurselevel*u;
>> p := (-90/360*1.5cm,-0.9cm) for i = -90 upto 630: .. 
>> (i/360*1.5cm,0.9cm*(sind(i))) endfor shifted (n,0);
>> draw p;
>> \stopMPcode
>> \stopframe}}
>> \stopanimation
>> \stoptext
>> 
>> 
>> What better way can I create a sine animation with Metapost?
>>  
>> 
> 
> Here is another way to do your animation. This is doing something, but I 
> guess not what you want. Could you describe what do you have in mind ?
> 
> \starttext
> \dorecurse{7}{ % 3180
> \startMPpage
>   myvariable := #1 ;
>   path p;
> numeric n, u;
> u := 1cm;
> n:=myvariable*u;
> p := (-90/360*1.5cm,-0.9cm) for i = -90 upto 630: .. 
> (i/360*1.5cm,0.9cm*(sind(i))) endfor shifted (n,0);
> draw p;
> \stopMPpage
> }
> \stoptext
> 
> Fabrice.
> 
> 
> ___
> 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] Metapost Animation of Sine

2021-07-21 Thread Jeroen
I am looking for a sine animation as the one file f.pdf on this site

http://www.12000.org/my_notes/Mathematica_animation_into_PDF_using_latex/index.htm

Jeroen

Op wo 21 jul. 2021 om 17:54 schreef Fabrice L :

> Hi,
>
> Le 21 juill. 2021 à 10:08, Jeroen  a écrit :
>
> I use this small animation to enlarge a circle
>
>
> \usemodule[animation]
> \setupinteraction[state=start]
> \starttext
> \startanimation[menu=yes,framerate=10]
> \dorecurse{7}{\expanded
>   {\startframe
> \startMPcode
> path p;
> numeric n, u;
> u := 1cm;
> n:=\recurselevel*u;
> p := fullcircle scaled n;
> draw p;
> \stopMPcode
>   \stopframe}}
> \stopanimation
> \stoptext
>
>
> This I use to draw a sine
>
>
> \starttext
> \startMPcode
>   draw(-90/360*1.5cm,-0.9cm) for i = -90 upto 630: ..
> (i/360*1.5cm,0.9cm*(sind(i)))endfor;
> \stopMPcode
> \stoptext
>
>
> When I put it together to animate the sine as following, it does not
> entirely create the sine animation I am looking for
>
>
> \usemodule[animation]
> \setupinteraction[state=start]
> \starttext
> \startanimation[menu=yes,framerate=10]
> \dorecurse{7}{\expanded
>   {\startframe
> \startMPcode
> path p;
> numeric n, u;
> u := 1cm;
> n:=\recurselevel*u;
> p := (-90/360*1.5cm,-0.9cm) for i = -90 upto 630: ..
> (i/360*1.5cm,0.9cm*(sind(i))) endfor shifted (n,0);
> draw p;
> \stopMPcode
> \stopframe}}
> \stopanimation
> \stoptext
>
>
> What better way can I create a sine animation with Metapost?
>
>
>
>
> Here is another way to do your animation. This is doing something, but I
> guess not what you want. Could you describe what do you have in mind ?
>
> \starttext
> \dorecurse{7}{ % 3180
> \startMPpage
> myvariable := #1 ;
> path p;
> numeric n, u;
> u := 1cm;
> n:=myvariable*u;
> p := (-90/360*1.5cm,-0.9cm) for i = -90 upto 630: ..
> (i/360*1.5cm,0.9cm*(sind(i))) endfor shifted (n,0);
> draw p;
> \stopMPpage
> }
> \stoptext
>
> Fabrice.
>
>
>
> ___
> 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] Metapost Animation of Sine

2021-07-21 Thread Fabrice L
Hi,

> Le 21 juill. 2021 à 10:08, Jeroen  a écrit :
> 
> I use this small animation to enlarge a circle
> 
> 
> \usemodule[animation]
> \setupinteraction[state=start]
> \starttext
> \startanimation[menu=yes,framerate=10]
> \dorecurse{7}{\expanded
>   {\startframe
> \startMPcode
> path p;
> numeric n, u;
> u := 1cm;
> n:=\recurselevel*u;
> p := fullcircle scaled n;
> draw p;
> \stopMPcode
>   \stopframe}}
> \stopanimation
> \stoptext
> 
> 
> This I use to draw a sine
> 
> 
> \starttext
> \startMPcode
>   draw(-90/360*1.5cm,-0.9cm) for i = -90 upto 630: .. 
> (i/360*1.5cm,0.9cm*(sind(i)))endfor;
> \stopMPcode
> \stoptext
> 
> 
> When I put it together to animate the sine as following, it does not entirely 
> create the sine animation I am looking for
> 
> 
> \usemodule[animation]
> \setupinteraction[state=start]
> \starttext
> \startanimation[menu=yes,framerate=10]
> \dorecurse{7}{\expanded
>   {\startframe
> \startMPcode
> path p;
> numeric n, u;
> u := 1cm;
> n:=\recurselevel*u;
> p := (-90/360*1.5cm,-0.9cm) for i = -90 upto 630: .. 
> (i/360*1.5cm,0.9cm*(sind(i))) endfor shifted (n,0);
> draw p;
> \stopMPcode
> \stopframe}}
> \stopanimation
> \stoptext
> 
> 
> What better way can I create a sine animation with Metapost?
>  
> 

Here is another way to do your animation. This is doing something, but I guess 
not what you want. Could you describe what do you have in mind ?

\starttext
\dorecurse{7}{ % 3180
\startMPpage
myvariable := #1 ;
path p;
numeric n, u;
u := 1cm;
n:=myvariable*u;
p := (-90/360*1.5cm,-0.9cm) for i = -90 upto 630: .. 
(i/360*1.5cm,0.9cm*(sind(i))) endfor shifted (n,0);
draw p;
\stopMPpage
}
\stoptext

Fabrice.


___
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 Animation of Sine

2021-07-21 Thread Jeroen
I use this small animation to enlarge a circle


\usemodule[animation]
\setupinteraction[state=start]
\starttext
\startanimation[menu=yes,framerate=10]
\dorecurse{7}{\expanded
  {\startframe
\startMPcode
path p;
numeric n, u;
u := 1cm;
n:=\recurselevel*u;
p := fullcircle scaled n;
draw p;
\stopMPcode
  \stopframe}}
\stopanimation
\stoptext


This I use to draw a sine


\starttext
\startMPcode
  draw(-90/360*1.5cm,-0.9cm) for i = -90 upto 630: ..
(i/360*1.5cm,0.9cm*(sind(i)))endfor;
\stopMPcode
\stoptext


When I put it together to animate the sine as following, it does not
entirely create the sine animation I am looking for


\usemodule[animation]
\setupinteraction[state=start]
\starttext
\startanimation[menu=yes,framerate=10]
\dorecurse{7}{\expanded
  {\startframe
\startMPcode
path p;
numeric n, u;
u := 1cm;
n:=\recurselevel*u;
p := (-90/360*1.5cm,-0.9cm) for i = -90 upto 630: ..
(i/360*1.5cm,0.9cm*(sind(i))) endfor shifted (n,0);
draw p;
\stopMPcode
\stopframe}}
\stopanimation
\stoptext


What better way can I create a sine animation with Metapost?
___
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] mp-geo Metapost package with ConTeXt

2021-07-18 Thread Henning Hraban Ramm

> Am 17.07.2021 um 20:50 schrieb Hans Hagen :
> 
> On 7/17/2021 2:42 PM, Arthur Rosendahl wrote:
>> On Sat, Jul 17, 2021 at 12:53:33PM +0200, Hans Hagen wrote:
>>> Just as an example, the context meeting is att the attached location:
>>> 
>>>   50°45’7” / 5°35’19”
>>> 
>>> https://www.openstreetmap.org/export#map=18/50.75175/5.58883
>>   If you want official data you can try the Belgian cadastre:
>> https://data.gov.be/en/dataset/tt098dcb-f5c7-49b8-8e0b-7c3811630d85 :-)
> Yet another format? No way. I managed to go big so for instance the area 
> where the colorado user group is located:
> 
>  https://www.openstreetmap.org/export#map=12/40.5117/-104.9496
> 
> produces a 122 MB osm file
> 
>  https://overpass-api.de/api/map?bbox=-105.1817,40.4096,-104.9493,40.6272
> 
> that gets turned into a 15 MB metapost file that becomes an 8.7 MB pdf file. 
> Unfortunately it takes 36 seconds to be produced (9 seconds xml loading, 17 
> seconds map processing, 3 seconds mp -- which is not that bad -- and some 
> 2.56 seconds pdf production) plus some 3 GB memory but that's still under my 
> limit. Maybe a decent modern desktop can do it in half that time, who knows.
> 
> Of course the rather detailed colorfull image is a challenge for the pdf 
> viewer but (sumatra) it manages and one can then zoom in a lot. I tried the 
> whole of slovenia to prove myself to mojca but overran my quota for that api 
> (and I'm not in the mood to install all kind of stuff here).

I downloaded a few countries for you:
https://sedna.fiee.net/d/328d53f6a3e04b23aee2/

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] mp-geo Metapost package with ConTeXt

2021-07-17 Thread Hans Hagen

On 7/17/2021 2:42 PM, Arthur Rosendahl wrote:

On Sat, Jul 17, 2021 at 12:53:33PM +0200, Hans Hagen wrote:

Just as an example, the context meeting is att the attached location:

   50°45’7” / 5°35’19”

https://www.openstreetmap.org/export#map=18/50.75175/5.58883


   If you want official data you can try the Belgian cadastre:
https://data.gov.be/en/dataset/tt098dcb-f5c7-49b8-8e0b-7c3811630d85 :-)
Yet another format? No way. I managed to go big so for instance the area 
where the colorado user group is located:


  https://www.openstreetmap.org/export#map=12/40.5117/-104.9496

produces a 122 MB osm file

  https://overpass-api.de/api/map?bbox=-105.1817,40.4096,-104.9493,40.6272

that gets turned into a 15 MB metapost file that becomes an 8.7 MB pdf 
file. Unfortunately it takes 36 seconds to be produced (9 seconds xml 
loading, 17 seconds map processing, 3 seconds mp -- which is not that 
bad -- and some 2.56 seconds pdf production) plus some 3 GB memory but 
that's still under my limit. Maybe a decent modern desktop can do it in 
half that time, who knows.


Of course the rather detailed colorfull image is a challenge for the pdf 
viewer but (sumatra) it manages and one can then zoom in a lot. I tried 
the whole of slovenia to prove myself to mojca but overran my quota for 
that api (and I'm not in the mood to install all kind of stuff here).


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] mp-geo Metapost package with ConTeXt

2021-07-17 Thread Arthur Rosendahl
On Sat, Jul 17, 2021 at 12:53:33PM +0200, Hans Hagen wrote:
> Just as an example, the context meeting is att the attached location:
> 
>   50°45’7” / 5°35’19”
> 
> https://www.openstreetmap.org/export#map=18/50.75175/5.58883

  If you want official data you can try the Belgian cadastre:
https://data.gov.be/en/dataset/tt098dcb-f5c7-49b8-8e0b-7c3811630d85 :-)

Best,

Arthur
___
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] mp-geo Metapost package with ConTeXt

2021-07-17 Thread Henning Hraban Ramm

> Am 17.07.2021 um 12:45 schrieb Hans Hagen :
> 
> On 7/17/2021 12:20 PM, Henning Hraban Ramm wrote:
>>> Am 17.07.2021 um 11:53 schrieb Bruce Horrocks :
>>> 
>>> 
>>> 
>>>> On 16 Jul 2021, at 20:55, Hans Hagen  wrote:
>>>> 
>>>> On 7/15/2021 10:30 PM, Bruce Horrocks wrote:
>>>>> On 15 Jul 2021, at 18:58, Hans Hagen  wrote:
>>>>>> 
>>>>>> I was wondering about that too. I admit that I looked into maps years 
>>>>>> ago but never could find quality data files.
>>>>> Does this help?
>>>>> <https://www.naturalearthdata.com>
>>>> i was halfway writing as reader for that fiel format when i noticed that 
>>>> is is also quite low res so i gave up on that and started playing 
>>>> (extending) with an more interesting alternative that mojca and i wrote 
>>>> years ago at a meeting
>>> 
>>> Off the top of my head I'm not aware of any higher resolution sources of 
>>> global data - what scale were you thinking of?
>> Can you work with OpenStreetMap data?
>> https://planet.openstreetmap.org
>> http://download.geofabrik.de
>> https://download.bbbike.org/osm/
>> I didn’t find excerpts that only have e.g. country borders or rivers. But 
>> with usual XML tools you could extract those.
> Indeed, that is what I was referring too. Mojca found this:
>  https://osm-boundaries.com/

Ah, our mails crossed...

> At a bachotex meeting (years ago, when the ctx group donated a nice roadmap 
> display to the conference) we made an openstreetmap -> metapost style but 
> afaik that never made it into a module. So, when I remembered that I updated 
> it. I can now render my hometown (need to figure out colors) quite okay. (One 
> can export an osm file in openstreetmap but with some limitations on size.)
> 
> I have to play a bit more with the style before I define it useable but the 
> interface is liek this:
> 
> % where i live
> 
> \startMPpage
>draw lmt_openstreetmap [
>filename = "hasselt.osm"
>grid = "dots",
>] ;
> \stopMPpage
> 
> % island in paris
> 
> \startMPpage
>draw lmt_openstreetmap [
>filename = "e:/tmp/map.osm"
>] ;
> \stopMPpage
> 
> The hasselt osm file is sime 12 MB, the colorful hasselt pdf file just below 
> 1 MB so that's okay (3.7 sec processing time on my machine so if all claims 
> are right sub seconds on a fast new apple).
> 
> Of course I need to make colors and what gets rendered configurable (via the 
> interface). It's more about the fun aspect .. no need to typeset complete 
> routes because that's what the web is for.

For our architectural guides I make maps with OSM data and Maperitive. It’s a 
PITA (sooo slow with Mono on OSX and hadly documented), but works.
Maperitive uses "mrules" style files (example attached).

[call]

mono --desktop Maperitive/Maperitive.Console.exe -defaultscript=false 
../baukultur.mscript
inkscape -z -f citymap.svgz -A citymap.pdf


[baukultur.mscript]

set-setting name=map.decoration.attribution value=false
set-setting name=map.decoration.grid value=false
set-setting name=map.decoration.scale value=false
set-setting name=map.rendering.font-family value="AlegreyaSans"

use-ruleset location=Maperitive/Rules/baukultur.mrules
// load some additional data, e.g. markers
load-source archiguide.osm
// exported OSM city map
load-source bonn.osm

// Stadthalle BG
move-pos y=50.68064 x=7.15849 zoom=17
set-home
set-geo-bounds 7.153,50.6840,7.162,50.6772
set-print-bounds-geo 7.153,50.6840,7.162,50.6772
export-svg file=citymap.svgz compatibility=inkscape map-scale=5000


Hraban




baukultur.mrules
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] mp-geo Metapost package with ConTeXt

2021-07-17 Thread Hans Hagen

Hi,

Just as an example, the context meeting is att the attached location:

  50°45’7” / 5°35’19”

https://www.openstreetmap.org/export#map=18/50.75175/5.58883

(Okay, I need to use a railway track dash pattern "railway".)

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
-


m-openstreetmap.pdf
Description: Adobe PDF document
___
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] mp-geo Metapost package with ConTeXt

2021-07-17 Thread Henning Hraban Ramm

> Am 17.07.2021 um 12:20 schrieb Henning Hraban Ramm :
> 
>> 
>> Am 17.07.2021 um 11:53 schrieb Bruce Horrocks :
>> 
>> 
>> 
>>> On 16 Jul 2021, at 20:55, Hans Hagen  wrote:
>>> 
>>> On 7/15/2021 10:30 PM, Bruce Horrocks wrote:
 On 15 Jul 2021, at 18:58, Hans Hagen  wrote:
> 
> I was wondering about that too. I admit that I looked into maps years ago 
> but never could find quality data files.
 Does this help?
 
>>> i was halfway writing as reader for that fiel format when i noticed that is 
>>> is also quite low res so i gave up on that and started playing (extending) 
>>> with an more interesting alternative that mojca and i wrote years ago at a 
>>> meeting
>> 
>> Off the top of my head I'm not aware of any higher resolution sources of 
>> global data - what scale were you thinking of?
> 
> Can you work with OpenStreetMap data?
> 
> https://planet.openstreetmap.org
> http://download.geofabrik.de
> https://download.bbbike.org/osm/
> 
> I didn’t find excerpts that only have e.g. country borders or rivers. But 
> with usual XML tools you could extract those.

There’s https://osm-boundaries.com, but it doesn’t really work (for me).

You should also be able to select elements via Overpass API, but it doesn’t 
work reliably for me at http://overpass-turbo.eu

This is the query for mainland Netherlands:
curl --remote-name --remote-header-name --location --max-redirs -1 
"https://osm-boundaries.com/Download/Submit?db=osm20210531=-2323309,-1216720=GeoJSON=4326=1;

You also need an API key that depends on your OSM account. Result attached.

Hraban



OSMB-dcc52d93616707aa0f6d582c82816ed1034354d6.geojson.gz
Description: GNU Zip compressed 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] mp-geo Metapost package with ConTeXt

2021-07-17 Thread Hans Hagen

On 7/17/2021 12:20 PM, Henning Hraban Ramm wrote:



Am 17.07.2021 um 11:53 schrieb Bruce Horrocks :




On 16 Jul 2021, at 20:55, Hans Hagen  wrote:

On 7/15/2021 10:30 PM, Bruce Horrocks wrote:

On 15 Jul 2021, at 18:58, Hans Hagen  wrote:


I was wondering about that too. I admit that I looked into maps years ago but 
never could find quality data files.

Does this help?
<https://www.naturalearthdata.com>

i was halfway writing as reader for that fiel format when i noticed that is is 
also quite low res so i gave up on that and started playing (extending) with an 
more interesting alternative that mojca and i wrote years ago at a meeting


Off the top of my head I'm not aware of any higher resolution sources of global 
data - what scale were you thinking of?


Can you work with OpenStreetMap data?

https://planet.openstreetmap.org
http://download.geofabrik.de
https://download.bbbike.org/osm/

I didn’t find excerpts that only have e.g. country borders or rivers. But with 
usual XML tools you could extract those.

Indeed, that is what I was referring too. Mojca found this:

  https://osm-boundaries.com/

At a bachotex meeting (years ago, when the ctx group donated a nice 
roadmap display to the conference) we made an openstreetmap -> metapost 
style but afaik that never made it into a module. So, when I remembered 
that I updated it. I can now render my hometown (need to figure out 
colors) quite okay. (One can export an osm file in openstreetmap but 
with some limitations on size.)


I have to play a bit more with the style before I define it useable but 
the interface is liek this:


% where i live

\startMPpage
draw lmt_openstreetmap [
filename = "hasselt.osm"
grid = "dots",
] ;
\stopMPpage

% island in paris

\startMPpage
draw lmt_openstreetmap [
filename = "e:/tmp/map.osm"
] ;
\stopMPpage

The hasselt osm file is sime 12 MB, the colorful hasselt pdf file just 
below 1 MB so that's okay (3.7 sec processing time on my machine so if 
all claims are right sub seconds on a fast new apple).


Of course I need to make colors and what gets rendered configurable (via 
the interface). It's more about the fun aspect .. no need to typeset 
complete routes because that's what the web is for.


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] mp-geo Metapost package with ConTeXt

2021-07-17 Thread Henning Hraban Ramm

> Am 17.07.2021 um 11:53 schrieb Bruce Horrocks :
> 
> 
> 
>> On 16 Jul 2021, at 20:55, Hans Hagen  wrote:
>> 
>> On 7/15/2021 10:30 PM, Bruce Horrocks wrote:
>>> On 15 Jul 2021, at 18:58, Hans Hagen  wrote:
 
 I was wondering about that too. I admit that I looked into maps years ago 
 but never could find quality data files.
>>> Does this help?
>>> 
>> i was halfway writing as reader for that fiel format when i noticed that is 
>> is also quite low res so i gave up on that and started playing (extending) 
>> with an more interesting alternative that mojca and i wrote years ago at a 
>> meeting
> 
> Off the top of my head I'm not aware of any higher resolution sources of 
> global data - what scale were you thinking of?

Can you work with OpenStreetMap data?

https://planet.openstreetmap.org
http://download.geofabrik.de
https://download.bbbike.org/osm/

I didn’t find excerpts that only have e.g. country borders or rivers. But with 
usual XML tools you could extract those.

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] mp-geo Metapost package with ConTeXt

2021-07-17 Thread Bruce Horrocks


> On 16 Jul 2021, at 20:55, Hans Hagen  wrote:
> 
> On 7/15/2021 10:30 PM, Bruce Horrocks wrote:
>> On 15 Jul 2021, at 18:58, Hans Hagen  wrote:
>>> 
>>> I was wondering about that too. I admit that I looked into maps years ago 
>>> but never could find quality data files.
>> Does this help?
>> 
> i was halfway writing as reader for that fiel format when i noticed that is 
> is also quite low res so i gave up on that and started playing (extending) 
> with an more interesting alternative that mojca and i wrote years ago at a 
> meeting

Off the top of my head I'm not aware of any higher resolution sources of global 
data - what scale were you thinking of?

For the UK there are free maps down to street level, either as a single file or 
API. The API details are here:


The license allows free use for apps made available to the public.

—
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] mp-geo Metapost package with ConTeXt

2021-07-16 Thread Alan Braslau

On 16/07/21 21:51, Hans Hagen wrote:

On 7/16/2021 4:53 PM, Gavin Polhemus wrote:

P.S. I marked the location of our local ConTeXt users group on the 
map, in case any of you want to visit.
1/3rd of your user group fled the country and is way closer by where i 
live now,


And in the same time zone!

--
Alan
___
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] mp-geo Metapost package with ConTeXt

2021-07-16 Thread Hans Hagen

On 7/15/2021 10:30 PM, Bruce Horrocks wrote:

On 15 Jul 2021, at 18:58, Hans Hagen  wrote:


I was wondering about that too. I admit that I looked into maps years ago but 
never could find quality data files.


Does this help?

i was halfway writing as reader for that fiel format when i noticed that 
is is also quite low res so i gave up on that and started playing 
(extending) with an more interesting alternative that mojca and i wrote 
years ago at a meeting


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] mp-geo Metapost package with ConTeXt

2021-07-16 Thread Hans Hagen

On 7/16/2021 4:53 PM, Gavin Polhemus wrote:


P.S. I marked the location of our local ConTeXt users group on the map, in case 
any of you want to visit.
1/3rd of your user group fled the country and is way closer by where i 
live 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
___


Re: [NTG-context] mp-geo Metapost package with ConTeXt

2021-07-16 Thread Gavin
Hi Hans, Aditya, and all,

Me:
>>>> I’d like to use the mp-geo Metapost package with ConTeXt to draw simple
>>> globes viewed from various directions. The package is here:
>>>> 
>>>>https://melusine.eu.org/syracuse/poulecl/mp-geo/ 
>>>> <https://melusine.eu.org/syracuse/poulecl/mp-geo/>

Aditya:
>> Actually the data files are fairly simple:
>> no_of_points
>> 
>> So, it would be much simpler to read and parse it via lua rather than 
>> scantokens. Rest of the code simply determines a "view" of what to show. So, 
>> it can be a good exercise in lua-MP interface.

Hans:
> I was wondering about that too. I admit that I looked into maps years ago but 
> never could find quality data files.

This is great fun! I slightly altered Hans’ code to produce the most basic area 
preserving projection of North America (code and map below). If anyone else is 
playing with the mp-geo data, it is in arc minutes, so divide by 60 to get 
degrees.

For my book I only want 5cm diameter globes with continents, so the map data in 
the mp-geo package is far more detailed than I need. The code is so fast, the 
detail doesn’t seem to be a problem.

I just started learning Metapost a month ago, and it’s great. I know almost 
nothing about Lua, but this looks like a fun project for learning more!

Thanks!
Gavin


P.S. I marked the location of our local ConTeXt users group on the map, in case 
any of you want to visit.


\starttext

\startluacode
  function mp.maptopath(filename)
  local t = { cycle = true }
  for phi, theta in 
string.gmatch(io.loaddata(filename),"%(([%+%-%d]+),([%+%-%d]+)%)") do
  t[#t+1] = { math.cosd(tonumber(phi)/60)*tonumber(theta+6125)/12, 
tonumber(phi)/12 }
  end
  mp.inject.path(t)
  end
\stopluacode

\startMPpage
  fill lua.mp.maptopath("data/usa1.dat");
  fill lua.mp.maptopath("data/usa2.dat") ;
  fill lua.mp.maptopath("data/mexique.dat") ;
  fill lua.mp.maptopath("data/canada.dat") ;
  fill fullcircle scaled 5 shifted (0, 203) 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] mp-geo Metapost package with ConTeXt

2021-07-15 Thread Bruce Horrocks
On 15 Jul 2021, at 18:58, Hans Hagen  wrote:
> 
> I was wondering about that too. I admit that I looked into maps years ago but 
> never could find quality data files.

Does this help?


—
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] mp-geo Metapost package with ConTeXt

2021-07-15 Thread Hans Hagen

On 7/15/2021 6:22 PM, Aditya Mahajan wrote:

On Thu, 15 Jul 2021, Hans Hagen wrote:


On 7/14/2021 4:43 PM, Gavin wrote:

Hello ConTeXters,

I’d like to use the mp-geo Metapost package with ConTeXt to draw simple

globes viewed from various directions. The package is here:


https://melusine.eu.org/syracuse/poulecl/mp-geo/

It looks like the last update was 2008 and I don’t read French, so I though

my chances of getting anything to work were pretty small. However, I was
pleasantly surprised that this MWE found the mp-geo package, the necessary
Metapost files in the ConTeXt installation, and the data files.


\starttext
\startMPcode
input mp-geo;
figure(-10u,-10u,10u,10u);
Mercator(3,48,30);
fin;
end
\stopMPcode
\stoptext

While all of the files were found, it did not produce a globe. Instead I got

an error complaining about an invalid character in the data files. This error
is repeated for about 20 files (a small fraction of the total). I put the
first error and its data file below. All the others are identical with
different .dat files.


Maybe it’s just an encoding mismatch or a hidden character I can easily

delete or replace. On the other hand, maybe I shouldn't even be attempting
this? 2008 is a long time ago in ConTeXt time. Feel free to tell me this
project is crazy, but if you have an idea how I can make this work, I’d really
appreciate it! It looks like a fun package.
Looks interesting (I didn't know about it, also the surface stuff).
Anyway, the message relates to scantokens not liking what gets read from
a file, quite probably a missing file (I'll make it return a different
message but still one needs to be aware of the fact that fiel reading in
mp is kind of weird so it really expects a file).


Actually the data files are fairly simple:

no_of_points


So, it would be much simpler to read and parse it via lua rather than scantokens. Rest of 
the code simply determines a "view" of what to show. So, it can be a good 
exercise in lua-MP interface.


I was wondering about that too. I admit that I looked into maps years 
ago but never could find quality data files.


\starttext

\startluacode
function mp.maptopath(filename)
local t = { cycle = true }
for x, y in 
string.gmatch(io.loaddata(filename),"%(([%+%-%d]+),([%+%-%d]+)%)") do

t[#t+1] = { tonumber(x), tonumber(y) }
end
mp.inject.path(t)
end
\stopluacode

\startMPpage
draw lua.mp.maptopath("slovenia.dat") ;
\stopMPpage

\startMPpage
draw lua.mp.maptopath("usa1.dat") rotated 90 ;
\stopMPpage

\startMPpage
draw lua.mp.maptopath("usa2.dat") ;
\stopMPpage

\stoptext

way to low quality ... we also want multiple shapes i guess .. i wonder 
if someone knows where to get good free data


(projections are more your turf)

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] mp-geo Metapost package with ConTeXt

2021-07-15 Thread Aditya Mahajan
On Thu, 15 Jul 2021, Hans Hagen wrote:

> On 7/14/2021 4:43 PM, Gavin wrote:
> > Hello ConTeXters,
> > 
> > I’d like to use the mp-geo Metapost package with ConTeXt to draw simple
> globes viewed from various directions. The package is here:
> > 
> > https://melusine.eu.org/syracuse/poulecl/mp-geo/
> > 
> > It looks like the last update was 2008 and I don’t read French, so I though
> my chances of getting anything to work were pretty small. However, I was
> pleasantly surprised that this MWE found the mp-geo package, the necessary
> Metapost files in the ConTeXt installation, and the data files.
> > 
> > \starttext
> > \startMPcode
> > input mp-geo;
> > figure(-10u,-10u,10u,10u);
> > Mercator(3,48,30);
> > fin;
> > end
> > \stopMPcode
> > \stoptext
> > 
> > While all of the files were found, it did not produce a globe. Instead I got
> an error complaining about an invalid character in the data files. This error
> is repeated for about 20 files (a small fraction of the total). I put the
> first error and its data file below. All the others are identical with
> different .dat files.
> > 
> > Maybe it’s just an encoding mismatch or a hidden character I can easily
> delete or replace. On the other hand, maybe I shouldn't even be attempting
> this? 2008 is a long time ago in ConTeXt time. Feel free to tell me this
> project is crazy, but if you have an idea how I can make this work, I’d really
> appreciate it! It looks like a fun package.
> Looks interesting (I didn't know about it, also the surface stuff). 
> Anyway, the message relates to scantokens not liking what gets read from 
> a file, quite probably a missing file (I'll make it return a different 
> message but still one needs to be aware of the fact that fiel reading in 
> mp is kind of weird so it really expects a file).

Actually the data files are fairly simple: 

no_of_points


So, it would be much simpler to read and parse it via lua rather than 
scantokens. Rest of the code simply determines a "view" of what to show. So, it 
can be a good exercise in lua-MP interface.

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] mp-geo Metapost package with ConTeXt

2021-07-15 Thread Hans Hagen

On 7/14/2021 4:43 PM, Gavin wrote:

Hello ConTeXters,

I’d like to use the mp-geo Metapost package with ConTeXt to draw simple globes 
viewed from various directions. The package is here:

https://melusine.eu.org/syracuse/poulecl/mp-geo/

It looks like the last update was 2008 and I don’t read French, so I though my 
chances of getting anything to work were pretty small. However, I was 
pleasantly surprised that this MWE found the mp-geo package, the necessary 
Metapost files in the ConTeXt installation, and the data files.

\starttext
\startMPcode
input mp-geo;
figure(-10u,-10u,10u,10u);
Mercator(3,48,30);
fin;
end
\stopMPcode
\stoptext

While all of the files were found, it did not produce a globe. Instead I got an 
error complaining about an invalid character in the data files. This error is 
repeated for about 20 files (a small fraction of the total). I put the first 
error and its data file below. All the others are identical with different .dat 
files.

Maybe it’s just an encoding mismatch or a hidden character I can easily delete 
or replace. On the other hand, maybe I shouldn't even be attempting this? 2008 
is a long time ago in ConTeXt time. Feel free to tell me this project is crazy, 
but if you have an idea how I can make this work, I’d really appreciate it! It 
looks like a fun package.
Looks interesting (I didn't know about it, also the surface stuff). 
Anyway, the message relates to scantokens not liking what gets read from 
a file, quite probably a missing file (I'll make it return a different 
message but still one needs to be aware of the fact that fiel reading in 
mp is kind of weird so it really expects a file).


That said, there are some issues that you need to sort out: no btex/etex 
and no TEX command but textext instead. You could ask the authors.


There are indeed funny characters in the files but nothing your 
bilingual local context user group member Alan couldn't help you with (a 
good reason to visit him. My french is too rusty (even with some french 
music running in the background right now.)


If you can get that code running it makes a nice article.

Hans

PS. 2008 is not that old, many context commands date from the 90's


-
  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-geo Metapost package with ConTeXt

2021-07-14 Thread Gavin
Hello ConTeXters,

I’d like to use the mp-geo Metapost package with ConTeXt to draw simple globes 
viewed from various directions. The package is here:

https://melusine.eu.org/syracuse/poulecl/mp-geo/

It looks like the last update was 2008 and I don’t read French, so I though my 
chances of getting anything to work were pretty small. However, I was 
pleasantly surprised that this MWE found the mp-geo package, the necessary 
Metapost files in the ConTeXt installation, and the data files.

\starttext
\startMPcode
input mp-geo;
figure(-10u,-10u,10u,10u);
Mercator(3,48,30);
fin;
end
\stopMPcode
\stoptext

While all of the files were found, it did not produce a globe. Instead I got an 
error complaining about an invalid character in the data files. This error is 
repeated for about 20 files (a small fraction of the total). I put the first 
error and its data file below. All the others are identical with different .dat 
files.

Maybe it’s just an encoding mismatch or a hidden character I can easily delete 
or replace. On the other hand, maybe I shouldn't even be attempting this? 2008 
is a long time ago in ConTeXt time. Feel free to tell me this project is crazy, 
but if you have an idea how I can make this work, I’d really appreciate it! It 
looks like a fun package.

Thanks!
Gavin


Error Log: (This error log below is actually from running Metapost directly on 
just the .mp file with the metapost code above. This error log is slightly more 
clear in its formatting than the ConTeXt log, but contains the same 
information.)

! Text line contains an invalid character.
 ^^@

 
   ;
Lecture->...nblec:=scantokens.readfrom.NomFichier;
  for.w=1upto.nblec:if.proje...

Mercator->...((EXPR4));Lecture("Cameriquesud.dat")
  ;Lecture("Ccaraibes.dat");...
l.3 Mercator(3,48,30)
 ;
? 
! An expression can't begin with `;'.
 
0
 
   ;
Lecture->...nblec:=scantokens.readfrom.NomFichier;
  for.w=1upto.nblec:if.proje...

Mercator->...((EXPR4));Lecture("Cameriquesud.dat")
  ;Lecture("Ccaraibes.dat");...
l.3 Mercator(3,48,30)
 ;


Data file Cameriquesud.dat is pretty short:

16
arborescence&"bresil.dat",vert
arborescence&"uruguay.dat",jaune
arborescence&"paraguay.dat",jaune
arborescence&"bolivie1.dat",bleu
arborescence&"bolivie2.dat",bleu
arborescence&"argentine1.dat",rouge
arborescence&"argentine2.dat",rouge
arborescence&"chili1.dat",violet
arborescence&"chili2.dat",violet
arborescence&"guineef.dat",jaune
arborescence&"surinam.dat",rouge
arborescence&"guyane.dat",orange
arborescence&"venezuela.dat",bleu
arborescence&"colombie.dat",rouge
arborescence&"perou.dat",rose
arborescence&"equateur.dat",jaune

___
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] Hand Style Sketching in Metapost

2021-05-21 Thread Jeroen
I have updated LMTX and indeed seems to be working now

Thanks

Op do 20 mei 2021 om 21:05 schreef Aditya Mahajan :

> On Thu, 20 May 2021, Jeroen wrote:
>
> > I have the following working example with hatching. This works fine, but
> > when I uncomment the sketching commands, no figure is rendered. Is the
> > mp-sketch macro still working?
>
> Seems to be working here with LMTX ver. 2021.04.29. See attached.
>
>
> 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] Hand Style Sketching in Metapost

2021-05-20 Thread Aditya Mahajan
On Thu, 20 May 2021, Jeroen wrote:

> I have the following working example with hatching. This works fine, but
> when I uncomment the sketching commands, no figure is rendered. Is the
> mp-sketch macro still working?

Seems to be working here with LMTX ver. 2021.04.29. See attached.

Aditya

hatch.pdf
Description: Adobe PDF document


hatch.tex
Description: TeX document
%D \module
%D   [   file=mp-sketch.mp
%Dversion=2021.05.13
%D  title=\CONTEXT\ \METAPOST\ graphics,
%D   subtitle=Sketch drawing,
%D author=Aditya Mahajan,
%D   date=\currentdate,
%D  copyright={Aditya Mahajan}]

%D This metapost module is inspired by a TeX.SE question:
%D http://tex.stackexchange.com/q/39296/323
%D
%D I thought that it would be fun to implement a similar feature in MetaPost.
%D
%D To use this package in MetaPost:
%D
%D \starttyping
%Dinput mp-sketch;
%D
%Dbeginfig(1)
%D  sketchypaths; % Make draw and fill sketchy
%D  ...
%D  naturalizepaths; % Restore the value of draw and fill
%D  ...
%Dendfig
%D \stoptyping
%D
%D The code is heavily inspired by Hans Hagen's Metafun macros.
%D
%D The macro \type{sketchypaths} is modeled after \type{visualizepaths} from
%D \filename{mp-tool}.

def sketchypaths =
let draw = sketchdraw ;
let fill = sketchfill ;
enddef ;

%D Check if \filename{mp-tool} is loaded
if not known context_tool :
  let normaldraw = draw;
  let normalfill = fill;

  def naturalizepaths =
  let fill = normalfill ;
  let draw = normaldraw ;
  enddef ;
fi

%D The variable \type{sketch_amount} determines the amount of randomness in the
%D drawing
numeric sketch_amount; sketch_amount := 0.75bp;

%D The variable \type{sketch_passes} determines the number of times the path
%D is drawn
numeric sketch_passes; sketch_passes := 1;

%D Based on \type{randomized}. Assumes p is path:
numeric sketch_segments; sketch_segments := 20;

primarydef p sketchrandomized s = (
if path p :
for t = 0 step 1/sketch_segments until 1-1/sketch_segments : 
((point   (t*arclength(p)) on p) 
randomshifted s) .. controls
((postcontrol (t*arclength(p)) on p) 
randomshifted s) and
((precontrol  ((t+1/sketch_segments)*arclength(p)) on p) 
randomshifted s) ..
endfor
if cycle p :
cycle
else :
((point arclength(p) on p) randomshifted s)
fi
else :
p
fi
) enddef ;


%D The macro \type{sketchdraw} draws the randomized path. The 
%D \type{expr} ... \type{text} trick is copied from the definition of 
%D \type{drawarrow}
def sketchdraw expr p =
   do_sketchdraw(p)
enddef;

def do_sketchdraw(expr p) text t =
  if (path p) :
  for i = 1 upto max(1,sketch_passes) :
normaldraw p 
   sketchrandomized sketch_amount 
   withtransparency ("multiply", 1/max(1,sketch_passes))
   t ;
  endfor;
  else :
  normaldraw p t;
  fi
enddef;

%D The macro \type{sketchfill} randomizes the path before filling it.
def sketchfill expr p =
  do_sketchfill(p)
enddef ;

def do_sketchfill(expr p) text t =
  if (path p) :
  for i = 1 upto max(1,sketch_passes) :
normalfill p 
   randomized sketch_amount 
   withtransparency ("multiply", 1/max(1,sketch_passes))
   t ;
  endfor;
  else :
  normalfill p t;
  fi
enddef;

endinput;

% Modified example from
% http://tex.loria.fr/prod-graph/zoonekynd/metapost/metapost.html

beginfig(1)
  pair A,B,C,O;
  A=(0,0); B=(3cm,0); C=(1cm,2cm);

  O - 1/2[B,C] = whatever * (B-C) rotated 90;
  O - 1/2[A,B] = whatever * (A-B) rotated 90;

  sketchypaths;
  sketch_amount := 5bp;
  draw A--B--C--cycle;

  draw O withpen pencircle scaled 4bp;

  sketch_amount := 2bp;
  draw fullcircle scaled 2abs(O-A) shifted O;
endfig
___
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] Hand Style Sketching in Metapost

2021-05-20 Thread Jeroen
I have the following working example with hatching. This works fine, but
when I uncomment the sketching commands, no figure is rendered. Is the
mp-sketch macro still working?


\starttext

\startMPcode


input hatching;

%input mp-sketch;


%sketchypaths;

%sketch_amount := 2bp;


u := 1cm;

path circle;

circle = fullcircle scaled 4u;

hatchfill circle withcolor (45, 5mm, -.5bp);

draw circle;


\stopMPcode

\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] Conflict between MetaPost (LMTX) and cmarrows

2021-04-27 Thread Hans Hagen

Hi,

you can't assume fuzzy scratch variables as used in

  def flex(text t) =   % t is a list of pairs
hide(n_:=0; for z=t: z_[incr n_]:=z; endfor
dz_:=z_[n_]-z_1)
z_1 for k=2 upto n_-1: ...z_[k]{dz_} endfor ...z_[n_] enddef;
  newinternal n_; pair z_[],dz_;

to be official .. in mpxl we use names like

  temp_pair_z

i.e. a temp_ namespace (as well as a mfun_ one) for all these 
potentially clashing short names


you could do

  newinternal n_; pair z_[],dz_;

at the top of your file (because we don't use them) but stil ...

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] Conflict between MetaPost (LMTX) and cmarrows

2021-04-27 Thread Hans Hagen

On 4/27/2021 6:31 PM, Jairo A. del Rio wrote:

Hi, Hans. I've attached the relevant files.

Jairo

El mar, 27 de abr. de 2021 a la(s) 07:35, Hans Hagen (j.ha...@xs4all.nl 
) escribió:


On 4/27/2021 9:23 AM, Jairo A. del Rio wrote:
 > So, should I share relevant files? AFAIK only cmarrows and .mf
files in
 > the cm source folder are involved. I hope you can check it if a
solution
 > is possible and not too demanding. Thanks beforehand.
you can make a minimal failure example but I gues sthat the solution
has
to be in the mf macros (as there is where some pair/numeric clash
happens)


indeed, as i mentioned, some variable is not set up right

you need to patch (probably in all these arrow files)

save x,y,x_,y_;

to

save x,y,x_,y_,z_;

and (in mapto)

   numeric x,x_[],y,y_[];

to

   numeric x,x_[],y,y_[];
   pair z_[];


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] Conflict between MetaPost (LMTX) and cmarrows

2021-04-27 Thread Hans Hagen

On 4/27/2021 9:23 AM, Jairo A. del Rio wrote:
So, should I share relevant files? AFAIK only cmarrows and .mf files in 
the cm source folder are involved. I hope you can check it if a solution 
is possible and not too demanding. Thanks beforehand.
you can make a minimal failure example but I gues sthat the solution has 
to be in the mf macros (as there is where some pair/numeric clash happens)


-
  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] Conflict between MetaPost (LMTX) and cmarrows

2021-04-27 Thread Jairo A. del Rio
So, should I share relevant files? AFAIK only cmarrows and .mf files in the
cm source folder are involved. I hope you can check it if a solution is
possible and not too demanding. Thanks beforehand.

Regards,

Jairo

El lun, 26 de abr. de 2021 a la(s) 03:56, Hans Hagen (j.ha...@xs4all.nl)
escribió:

> On 4/26/2021 9:59 AM, Jairo A. del Rio wrote:
> >
> >
> > El lun, 26 de abr. de 2021 a la(s) 01:49, Hans Hagen (j.ha...@xs4all.nl
> > <mailto:j.ha...@xs4all.nl>) escribió:
> >
> > On 4/26/2021 6:59 AM, Jairo A. del Rio wrote:
> >  > The following:
> >  >
> >  > \starttext
> >  >
> >  > \startMPinitializations
> >  >
> >  > input cmarrows;
> >  >
> >  > setup_cmarrows(arrow_name = "texarrow"; parameter_file =
> "cmr6.mf";
> >  > macro_name = "nicearrow");
> >  >
> >  > \stopMPinitializations
> >  >
> >  > \startMPpage
> >
> >  > metafun > log > error: Equation cannot be performed (numeric=pair)
> > I don't know, but from the message it looks like some 'local'
> variables
> > is not saved and defined. I'm surprised that loading some mf file
> works
> > at all (because it also assumes some mf related definitions). I also
> > hav
> > eno clue if such a package adopts 'core' metafun code (and mpiv
> metafun
> > is different from mpii).
> >
> >
> > It's a generic, "pure" MetaPost package:
> >
> > https://www.ctan.org/pkg/cmarrows <https://www.ctan.org/pkg/cmarrows>
>
> that doesn't make it immune from clashes in used variables with differnt
> types ... metafun is more than plain mp so more can clash
>
> > Fonts are in /fonts/source/public in a TeX Live distribution, in case it
> > helps.
> i have a rather minimal tex setup so i can't run that (i'm not going to
> clutter my system 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
___


Re: [NTG-context] Conflict between MetaPost (LMTX) and cmarrows

2021-04-26 Thread Hans Hagen

On 4/26/2021 9:59 AM, Jairo A. del Rio wrote:



El lun, 26 de abr. de 2021 a la(s) 01:49, Hans Hagen (j.ha...@xs4all.nl 
<mailto:j.ha...@xs4all.nl>) escribió:


On 4/26/2021 6:59 AM, Jairo A. del Rio wrote:
 > The following:
 >
 > \starttext
 >
 > \startMPinitializations
 >
 > input cmarrows;
 >
 > setup_cmarrows(arrow_name = "texarrow"; parameter_file = "cmr6.mf";
 > macro_name = "nicearrow");
 >
 > \stopMPinitializations
 >
 > \startMPpage

 > metafun > log > error: Equation cannot be performed (numeric=pair)
I don't know, but from the message it looks like some 'local' variables
is not saved and defined. I'm surprised that loading some mf file works
at all (because it also assumes some mf related definitions). I also
hav
eno clue if such a package adopts 'core' metafun code (and mpiv metafun
is different from mpii).


It's a generic, "pure" MetaPost package:

https://www.ctan.org/pkg/cmarrows <https://www.ctan.org/pkg/cmarrows>


that doesn't make it immune from clashes in used variables with differnt 
types ... metafun is more than plain mp so more can clash


Fonts are in /fonts/source/public in a TeX Live distribution, in case it 
helps.
i have a rather minimal tex setup so i can't run that (i'm not going to 
clutter my system 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
___


Re: [NTG-context] Conflict between MetaPost (LMTX) and cmarrows

2021-04-26 Thread Jairo A. del Rio
El lun, 26 de abr. de 2021 a la(s) 01:49, Hans Hagen (j.ha...@xs4all.nl)
escribió:

> On 4/26/2021 6:59 AM, Jairo A. del Rio wrote:
> > The following:
> >
> > \starttext
> >
> > \startMPinitializations
> >
> > input cmarrows;
> >
> > setup_cmarrows(arrow_name = "texarrow"; parameter_file = "cmr6.mf";
> > macro_name = "nicearrow");
> >
> > \stopMPinitializations
> >
> > \startMPpage
>
> > metafun > log > error: Equation cannot be performed (numeric=pair)
> I don't know, but from the message it looks like some 'local' variables
> is not saved and defined. I'm surprised that loading some mf file works
> at all (because it also assumes some mf related definitions). I also hav
> eno clue if such a package adopts 'core' metafun code (and mpiv metafun
> is different from mpii).
>

It's a generic, "pure" MetaPost package:

https://www.ctan.org/pkg/cmarrows

Fonts are in /fonts/source/public in a TeX Live distribution, in case it
helps.

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

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] Conflict between MetaPost (LMTX) and cmarrows

2021-04-26 Thread Hans Hagen

On 4/26/2021 6:59 AM, Jairo A. del Rio wrote:

The following:

\starttext

\startMPinitializations

input cmarrows;

setup_cmarrows(arrow_name = "texarrow"; parameter_file = "cmr6.mf"; 
macro_name = "nicearrow");


\stopMPinitializations

\startMPpage



metafun > log > error: Equation cannot be performed (numeric=pair)
I don't know, but from the message it looks like some 'local' variables 
is not saved and defined. I'm surprised that loading some mf file works 
at all (because it also assumes some mf related definitions). I also hav 
eno clue if such a package adopts 'core' metafun code (and mpiv metafun 
is different from mpii).


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] Conflict between MetaPost (LMTX) and cmarrows

2021-04-25 Thread Jairo A. del Rio
The following:

\starttext

\startMPinitializations

input cmarrows;

setup_cmarrows(arrow_name = "texarrow"; parameter_file = "cmr6.mf";
macro_name = "nicearrow");

\stopMPinitializations

\startMPpage


nicearrow (origin -- (1cm*left));

\stopMPpage

\stoptext

compiles perfectly with ConTeXt MkIV. With LMTX, however, the following
happens:

metapost > initializing instance 'metafun:1' using format 'metafun' and
method 'default'

metapost > loading 'metafun' as 'metafun.mpxl' using method 'default'

metapost > initializing number mode 'scaled'

metapost > message : Loading cmarrows 2006/12/18, v0.9

metafun > log > overloading immutable 'eps'

metafun > log >

metafun > log > error: Equation cannot be performed (numeric=pair)

metafun > log >

metapost > log >

metapost > log > 

metapost > log > ;

metapost > log >  z_[incr.n]:=(EXPR0);

metapost > log > ENDFOR

metapost > log > 
...nt(length(path))of(path),z2,point.ttt.of(path),z9-(0,3rule_thickness#),point.tt.of(path)-3rule_thickness#*(unitvector(direction.tt.of(path))rotated90):z_[incr.n]:=z;endfor

metapost > log > ;transform.T...

metapost > log > hide->exitif.numeric.begingroup(TEXT0)

metapost > log > ;endgroup;

metapost > log >
mapto->begingroup.hide(numeric.n;n:=0;numeric.x,x_[],y,y_[];for.z=(TEXT2):z_[incr.n]:=z;endfor;transform.T;z_2=z_1transformed.T;z_4=z_3transformed.T;z_6=z_5transformed.T;)

metapost > log > T.endgroup

metapost > log >
nicearrow__sgbxww->...(z0,point(length(EXPR2))of(EXPR2),z2,point.ttt.of(EXPR2),z9-(0,3rule_thickness#),point.tt.of(EXPR2)-3rule_thickness#*(unitvector(direction.tt.of(EXPR2))rotated90))

metapost > log > ;fi.save.f,s...

metapost > log > 

metapost > log > ;

metapost > log > <*> nicearrow (origin -- (1cm*left));

metafun > log >

metafun > log > I'm sorry, but I don't know how to make such things equal.
(See the two

expressions just above the error message.)

metafun > log >

metapost > log > ;

metapost > log >

What's happening? Is that intended or a bug?

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] Parenthesis error in metapost

2021-04-07 Thread Hans Hagen

On 4/7/2021 10:14 AM, Mikael Sundqvist wrote:

Hi,

the following code has been working before:

\starttext
\startMPpage[instance=decimalfun]
draw function(1,"x","x*sin(x)",0.5,1,1/100) scaled 1in;
\stopMPpage
\stoptext

Now (with an updated ConTeXt) I get an error:

metapost> loading 'metafun' as 'metafun.mpxl' using method 'decimal'
metapost> initializing number mode 'decimal'
metafun > log >
metafun > log > error: Missing ')' has been inserted
metafun > log >
metapost> log > 
metapost> log >    (
metapost> log >  x*sin(
metapost    > log >x)
metapost> log > 
metapost> log >)

Maybe I have done something wrong earlier, but I cannot see any
unmatched parenthesis now.
sin is just not defined in decimal mode (in scaled and double they use 
the math library) .. so i'll fix 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] Parenthesis error in metapost

2021-04-07 Thread Mikael Sundqvist
Hi,

the following code has been working before:

\starttext
\startMPpage[instance=decimalfun]
draw function(1,"x","x*sin(x)",0.5,1,1/100) scaled 1in;
\stopMPpage
\stoptext

Now (with an updated ConTeXt) I get an error:

metapost> loading 'metafun' as 'metafun.mpxl' using method 'decimal'
metapost> initializing number mode 'decimal'
metafun > log >
metafun > log > error: Missing ')' has been inserted
metafun > log >
metapost> log > 
metapost> log >    (
metapost> log >  x*sin(
metapost    > log >x)
metapost> log > 
metapost> log >)

Maybe I have done something wrong earlier, but I cannot see any
unmatched parenthesis now.

/Mikael
___
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: directionpoint gives unexpected point(?)

2021-02-12 Thread Hans Hagen

Hi,

Like this:

metapost.registerscript("scrutenized", function()
local p = mp.scan.path()
local r = math.round
local d = 10^mp.scan.numeric()
for i=1,#p do
local pi = p[i]
pi[1] = r(pi[1] * d) / d
pi[2] = r(pi[2] * d) / d
end
local x1 = r(p[1][1])
local y1 = r(p[1][2])
local n = 1
local t = { p[1], cycle = p.cycle }
for i=2,#p do
local pi = p[i]
local x2 = r(pi[1])
local y2 = r(pi[2])
if x1 ~= x2 or y1 ~= y2 then
n = n + 1
t[n] = p[i]
x1 = x2
y1 = y2
end
end
mp.inject.path(t)
end)
\stopluacode

\startMPdefinitions{doublefun}
newscriptindex mfid_scrutenized ; mfid_scrutenized := scriptindex 
"scrutenized" ;


primarydef p scrutenized  n =
runscript mfid_scrutenized p n
enddef ;
\stopMPdefinitions

and then

p[1] := p[1] scrutenized 5 ; % 5 decimals
p[2] := p[2] scrutenized 5 ; % 5 decimals

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] Metapost: directionpoint gives unexpected point(?)

2021-02-12 Thread Taco Hoekwater


> On 12 Feb 2021, at 10:31, Mikael Sundqvist  wrote:
> 
> Hi Taco,
> 
> thanks, from your observation and the way I build the paths, I found
> out that I can avoid the problem by shortening the paths I join just
> slightly:
> 
> cl := (fullcircle scaled 4u) shifted z0;
> cl := cl cutbefore point (1/6+epsilon) along cl cutafter point
> (2/6-epsilon) along cl;
> cs := (fullcircle scaled 16u) shifted z1;
> cs := cs cutafter point (1/6-epsilon) along cs;
> 
> and indeed, it works here now, with different values of the scale u,
> and it seems more stable.


Here is a quick hack I wrote that does the cleanup in a postprocessing stage. 
It is not very generic or clever, but it works for your case:

def clean_path(suffix p) =
  begingroup;
  save q,precontrols,postcontrols,points, skip, i,j;
  boolean skip;
  pair precontrols[],postcontrols[],points[] ;
  j := 0;
  for i = 0 upto length p:
skip := false;
if abs(xpart point i of p - xpart point i+1 of p)<0.01:
   if abs(ypart point i of p - ypart point i+1 of p)<0.01:
 skip := true;
   fi
fi
if not skip:
   points[j] := point i of p;
   postcontrols[j] := postcontrol i of p;
   precontrols[j+1] := precontrol i+1 of p;
   j := j + 1;
fi
  endfor;
  if abs(xpart point 0 of p - xpart point length p of p)<0.01:
 if abs(ypart point 0 of p - ypart point length p of p)<0.01:
   j := j - 1;
 fi
  fi
  p := for i=0 upto j-1: points[i] .. controls postcontrols[i] and 
precontrols[i+1] .. endfor cycle;
  endgroup;
enddef;

show p0;
clean_path(p0);
show p0;

> 
> PS I found out that eps and epsilon both worked, and I do not see in
> the metafun manual if there is a difference.

The original intent was for eps to be just a ’small enough value that a human 
will not notice it’ where epsilon is intended as ’the smallest representable 
value’. Neither really work that way because depending on how you use metapost 
eps can be quite visible (especially in non-scaled number systems) and (more 
importantly) in the new non-scaled number systems epsilon cannot really be the 
smallest representable value for numerical and practical reasons.

So in reality, we always use these definitions:

  eps  := .00049 ;  % this is a pretty small positive number
  epsilon  := 1/256/256 


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] Metapost: directionpoint gives unexpected point(?)

2021-02-12 Thread Hans Hagen

On 2/12/2021 9:35 AM, Taco Hoekwater wrote:

Hi,


On 11 Feb 2021, at 17:41, Mikael Sundqvist  wrote:

Thanks for your investigation and extended example!

So, if I understand it correctly, the problem occurs where the
different circles are glued together with the .. construction.


Took me a while to get it, but the problem is the definition of p0:

p[0] := cs .. cl .. (cs rotated 120) .. (cl rotated 120) .. (cs rotated 240) .. 
(cl rotated 240) .. cycle;

Here are cs and cl after your earlier definition:

cs := (141.732246,-49.097491614210789)
   ..(75.312386775380347,111.25424516116959)
   ..(28.347427842053655,147.2925755432174);

cl := (28.346108531095332,147.29283827977969)

   ..(0,154.88788322842163)
   ..(-28.346108531095332,147.29283827977969);

Note how the last point of cs and the first point of cl are nearly the same. 
When you combine these bits into p0, p0 becomes a cyclic path with 18 points 
(where you really want/need only 12 points).

The micro-segments between these nearly-identical paths are the problem. At 
smaller u values the differences between the points become zero, and the 
directionpoint of a path of length zero is mathematically undefined.

I do not know a quick generic solution off hand, but that is what the issue is.
Brilliant, as usual. So, now I can kick in with the dirty hackery (can 
be some proper thing but that's for later):


\starttext

\startluacode

function mp.foo()
local p = mp.scan.path()
local r = math.round
local d = 10
for i=1,#p do
local pi = p[i]
pi[1] = r(pi[1] * d) / d
pi[2] = r(pi[2] * d) / d
end
local x1 = r(p[1][1])
local y1 = r(p[1][2])
local n = 1
local t = { p[1], cycle = p.cycle }
for i=2,#p do
local x2 = r(p[i][1])
local y2 = r(p[i][2])
if x1 ~= x2 or y1 ~= y2 then
n = n + 1
t[n] = p[i]
x1 = x2
y1 = y2
end
end
--inspect(t)
mp.inject.path(t)
end

\stopluacode

\startMPdefinitions{doublefun}

def FOO(expr u) =

path p[];

% This defines the reulleaux curves
% p[0] is a "base" reulleaux curve
path cl,cs,rl ;
z0 = (0,6/sqrt(3)*u);
z1 = z0 rotated 120;
cl := (fullcircle scaled 4u) shifted z0;
cl := cl cutbefore point 1/6 along cl cutafter point 2/6 along cl;
cs := (fullcircle scaled 16u) shifted z1;
cs := cs cutafter point 1/6 along cs;
p[0] := cs .. cl .. (cs rotated 120) .. (cl rotated 120) .. (cs
rotated 240) .. (cl rotated 240) .. cycle;

% p[0] := runscript("mp.foo()") p[0];

% the first curve (darkyellow)
% p[1] := p[0] rotated 27 shifted (-10u,2u);
p[1] := p[0] rotated 27 shifted (-10u,2u);
draw p1 withpen pencircle scaled 2bp withcolor darkyellow;
% the second curve (darkblue)
p[2] := p[1] rotated 180;
draw p2 withpen pencircle scaled 2bp withcolor darkblue;

if true :

p[1] := runscript("mp.foo()") p[1];
p[2] := runscript("mp.foo()") p[2];

p3 := for phi=0 step 30 until 360: ((directionpoint dir(phi) of p1)
shifted (directionpoint dir(phi) of p2)) .. endfor cycle;
draw p3 withpen pencircle scaled 2bp withcolor darkred;

else :

drawarrow for phi=0 step 30 until 360: (directionpoint dir(phi) of 
p1) -- endfor cycle withpen pencircle scaled 1bp withcolor darkgreen;
drawarrow for phi=0 step 30 until 360: (directionpoint dir(phi) of 
p2) -- endfor cycle withpen pencircle scaled 1bp withcolor darkmagenta;

drawarrow for phi=0 step 30 until 360:
((directionpoint dir(phi) of p1) shifted (directionpoint 
dir(phi) of p2)) -- endfor cycle

withpen pencircle scaled 1bp withcolor darkred;

fi ;

% We give one direction as example
% These are merely here to show the construction of the curve
% But they also show what is going wrong

direx:=40;

z11=directionpoint dir(direx) of p1;
z22=directionpoint dir(direx) of p2;

p4 = ((-u,0)--(u,0)) rotated direx;

% These arrows should be tangent
drawarrow p4 shifted z11;
drawarrow p4 shifted z22;
drawarrow p4 shifted (z11 shifted z22);

% Draw the parallelogram.
draw origin -- z11 dashed evenly;
draw origin -- z22 dashed evenly;
draw z11 -- (z11 shifted z22) dashed evenly;
draw z22 -- (z11 shifted z22) dashed evenly;

enddef ;
\stopMPdefinitions

\startMPpage[offset=4bp,instance=doublefun]
FOO(1cm);
\stopMPpage
\startMPpage[offset=4bp,instance=doublefun]
FOO(.8cm);
\stopMPpage
\startMPpage[offset=4bp,instance=doublefun]
FOO(.5cm);
\stopMPpage
\startMPpage[offset=4bp,instance=doublefun]
FOO(.2cm);
\stopMPpage
\stoptext



-
  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 

Re: [NTG-context] Metapost: directionpoint gives unexpected point(?)

2021-02-12 Thread Mikael Sundqvist
Hi Taco,

thanks, from your observation and the way I build the paths, I found
out that I can avoid the problem by shortening the paths I join just
slightly:

cl := (fullcircle scaled 4u) shifted z0;
cl := cl cutbefore point (1/6+epsilon) along cl cutafter point
(2/6-epsilon) along cl;
cs := (fullcircle scaled 16u) shifted z1;
cs := cs cutafter point (1/6-epsilon) along cs;

and indeed, it works here now, with different values of the scale u,
and it seems more stable.

/Mikael

PS I found out that eps and epsilon both worked, and I do not see in
the metafun manual if there is a difference.

On Fri, Feb 12, 2021 at 9:35 AM Taco Hoekwater  wrote:
>
> Hi,
>
> > On 11 Feb 2021, at 17:41, Mikael Sundqvist  wrote:
> >
> > Thanks for your investigation and extended example!
> >
> > So, if I understand it correctly, the problem occurs where the
> > different circles are glued together with the .. construction.
>
> Took me a while to get it, but the problem is the definition of p0:
>
> p[0] := cs .. cl .. (cs rotated 120) .. (cl rotated 120) .. (cs rotated 240) 
> .. (cl rotated 240) .. cycle;
>
> Here are cs and cl after your earlier definition:
>
> cs := (141.732246,-49.097491614210789)
>   ..(75.312386775380347,111.25424516116959)
>   ..(28.347427842053655,147.2925755432174);
>
> cl := (28.346108531095332,147.29283827977969)
>   ..(0,154.88788322842163)
>   ..(-28.346108531095332,147.29283827977969);
>
> Note how the last point of cs and the first point of cl are nearly the same. 
> When you combine these bits into p0, p0 becomes a cyclic path with 18 points 
> (where you really want/need only 12 points).
>
> The micro-segments between these nearly-identical paths are the problem. At 
> smaller u values the differences between the points become zero, and the 
> directionpoint of a path of length zero is mathematically undefined.
>
> I do not know a quick generic solution off hand, but that is what the issue 
> is.
>
> 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
___


<    1   2   3   4   5   6   7   8   9   10   >