Re: [NTG-context] animation using \startuseMPgraphic

2020-04-21 Thread Jeong Dal
Dear Hans,

I have not experienced a bottleneck when running ConTeXt.
It is stable and fast. 

I am satisfied with ConTeXt except there are many features and commands which 
are not explained.
Frankly speaking, I don’t need that much commands for my job. 
Also it is not the problem because there are many experts who willingly give 
the solutions in the list mail

I appreciate you and your team.

Best regards,

Dalyoung

> 2020. 4. 21. 오전 2:19, Hans Hagen  작성:
> 
> On 4/20/2020 4:40 PM, Jeong Dal wrote:
> 
>> Of course, it runs so fast that it is meaningless to shorten the runtime.
>> It is my old habit to check the algorithmic efficiency.
> 
> We share the same habit ... unfortunately there is not much performance to 
> gain after all these years. Of course users are invited to tell me where they 
> see a (real) bottleneck that doesn't make sense to them.
> 
> 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] animation using \startuseMPgraphic

2020-04-20 Thread Hans Hagen

On 4/20/2020 4:40 PM, Jeong Dal wrote:


Of course, it runs so fast that it is meaningless to shorten the runtime.
It is my old habit to check the algorithmic efficiency.


We share the same habit ... unfortunately there is not much performance 
to gain after all these years. Of course users are invited to tell me 
where they see a (real) bottleneck that doesn't make sense to them.


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] animation using \startuseMPgraphic

2020-04-20 Thread Jeong Dal
Dear Hans,

Of course, it runs so fast that it is meaningless to shorten the runtime.
It is my old habit to check the algorithmic efficiency.

It is just my interest.

Thank you for your concern.

Best regards,

Dalyoung




___
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] animation using \startuseMPgraphic

2020-04-19 Thread Jeong Dal
Dear Aditya,

Thank you for your link.
It is good to see your nice code.

I’ll see how to apply \startMPanimation … \stopMPanimation to my sample.

Thank you again.

Best regards,

Dalyoung

___
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] animation using \startuseMPgraphic

2020-04-19 Thread Hans Hagen

On 4/19/2020 9:02 PM, Jeong Dal wrote:

Dear Wolfgang,

I’d like to ask you one more.

To make an animation, almost same graphics are drawn repeatedly.
In my code, for example,
The base figure(two circles, line, boundingbox) is fixed and only points 
are moved.

But it draws the base figure every time and it is not inefficient.


In what sense? Runtime? Even moving the definitions doesn't really save 
cpu cycles. MP runtime is normally not the bottleneck in a run.


\startMPextensions
vardef findPointD(expr C, Q, r) =
numeric dist, ang;
pair X, Y;
dist := r**2/sqrt((xpart Q - xpart C)**2 + (ypart Q - ypart C)**2);
ang := angle(Q - C);
Y := C + dir(ang)*dist;
Y
enddef;
\stopMPextensions

Is there a way to draw the base figure once, and draw the points only at 
each frame?
I guess you could stack them on top of a base background image but I 
wonder if it's worth the trouble.


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] animation using \startuseMPgraphic

2020-04-19 Thread Jeong Dal
Dear Wolfgang,

I’d like to ask you one more.

To make an animation, almost same graphics are drawn repeatedly.
In my code, for example,
The base figure(two circles, line, boundingbox) is fixed and only points are 
moved.
But it draws the base figure every time and it is not inefficient.

Is there a way to draw the base figure once, and draw the points only at each 
frame?

Thank you.
Best regards,

Dalyoung

\startuseMPgraphic{inversionPoint}{n}
vardef findPointD(expr C, Q, r) = 
numeric dist, ang;
pair X, Y;
dist := r**2/sqrt((xpart Q - xpart C)**2 + (ypart Q - ypart C)**2);
ang := angle(Q - C);
Y := C + dir(ang)*dist;
Y
enddef;

numeric radius, now, move;
pair A,B,C,P,Q;
path p,q;
   radius := 2cm;
   C := origin;
   p := fullcircle scaled (2*radius);
   z[1] = point 6 of p;
   z[2] = point .8 of p;

   q := (1.5*z1 - .5*z2) -- (-.5z1 + 1.5*z2);
   %q := fullcircle scaled radius shifted (2cm, 1cm);
   draw p;
   draw q; 

% end of base figure
% draw points

move := 0.1;
now := move*\MPvar{n};
P := point now along q;
Q := findPointD(C, P, radius);
drawdot P;
drawdot Q withcolor .625red;
dotlabel.lft(textext("P"),P);
dotlabel.rt(textext("Q"),Q) withcolor .625red;
\stopuseMPgraphic

___
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] animation using \startuseMPgraphic

2020-04-19 Thread Aditya Mahajan

On Sun, 19 Apr 2020, Jeong Dal wrote:


Dear all,

I am trying to make an animation using the animation module.
But it draws 10 figures instead of creating animation.
Is there anything I have to do more?
Or, is there a better way to do this?

Thank you for reading.

Best regards,

Dalyoung


\startuseMPgraphic{inversionPoint}{n}
vardef findPointD(expr C, Q, r) =
   numeric dist, ang;
   pair X, Y;
   dist := r**2/sqrt((xpart Q - xpart C)**2 + (ypart Q - ypart C)**2);
   ang := angle(Q - C);
   Y := C + dir(ang)*dist;
   Y
enddef;
numeric radius, now, move;
pair A,B,C,P,Q;
path p,q;

radius := 2cm;
C := origin;
p := fullcircle scaled (2*radius);
z[1] = point 6 of p;
z[2] = point .8 of p;

