[NTG-context] Re: Seeking advice for module that draws globes

2023-12-17 Thread Henning Hraban Ramm

Am 18.12.23 um 00:58 schrieb Hans Hagen via ntg-context:

On 12/17/2023 11:22 PM, Gavin via ntg-context wrote:
2. How do I organize this according to TDS for sharing? I know what 
TDS is and why it’s important, but that’s about it!


Hraban will guide you here.


I’ll try ;)

Hi Gavin, thank you for sharing this useful module!

Have a look at
https://wiki.contextgarden.net/Modules#Module_writing_guidelines
… and please tell me, if you miss anything or find errors!

Also look at the structure of other modules in the distribution, or e.g.
https://codeberg.org/fiee/context-simpleslides
This is how your code should be structured, i.e.
– LICENSE and README stay on top; add VERSION
– luageoTest.tex (and further documentation) goes into 
doc/context/third/luageo

– the rest goes into tex/context/third/luageo
– an interface file is optional

The publication process via https://modules.contextgarden.net is also 
outlined in the wiki page.


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

maillist : ntg-context@ntg.nl / 
https://mailman.ntg.nl/mailman3/lists/ntg-context.ntg.nl
webpage  : https://www.pragma-ade.nl / https://context.aanhet.net (mirror)
archive  : https://github.com/contextgarden/context
wiki : https://wiki.contextgarden.net
___


[NTG-context] Cron /var/www/aanhet.net/context/bin/cron/context-mirror

2023-12-17 Thread Cron Daemon
rsync: [Receiver] failed to connect to rsync.pragma-ade.nl (213.125.29.165): No 
route to host (113)
rsync error: error in socket IO (code 10) at clientserver.c(139) 
[Receiver=3.2.7]
___
If your question is of interest to others as well, please add an entry to the 
Wiki!

maillist : ntg-context@ntg.nl / 
https://mailman.ntg.nl/mailman3/lists/ntg-context.ntg.nl
webpage  : https://www.pragma-ade.nl / https://context.aanhet.net (mirror)
archive  : https://github.com/contextgarden/context
wiki : https://wiki.contextgarden.net
___


[NTG-context] Re: Seeking advice for module that draws globes

2023-12-17 Thread Gavin via ntg-context
Hi Hans,

Thanks for all the suggestions! I am going through them carefully.

> - in mp you can do this
> 
> vardef theglobe(expr lat, lon) =
>for i = 1 upto lua.mp.makeglobe(lat, lon):
>(lua.mp.getglobepath(i)) 
>endfor
>cycle
> enddef ;

Does "" allow a disconnected path? I haven’t seen "" or a disconnected 
path before.

Also, we do have a strange artifact, at least when I run this code. There is a 
line running across Brazil:



I only got the line for (23,0), not for other latitude and longitude. I’m not 
sure what caused that. The code for cutting and mending paths that cross the 
horizon is tricky. I’m not sure how it will interact with "" and “cycle" 
connecting everything.

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

maillist : ntg-context@ntg.nl / 
https://mailman.ntg.nl/mailman3/lists/ntg-context.ntg.nl
webpage  : https://www.pragma-ade.nl / https://context.aanhet.net (mirror)
archive  : https://github.com/contextgarden/context
wiki : https://wiki.contextgarden.net
___


[NTG-context] Re: Seeking advice for module that draws globes

2023-12-17 Thread Hans Hagen via ntg-context

On 12/17/2023 11:22 PM, Gavin via ntg-context wrote:

Hello ConTeXters,

I wrote a little ConTeXt module for drawing globes. I would love some advice on 
how to improve it and share it. The code is quite short (about 250 lines). Most 
of the work is done by Lua, which reads the data files and calculates paths. 
These paths are passed to MetaFun, which draws the globe.


Just some quiks remarks ...

- you use the right strategy (tex/lua/mp)

- in mp you can do this

vardef theglobe(expr lat, lon) =
for i = 1 upto lua.mp.makeglobe(lat, lon):
(lua.mp.getglobepath(i)) 
endfor
cycle
enddef ;

and then:

