cleanup
This commit is contained in:
parent
639b965b84
commit
3b35f93223
|
@ -25,17 +25,9 @@ PEN_DOWN_POSITION = 40
|
||||||
PEN_DOWN_SPEED = 150
|
PEN_DOWN_SPEED = 150
|
||||||
PEN_DOWN_DELAY = 0
|
PEN_DOWN_DELAY = 0
|
||||||
|
|
||||||
# ACCELERATION = 8
|
ACCELERATION = 4
|
||||||
# MAX_VELOCITY = 6
|
|
||||||
# CORNER_FACTOR = 0.005
|
|
||||||
|
|
||||||
ACCELERATION = 6
|
|
||||||
MAX_VELOCITY = 4
|
MAX_VELOCITY = 4
|
||||||
CORNER_FACTOR = 0.0025
|
CORNER_FACTOR = 0.005
|
||||||
|
|
||||||
# ACCELERATION = 4
|
|
||||||
# MAX_VELOCITY = 1
|
|
||||||
# CORNER_FACTOR = 0.001
|
|
||||||
|
|
||||||
VID_PID = '04D8:FD92'
|
VID_PID = '04D8:FD92'
|
||||||
|
|
||||||
|
|
|
@ -177,7 +177,6 @@ class Drawing(object):
|
||||||
scale = min(width / drawing.width, height / drawing.height)
|
scale = min(width / drawing.width, height / drawing.height)
|
||||||
drawings.append((scale, angle, drawing))
|
drawings.append((scale, angle, drawing))
|
||||||
scale, angle, drawing = max(drawings)
|
scale, angle, drawing = max(drawings)
|
||||||
print angle
|
|
||||||
return drawing.scale(scale, scale).center(width, height)
|
return drawing.scale(scale, scale).center(width, height)
|
||||||
|
|
||||||
def remove_paths_outside(self, width, height):
|
def remove_paths_outside(self, width, height):
|
||||||
|
@ -193,11 +192,11 @@ class Drawing(object):
|
||||||
paths.append(path)
|
paths.append(path)
|
||||||
return Drawing(paths)
|
return Drawing(paths)
|
||||||
|
|
||||||
def render(self, scale=109, margin=1, line_width=0.5/25.4):
|
def render(self, scale=109, margin=1, line_width=0.5/25.4, show_bounds=True):
|
||||||
if cairo is None:
|
if cairo is None:
|
||||||
raise Exception('Drawing.render() requires cairo')
|
raise Exception('Drawing.render() requires cairo')
|
||||||
x1, y1, x2, y2 = self.bounds
|
# x1, y1, x2, y2 = self.bounds
|
||||||
# x1, y1, x2, y2 = (0, 0, 12, 8.5)
|
x1, y1, x2, y2 = (0, 0, 12, 8.5)
|
||||||
w = x2 - x1
|
w = x2 - x1
|
||||||
h = y2 - y1
|
h = y2 - y1
|
||||||
margin *= scale
|
margin *= scale
|
||||||
|
@ -212,10 +211,11 @@ class Drawing(object):
|
||||||
dc.translate(-x1, -y1)
|
dc.translate(-x1, -y1)
|
||||||
dc.set_source_rgb(1, 1, 1)
|
dc.set_source_rgb(1, 1, 1)
|
||||||
dc.paint()
|
dc.paint()
|
||||||
# dc.set_source_rgb(0.5, 0.5, 0.5)
|
if show_bounds:
|
||||||
# dc.set_line_width(1 / scale)
|
dc.set_source_rgb(0.5, 0.5, 0.5)
|
||||||
# dc.rectangle(x1, y1, w, h)
|
dc.set_line_width(1 / scale)
|
||||||
# dc.stroke()
|
dc.rectangle(0, 0, 12, 8.5)
|
||||||
|
dc.stroke()
|
||||||
dc.set_source_rgb(0, 0, 0)
|
dc.set_source_rgb(0, 0, 0)
|
||||||
dc.set_line_width(line_width)
|
dc.set_line_width(line_width)
|
||||||
for path in self.paths:
|
for path in self.paths:
|
||||||
|
|
|
@ -26,7 +26,7 @@ def star(x, y, r):
|
||||||
return points[0::2] + points[1::2]
|
return points[0::2] + points[1::2]
|
||||||
|
|
||||||
def main():
|
def main():
|
||||||
points = poisson_disc(0, 0, 11, 8.5, 0.4, 64)
|
points = poisson_disc(0, 0, 12, 8.5, 0.4, 64)
|
||||||
index = Index(points)
|
index = Index(points)
|
||||||
paths = []
|
paths = []
|
||||||
for x1, y1 in points:
|
for x1, y1 in points:
|
||||||
|
@ -36,10 +36,10 @@ def main():
|
||||||
d = math.hypot(x2 - x1, y2 - y1)
|
d = math.hypot(x2 - x1, y2 - y1)
|
||||||
paths.append(star(x1, y1, d / 2))
|
paths.append(star(x1, y1, d / 2))
|
||||||
drawing = axi.Drawing(paths)
|
drawing = axi.Drawing(paths)
|
||||||
drawing = drawing.remove_paths_outside(11, 8.5)
|
drawing = drawing.remove_paths_outside(12, 8.5)
|
||||||
drawing = drawing.sort_paths()
|
drawing = drawing.sort_paths()
|
||||||
# im = drawing.render()
|
im = drawing.render()
|
||||||
# im.write_to_png('out.png')
|
im.write_to_png('out.png')
|
||||||
axi.draw(drawing)
|
axi.draw(drawing)
|
||||||
|
|
||||||
if __name__ == '__main__':
|
if __name__ == '__main__':
|
||||||
|
|
Loading…
Reference in New Issue