Cleaned and running

master^2
MitchellHansen 6 years ago
parent fd5940d766
commit a9114c4dd9

@ -78,8 +78,8 @@ class Renderer():
y = None y = None
if (prev_x != x and prev_x is not None) or (prev_y != y and prev_y is not None): if (prev_x != x and prev_x is not None) or (prev_y != y and prev_y is not None):
self.svg_context.line_to(prev_x - self.settings.head_x_offset, prev_y) self.svg_context.line_to(prev_x, prev_y)
self.svg_context.line_to(x - self.settings.head_x_offset, y) self.svg_context.line_to(x, y)
self.svg_context.stroke() self.svg_context.stroke()
print("Largest X : " + str(largest_x)) print("Largest X : " + str(largest_x))
@ -88,14 +88,14 @@ class Renderer():
print("Largest Y : " + str(largest_y)) print("Largest Y : " + str(largest_y))
print("Smallest Y : " + str(smallest_y)) print("Smallest Y : " + str(smallest_y))
if largest_x > self.settings.bed_max_x: if largest_x > self.settings.canvas_x:
print("X OVERFLOW") print("X OVERFLOW")
if largest_y > self.settings.bed_max_y: if largest_y > self.settings.canvas_y:
print("Y OVERFLOW") print("Y OVERFLOW")
if smallest_x < self.settings.bed_min_x: if smallest_x < 0:
print("X_UNDERFLOW") print("X_UNDERFLOW")
if smallest_y < self.settings.bed_min_y: if smallest_y < 0:
print("Y_UNDERFLOW") print("Y_UNDERFLOW")
self.save_surfaces() self.save_surfaces()
@ -108,7 +108,7 @@ class Renderer():
# Save the SVG so we can view it, then immediately reopen it so it's ready for a re-render # Save the SVG so we can view it, then immediately reopen it so it's ready for a re-render
self.svg_surface.finish() self.svg_surface.finish()
os.rename("tmp/rendered-output-t.svg", "tmp/rendered-output.svg") os.rename("tmp/rendered-output-t.svg", "tmp/rendered-output.svg")
self.svg_surface = cairo.SVGSurface("tmp/rendered-output-t.svg", self.settings.bed_actual_x, self.settings.bed_actual_y) self.svg_surface = cairo.SVGSurface("tmp/rendered-output-t.svg", self.settings.canvas_x, self.settings.canvas_y)
self.svg_context = cairo.Context(self.svg_surface) self.svg_context = cairo.Context(self.svg_surface)
# def render(self): # def render(self):

@ -14,12 +14,8 @@ class Svg2GcodeConverter:
self.gcode_preamble = ''' self.gcode_preamble = '''
G91 ; Set to relative mode for the initial pen lift G91 ; Set to relative mode for the initial pen lift
G1 Z20 ; Lift head by 20 G1 Z1 ; Lift head by 1
G90 ; Set back to absolute position mode G90 ; Set back to absolute position mode
M107 ; Fan off
M190 S0 ; Set bed temp
M104 S0 ; Set nozzle temp
G28 ; home all axes
G0 F{1} ; Set the feed rate G0 F{1} ; Set the feed rate
G1 Z{0} ; Move the pen to just above the paper G1 Z{0} ; Move the pen to just above the paper
'''.format(1, self.settings.speed) '''.format(1, self.settings.speed)

@ -31,7 +31,7 @@ class Settings:
# Whether we render lift markers # Whether we render lift markers
self.lift_markers = False self.lift_markers = False
self.lift_counter = 0
# ============ CALCULATED VALUES =========== # ============ CALCULATED VALUES ===========
self.distance_between_centers = abs(self.left_pulley_xy_offset[0]) + self.canvas_x + self.right_pulley_xy_offset[0] self.distance_between_centers = abs(self.left_pulley_xy_offset[0]) + self.canvas_x + self.right_pulley_xy_offset[0]
@ -128,7 +128,7 @@ class Tracer(Tk):
self.render() self.render()
def render(self): def render(self):
self.image_converter.convert_image(self.filename) self.image_converter.convert_image(self.filename, self.image_converter_settings)
self.gcode_converter.convert_gcode() self.gcode_converter.convert_gcode()
self.cairo_renderer.clear_screen() self.cairo_renderer.clear_screen()
@ -157,10 +157,6 @@ class Tracer(Tk):
self.n.add(self.f2, text="Original") self.n.add(self.f2, text="Original")
self.label1.pack(expand=True, fill="both") self.label1.pack(expand=True, fill="both")
if __name__ == "__main__": if __name__ == "__main__":
Tracer() Tracer()

Loading…
Cancel
Save