1. masayuko
  2. blockdiag

Commits

masayuko  committed 5b7cb45

use an integer division

  • Participants
  • Parent commits e2a9d6f
  • Branches default

Comments (0)

Files changed (3)

File src/blockdiag/imagedraw/png.py

View file
  • Ignore whitespace
 #  See the License for the specific language governing permissions and
 #  limitations under the License.
 
+from __future__ import division
 import sys
 if sys.version_info[0] == 2:
     range = xrange
         # centering image.
         w, h = image.size
         if box.width > w:
-            x = box[0] + (box.width - w) / 2
+            x = box[0] + (box.width - w) // 2
         else:
             x = box[0]
 
         if box.height > h:
-            y = box[1] + (box.height - h) / 2
+            y = box[1] + (box.height - h) // 2
         else:
             y = box[1]
 

File src/blockdiag/metrics.py

View file
  • Ignore whitespace
 #  See the License for the specific language governing permissions and
 #  limitations under the License.
 
+from __future__ import division
 import copy
 from collections import defaultdict
 from blockdiag import noderenderer
 
         if use_padding:
             width = node.width or self.metrics.node_width
-            xdiff = int((self.node_width[x] - width) / 2)
+            xdiff = (self.node_width[x] - width) // 2
             if xdiff < 0:
                 xdiff = 0
 
             height = node.height or self.metrics.node_height
-            ydiff = int((self.node_height[y] - height) / 2)
+            ydiff = (self.node_height[y] - height) // 2
             if ydiff < 0:
                 ydiff = 0
         else:
 
         if use_padding:
             width = node.width or self.metrics.node_width
-            xdiff = int((self.node_width[x] - width) / 2)
+            xdiff = (self.node_width[x] - width) // 2
             if xdiff < 0:
                 xdiff = 0
 
             height = node.height or self.metrics.node_height
-            ydiff = int((self.node_height[y] - height) / 2)
+            ydiff = (self.node_height[y] - height) // 2
             if ydiff < 0:
                 ydiff = 0
         else:
 
     @property
     def marginbox(self):
