| SVG Generation | BaKoMa TeX | Overviews | |
To see SVG files you need SVG enabled browser.
We recommend Microsoft Internet Explorer with Adobe SVG plugin
(www.adobe.com/svg/viewer/install/main.html).
You needn't even recompile your documents.
Any DVI file may be saved as SVG by using
`File|Generate SVG...' DVI Viewer menu command.
SVG output is compatible with another output formats
(PDF, PS, HTML, View, and Print) so, that the same graphical
formats, font formats, and other features are supported.
In details:
However, importing GIF files may produce undesired rasterisation artefacts depending on resolution of target display. In fact, importing animated GIF files is implemented via importing multi-page Postscript. The way is: GIF2EPS import filter generates multi-page Postscript, such that every page includes subimages extracted from GIF file. So, if you familiar with Postscript using multi-page Postscript is simple and powerful way for creating animated scalable graphics.
Internally, this package uses svg-specials to describe animation. Package source may be found in `BaKoMa\TEX\LATEX' directory of installed BaKoMa TeX. In fact, this package is far from final. I am planning to add more animation effects to it in future.
In static output (Preview, Print, PDF) imported multi-page Postscript is visible as superposition of all pages. This approach is compatible with DVIPS and previous versions of DVIEW. However, new svgstatus operator lets you to customize this approach.
In fact, animated GIF files are imported via translating they into multi-page Postscript by GIF2EPS filter, which places every subimage into separate page with proper settings. Advantage of using multi-page Postscript directly (instead of using GIF) is that scalable graphics may be used. In other side, using this approach is easier then svg-specials or svgmark operator because knowledge of SVG features isn't required.
| [ /Start svgframe | starts frames |
| [ /Next svgframe | starts new frame |
| [ /End svgframe | ends frames. |
| [ /Dur <seconds> /Params svgframe | defines duration of displaying for current and following frames |
| [ /repeatCount <num> /Params svgframe | defines looping count (default is indefinite) |
In importing Postscript figure (and other XXX2EPS) DVIEW does:
[ /Start svgframe
[ /Dur 1 20 div /Params svgframe % Default Speed ...
/showpage { /Next svgframe initgraphics } bind def
(figure.eps) run
[ /End svgframe
In fact, this code supports importing multi-page Postscript
as animated frames.
/svgstatus where {pop} {/svgstatus false def} ifelse
/svgframe where {pop} {/svgframe /cleartomark load def} ifelse
Simple example:
% Compatibility definitions.
/svgstatus where {pop} {/svgstatus false def} ifelse
/svgframe where {pop} {/svgframe /cleartomark load def} ifelse
% We define procedure to draw n's frame
% It gets frame number from operand stack.
/DrawFrame { % <frame-number> DrawFrame
% Simple code draws circles of different sizes
newpath dup dup 0 360 arc stroke
} bind def
% We draw many or just one frame depend on svgstatus
svgstatus {
0 1 100 { DrawFrame showpage } for
} {
50 DrawFrame % Choose most reasonable frame for static ...
} ifelse
In many cases it is reasonable to skip all frames
except of one basic figure.
Please note, that your Postscript file may be embedded into
another Postscript file (as DVIPS does it).
In this reason, using `currentfile closefile' is impossible.
Most reasonable way is skipping rest of file up to some tag,
like following:
% 1. There is code of first frame,
% which is also used for static presentation.
0 0 100 0 360 arc stroke
% 2. Code for skipping following frames.
svgstatus not {
/buf 128 string def
{ currentfile buf readline pop
(%ENDFRAMES) anchorsearch { pop pop exit } if pop } loop
} if
% 3. Code for following frames
100 -1 30 { showpage 0 exch 0 exch 0 360 arc stroke } for
% 4. Tag for skipping frames unused for static output.
%ENDFRAMES
This way is used in SVG.STY file (see in `BaKoMa\TEX\LATEX' directory of installed BaKoMa TeX), which may be examined to learn this approach.
SVG-special has syntax: \special{svg:...}. Body (...) of SVG-special is directly send to SVG output, with proper wrapping groups managed by BaKoMa TeX. In generating another output (Print, PS, PDF, etc.) these specials are just ignored. There is simple example:
\special{svg:<g opacity="0">
<animate attributeType="CSS" attributeName="opacity"
from="0" to="1" fill="freeze"
begin="0s" dur="2s"/>}%
This text should be appeared in 2 seconds
\special{svg:</g>}
This operator may be used inside \special{ps: ...} or inside imported Postscript graphics.
Previous example may be recoded with svgmark:
[ /opacity 0 /g true svgmark % it is `<opacity="0">'
[ /attributeType /CSS /attributeName /opacity
/from 0 /to 1 /fill /freeze
/begin 0 /dur 2 /animate svgmark
(This text should be appeared in 2 seconds) show
[ /g false svgmark % it is `</g>'
Comments:Samples/Slides directory of installied BaKoMa TeX includes EPS-files (atom.eps, diagram.eps, End.eps, etc.) whose use svgmark operator for animation effects.
For compatibility with another Postscript interpreters svgmark operator should be defined like following:
/svgmark where {pop} {/svgmark /cleartomark load def} ifelse