CMS 3D CMS Logo

List of all members | Public Member Functions | Public Attributes | Static Public Attributes
svgfig.Line Class Reference
Inheritance diagram for svgfig.Line:
svgfig.Curve svgfig.HLine svgfig.LineAxis svgfig.VLine svgfig.XAxis svgfig.YAxis

Public Member Functions

def __init__ (self, x1, y1, x2, y2, arrow_start=None, arrow_end=None, attr)
 
def __repr__ (self)
 
def Path (self, trans=None, local=False)
 
def SVG (self, trans=None)
 
- Public Member Functions inherited from svgfig.Curve
def __init__ (self, f, low, high, loop=False, attr)
 
def __repr__ (self)
 
def Path (self, trans=None, local=False)
 
def sample (self, trans=None)
 end nested class More...
 
def subsample (self, left, right, depth, trans=None)
 
def SVG (self, trans=None)
 

Public Attributes

 arrow_end
 
 attr
 
 f
 
 high
 
 loop
 
 low
 
 y2
 
- Public Attributes inherited from svgfig.Curve
 attr
 
 f
 
 high
 
 last_samples
 
 loop
 
 low
 

Static Public Attributes

dictionary defaults = {}
 
- Static Public Attributes inherited from svgfig.Curve
dictionary defaults = {}
 
int discontinuity_limit = 5
 
float linearity_limit = 0.05
 
bool random_sampling = True
 
int recursion_limit = 15
 

Detailed Description

Draws a line between two points.

Line(x1, y1, x2, y2, arrow_start, arrow_end, attribute=value)

x1, y1                  required        the starting point
x2, y2                  required        the ending point
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

Definition at line 1977 of file svgfig.py.

Constructor & Destructor Documentation

def svgfig.Line.__init__ (   self,
  x1,
  y1,
  x2,
  y2,
  arrow_start = None,
  arrow_end = None,
  attr 
)

Definition at line 1996 of file svgfig.py.

1996  def __init__(self, x1, y1, x2, y2, arrow_start=None, arrow_end=None, **attr):
1997  self.x1, self.y1, self.x2, self.y2 = x1, y1, x2, y2
1998  self.arrow_start, self.arrow_end = arrow_start, arrow_end
1999 
2000  self.attr = dict(self.defaults)
2001  self.attr.update(attr)
2002 
def __init__(self, x1, y1, x2, y2, arrow_start=None, arrow_end=None, attr)
Definition: svgfig.py:1996
dictionary defaults
Definition: svgfig.py:1510

Member Function Documentation

def svgfig.Line.__repr__ (   self)
def svgfig.Line.Path (   self,
  trans = None,
  local = False 
)
Apply the transformation "trans" and return a Path object in
global coordinates.  If local=True, return a Path in local coordinates
(which must be transformed again).

Definition at line 2035 of file svgfig.py.

2035  def Path(self, trans=None, local=False):
2036  """Apply the transformation "trans" and return a Path object in
2037  global coordinates. If local=True, return a Path in local coordinates
2038  (which must be transformed again)."""
2039  self.f = lambda t: (self.x1 + t*(self.x2 - self.x1), self.y1 + t*(self.y2 - self.y1))
2040  self.low = 0.
2041  self.high = 1.
2042  self.loop = False
2043 
2044  if trans == None:
2045  return Path([("M", self.x1, self.y1, not local), ("L", self.x2, self.y2, not local)], **self.attr)
2046  else:
2047  return Curve.Path(self, trans, local)
2048 
def Path(self, trans=None, local=False)
Definition: svgfig.py:2035
def svgfig.Line.SVG (   self,
  trans = None 
)
Apply the transformation "trans" and return an SVG object.

Definition at line 2003 of file svgfig.py.

References svgfig.Line.arrow_end, svgfig.Ticks.arrow_start, svgfig.make_marker(), SiStripHistoPlotter::PlotParameter.Path, Json::PathArgument.Path, and svgfig.Curve.Path().

2003  def SVG(self, trans=None):
2004  """Apply the transformation "trans" and return an SVG object."""
2005 
2006  line = self.Path(trans).SVG()
2007 
2008  if (self.arrow_start != False and self.arrow_start != None) or (self.arrow_end != False and self.arrow_end != None):
2009  defs = SVG("defs")
2010 
2011  if self.arrow_start != False and self.arrow_start != None:
2012  if isinstance(self.arrow_start, SVG):
2013  defs.append(self.arrow_start)
2014  line.attr["marker-start"] = "url(#%s)" % self.arrow_start["id"]
2015  elif isinstance(self.arrow_start, str):
2016  defs.append(make_marker(self.arrow_start, "arrow_start"))
2017  line.attr["marker-start"] = "url(#%s)" % self.arrow_start
2018  else:
2019  raise TypeError("arrow_start must be False/None or an id string for the new marker")
2020 
2021  if self.arrow_end != False and self.arrow_end != None:
2022  if isinstance(self.arrow_end, SVG):
2023  defs.append(self.arrow_end)
2024  line.attr["marker-end"] = "url(#%s)" % self.arrow_end["id"]
2025  elif isinstance(self.arrow_end, str):
2026  defs.append(make_marker(self.arrow_end, "arrow_end"))
2027  line.attr["marker-end"] = "url(#%s)" % self.arrow_end
2028  else:
2029  raise TypeError("arrow_end must be False/None or an id string for the new marker")
2030 
2031  return SVG("g", defs, line)
2032 
2033  return line
2034 
def make_marker(id, shape, attr)
Definition: svgfig.py:1965
def Path(self, trans=None, local=False)
Definition: svgfig.py:1654
def SVG(self, trans=None)
Definition: svgfig.py:2003

Member Data Documentation

svgfig.Line.arrow_end

Definition at line 1998 of file svgfig.py.

Referenced by svgfig.Line.SVG(), svgfig.LineGlobal.SVG(), and svgfig.CurveAxis.SVG().

svgfig.Line.attr
dictionary svgfig.Line.defaults = {}
static

Definition at line 1991 of file svgfig.py.

Referenced by tree.Tree.reset(), and tree.Tree.var().

svgfig.Line.f
svgfig.Line.high
svgfig.Line.loop

Definition at line 2042 of file svgfig.py.

svgfig.Line.low
svgfig.Line.y2