Package: avg
Animated ScalableVectorGraphics (SVG)This library provides an easy way to make animations using the scalable vector
graphics (SVG) format.  SVG is a web-standard format and can be opened by all
modern web browsers.  An SVG can often be placed wherever any other image type
can be placed.  Even many email clients can view SVG animations.  This format
provides an easy way for others to view an animation without requiring any
additional software installation.ShapesFirst, create your shapes with theshapeclass.  A shape object can be
initialized with the following parameters:x: float or array, default 0.0x values of the shape or the x-axis radius of an ellipse.y: float or array, default 0.0y values of the shape or the y-axis radius of an ellipse.stroke: float or array, default 1.0Stroke width or animated widths.color: float or array, default 0x000000Stroke or fill color or animated colors.  It is a fill color or colors
ifstrokeis a scalar zero.alpha: float or array, default 1.0Opacity or animated opacity values.  A 0.0 means fully transparent and a
1.0 means fully opaque.dur: float, default 1.0Animation duration in seconds.Here is an example:theta=[2*m.pi*n/(100-1)forninrange(100)]stroke=[0.5+0.3*m.sin(2*t)fortintheta]color=[(cl(t)<<16)+(cl(t-120*m.pi/180)<<8)+(cl(t+120*m.pi/180))fortintheta]alpha=[0.6+0.4*m.cos(6*t)fortintheta]tri=avg.shape([-1.0,1.0,0.0,-1.0],[-0.866,-0.866,0.866,-0.866],stroke=stroke,color=color,alpha=alpha,dur=10)In this example, the stroke, color, and alpha have all been made to change over
the period of 10 seconds.  Thecl( )is just a custom triangle function.FramesSecond, place shapes or other frames into frames.  Theframeclass provides
the following initialization parameters:objs: shape or frame or list of suchA single shape or frame object or a list of such objects.x: float or array_like, default 0.0x-axis values of translation of the objects within the frame.y: float or array_like, default 0.0y-axis values of translation of the objects within the frame.ang: float or array_like, default 0.0Angles of rotation of the objects within the frame in degrees.scale: float or array_like, default 1.0Scaling factors of the objects within the frame.dur: float, default 1.0Animation duration in seconds.Here is an example:x=[2*m.sin(3*t)fortintheta]y=[-m.cos(3*t)fortintheta]ang=[-3*t*180/m.pifortintheta]scale=[1+0.5*m.sin(2*t)fortintheta]frm=avg.frame(tri,x,y,ang,scale,dur=10)So, thetrishape will move to the postions(x, y), rotate to the anglesang, and scale byscale.  You can put multiple shapes and frames into
another frame.  Supposeaandbare shapes andC,D, andEare frames.
These can be put into another frame as follows:frm=avg.frame([a,b,C,D,E],x,y,dur=10)AnimateWhen you have finished defining all your shapes and frames, you can create the
animation file using theanimatefunction.  This function takes the following
paramters:obj: shape object, frame object, or list of such objectsThe data to create an animation.filename: string, default 'ani.svg'The desired name of output file.  End it with '.svg' in order for
your system to know which application to use to open it.x_lim: array, default [-1, 1]A list of the minimum and maximum x values to display in the animation.y_lim: array, default [-1, 1]A list of the minimum and maximum y values to display in the animation.width: float, default 640Desired width of the animation image in pixels.  This is also used in
determining the scaling factor for the dimensions of the image.  If not
specified, the image will actually automatically scale to fit the size
of the browser window.progress: bool, default FalseFlag to show progress bar.Here is an example:avg.animate(frm,x_lim=[-3,3],y_lim=[-3,3])Note that not specifying the width will make the image scale to the size of its
container, like the browser window.  However, it also means that parts of the
animation can sometimes be viewable outside the limits specified.