-
Notifications
You must be signed in to change notification settings - Fork 10
CodeReference
- summary One-sentence summary of this page.
_(The following applies only to the 1.x branch of SVGFig. For version 2.x, see [Version2Announcement].)_
- *[#Graphics_Primitives Graphics Primitives]* ([GeneralPrimitive general features])
- *[#Curves Curves]*
- [ClassCurve Curve], [DefFuncRtoR2 funcRtoR2()], [DefFuncRtoC funcRtoC()], [DefFuncRtoR funcRtoR()], [ClassLine Line], [ClassVLine HLine and VLine], [ClassRect Rect], [ClassEllipse Ellipse]
- *[http://code.google.com/p/svgfig/wiki/CodeReference#Ticks%2C_Axes%2C_and_Gridlines Ticks, Axes, and Gridlines]*
- [TickSpecification tick specification], [ClassTicks Ticks], [ClassCurveAxis CurveAxis], [ClassLineAxis LineAxis], [ClassAxes XAxis, YAxis, and Axes], [ClassGrid Grid, HGrid, and VGrid]
- *[#Miscellaneous_Graphics_Primitives Miscellaneous Graphics Primitives]*
- [ClassPath Path], [DefPathtoPath pathtoPath()], [ClassPoly Poly], [ClassDots Dots], [ClassYErrorBars YErrorBars and XErrorBars], [ClassLine LineGlobal], [ClassText Text], [ClassTextGlobal TextGlobal]
- *[#Figures Figures]*
- [ClassFig class Fig], [ClassPlot class Plot], [ClassFrame class Frame]
- *[#Transformations Transformations]*
- [DefTotrans totrans()], [DefWindow window()], [DefRotate rotate()]
- *[#SVG_Objects SVG Objects]*
- [ClassSVG SVG], [DefCanvas canvas() and canvas_outline()], [Defload load() and load_stream()], [DefTemplate template()], [DefMake_symbol make_symbol()], [DefMake_marker make_marker()]
- *[#Other_Functions Other Functions]*
- [DefRgb rgb()]
A _graphics primitive_ is any one graphics object, such as a line, curve, or polygon. You can apply coordinate transformations to graphics primitives, group them together into figures, and then convert them to SVG objects.
- [GeneralPrimitive General features] of all graphics primitives
A _curve_ is a graphics primitive representing a parametric curve. Curves map correctly under coordinate transformations -- SVGFig uses an adaptive sampling algorithm to convert the end result to SVG.
- [ClassCurve class Curve]: a parametric curve defined by a function; svgfig uses an adaptive sampling algorithm to convert Curves to SVG path elements. You can use the functions [DefFuncRtoR2 funcRtoR2()], [DefFuncRtoC funcRtoC()], and [DefFuncRtoR funcRtoR()] to assist in the creation of parametric equations.
Curve has the following child classes:
- [ClassLine class Line]: a straight line connecting two points, may become curved after a nonlinear coordinate transformation
- [ClassVLine class HLine and class VLine] (children of Line): a horizontal or vertical line
- [ClassRect class Rect]: a horizontal or vertical rectangle
- [ClassEllipse class Ellipse]: an arbitrary ellipse or circle
Ticks are graphics primitive representing sequences of tickmarks. These may be drawn using any of the [TickSpecification standard tick specification methods].
- [ClassTicks class Ticks]: a collection of tick marks drawn along a parametric curve (draws the ticks, but not the curve)
- [ClassCurveAxis class CurveAxis] (child of Curve and Ticks): a Curve with Ticks
- [ClassLineAxis class LineAxis] (child of Line and Ticks): a Line with Ticks
- [ClassAxes class XAxis and class YAxis] (children of !LineAxis): a horizontal or vertical axis with ticks
- [ClassAxes class Axes]: Both an XAxis and a YAxis
- [ClassGrid class Grid, class HGrid, and class VGrid] (children of Ticks): a sequence of horizontal and/or vertical gridlines
- [ClassPath class Path] any collection of straight or curved arcs, similar to an SVG path element
- [DefPathtoPath pathtoPath()] A function to convert an SVG path element into an object of class Path
- [ClassPoly class Poly]: a smooth or piecewise-linear curve defined by a sequence of points
- [ClassDots class Dots]: a collection of SVG symbols drawn at specified coordinates
- [ClassYErrorBars class YErrorBars and class XErrorBars]: a collection of error bars
- [ClassLine class LineGlobal]: a straight line connecting two points, remains straight under coordinate transformations. One or both endpoints may be specified in global coordinates
- [ClassText class Text]: text placed at specified local coordinates
- [ClassTextGlobal class TextGlobal]: text placed at specified global coordinate
A _figure_ is any set of graphics primitive. A figure is itself a primitive, making it possible to create nested collections. Any transformation applied to a figure is applied separately to each of its members.
There are three classes for creating figures:
- [ClassFig class Fig]: any collection of graphics primitives
- [ClassPlot class Plot]: a figure with coordinate axes
- [ClassFrame class Frame]: a figure with a coordinate frame
Each of the graphics primitives above is subject to _coordinate transformations_. The following functions can be helpful in creating these transformations:
- [DefTotrans totrans()]: turns a string expression or complex function into an R^2^-to-R^2^ function
- [DefWindow window()]: creates a transformation by mapping a rectangle of "inner" coordinates to a rectangle of "outer" coordinates
- [DefRotate rotate()]: rotates the plane around a specified point
An _SVG object_ is a python representation of an SVG element (or group of elements). Graphics primitives can be converted to SVG objects, which can then be assembled and written to SVG image files.
- [ClassSVG class SVG]: any SVG element (e.g. an SVG canvas, an SVG path, an SVG group element, an SVG defs element, etc.) SVG elements can be created directly using the [ClassSVG SVG constructor], or from any graphics primitive by using the (graphics primitive object).SVG() member function. The following functions also create SVG elements:
- [DefCanvas canvas() and canvas_outline()]: functions to create a top-level SVG element; good for changing the aspect ratio
- [Defload load() and load_stream()]: functions to create an SVG element from an SVG file or XML stream
- [DefTemplate template()]: function to create an SVG element from an SVG template file
- [DefMake_symbol make_symbol()]: function to create a SVG symbol element from a template of standard shapes
- [DefMake_marker make_marker()]: function to create a SVG marker element from a template of standard shapes
The following helper functions may be useful when working with graphics primitives or SVGs:
- [DefRgb rgb()]: expresses an rgb triple as a hex string