* animation using \startuseMPgraphic [not found] <mailman.1.1587204001.32518.ntg-context@ntg.nl> @ 2020-04-19 5:08 ` Jeong Dal 2020-04-19 7:19 ` Wolfgang Schuster 2020-04-19 16:32 ` Aditya Mahajan 0 siblings, 2 replies; 10+ messages in thread From: Jeong Dal @ 2020-04-19 5:08 UTC (permalink / raw) To: ntg-context [-- Attachment #1.1: Type: text/plain, Size: 1315 bytes --] 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 [-- Attachment #1.2: Type: text/html, Size: 12040 bytes --] [-- Attachment #2: Type: text/plain, Size: 493 bytes --] ___________________________________________________________________________________ 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 ___________________________________________________________________________________ ^ permalink raw reply [flat|nested] 10+ messages in thread
* Re: animation using \startuseMPgraphic 2020-04-19 5:08 ` animation using \startuseMPgraphic Jeong Dal @ 2020-04-19 7:19 ` Wolfgang Schuster 2020-04-19 11:18 ` Jeong Dal 2020-04-19 16:32 ` Aditya Mahajan 1 sibling, 1 reply; 10+ messages in thread From: Wolfgang Schuster @ 2020-04-19 7:19 UTC (permalink / raw) To: mailing list for ConTeXt users, Jeong Dal 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 ___________________________________________________________________________________ ^ permalink raw reply [flat|nested] 10+ messages in thread
* Re: animation using \startuseMPgraphic 2020-04-19 7:19 ` Wolfgang Schuster @ 2020-04-19 11:18 ` Jeong Dal 2020-04-19 19:02 ` Jeong Dal 2020-04-19 22:49 ` Jeong Dal 0 siblings, 2 replies; 10+ messages in thread From: Jeong Dal @ 2020-04-19 11:18 UTC (permalink / raw) To: Wolfgang Schuster; +Cc: mailing list for ConTeXt users 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 <wolfgang.schuster.lists@gmail.com> 작성: > > 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 ___________________________________________________________________________________ ^ permalink raw reply [flat|nested] 10+ messages in thread
* Re: animation using \startuseMPgraphic 2020-04-19 11:18 ` Jeong Dal @ 2020-04-19 19:02 ` Jeong Dal 2020-04-19 20:57 ` Hans Hagen 2020-04-19 22:49 ` Jeong Dal 1 sibling, 1 reply; 10+ messages in thread From: Jeong Dal @ 2020-04-19 19:02 UTC (permalink / raw) To: Wolfgang Schuster; +Cc: mailing list for ConTeXt users [-- Attachment #1.1: Type: text/plain, Size: 1311 bytes --] 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 [-- Attachment #1.2: Type: text/html, Size: 18292 bytes --] [-- Attachment #2: Type: text/plain, Size: 493 bytes --] ___________________________________________________________________________________ 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 ___________________________________________________________________________________ ^ permalink raw reply [flat|nested] 10+ messages in thread
* Re: animation using \startuseMPgraphic 2020-04-19 19:02 ` Jeong Dal @ 2020-04-19 20:57 ` Hans Hagen 0 siblings, 0 replies; 10+ messages in thread From: Hans Hagen @ 2020-04-19 20:57 UTC (permalink / raw) To: mailing list for ConTeXt users 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 ___________________________________________________________________________________ ^ permalink raw reply [flat|nested] 10+ messages in thread
* Re: animation using \startuseMPgraphic 2020-04-19 11:18 ` Jeong Dal 2020-04-19 19:02 ` Jeong Dal @ 2020-04-19 22:49 ` Jeong Dal 1 sibling, 0 replies; 10+ messages in thread From: Jeong Dal @ 2020-04-19 22:49 UTC (permalink / raw) To: list ntg-context@ntg.nl ntg-context@ntg.nl ntg-context@ntg.nl ntg-context@ntg.nl 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 ___________________________________________________________________________________ ^ permalink raw reply [flat|nested] 10+ messages in thread
* Re: animation using \startuseMPgraphic 2020-04-19 5:08 ` animation using \startuseMPgraphic Jeong Dal 2020-04-19 7:19 ` Wolfgang Schuster @ 2020-04-19 16:32 ` Aditya Mahajan 1 sibling, 0 replies; 10+ messages in thread From: Aditya Mahajan @ 2020-04-19 16:32 UTC (permalink / raw) To: mailing list for ConTeXt users 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 ___________________________________________________________________________________ ^ permalink raw reply [flat|nested] 10+ messages in thread
[parent not found: <mailman.166.1587373273.1194.ntg-context@ntg.nl>]
* Re: animation using \startuseMPgraphic [not found] <mailman.166.1587373273.1194.ntg-context@ntg.nl> @ 2020-04-20 14:40 ` Jeong Dal 2020-04-20 17:19 ` Hans Hagen 0 siblings, 1 reply; 10+ messages in thread From: Jeong Dal @ 2020-04-20 14:40 UTC (permalink / raw) To: list ntg-context@ntg.nl ntg-context@ntg.nl ntg-context@ntg.nl ntg-context@ntg.nl 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 ___________________________________________________________________________________ ^ permalink raw reply [flat|nested] 10+ messages in thread
* Re: animation using \startuseMPgraphic 2020-04-20 14:40 ` Jeong Dal @ 2020-04-20 17:19 ` Hans Hagen 2020-04-21 11:10 ` Jeong Dal 0 siblings, 1 reply; 10+ messages in thread From: Hans Hagen @ 2020-04-20 17:19 UTC (permalink / raw) To: mailing list for ConTeXt users, Jeong Dal 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 ___________________________________________________________________________________ ^ permalink raw reply [flat|nested] 10+ messages in thread
* Re: animation using \startuseMPgraphic 2020-04-20 17:19 ` Hans Hagen @ 2020-04-21 11:10 ` Jeong Dal 0 siblings, 0 replies; 10+ messages in thread From: Jeong Dal @ 2020-04-21 11:10 UTC (permalink / raw) To: Hans Hagen; +Cc: mailing list for ConTeXt users 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 <j.hagen@xs4all.nl> 작성: > > 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 ___________________________________________________________________________________ ^ permalink raw reply [flat|nested] 10+ messages in thread
end of thread, other threads:[~2020-04-21 11:10 UTC | newest] Thread overview: 10+ messages (download: mbox.gz / follow: Atom feed) -- links below jump to the message on this page -- [not found] <mailman.1.1587204001.32518.ntg-context@ntg.nl> 2020-04-19 5:08 ` animation using \startuseMPgraphic Jeong Dal 2020-04-19 7:19 ` Wolfgang Schuster 2020-04-19 11:18 ` Jeong Dal 2020-04-19 19:02 ` Jeong Dal 2020-04-19 20:57 ` Hans Hagen 2020-04-19 22:49 ` Jeong Dal 2020-04-19 16:32 ` Aditya Mahajan [not found] <mailman.166.1587373273.1194.ntg-context@ntg.nl> 2020-04-20 14:40 ` Jeong Dal 2020-04-20 17:19 ` Hans Hagen 2020-04-21 11:10 ` Jeong Dal
This is a public inbox, see mirroring instructions for how to clone and mirror all data and code used for this inbox; as well as URLs for NNTP newsgroup(s).