SVG is a web-based standard for describing 2-dimensional graphics based on XML.
This module allows one to generate an SVG drawing programmatically by way of a
collection of routine calls that draw objects according to a current graphics state.
Structure Documentation
SVG_Point
: struct
•
x
: double
•
y
: double
A 2-dimensional real-valued point (x,y). A proper mylib object.
SVG_Box
: struct
•
w
: double
•
h
: double
A rectangular region of width w and height h. A proper mylib object.
The rectangular region window positioned so that its upper-left corner is at the point corner.
A proper mylib object.
SVG_Path
: void
A series of one or more continuous stroke objects that can be line segments, bezier curve segments,
or elliptical arcs. A proper mylib object.
SVG_Context
: void
An object modeling a particular graphics state, i.e. a setting of stroke, fill, text drawing, and
arrow attributes. A proper mylib object.
Precisely, a graphics state contains a specification of the following:
a stroke color, stroke thickness, and stroke opacity, and whether stroking is on or off.
whether a join between two consecutive strokes is mitered, rounded, or beveled, and if
mitered a limit on how far the miter will extend.
whether the end or beginning of a stroke not connected to another is to be given a
square, round, or butt cap.
a specification of a dashing pattern for a stroke, or that there is none.
a fill color and fill opacity, and whether filling is on or off.
whether or not an open curve should have arrowheads at its beginning and end, the
style and size and of the arrowheads, and the graphics context to be used when drawing them.
a font type and style for text, the point size for the text, and its alignment relative to
the anchor point with respect to which it is to be drawn.
The fill color and opacity only apply if a stroked object is closed (e.g. a rectangle or a
path that is closed with a call to Append_Close.
Text is actually stroked and if the outline is closed the symbol or symbol part is filled.
If an object is both stroked and filled then the stroke takes precedence over any area that
would be covered by the fill. That is, when an object is filled but not stroked then the
fill extends to the infintessimally thin border that defines the enclosed region, but when
the object is stroked and filled, then the fill extends only to the boundary of the stroke
that depends on the width of the stroke. Extra care (and SVG commands) are required to
acheive this effect which we believe should be the correct semantics of a simultaneously
filled and stroked object.
Arrowheads can either have NULL as their graphics context, in which case the current graphics
context for the canvas is used to draw the arrow, or if they have had a graphics context assigned
to them, said context is used. Thus one can, for example, have arrows that are of a different
color and opacity then that of the curve they delimit. Moreover, arrows are carefully drawn
so that their tip and tail both lie on the specified curve. This is not the same as SVG
marks which are simply oriented according to the tangent of the curve at its endpoints.
SVG_Canvas
: void
A drawing canvas corresponding to a .svg file under creation. This is not a proper object, it
can only be created by Begin_SVG_Drawing, then used until a drawing is complete, where upon
it is killed and the drawing completed with a call to Finish_SVG_Drawing. A canvas has its
own graphics context or SVG_Context that is consulted when drawing objects onto the
canvas. One can have any number of canvases in existence at a given time. The code is
fully re-entrant.
The type of arrow to be drawn (if any) at the end of open sub-paths. The underlying
path is not stroked in the area occupied by the arrows. Arrows are drawn with
respect to a special graphics context (see Set_Arrow_Context) that is part of each
SVG_Canvas, unless it is NULL in which case the arrow is drawn with the same
graphics context as the path. The figure below shows the four types of arrows and
their possible orientations at each end. For each group, the leftmost arrow is drawn
with the same context as the path (olive_drab, 7-width stroke, miter join, butt cap, and
no fill). The next
arrow to the right has both the stroke and fill color set to blue_violet, 4-width stroke,
bevel joins and square caps. The next over has the same style as the previous except that
it has red fill and both the join and cap styles are round.
The rightmost arrow in each group is has the same style as the previous arrow except
that the stroke opacity is .4 and the fill opacity is .6.