[NTG-context] Re: multipage metapost output from ConTeXt

2023-11-29 Thread Emanuel Han via ntg-context
Dear Aditya and Fabrice,
thanks for your responses.

I included some of Fabrice's code into mine for testing purpose, and indeed the 
multipage works now.
What is bizarre is that issues appear now that didn't appear before:
Path A is drawn with color red on page 1, and in color black on all following 
pages, while it should stay red.

textext(, ) is overwriting  with "T="(currentime) 
which has been used previously in textext() before the for k=1 endfor loop. 
This overwriting happens only for the first textext() which occurs inside the 
for k=1 endfor loop. All other textext() inside the for k=1 endfor loop are not 
drawn at all. If the line « draw textext("T="(currentime)) scaled 2 
shifted(0,2in) withcolor magenta ; » is commented out, the first textext() 
inside the for k=1 endfor loop is not drawn neither. It must be an issue with 
textext(), because when I replace textext() by lmt_outline[], the text is drawn.

Adjusted mwe:

\enableregime[utf] % enable unicoded input
\definefontfamily [RomanFont] [rm] [calluna]
\definefontfamily [KoreanFont] [rm] [applemyungjo]
\definefontfamily [JapaneseFont] [rm] [hannotatesc]
\definefontfeature
[fea]
[mode=node,language=dflt,script=arab,
init=yes,
medi=yes,
fina=yes,
isol=yes,
calt=yes,
rlig=yes,
tlig=yes,
trep=yes,
curs=yes,
kern=yes,
mark=yes
]

\starttypescript [serif] [notonaskharabic]
\definefontsynonym [notonaskharabic-Light] [name:notonaskharabic] [features=fea]
\definefontsynonym [notonaskharabic-Bold] [name:notonaskharabic] [features=fea]
\definefontsynonym [notonaskharabic-Italic] [name:notonaskharabic] 
[features=fea]
\definefontsynonym [notonaskharabic-Bold-Italic] [name:notonaskharabic] 
[features=fea]
\stoptypescript

\starttypescript [serif] [notonaskharabic]
\usetypescript[serif][fallback]
\definefontsynonym [Serif] [notonaskharabic-Light] [features=fea]
\definefontsynonym [SerifItalic] [notonaskharabic-Italic] [features=fea]
\definefontsynonym [SerifBold] [notonaskharabic-Bold] [features=fea]
\definefontsynonym [SerifBoldItalic] [notonaskharabic-Bold-Italic] 
[features=fea]
\stoptypescript

\starttypescript [notonaskharabic]
\definetypeface [notonaskharabic] [rm] [serif] [notonaskharabic] [default]
\stoptypescript

\usetypescript[notonaskharabic]
\setupbodyfont [RomanFont]

\usecolors[crayola]

\startMPinclusions
picture p[];
path TheFrame ;
TheFrame := fullsquare scaled 5in ;

z0 = (0,0);
z1 = (60,40);
z2 = (40,90);
z3 = (10,70);
z4 = (30,50);
z5 = (90,70);
z6 = (-10,70);

path A; A = z0..z1..z2..z3..z4 ;
pair AStartPoint; AStartPoint = point 0 of A;
pair AEndPoint; AEndPoint = point 4 of A;
path B; B = z5..z6;
pair BStartPoint; BStartPoint = point 0 of B;
pair BEndPoint; BEndPoint = point 1 of B;
path C; C = AStartPoint..AEndPoint;

p1:=image(
draw A withcolor red;
);

p2:=image(draw A; label(lmt_outline [
text = "\JapaneseFont 日本語"
], AEndPoint););

p3:=image(
label(textext("\notonaskharabic \textdir TRT دانگ") scaled 1.2, BStartPoint);
);

p4:=image(draw A; label(lmt_outline [
text = "\KoreanFont 한국어"
], AStartPoint););

p5:=image(
label(textext("bāng"), BEndPoint);
draw C withcolor green;
);

p6:=image(
draw B withcolor blue;
);
\stopMPinclusions

\starttext
\dorecurse{6}{ % Frame
\setupMPpage[background=color, backgroundcolor=SpringGreen]
\startMPpage[pagestate=start]
currentime := #1 ;
% Just for learning :
draw TheFrame withpen pencircle scaled .1in withcolor magenta ;
draw textext("T="(currentime)) scaled 2 shifted(0,2in) withcolor 
magenta ;
for k=1 upto currentime: draw p[k]; endfor
setbounds currentpicture to TheFrame ;

desiredformat := 1080;% In pixels (will be converted by default at 72dpi)
currentpicture := currentpicture xysized (desiredformat ,desiredformat );

\stopMPpage
}