-        return Box(self._box.x1 - int(self.span_width / 8),
-                   self._box.y1 - int(self.span_height / 4),
-                   self._box.x2 + int(self.span_width / 8),
-                   self._box.y2 + int(self.span_height / 4))
+        return Box(self._box.x1 - self.span_width // 8,
+                   self._box.y1 - self.span_height // 4,
+                   self._box.x2 + self.span_width // 8,
+                   self._box.y2 + self.span_height // 4)
 
     @property
     def corebox(self):
 
     @property
     def grouplabelbox(self):
-        return Box(self._box.x1, self._box.y1 - int(self.span_height / 2),
+        return Box(self._box.x1, self._box.y1 - self.span_height // 2,
                    self._box.x2, self._box.y1)
 
 
         if direct == 'up':
             xy = node.bottom
             head.append(XY(xy.x, xy.y + 1))
-            head.append(XY(xy.x - int(cell / 2), xy.y + cell))
+            head.append(XY(xy.x - cell // 2, xy.y + cell))
             head.append(XY(xy.x, xy.y + cell * 2))
-            head.append(XY(xy.x + int(cell / 2), xy.y + cell))
+            head.append(XY(xy.x + cell // 2, xy.y + cell))
             head.append(XY(xy.x, xy.y + 1))
         elif direct == 'down':
             xy = node.top
             head.append(XY(xy.x, xy.y - 1))
-            head.append(XY(xy.x - int(cell / 2), xy.y - cell))
+            head.append(XY(xy.x - cell // 2, xy.y - cell))
             head.append(XY(xy.x, xy.y - cell * 2))
-            head.append(XY(xy.x + int(cell / 2), xy.y - cell))
+            head.append(XY(xy.x + cell // 2, xy.y - cell))
             head.append(XY(xy.x, xy.y - 1))
         elif direct == 'right':
             xy = node.left
             head.append(XY(xy.x - 1, xy.y))
-            head.append(XY(xy.x - cell, xy.y - int(cell / 2)))
+            head.append(XY(xy.x - cell, xy.y - cell // 2))
             head.append(XY(xy.x - cell * 2, xy.y))
-            head.append(XY(xy.x - cell, xy.y + int(cell / 2)))
+            head.append(XY(xy.x - cell, xy.y + cell // 2))
             head.append(XY(xy.x - 1, xy.y))
         elif direct == 'left':
             xy = node.right
             head.append(XY(xy.x + 1, xy.y))
-            head.append(XY(xy.x + cell, xy.y - int(cell / 2)))
+            head.append(XY(xy.x + cell, xy.y - cell // 2))
             head.append(XY(xy.x + cell * 2, xy.y))
-            head.append(XY(xy.x + cell, xy.y + int(cell / 2)))
+            head.append(XY(xy.x + cell, xy.y + cell // 2))
             head.append(XY(xy.x + 1, xy.y))
         elif direct == 'rup':
             xy = node.bottom
             shaft.moveTo(node1.right)
 
             if self.edge.skipped:
-                shaft.lineTo(cell1.right.x + int(span.x / 2), cell1.right.y)
-                shaft.lineTo(cell1.right.x + int(span.x / 2),
-                             cell1.bottomright.y + int(span.y / 2))
-                shaft.lineTo(cell2.left.x - int(span.x / 4),
-                             cell2.bottomright.y + int(span.y / 2))
-                shaft.lineTo(cell2.left.x - int(span.x / 4), cell2.left.y)
+                shaft.lineTo(cell1.right.x + span.x // 2, cell1.right.y)
+                shaft.lineTo(cell1.right.x + span.x // 2,
+                             cell1.bottomright.y + span.y // 2)
+                shaft.lineTo(cell2.left.x - span.x // 4,
+                             cell2.bottomright.y + span.y // 2)
+                shaft.lineTo(cell2.left.x - span.x // 4, cell2.left.y)
 
             shaft.lineTo(node2.left)
 
             shaft.moveTo(node1.right)
 
             if self.edge.skipped:
-                shaft.lineTo(cell1.right.x + int(span.x / 2), cell1.right.y)
-                shaft.lineTo(cell1.right.x + int(span.x / 2),
-                             cell2.bottomleft.y + int(span.y / 2))
-                shaft.lineTo(cell2.left.x - int(span.x / 4),
-                             cell2.bottomleft.y + int(span.y / 2))
-                shaft.lineTo(cell2.left.x - int(span.x / 4), cell2.left.y)
+                shaft.lineTo(cell1.right.x + span.x // 2, cell1.right.y)
+                shaft.lineTo(cell1.right.x + span.x // 2,
+                             cell2.bottomleft.y + span.y // 2)
+                shaft.lineTo(cell2.left.x - span.x // 4,
+                             cell2.bottomleft.y + span.y // 2)
+                shaft.lineTo(cell2.left.x - span.x // 4, cell2.left.y)
             else:
-                shaft.lineTo(cell2.left.x - int(span.x / 4), cell1.right.y)
-                shaft.lineTo(cell2.left.x - int(span.x / 4), cell2.left.y)
+                shaft.lineTo(cell2.left.x - span.x // 4, cell1.right.y)
+                shaft.lineTo(cell2.left.x - span.x // 4, cell2.left.y)
 
             shaft.lineTo(node2.left)
 
         elif _dir == 'right-down':
             shaft.moveTo(node1.right)
-            shaft.lineTo(cell1.right.x + int(span.x / 2), cell1.right.y)
+            shaft.lineTo(cell1.right.x + span.x // 2, cell1.right.y)
 
             if self.edge.skipped:
-                shaft.lineTo(cell1.right.x + int(span.x / 2),
-                             cell2.topleft.y - int(span.y / 2))
-                shaft.lineTo(cell2.left.x - int(span.x / 4),
-                             cell2.topleft.y - int(span.y / 2))
-                shaft.lineTo(cell2.left.x - int(span.x / 4), cell2.left.y)
+                shaft.lineTo(cell1.right.x + span.x // 2,
+                             cell2.topleft.y - span.y // 2)
+                shaft.lineTo(cell2.left.x - span.x // 4,
+                             cell2.topleft.y - span.y // 2)
+                shaft.lineTo(cell2.left.x - span.x // 4, cell2.left.y)
             else:
-                shaft.lineTo(cell1.right.x + int(span.x / 2), cell2.left.y)
+                shaft.lineTo(cell1.right.x + span.x // 2, cell2.left.y)
 
             shaft.lineTo(node2.left)
 
         elif _dir == 'up':
             if self.edge.skipped:
                 shaft.moveTo(node1.right)
-                shaft.lineTo(cell1.right.x + int(span.x / 4), cell1.right.y)
-                shaft.lineTo(cell1.right.x + int(span.x / 4),
-                             cell2.bottom.y + int(span.y / 2))
-                shaft.lineTo(cell2.bottom.x, cell2.bottom.y + int(span.y / 2))
+                shaft.lineTo(cell1.right.x + span.x // 4, cell1.right.y)
+                shaft.lineTo(cell1.right.x + span.x // 4,
+                             cell2.bottom.y + span.y // 2)
+                shaft.lineTo(cell2.bottom.x, cell2.bottom.y + span.y // 2)
             else:
                 shaft.moveTo(node1.top)
 
 
         elif _dir in ('left-up', 'left', 'same'):
             shaft.moveTo(node1.right)
-            shaft.lineTo(cell1.right.x + int(span.x / 4), cell1.right.y)
-            shaft.lineTo(cell1.right.x + int(span.x / 4),
-                         cell2.top.y - int(span.y / 2 + span.y / 8))
+            shaft.lineTo(cell1.right.x + span.x // 4, cell1.right.y)
+            shaft.lineTo(cell1.right.x + span.x // 4,
+                         cell2.top.y - span.y // 2 + span.y // 8)
             shaft.lineTo(cell2.top.x,
-                         cell2.top.y - int(span.y / 2 + span.y / 8))
+                         cell2.top.y - span.y // 2 + span.y // 8)
             shaft.lineTo(node2.top)
 
         elif _dir == 'left-down':
             if self.edge.skipped:
                 shaft.moveTo(node1.right)
-                shaft.lineTo(cell1.right.x + int(span.x / 2), cell1.right.y)
-                shaft.lineTo(cell1.right.x + int(span.x / 2),
-                             cell2.top.y - int(span.y / 2))
-                shaft.lineTo(cell2.top.x, cell2.top.y - int(span.y / 2))
+                shaft.lineTo(cell1.right.x + span.x // 2, cell1.right.y)
+                shaft.lineTo(cell1.right.x + span.x // 2,
+                             cell2.top.y - span.y // 2)
+                shaft.lineTo(cell2.top.x, cell2.top.y - span.y // 2)
             else:
                 shaft.moveTo(node1.bottom)
                 shaft.lineTo(cell1.bottom.x,
-                             cell2.top.y - int(span.y / 2))
-                shaft.lineTo(cell2.top.x, cell2.top.y - int(span.y / 2))
+                             cell2.top.y - span.y // 2)
+                shaft.lineTo(cell2.top.x, cell2.top.y - span.y // 2)
 
             shaft.lineTo(node2.top)
 
         elif _dir == 'down':
             if self.edge.skipped:
                 shaft.moveTo(node1.right)
-                shaft.lineTo(cell1.right.x + int(span.x / 2), cell1.right.y)
-                shaft.lineTo(cell1.right.x + int(span.x / 2),
-                             cell2.top.y - int(span.y / 2 + span.y / 8))
+                shaft.lineTo(cell1.right.x + span.x // 2, cell1.right.y)
+                shaft.lineTo(cell1.right.x + span.x // 2,
+                             cell2.top.y - span.y // 2 + span.y // 8)
                 shaft.lineTo(cell2.top.x,
-                             cell2.top.y - int(span.y / 2 + span.y / 8))
+                             cell2.top.y - span.y // 2 + span.y // 8)
             else:
                 shaft.moveTo(node1.bottom)
 
                 box = Box(node1.bottomright.x + span.x,
                           node1.bottomright.y,
                           node2.bottomleft.x - span.x,
-                          node2.bottomleft.y + int(span.y / 2))
+                          node2.bottomleft.y + span.y // 2)
             else:
-                box = Box(node1.topright.x, node1.topright.y - int(span.y / 8),
-                          node2.left.x, node2.left.y - int(span.y / 8))
+                box = Box(node1.topright.x, node1.topright.y - span.y // 8,
+                          node2.left.x, node2.left.y - span.y // 8)
 
         elif _dir == 'right-up':
-            box = Box(node2.left.x - span.x, node1.top.y - int(node.y / 2),
+            box = Box(node2.left.x - span.x, node1.top.y - node.y // 2,
                       node2.bottomleft.x, node1.top.y)
 
         elif _dir == 'right-down':
-            box = Box(node1.right.x, node2.topleft.y - int(span.y / 8),
-                      node1.right.x + span.x, node2.left.y - int(span.y / 8))
+            box = Box(node1.right.x, node2.topleft.y - span.y // 8,
+                      node1.right.x + span.x, node2.left.y - span.y // 8)
 
         elif _dir in ('up', 'left-up', 'left', 'same'):
             if self.edge.node2.xy.y < self.edge.node1.xy.y:
-                box = Box(node1.topright.x - span.x / 2 + int(span.x / 4),
-                          node1.topright.y - span.y / 2,
-                          node1.topright.x + span.x / 2 + int(span.x / 4),
+                box = Box(node1.topright.x - span.x // 2 + span.x // 4,
+                          node1.topright.y - span.y // 2,
+                          node1.topright.x + span.x // 2 + span.x // 4,
                           node1.topright.y)
             else:
-                box = Box(node1.top.x + int(span.x / 4),
+                box = Box(node1.top.x + span.x // 4,
                           node1.top.y - span.y,
-                          node1.topright.x + int(span.x / 4),
-                          node1.topright.y - int(span.y / 2))
+                          node1.topright.x + span.x // 4,
+                          node1.topright.y - span.y // 2)
 
         elif _dir in ('left-down', 'down'):
-            box = Box(node2.top.x + int(span.x / 4),
+            box = Box(node2.top.x + span.x // 4,
                       node2.top.y - span.y,
-                      node2.topright.x + int(span.x / 4),
-                      node2.topright.y - int(span.y / 2))
+                      node2.topright.x + span.x // 4,
+                      node2.topright.y - span.y // 2)
 
         # shrink box
-        box = Box(box[0] + int(span.x / 8), box[1],
-                  box[2] - int(span.x / 8), box[3])
+        box = Box(box[0] + span.x // 8, box[1],
+                  box[2] - span.x // 8, box[3])
 
         return box
 
                 shaft.lineTo(node2.left)
             else:
                 shaft.moveTo(node1.bottom)
-                shaft.lineTo(cell1.bottom.x, cell1.bottom.y + int(span.y / 2))
-                shaft.lineTo(cell2.right.x + int(span.x / 4),
-                             cell1.bottom.y + int(span.y / 2))
-                shaft.lineTo(cell2.right.x + int(span.x / 4),
-                             cell2.top.y - int(span.y / 2 + span.y / 8))
+                shaft.lineTo(cell1.bottom.x, cell1.bottom.y + span.y // 2)
+                shaft.lineTo(cell2.right.x + span.x // 4,
+                             cell1.bottom.y + span.y // 2)
+                shaft.lineTo(cell2.right.x + span.x // 4,
+                             cell2.top.y - span.y // 2 + span.y // 8)
                 shaft.lineTo(cell2.top.x,
-                             cell2.top.y - int(span.y / 2 + span.y / 8))
+                             cell2.top.y - span.y // 2 + span.y // 8)
                 shaft.lineTo(node2.top)
 
         elif _dir == 'right-down':
             shaft.moveTo(node1.bottom)
-            shaft.lineTo(cell1.bottom.x, cell1.bottom.y + int(span.y / 2))
+            shaft.lineTo(cell1.bottom.x, cell1.bottom.y + span.y // 2)
 
             if self.edge.skipped:
-                shaft.lineTo(cell2.left.x - int(span.x / 2),
-                             cell1.bottom.y + int(span.y / 2))
-                shaft.lineTo(cell2.topleft.x - int(span.x / 2),
-                             cell2.topleft.y - int(span.y / 2))
-                shaft.lineTo(cell2.top.x, cell2.top.y - int(span.y / 2))
+                shaft.lineTo(cell2.left.x - span.x // 2,
+                             cell1.bottom.y + span.y // 2)
+                shaft.lineTo(cell2.topleft.x - span.x // 2,
+                             cell2.topleft.y - span.y // 2)
+                shaft.lineTo(cell2.top.x, cell2.top.y - span.y // 2)
             else:
-                shaft.lineTo(cell2.top.x, cell1.bottom.y + int(span.y / 2))
+                shaft.lineTo(cell2.top.x, cell1.bottom.y + span.y // 2)
 
             shaft.lineTo(node2.top)
 
         elif _dir in ('left-up', 'left', 'same'):
             shaft.moveTo(node1.right)
-            shaft.lineTo(cell1.right.x + int(span.x / 4), cell1.right.y)
-            shaft.lineTo(cell1.right.x + int(span.x / 4),
-                         cell2.top.y - int(span.y / 2 + span.y / 8))
+            shaft.lineTo(cell1.right.x + span.x // 4, cell1.right.y)
+            shaft.lineTo(cell1.right.x + span.x // 4,
+                         cell2.top.y - span.y // 2 + span.y // 8)
             shaft.lineTo(cell2.top.x,
-                         cell2.top.y - int(span.y / 2 + span.y / 8))
+                         cell2.top.y - span.y // 2 + span.y // 8)
             shaft.lineTo(node2.top)
 
         elif _dir == 'left-down':
             shaft.moveTo(node1.bottom)
 
             if self.edge.skipped:
-                shaft.lineTo(cell1.bottom.x, cell1.bottom.y + int(span.y / 2))
-                shaft.lineTo(cell2.right.x + int(span.x / 2),
-                             cell1.bottom.y + int(span.y / 2))
-                shaft.lineTo(cell2.right.x + int(span.x / 2),
-                             cell2.top.y - int(span.y / 2))
+                shaft.lineTo(cell1.bottom.x, cell1.bottom.y + span.y // 2)
+                shaft.lineTo(cell2.right.x + span.x // 2,
+                             cell1.bottom.y + span.y // 2)
+                shaft.lineTo(cell2.right.x + span.x // 2,
+                             cell2.top.y - span.y // 2)
             else:
-                shaft.lineTo(cell1.bottom.x, cell2.top.y - int(span.y / 2))
+                shaft.lineTo(cell1.bottom.x, cell2.top.y - span.y // 2)
 
-            shaft.lineTo(cell2.top.x, cell2.top.y - int(span.y / 2))
+            shaft.lineTo(cell2.top.x, cell2.top.y - span.y // 2)
             shaft.lineTo(node2.top)
 
         elif _dir == 'down':
             shaft.moveTo(node1.bottom)
 
             if self.edge.skipped:
-                shaft.lineTo(cell1.bottom.x, cell1.bottom.y + int(span.y / 2))
-                shaft.lineTo(cell1.right.x + int(span.x / 2),
-                             cell1.bottom.y + int(span.y / 2))
-                shaft.lineTo(cell2.right.x + int(span.x / 2),
-                             cell2.top.y - int(span.y / 2))
-                shaft.lineTo(cell2.top.x, cell2.top.y - int(span.y / 2))
+                shaft.lineTo(cell1.bottom.x, cell1.bottom.y + span.y // 2)
+                shaft.lineTo(cell1.right.x + span.x // 2,
+                             cell1.bottom.y + span.y // 2)
+                shaft.lineTo(cell2.right.x + span.x // 2,
+                             cell2.top.y - span.y // 2)
+                shaft.lineTo(cell2.top.x, cell2.top.y - span.y // 2)
 
             shaft.lineTo(node2.top)
 
                 box = Box(node1.bottomright.x + span.x,
                           node1.bottomright.y,
                           node2.bottomleft.x - span.x,
-                          node2.bottomleft.y + int(span.y / 2))
+                          node2.bottomleft.y + span.y // 2)
             else:
-                box = Box(node1.topright.x, node1.topright.y - int(span.y / 8),
-                          node2.left.x, node2.left.y - int(span.y / 8))
+                box = Box(node1.topright.x, node1.topright.y - span.y // 8,
+                          node2.left.x, node2.left.y - span.y // 8)
 
         elif _dir == 'right-up':
             box = Box(node2.left.x - span.x, node2.left.y,
                       node2.bottomleft.x, node2.bottomleft.y)
 
         elif _dir == 'right-down':
-            box = Box(node2.topleft.x, node2.topleft.y - int(span.y / 2),
+            box = Box(node2.topleft.x, node2.topleft.y - span.y // 2,
                       node2.top.x, node2.top.y)
 
         elif _dir in ('up', 'left-up', 'left', 'same'):
             if self.edge.node2.xy.y < self.edge.node1.xy.y:
-                box = Box(node1.topright.x - int(span.x / 2 + span.x / 4),
-                          node1.topright.y - int(span.y / 2),
-                          node1.topright.x + int(span.x / 2 + span.x / 4),
+                box = Box(node1.topright.x - span.x // 2 + span.x // 4,
+                          node1.topright.y - span.y // 2,
+                          node1.topright.x + span.x // 2 + span.x // 4,
                           node1.topright.y)
             else:
-                box = Box(node1.top.x + int(span.x / 4),
+                box = Box(node1.top.x + span.x // 4,
                           node1.top.y - span.y,
-                          node1.topright.x + int(span.x / 4),
-                          node1.topright.y - int(span.y / 2))
+                          node1.topright.x + span.x // 4,
+                          node1.topright.y - span.y // 2)
 
         elif _dir == 'down':
-            box = Box(node2.top.x + int(span.x / 4),
-                      node2.top.y - int(span.y / 2),
-                      node2.topright.x + int(span.x / 4),
+            box = Box(node2.top.x + span.x // 4,
+                      node2.top.y - span.y // 2,
+                      node2.topright.x + span.x // 4,
                       node2.topright.y)
 
         elif _dir == 'left-down':
             box = Box(node1.bottomleft.x, node1.bottomleft.y,
-                      node1.bottom.x, node1.bottom.y + int(span.y / 2))
+                      node1.bottom.x, node1.bottom.y + span.y // 2)
 
         # shrink box
-        box = Box(box[0] + int(span.x / 8), box[1],
-                  box[2] - int(span.x / 8), box[3])
+        box = Box(box[0] + span.x // 8, box[1],
+                  box[2] - span.x // 8, box[3])
 
         return box
 
             shaft.moveTo(node1.bottom)
 
             if self.edge.skipped:
-                shaft.lineTo(cell1.bottom.x, cell1.bottom.y + int(span.y / 2))
-                shaft.lineTo(cell2.left.x - int(span.x / 4),
-                             cell1.bottom.y + int(span.y / 2))
-                shaft.lineTo(cell2.left.x - int(span.x / 4), cell2.left.y)
+                shaft.lineTo(cell1.bottom.x, cell1.bottom.y + span.y // 2)
+                shaft.lineTo(cell2.left.x - span.x // 4,
+                             cell1.bottom.y + span.y // 2)
+                shaft.lineTo(cell2.left.x - span.x // 4, cell2.left.y)
             else:
                 shaft.lineTo(cell1.bottom.x, cell2.left.y)
 
             if self.edge.skipped:
                 box = Box(cell1.bottom.x, cell1.bottom.y,
                           cell1.bottomright.x,
-                          cell1.bottomright.y + int(span.y / 2))
+                          cell1.bottomright.y + span.y // 2)
             else:
-                box = Box(cell1.bottom.x, cell2.left.y - int(span.y / 2),
+                box = Box(cell1.bottom.x, cell2.left.y - span.y // 2,
                           cell1.bottom.x, cell2.left.y)
         else:
             box = super(FlowchartLandscapeEdgeMetrics, self).labelbox
             shaft.moveTo(node1.right)
 
             if self.edge.skipped:
-                shaft.lineTo(cell1.right.x + int(span.x * 3 / 4),
+                shaft.lineTo(cell1.right.x + span.x * 3 // 4,
                              cell1.right.y)
-                shaft.lineTo(cell1.right.x + int(span.x * 3 / 4),
-                             cell2.topleft.y - int(span.y / 2))
-                shaft.lineTo(cell2.top.x, cell2.top.y - int(span.y / 2))
+                shaft.lineTo(cell1.right.x + span.x * 3 // 4,
+                             cell2.topleft.y - span.y // 2)
+                shaft.lineTo(cell2.top.x, cell2.top.y - span.y // 2)
             else:
                 shaft.lineTo(cell2.top.x, cell1.right.y)
 
         cell2 = self.cell(self.edge.node2, use_padding=False)
 
         if _dir == 'down':
-            box = Box(cell2.topleft.x, cell2.top.y - int(span.y / 2),
+            box = Box(cell2.topleft.x, cell2.top.y - span.y // 2,
                       cell2.top.x, cell2.top.y)
         elif _dir == 'right':
             if self.edge.skipped:
                 box = Box(cell1.bottom.x, cell1.bottom.y,
                           cell1.bottomright.x,
-                          cell1.bottomright.y + int(span.y / 2))
+                          cell1.bottomright.y + span.y // 2)
             else:
-                box = Box(cell1.bottom.x, cell2.left.y - int(span.y / 2),
+                box = Box(cell1.bottom.x, cell2.left.y - span.y // 2,
                           cell1.bottom.x, cell2.left.y)
         else:
             box = super(FlowchartPortraitEdgeMetrics, self).labelbox

File src/blockdiag/utils/__init__.py

View file
  • Ignore whitespace
 #  See the License for the specific language governing permissions and
 #  limitations under the License.
 
+from __future__ import division
 import re
 import sys
 import math
 
     @property
     def top(self):
-        return XY(self.x1 + self.width / 2, self.y1)
+        return XY(self.x1 + self.width // 2, self.y1)
 
     @property
     def topright(self):
 
     @property
     def bottom(self):
-        return XY(self.x1 + self.width / 2, self.y2)
+        return XY(self.x1 + self.width // 2, self.y2)
 
     @property
     def bottomright(self):
 
     @property
     def left(self):
-        return XY(self.x1, self.y1 + self.height / 2)
+        return XY(self.x1, self.y1 + self.height // 2)
 
     @property
     def right(self):
-        return XY(self.x2, self.y1 + self.height / 2)
+        return XY(self.x2, self.y1 + self.height // 2)
 
     @property
     def center(self):
-        return XY(self.x1 + self.width / 2, self.y1 + self.height / 2)
+        return XY(self.x1 + self.width // 2, self.y1 + self.height // 2)
 
 
 def any(seq):