\startMPpage
GlobeDiameter = 10cm ;
fill fullcircle
scaled GlobeDiameter
withcolor .9white ;
path p ; p := theglobe(23, 0)
scaled .5GlobeDiameter
;
draw p
withpen pencircle scaled .2mm
withcolor blue
withtransparency (1,.5) ;
fill p
withcolor red
withtransparency (1,.5) ;
draw fullcircle
scaled GlobeDiameter
withcolor black ;
\stopMPpage

i use transparency to demo that a single path has advantages; you'll 
also notice that the runtime is actually at the mp end.


- in your lua code do this

local cosd = math.cosd
local sind = math.sind
local sqrt = math.sqrt

- also, use "MP.makeglobe" in the mp code and at the lua end function 
MP.makeglobe"" as that is the user namespace.


I'll mail you the lua file with some suggestions. When all is stable I 
can spend a few hours on optimizing if needed.



I am a novice at both Lua and MetaPost. I’m also new to Git and have never 
shared anything of substance with the ConTeXt community. (This barely counts as 
substantive, but I figure it’s best to start small.) I’m sure many of you could 
find opportunities for improvement with even a quick glance at the code. I 
welcome anything, from advice on performance to suggestions about the license. 
My most pressing questions are these:



1. How do I avoid redrawing diagrams with every typeset? The globe above takes 
about 0.7s, which is not bad, but it adds up in a book with many diagrams.


see previous mail


2. How do I organize this according to TDS for sharing? I know what TDS is and 
why it’s important, but that’s about it!

3. Should I be creating a namespace for this module, or launching a separate 
MetaFun instance? I have a general sense of what “namespace” and “instance” 
mean is this context, but I don’t know the consequences or the how-to.

