Commit 3637990d authored by Margaux Mouchene's avatar Margaux Mouchene
Browse files

change bresenham loc

parent 9e827d93
......@@ -169,6 +169,8 @@ class MapView(AbstractMapView):
# painter.drawText(10+dx, 20+dy, 'Map')
# interaction
print('map state', self.model.map_istate)
print('plot state', self.plot_model.plot_istate)
def mousePressEvent(self, e):
"""
......
......@@ -115,35 +115,3 @@ def openUrl(self):
url = QUrl('https://deformvis.gricad-pages.univ-grenoble-alpes.fr/insarviz/index.html') # noqa
if not QDesktopServices.openUrl(url):
QMessageBox.warning(self, 'Open Url', 'Could not open url')
def line(x0, y0, x1, y1):
"""Bresenham algorithm for line drawing.
yields pixels for the line from (x0, y0) to (x1, y1)
both ends are included.
"""
dx, dy = x1-x0, y1-y0
xsign = 1 if dx > 0 else -1
ysign = 1 if dy > 0 else -1
dx, dy = abs(dx), abs(dy)
if dx > dy:
xx, xy, yx, yy = xsign, 0, 0, ysign
else:
dx, dy = dy, dx
xx, xy, yx, yy = 0, ysign, xsign, 0
D = 2*dy - dx
y = 0
for x in range(dx + 1):
yield x0 + x*xx + y*yx, y0 + x*xy + y*yy
if D >= 0:
y += 1
D -= 2*dx
D += 2*dy
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment