rule improvements
This commit is contained in:
parent
1385886ab1
commit
1b3c27e441
|
@ -11,7 +11,7 @@ from .progress import Bar
|
||||||
|
|
||||||
TIMESLICE_MS = 10
|
TIMESLICE_MS = 10
|
||||||
|
|
||||||
MICROSTEPPING_MODE = 1
|
MICROSTEPPING_MODE = 2
|
||||||
STEP_DIVIDER = 2 ** (MICROSTEPPING_MODE - 1)
|
STEP_DIVIDER = 2 ** (MICROSTEPPING_MODE - 1)
|
||||||
|
|
||||||
STEPS_PER_INCH = 2032 / STEP_DIVIDER
|
STEPS_PER_INCH = 2032 / STEP_DIVIDER
|
||||||
|
@ -21,13 +21,13 @@ PEN_UP_POSITION = 60
|
||||||
PEN_UP_SPEED = 150
|
PEN_UP_SPEED = 150
|
||||||
PEN_UP_DELAY = 0
|
PEN_UP_DELAY = 0
|
||||||
|
|
||||||
PEN_DOWN_POSITION = 40
|
PEN_DOWN_POSITION = 45
|
||||||
PEN_DOWN_SPEED = 150
|
PEN_DOWN_SPEED = 150
|
||||||
PEN_DOWN_DELAY = 0
|
PEN_DOWN_DELAY = 0
|
||||||
|
|
||||||
ACCELERATION = 4
|
ACCELERATION = 8
|
||||||
MAX_VELOCITY = 4
|
MAX_VELOCITY = 3
|
||||||
CORNER_FACTOR = 0.005
|
CORNER_FACTOR = 0.001
|
||||||
|
|
||||||
VID_PID = '04D8:FD92'
|
VID_PID = '04D8:FD92'
|
||||||
|
|
||||||
|
@ -150,7 +150,7 @@ class Device(object):
|
||||||
self.error = ex, ey
|
self.error = ex, ey
|
||||||
self.stepper_move(step_ms, int(sx), int(sy))
|
self.stepper_move(step_ms, int(sx), int(sy))
|
||||||
t += step_s
|
t += step_s
|
||||||
self.wait()
|
# self.wait()
|
||||||
|
|
||||||
def run_path(self, path):
|
def run_path(self, path):
|
||||||
planner = self.make_planner()
|
planner = self.make_planner()
|
||||||
|
|
|
@ -155,6 +155,7 @@ def title(rule):
|
||||||
ds = [d1, d2]
|
ds = [d1, d2]
|
||||||
d = vertical_stack(ds, 0.125)
|
d = vertical_stack(ds, 0.125)
|
||||||
d = d.join_paths(0.01)
|
d = d.join_paths(0.01)
|
||||||
|
d = d.simplify_paths(0.001)
|
||||||
return d
|
return d
|
||||||
|
|
||||||
def decoder(rule):
|
def decoder(rule):
|
||||||
|
@ -176,31 +177,44 @@ def decoder(rule):
|
||||||
d = axi.Drawing(paths)
|
d = axi.Drawing(paths)
|
||||||
d = d.scale_to_fit_width(8.5 * 2 / 3)
|
d = d.scale_to_fit_width(8.5 * 2 / 3)
|
||||||
d = d.scale(-1, 1)
|
d = d.scale(-1, 1)
|
||||||
|
d = d.join_paths(0.01)
|
||||||
|
d = d.simplify_paths(0.001)
|
||||||
return d
|
return d
|
||||||
|
|
||||||
def single():
|
def label(text):
|
||||||
random.seed(6)
|
d = axi.Drawing(axi.text(text, axi.FUTURAL))
|
||||||
rule = 110
|
d = d.scale_to_fit_height(0.125)
|
||||||
|
d = d.rotate(-90)
|
||||||
|
d = d.move(12, 8.5, 1, 1)
|
||||||
|
d = d.join_paths(0.01)
|
||||||
|
d = d.simplify_paths(0.001)
|
||||||
|
return d
|
||||||
|
|
||||||
|
def single(number, rule, seed):
|
||||||
|
path = '%d-%d-%d' % (number, rule, seed)
|
||||||
|
random.seed(seed)
|
||||||
|
# rule = 90
|
||||||
w = 96
|
w = 96
|
||||||
h = 128
|
h = 120
|
||||||
d = create_drawing(rule, w, h)
|
d = create_drawing(rule, w, h)
|
||||||
d = d.scale_to_fit_width(8.5)
|
d = d.scale_to_fit_width(8.5)
|
||||||
|
|
||||||
|
d = d.sort_paths()
|
||||||
|
d = d.join_paths(0.01)
|
||||||
|
d = d.simplify_paths(0.001)
|
||||||
|
|
||||||
d = vertical_stack([title(rule), d, decoder(rule)], 0.25)
|
d = vertical_stack([title(rule), d, decoder(rule)], 0.25)
|
||||||
d = d.rotate(-90)
|
d = d.rotate(-90)
|
||||||
d = d.scale_to_fit(12, 8.5)
|
d = d.scale_to_fit(12, 8.5)
|
||||||
d = d.rotate(90)
|
d.add(label('#%d' % number))
|
||||||
# print 'sorting paths'
|
|
||||||
# d = d.sort_paths()
|
rotated = d.rotate(90).center(8.5, 12)
|
||||||
# print 'joining paths'
|
|
||||||
# d = d.join_paths(0.01)
|
d.dump(path + '.axi')
|
||||||
# print 'simplifying paths'
|
im = rotated.render(
|
||||||
# d = d.simplify_paths(0.001)
|
|
||||||
print d.bounds
|
|
||||||
d.dump('out.axi')
|
|
||||||
im = d.render(
|
|
||||||
scale=109 * 1, line_width=0.3/25.4,
|
scale=109 * 1, line_width=0.3/25.4,
|
||||||
show_axi_bounds=False, use_axi_bounds=False)
|
show_axi_bounds=False, use_axi_bounds=False)
|
||||||
im.write_to_png('out.png')
|
im.write_to_png(path + '.png')
|
||||||
# axi.draw(d)
|
# axi.draw(d)
|
||||||
|
|
||||||
def multiple():
|
def multiple():
|
||||||
|
@ -227,12 +241,18 @@ def multiple():
|
||||||
d = horizontal_stack(ds, 0.25)
|
d = horizontal_stack(ds, 0.25)
|
||||||
d = vertical_stack([title, d], 0.2)
|
d = vertical_stack([title, d], 0.2)
|
||||||
d = d.scale_to_fit(12, 8.5)
|
d = d.scale_to_fit(12, 8.5)
|
||||||
# print 'sorting paths'
|
print len(d.paths)
|
||||||
# d = d.sort_paths()
|
print 'joining paths'
|
||||||
# print 'joining paths'
|
d = d.join_paths(0.01)
|
||||||
# d = d.join_paths(0.01)
|
print len(d.paths)
|
||||||
# print 'simplifying paths'
|
print 'sorting paths'
|
||||||
# d = d.simplify_paths(0.001)
|
d = d.sort_paths()
|
||||||
|
print len(d.paths)
|
||||||
|
print 'joining paths'
|
||||||
|
d = d.join_paths(0.01)
|
||||||
|
print len(d.paths)
|
||||||
|
print 'simplifying paths'
|
||||||
|
d = d.simplify_paths(0.001)
|
||||||
print d.bounds
|
print d.bounds
|
||||||
d.dump('out.axi')
|
d.dump('out.axi')
|
||||||
im = d.render(scale=109 * 1, line_width=0.3/25.4, show_axi_bounds=False)
|
im = d.render(scale=109 * 1, line_width=0.3/25.4, show_axi_bounds=False)
|
||||||
|
@ -240,7 +260,10 @@ def multiple():
|
||||||
# axi.draw(d)
|
# axi.draw(d)
|
||||||
|
|
||||||
def main():
|
def main():
|
||||||
single()
|
number = 26
|
||||||
|
rule = 90
|
||||||
|
for seed in [3]:
|
||||||
|
single(number, rule, seed)
|
||||||
# multiple()
|
# multiple()
|
||||||
|
|
||||||
if __name__ == '__main__':
|
if __name__ == '__main__':
|
||||||
|
|
Loading…
Reference in New Issue