\stoptext
On Nov. 27 2023, at 11:25 pm, Aditya Mahajan  wrote:
> On Mon, 27 Nov 2023, Fabrice L wrote:
>
> > Hi,
> >
> > It is fun fact very easy to do. You just use \startMPpage (…) \stopMPpage 
> > multiple times. Here is an example which build an animation of a particle 
> > moving according to a Brownian motion.
>
> A very similar option is to pass a variable to a metapost drawing. This is 
> what I use:
> https://adityam.github.io/context-blog/post/metapost-animation/
> It only works when viewed in acrobat, you can just comment out the animation 
> part and wrap it in \startTEXpage .. \stopTEXpage to get multi-page animation.
> Aditya___
> 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
> ___
>

___
If your question 

[NTG-context] Re: Support Chinese Date Conversion

2023-11-29 Thread Yihan Song
Hi Hans,

That works for me, I patch the core-con.lua with your implementation,
update the local cache by running `mtxrun --script cache --make`, context
my document and get the same "as-is" result as before, I think that would
be a valuable idea to have an extra as-is function for potential number
conversions.

And I just realize, for Chinese date, only year section follows the as-is
pattern, for month or day, December should be represented as 十二月 instead of
一二, twenty-sixth is 二十六日 instead of 二六, we might need to consider to narrow
down the name to be year could be more precise and meaningful.

Cheers,
Yihan


On Wed, Nov 29, 2023 at 5:24 PM Hans Hagen  wrote:

> On 11/29/2023 7:56 AM, Yihan Song wrote:
> > Dears,
> >
> > I am opening a PR  to
> > improve the Chinese date conversion but it seems that repo is just a
> > mirror site without development activities, can someone help to review
> > this one?
>
> sending patched files is faster (i need to check and diff anyway)
>
> can you test with this:
>
>  if name == "date" then
>  -- We could do some number juggling instead but this is fast
> enough. There is
>  -- no error checking here so we assume a proper year. Maybe a
> better name is
>  -- asis (so that it can be used for more than dates).
>  local vector = vector.normal
>  for s in gmatch(tostring(n),".") do
>  r = r + 1 ; result[r] = vector[tonumber(s)]
>  end
>  return concat(result)
>  end
>
> (btw, we also need to adapt the lmt file ... once mkiv is frozen we only
> add to lmtx)
>
> 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] Re: usage of conversion in \date

2023-11-29 Thread Peter Münster
On Wed, Nov 29 2023, Hans Hagen wrote:

> \setuplanguage[fr][date={day:++,\ ,month,\ ,year}]

Unfortunately this does not work as I need. Only the "1" should be
converted to 1er, not the other numbers.

French is a bit special:
You say "le premier novembre" but not "le un novembre".
You say "le deux novembre" but not "le deuxième novembre".

According to https://wiki.contextgarden.net/Command/date:
"The name suffixes indicate number conversions. Any conversion, either
 built-in or defined by \defineconversion, can be used there."

But it does not seem to work...

-- 
   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: Support Chinese Date Conversion

2023-11-29 Thread Hans Hagen

On 11/29/2023 7:56 AM, Yihan Song wrote:

Dears,

I am opening a PR  to 
improve the Chinese date conversion but it seems that repo is just a 
mirror site without development activities, can someone help to review 
this one?


sending patched files is faster (i need to check and diff anyway)

can you test with this:

if name == "date" then
-- We could do some number juggling instead but this is fast 
enough. There is
-- no error checking here so we assume a proper year. Maybe a 
better name is

-- asis (so that it can be used for more than dates).
local vector = vector.normal
for s in gmatch(tostring(n),".") do
r = r + 1 ; result[r] = vector[tonumber(s)]
end
return concat(result)
end

(btw, we also need to adapt the lmt file ... once mkiv is frozen we only 
add to lmtx)


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] Re: usage of conversion in \date

2023-11-29 Thread Hans Hagen

On 11/28/2023 6:09 PM, Peter Münster wrote:

Hi,

When printing a date in French, I would like to convert the "1" to
"1\ier", but it does not work as I expect:

--8<---cut here---start->8---
\startluacode
-- from https://wiki.contextgarden.net/Command/defineconversion:
interfaces.implement {
 name  = "FRdate",
 public= true,
 arguments = "string",
 actions   =
 function(s)
 local n = tonumber(s)
 if n == 1 then
 context"1\\ier"
 else
 context(s)
 end
 end
}
\stopluacode
\def\ier{\highordinalstr{er}}
\mainlanguage[fr]
\defineconversion[frd][\FRdate]
\setuplanguage[fr][date={day:frd,\ ,month,\ ,year}]
\starttext
Conversion: \convertnumber{frd}{1}, \convertnumber{frd}{2} (OK)\\
Dates: \date[d=1], \date[d=2] (not OK)
\stoptext
--8<---cut here---end--->8---

How could I get "1\ier\ novembre 2023" please?

\mainlanguage[fr]

\setuplanguage[fr][date={day:++,\ ,month,\ ,year}]

\starttext
Dates: \date[d=1], \date[d=2] (not OK)
\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 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
___