This commit is contained in:
Michael Fogleman 2018-02-10 15:58:45 -05:00
parent 639b965b84
commit 3b35f93223
3 changed files with 14 additions and 22 deletions

View File

@ -25,17 +25,9 @@ PEN_DOWN_POSITION = 40
PEN_DOWN_SPEED = 150
PEN_DOWN_DELAY = 0
# ACCELERATION = 8
# MAX_VELOCITY = 6
# CORNER_FACTOR = 0.005
ACCELERATION = 6
ACCELERATION = 4
MAX_VELOCITY = 4
CORNER_FACTOR = 0.0025
# ACCELERATION = 4
# MAX_VELOCITY = 1
# CORNER_FACTOR = 0.001
CORNER_FACTOR = 0.005
VID_PID = '04D8:FD92'

View File

@ -177,7 +177,6 @@ class Drawing(object):
scale = min(width / drawing.width, height / drawing.height)
drawings.append((scale, angle, drawing))
scale, angle, drawing = max(drawings)
print angle
return drawing.scale(scale, scale).center(width, height)
def remove_paths_outside(self, width, height):
@ -193,11 +192,11 @@ class Drawing(object):
paths.append(path)
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:
raise Exception('Drawing.render() requires cairo')
x1, y1, x2, y2 = self.bounds
# x1, y1, x2, y2 = (0, 0, 12, 8.5)
# x1, y1, x2, y2 = self.bounds
x1, y1, x2, y2 = (0, 0, 12, 8.5)
w = x2 - x1
h = y2 - y1
margin *= scale
@ -212,10 +211,11 @@ class Drawing(object):
dc.translate(-x1, -y1)
dc.set_source_rgb(1, 1, 1)
dc.paint()
# dc.set_source_rgb(0.5, 0.5, 0.5)
# dc.set_line_width(1 / scale)
# dc.rectangle(x1, y1, w, h)
# dc.stroke()
if show_bounds:
dc.set_source_rgb(0.5, 0.5, 0.5)
dc.set_line_width(1 / scale)
dc.rectangle(0, 0, 12, 8.5)
dc.stroke()
dc.set_source_rgb(0, 0, 0)
dc.set_line_width(line_width)
for path in self.paths:

View File

@ -26,7 +26,7 @@ def star(x, y, r):
return points[0::2] + points[1::2]
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)
paths = []
for x1, y1 in points:
@ -36,10 +36,10 @@ def main():
d = math.hypot(x2 - x1, y2 - y1)
paths.append(star(x1, y1, d / 2))
drawing = axi.Drawing(paths)
drawing = drawing.remove_paths_outside(11, 8.5)
drawing = drawing.remove_paths_outside(12, 8.5)
drawing = drawing.sort_paths()
# im = drawing.render()
# im.write_to_png('out.png')
im = drawing.render()
im.write_to_png('out.png')
axi.draw(drawing)
if __name__ == '__main__':