Пример #1
0
    def transform(self, trans):
        trans = svg.cannonical_transformation(trans)

        oldx, oldy = self.x, self.y
        self.x, self.y = trans(self.x, self.y)

        if self.rotate:
            shiftx, shifty = trans(oldx + epsilon, oldy)
            angle = math.atan2(shifty, shiftx)
            trans = eval(
                "lambda x, y: (%(newx)s + cos(%(angle)s)*(x - %(oldx)s) - sin(%(angle)s)*(y - %(oldy)s), %(newy)s + sin(%(angle)s)*(x - %(oldx)s) + cos(%(angle)s)*(y - %(oldy)s))"
                % {
                    "newx": repr(self.x),
                    "newy": repr(self.y),
                    "oldx": repr(oldx),
                    "oldy": repr(oldy),
                    "angle": repr(angle)
                }, math.__dict__)

        else:
            trans = eval(
                "lambda x, y: (x + %(newx)s - %(oldx)s, y + %(newy)s - %(oldy)s)"
                % {
                    "newx": repr(self.x),
                    "newy": repr(self.y),
                    "oldx": repr(oldx),
                    "oldy": repr(oldy)
                })

        for child in self.children:
            if isinstance(child, svg.SVG): child.transform(trans)
Пример #2
0
def transformation_jacobian(expr, x, y, scale=1.):
  func = svg.cannonical_transformation(expr)
  eps = epsilon
  if scale != 0.: eps *= scale

  X0, Y0 = func(x, y)
  xhatx, xhaty = func(x + eps, y)
  yhatx, yhaty = func(x, y + eps)

  return (1.*(xhatx - X0)/eps, 1.*(xhaty - Y0)/eps), (1.*(yhatx - X0)/eps, 1.*(yhaty - Y0)/eps)
Пример #3
0
def transformation_angle(expr, x, y, scale=1.):
  func = svg.cannonical_transformation(expr)
  eps = epsilon
  if scale != 0.: eps *= scale

  xprime, yprime = func(x + eps, y)
  x, y = func(x, y)

  delx, dely = xprime - x, yprime - y
  return math.atan2(dely, delx)
Пример #4
0
def transform(trans, obj):
  if isinstance(trans, basestring):
    trans = svg.cannonical_transformation(trans)

  obj = copy.deepcopy(obj)
  if callable(trans):
    obj.transform(trans)
  else:
    for t in trans: obj.transform(t)
  return obj
Пример #5
0
def transformation_angle(expr, x, y, scale=1.):
    func = svg.cannonical_transformation(expr)
    eps = epsilon
    if scale != 0.: eps *= scale

    xprime, yprime = func(x + eps, y)
    x, y = func(x, y)

    delx, dely = xprime - x, yprime - y
    return math.atan2(dely, delx)
Пример #6
0
def transform(trans, obj):
    if isinstance(trans, basestring):
        trans = svg.cannonical_transformation(trans)

    obj = copy.deepcopy(obj)
    if callable(trans):
        obj.transform(trans)
    else:
        for t in trans:
            obj.transform(t)
    return obj
Пример #7
0
def transformation_jacobian(expr, x, y, scale=1.):
    func = svg.cannonical_transformation(expr)
    eps = epsilon
    if scale != 0.: eps *= scale

    X0, Y0 = func(x, y)
    xhatx, xhaty = func(x + eps, y)
    yhatx, yhaty = func(x, y + eps)

    return (1. * (xhatx - X0) / eps,
            1. * (xhaty - Y0) / eps), (1. * (yhatx - X0) / eps,
                                       1. * (yhaty - Y0) / eps)
Пример #8
0
  def transform(self, trans):
    trans = svg.cannonical_transformation(trans)

    oldx, oldy = self.x, self.y
    self.x, self.y = trans(self.x, self.y)

    if self.rotate:
      shiftx, shifty = trans(oldx + epsilon, oldy)
      angle = math.atan2(shifty, shiftx)
      trans = eval("lambda x, y: (%(newx)s + cos(%(angle)s)*(x - %(oldx)s) - sin(%(angle)s)*(y - %(oldy)s), %(newy)s + sin(%(angle)s)*(x - %(oldx)s) + cos(%(angle)s)*(y - %(oldy)s))" % {"newx": repr(self.x), "newy": repr(self.y), "oldx": repr(oldx), "oldy": repr(oldy), "angle": repr(angle)}, math.__dict__)

    else:
      trans = eval("lambda x, y: (x + %(newx)s - %(oldx)s, y + %(newy)s - %(oldy)s)" %
                   {"newx": repr(self.x), "newy": repr(self.y), "oldx": repr(oldx), "oldy": repr(oldy)})

    for child in self.children:
      if isinstance(child, svg.SVG): child.transform(trans)
Пример #9
0
 def transform(self, trans):
   self.trans.append(svg.cannonical_transformation(trans))
Пример #10
0
  def transform(self, t): self.trans.append(svg.cannonical_transformation(t))

  def bbox(self): return pathdata.bbox(self.d())
Пример #11
0
 def transform(self, trans):
     self.trans.append(svg.cannonical_transformation(trans))
Пример #12
0
 def transform(self, t):
   t = svg.cannonical_transformation(t)
   x1, y1 = t(self.x, self.y)
   x2, y2 = t(self.x + self.width, self.y + self.height)
   self.x, self.y = x1, y1
   self.width, self.height = x2 - x1, y2 - y1