Public Member Functions | |
def | __init__ |
def | __repr__ |
def | SVG |
Public Attributes | |
arrow_end | |
attr | |
local2 | |
y2 | |
Static Public Attributes | |
dictionary | defaults = {} |
Draws a line between two points, one or both of which is in global coordinates. Line(x1, y1, x2, y2, lcoal1, local2, arrow_start, arrow_end, attribute=value) x1, y1 required the starting point x2, y2 required the ending point local1 default=False if True, interpret first point as a local coordinate (apply transform) local2 default=False if True, interpret second point as a local coordinate (apply transform) arrow_start default=None if an identifier string/Unicode, draw a new arrow object at the beginning of the line; if a marker, draw that marker instead arrow_end default=None same for the end of the line attribute=value pairs keyword list SVG attributes
def svgfig::LineGlobal::__init__ | ( | self, | |
x1, | |||
y1, | |||
x2, | |||
y2, | |||
local1 = False , |
|||
local2 = False , |
|||
arrow_start = None , |
|||
arrow_end = None , |
|||
attr | |||
) |
def svgfig::LineGlobal::__repr__ | ( | self | ) |
def svgfig::LineGlobal::SVG | ( | self, | |
trans = None |
|||
) |
Apply the transformation "trans" and return an SVG object.
Definition at line 2084 of file svgfig.py.
02085 : 02086 """Apply the transformation "trans" and return an SVG object.""" 02087 if isinstance(trans, basestring): trans = totrans(trans) 02088 02089 X1, Y1, X2, Y2 = self.x1, self.y1, self.x2, self.y2 02090 02091 if self.local1: X1, Y1 = trans(X1, Y1) 02092 if self.local2: X2, Y2 = trans(X2, Y2) 02093 02094 line = SVG("path", d="M%s %s L%s %s" % (X1, Y1, X2, Y2), **self.attr) 02095 02096 if (self.arrow_start != False and self.arrow_start != None) or (self.arrow_end != False and self.arrow_end != None): 02097 defs = SVG("defs") 02098 02099 if self.arrow_start != False and self.arrow_start != None: 02100 if isinstance(self.arrow_start, SVG): 02101 defs.append(self.arrow_start) 02102 line.attr["marker-start"] = "url(#%s)" % self.arrow_start["id"] 02103 elif isinstance(self.arrow_start, basestring): 02104 defs.append(make_marker(self.arrow_start, "arrow_start")) 02105 line.attr["marker-start"] = "url(#%s)" % self.arrow_start 02106 else: 02107 raise TypeError, "arrow_start must be False/None or an id string for the new marker" 02108 02109 if self.arrow_end != False and self.arrow_end != None: 02110 if isinstance(self.arrow_end, SVG): 02111 defs.append(self.arrow_end) 02112 line.attr["marker-end"] = "url(#%s)" % self.arrow_end["id"] 02113 elif isinstance(self.arrow_end, basestring): 02114 defs.append(make_marker(self.arrow_end, "arrow_end")) 02115 line.attr["marker-end"] = "url(#%s)" % self.arrow_end 02116 else: 02117 raise TypeError, "arrow_end must be False/None or an id string for the new marker" 02118 02119 return SVG("g", defs, line) 02120 02121 return line
dictionary svgfig::LineGlobal::defaults = {} [static] |