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 1976 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 1995 of file svgfig.py.

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

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 2034 of file svgfig.py.

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

Definition at line 2002 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().

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

Member Data Documentation

svgfig.Line.arrow_end

Definition at line 1997 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 1990 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 2041 of file svgfig.py.

svgfig.Line.low
svgfig.Line.y2