q := (1.5*z1 - .5*z2) -- (-.5z1 + 1.5*z2);
%q := fullcircle scaled radius shifted (2cm, 1cm);
draw p;
draw q;
%for i := 0 step 0.1 until 1:
   move := 0.1;
   now := move*\MPvar{n};
   P := point now along q;
   Q := findPointD(C, P, radius);
   drawdot P;
   drawdot Q withcolor .625red;
   dotlabel.lft(textext("P"),P);
   dotlabel.rt(textext("Q"),Q) withcolor .625red;
%endfor;
\stopuseMPgraphic

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

\starttext
%\startplacefigure[]
   \startanimation[menu=yes]
   \dorecurse{10}{
   \useMPgraphic{inversionPoint}{n=\recurselevel}
   }
   \stopanimation
%\stopplacefigure
\stoptext


Also see my simple wrapper around this:

https://adityam.github.io/context-blog/post/metapost-animation/

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] animation using \startuseMPgraphic

2020-04-19 Thread Jeong Dal
Dear Wolfgang,

Thank you for your help.
It works fine.

As you said, I need to use boundingbox for stable animation.

Thank you again.

Best regards,

Dalyoung


> 2020. 4. 19. 오후 4:19, Wolfgang Schuster  
> 작성:
> 
> Jeong Dal schrieb am 19.04.2020 um 07:08:
>> Dear all,
>> I am trying to make an animation using the animation module.
>> But it draws 10 figures instead of creating animation.
>> Is there anything I have to do more?
> 
> You have to put each animation step in a frame environment. I recommend also 
> to set the boundingbox to the same size for each frame, otherwise your 
> graphic jumps around.
> 
> When you use \recurselevel you have to use this:
> 
> \startanimation[menu=yes]
>  \dorecurse{10}
>{\startexpanded
>   \startframe
> \useMPgraphic{inversionPoint}{n=\recurselevel}%
>   \stopframe
> \stopexpanded}
> \stopanimation
> 
> or use #1 to access the counter level and get rid of \startexpanded:
> 
> \startanimation[menu=yes]
>  \dorecurse{10}
>{\startframe
>   \useMPgraphic{inversionPoint}{n=#1}%
> \stopframe}
> \stopanimation
> 
> Wolfgang

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

maillist : ntg-context@ntg.nl / http://www.ntg.nl/mailman/listinfo/ntg-context
webpage  : http://www.pragma-ade.nl / http://context.aanhet.net
archive  : https://bitbucket.org/phg/context-mirror/commits/
wiki : http://contextgarden.net
___


Re: [NTG-context] animation using \startuseMPgraphic

2020-04-19 Thread Wolfgang Schuster

Jeong Dal schrieb am 19.04.2020 um 07:08:

Dear all,

I am trying to make an animation using the animation module.
But it draws 10 figures instead of creating animation.
Is there anything I have to do more?


You have to put each animation step in a frame environment. I recommend 
also to set the boundingbox to the same size for each frame, otherwise 
your graphic jumps around.


When you use \recurselevel you have to use this:

\startanimation[menu=yes]
  \dorecurse{10}
{\startexpanded
   \startframe
 \useMPgraphic{inversionPoint}{n=\recurselevel}%
   \stopframe
 \stopexpanded}
\stopanimation

or use #1 to access the counter level and get rid of \startexpanded:

\startanimation[menu=yes]
  \dorecurse{10}
{\startframe
   \useMPgraphic{inversionPoint}{n=#1}%
 \stopframe}
\stopanimation

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

maillist : ntg-context@ntg.nl / http://www.ntg.nl/mailman/listinfo/ntg-context
webpage  : http://www.pragma-ade.nl / http://context.aanhet.net
archive  : https://bitbucket.org/phg/context-mirror/commits/
wiki : http://contextgarden.net
___


[NTG-context] animation using \startuseMPgraphic

2020-04-18 Thread Jeong Dal
Dear all,

I am trying to make an animation using the animation module.
But it draws 10 figures instead of creating animation.
Is there anything I have to do more?
Or, is there a better way to do this?

Thank you for reading.

Best regards,

Dalyoung


\startuseMPgraphic{inversionPoint}{n}
vardef findPointD(expr C, Q, r) = 
numeric dist, ang;
pair X, Y;
dist := r**2/sqrt((xpart Q - xpart C)**2 + (ypart Q - ypart C)**2);
ang := angle(Q - C);
Y := C + dir(ang)*dist;
Y
enddef;
numeric radius, now, move;
pair A,B,C,P,Q;
path p,q;

radius := 2cm;
C := origin;
p := fullcircle scaled (2*radius);
z[1] = point 6 of p;
z[2] = point .8 of p;

q := (1.5*z1 - .5*z2) -- (-.5z1 + 1.5*z2);
%q := fullcircle scaled radius shifted (2cm, 1cm);
draw p;
draw q; 
%for i := 0 step 0.1 until 1:
move := 0.1;
now := move*\MPvar{n};
P := point now along q;
Q := findPointD(C, P, radius);
drawdot P;
drawdot Q withcolor .625red;
dotlabel.lft(textext("P"),P);
dotlabel.rt(textext("Q"),Q) withcolor .625red;
%endfor;
\stopuseMPgraphic

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

\starttext
%\startplacefigure[]
\startanimation[menu=yes]
\dorecurse{10}{
\useMPgraphic{inversionPoint}{n=\recurselevel}
}
\stopanimation
%\stopplacefigure
\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
___