[NTG-context] animation using \startuseMPgraphic
Hans Hagen
j.hagen at xs4all.nl
Sun Apr 19 22:57:59 CEST 2020
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
-----------------------------------------------------------------
More information about the ntg-context
mailing list