|
|
@ -15,6 +15,8 @@ class Margin(object): |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
class Box(object): |
|
|
|
class Box(object): |
|
|
|
|
|
|
|
_margin = .02 |
|
|
|
|
|
|
|
|
|
|
|
def __init__(self): |
|
|
|
def __init__(self): |
|
|
|
self.xmin = self.ymin = 0 |
|
|
|
self.xmin = self.ymin = 0 |
|
|
|
self.xmax = self.ymax = 1 |
|
|
|
self.xmax = self.ymax = 1 |
|
|
@ -37,6 +39,12 @@ class Box(object): |
|
|
|
if not self.height: |
|
|
|
if not self.height: |
|
|
|
self.ymin -= .5 |
|
|
|
self.ymin -= .5 |
|
|
|
self.ymax = self.ymin + 1 |
|
|
|
self.ymax = self.ymin + 1 |
|
|
|
|
|
|
|
xmargin = self._margin * self.width |
|
|
|
|
|
|
|
self.xmin -= xmargin |
|
|
|
|
|
|
|
self.xmax += xmargin |
|
|
|
|
|
|
|
ymargin = self._margin * self.height |
|
|
|
|
|
|
|
self.ymin -= ymargin |
|
|
|
|
|
|
|
self.ymax += ymargin |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
class View(object): |
|
|
|
class View(object): |
|
|
@ -44,6 +52,7 @@ class View(object): |
|
|
|
self.width = width |
|
|
|
self.width = width |
|
|
|
self.height = height |
|
|
|
self.height = height |
|
|
|
self.box = box |
|
|
|
self.box = box |
|
|
|
|
|
|
|
self.box.fix() |
|
|
|
|
|
|
|
|
|
|
|
def x(self, x): |
|
|
|
def x(self, x): |
|
|
|
return self.width * (x - self.box.xmin) / float(self.box.width) |
|
|
|
return self.width * (x - self.box.xmin) / float(self.box.width) |
|
|
|