I’d like to share this module, even though the potential demand is tiny, at 
best. I’m going through the Module Writing Guidelines 
(https://wiki.contextgarden.net/Modules#Module_writing_guidelines), but there 
is a lot that I don’t understand in those instructions. Questions 2 and 3 above 
relate to the instructions that are most mysterious to me. I think I can figure 
most of the others out.

I have been using ConTeXt for several years to write a high school physics 
textbook (along with the problem sets, tests, equations sheets, etc.). I wrote 
this module because I needed globes in some diagrams. I found an old MetaPost 
tool, mp-geo, that seemed to have the right ingredients, but I couldn’t get it 
to work, so I wrote my own tool using the data files from mp-geo. Hans and 
others on the list gave me valuable advice for these globes a couple years ago 
(and gave other valuable advice on all sorts of things before and since).

Many diagrams in my physics book use TikZ and pgfplots. I'd like to convert 
everything to MetaFun. I think the best way will be writing a few more modules 
for things like graphs (including polar and 3D plots), simple circuits, simple 
Feynman diagrams, etc. I’m hoping that these would be useful to the ConTeXt 
community. The luageo module has the basic design I’d like to use for the 
others: Lua for data handling and calculations, producing paths that are drawn 
by MetaFun. With some mentoring from the generous ConTeXt community, I’m hoping 
we can provide MetaFun alternatives to some of the TikZ libraries.


next year Mikael S and I are going to look into 3D (and projections) as 
we can only work on math when we have a parallel metafun pet project.



I have an alpha version of luagraph by Alan Braslau, which was helpful in 
designing luageo. Working on luagraph is my next project.

Gavin



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

maillist : ntg-context@ntg.nl / 
https://mailman.ntg.nl/mailman3/lists/ntg-context.ntg.nl
webpage  : https://www.pragma-ade.nl / https://context.aanhet.net (mirror)
archive  : https://github.com/contextgarden/context
wiki : https://wiki.contextgarden.net
___


--

-
  Hans Hagen 

[NTG-context] Re: Seeking advice for module that draws globes

2023-12-17 Thread Hans Hagen via ntg-context

On 12/17/2023 11:22 PM, Gavin via ntg-context wrote:


1. How do I avoid redrawing diagrams with every typeset? The globe above takes 
about 0.7s, which is not bad, but it adds up in a book with many diagrams.


\startbuffer[demo]
\usemodule [luageo]
\startMPpage
GlobeDiameter = 10cm ;
fill fullcircle scaled GlobeDiameter withcolor .9white ;  % Fill a 
circle with the water color.
drawglobe(23, 0) scaled GlobeDiameter withcolor .75white ;% Draw 
the land.
draw fullcircle scaled GlobeDiameter withcolor black ;% Add a 
border, if you want.

\stopMPpage
\stopbuffer

\typesetbuffer[demo]


2. How do I organize this according to TDS for sharing? I know what TDS is and 
why it’s important, but that’s about it!


Hraban will guide you here.


3. Should I be creating a namespace for this module, or launching a separate 
MetaFun instance? I have a general sense of what “namespace” and “instance” 
mean is this context, but I don’t know the consequences or the how-to.

If the code is robust there is no need for an instance.

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 / 
https://mailman.ntg.nl/mailman3/lists/ntg-context.ntg.nl
webpage  : https://www.pragma-ade.nl / https://context.aanhet.net (mirror)
archive  : https://github.com/contextgarden/context
wiki : https://wiki.contextgarden.net
___


[NTG-context] Seeking advice for module that draws globes

2023-12-17 Thread Gavin via ntg-context
Hello ConTeXters,

I wrote a little ConTeXt module for drawing globes. I would love some advice on 
how to improve it and share it. The code is quite short (about 250 lines). Most 
of the work is done by Lua, which reads the data files and calculates paths. 
These paths are passed to MetaFun, which draws the globe.

Below is an example document with the output. (I attached a small .png of the 
output for the mailing list. The output PDF has excessive detail.) The module 
(code and data) is on GitHub at https://github.com/GavinPolhemus/luageo.

\usemodule [luageo]
\startMPpage
GlobeDiameter = 10cm ;
fill fullcircle scaled GlobeDiameter withcolor .9white ;  % Fill a circle 
with the water color.
drawglobe(23, 0) scaled GlobeDiameter withcolor .75white ;% Draw the land, 
centered on the given latitude and longitude.
draw fullcircle scaled GlobeDiameter withcolor black ;% Add a border, 
if you want.
\stopMPpage



I am a novice at both Lua and MetaPost. I’m also new to Git and have never 
shared anything of substance with the ConTeXt community. (This barely counts as 
substantive, but I figure it’s best to start small.) I’m sure many of you could 
find opportunities for improvement with even a quick glance at the code. I 
welcome anything, from advice on performance to suggestions about the license. 
My most pressing questions are these:

1. How do I avoid redrawing diagrams with every typeset? The globe above takes 
about 0.7s, which is not bad, but it adds up in a book with many diagrams.

2. How do I organize this according to TDS for sharing? I know what TDS is and 
why it’s important, but that’s about it!

3. Should I be creating a namespace for this module, or launching a separate 
MetaFun instance? I have a general sense of what “namespace” and “instance” 
mean is this context, but I don’t know the consequences or the how-to.

I’d like to share this module, even though the potential demand is tiny, at 
best. I’m going through the Module Writing Guidelines 
(https://wiki.contextgarden.net/Modules#Module_writing_guidelines), but there 
is a lot that I don’t understand in those instructions. Questions 2 and 3 above 
relate to the instructions that are most mysterious to me. I think I can figure 
most of the others out.

I have been using ConTeXt for several years to write a high school physics 
textbook (along with the problem sets, tests, equations sheets, etc.). I wrote 
this module because I needed globes in some diagrams. I found an old MetaPost 
tool, mp-geo, that seemed to have the right ingredients, but I couldn’t get it 
to work, so I wrote my own tool using the data files from mp-geo. Hans and 
others on the list gave me valuable advice for these globes a couple years ago 
(and gave other valuable advice on all sorts of things before and since).

Many diagrams in my physics book use TikZ and pgfplots. I'd like to convert 
everything to MetaFun. I think the best way will be writing a few more modules 
for things like graphs (including polar and 3D plots), simple circuits, simple 
Feynman diagrams, etc. I’m hoping that these would be useful to the ConTeXt 
community. The luageo module has the basic design I’d like to use for the 
others: Lua for data handling and calculations, producing paths that are drawn 
by MetaFun. With some mentoring from the generous ConTeXt community, I’m hoping 
we can provide MetaFun alternatives to some of the TikZ libraries.

I have an alpha version of luagraph by Alan Braslau, which was helpful in 
designing luageo. Working on luagraph is my next project.

Gavin


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

maillist : ntg-context@ntg.nl / 
https://mailman.ntg.nl/mailman3/lists/ntg-context.ntg.nl
webpage  : https://www.pragma-ade.nl / https://context.aanhet.net (mirror)
archive  : https://github.com/contextgarden/context
wiki : https://wiki.contextgarden.net
___


[NTG-context] Re: error with definestartstop and startmode

2023-12-17 Thread Wolfgang Schuster

Peter Münster schrieb am 17.12.2023 um 10:09:

On Sat, Dec 16 2023, Hans Hagen via ntg-context wrote:


\usemodule[abbreviations-logos]
\defineblock [H] [before=\startcolor[blue],after=\stopcolor]
\keepblocks[H]

Thanks for this solution.

Is there also something for inline-mode? Example:

test \beginH TEST\endH test


You can create different versions of your environment and let context choose
one whether the mode is enabled or disabled.

%\enablemode[H]

\startmode [H]
  \definestartstop [H] [color=blue]
\stopmode

\startnotmode [H]
  \define\startH{\ignoreupto\stopH}
\stopnotmode

\starttext

xxx \startH yyy \stopH zzz

\stoptext

Wolfgang

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

maillist : ntg-context@ntg.nl / 
https://mailman.ntg.nl/mailman3/lists/ntg-context.ntg.nl
webpage  : https://www.pragma-ade.nl / https://context.aanhet.net (mirror)
archive  : https://github.com/contextgarden/context
wiki : https://wiki.contextgarden.net
___


[NTG-context] Re: error with definestartstop and startmode

2023-12-17 Thread Peter Münster
On Sat, Dec 16 2023, Hans Hagen via ntg-context wrote:

> \usemodule[abbreviations-logos]
> \defineblock [H] [before=\startcolor[blue],after=\stopcolor]
> \keepblocks[H]

Thanks for this solution.

Is there also something for inline-mode? Example:

test \beginH TEST\endH test

TIA,
-- 
   Peter
___
If your question is of interest to others as well, please add an entry to the 
Wiki!

maillist : ntg-context@ntg.nl / 
https://mailman.ntg.nl/mailman3/lists/ntg-context.ntg.nl
webpage  : https://www.pragma-ade.nl / https://context.aanhet.net (mirror)
archive  : https://github.com/contextgarden/context
wiki : https://wiki.contextgarden.net
___


[NTG-context] Re: APA 7 and https

2023-12-17 Thread Oliver Marugg
Hi Alan

Many thanks for your solution. 

Oliver 

> Am 16.12.2023 um 22:33 schrieb Alan Braslau :
> 
> A "better" solution is to put
> 
> doi = {https://doi.org/__doi__},
> 
> in your bibtex database
> 
> but I would actually use
> 
> url = {https://doi.org/__doi__},
> 
> Not all editors want the complete url for the doi, but some do.
> The current scheme lets the user define url= and doi= as they wish (and
> even both) and does not impose a particular format.
> 
> Alan
> 
> 
> 
> On Fri, 15 Dec 2023 22:07:25 -
> rauricast...@gmail.com wrote:
> 
>> Hi
>> 
>> I found a solution to reach APA7 list and links.
>> 
>> Using
>> $PATH/ConTeXtPATH/tex/texmf-context/tex/context/base/mkiv/publ-imp-apa.mkvi
>> in line 1306-1312,  where \starttexdefinition mutable protected
>> btx:apa:doi \texdefinition {btx:format:goto} {
>>url(https://doi.org/\btxflush{doi})
>>} {
>>   \hyphenatedurl{https://\btxflush{doi}}
>>}
>> \stoptexdefinition
>> 
>> Change:
>> url(http://dx.doi.org/\btxflush{doi}) to
>> url(https://doi.org/\btxflush{doi}) and 
>> \hyphenatedurl{doi:\btxflush{doi}} to
>> \hyphenatedurl{https://\btxflush{doi}}. 
>> 
>> With this two changes the correct format in the list of publications
>> is shown according apa7 and as well https links instead of http links
>> will be generated, which is also needed in apa7. Not all apa7
>> definitions are yet reach with this changes, but its a small step
>> towards.
>> 
>> Merry Christmas.
>> 
>> Oliver

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

maillist : ntg-context@ntg.nl / 
https://mailman.ntg.nl/mailman3/lists/ntg-context.ntg.nl
webpage  : https://www.pragma-ade.nl / https://context.aanhet.net (mirror)
archive  : https://github.com/contextgarden/context
wiki : https://wiki.contextgarden.net
___