Beispiel #1
0
def main(gfile, args=None):
	start = datetime.now()
	name = gfile if isinstance(gfile,str) else gfile.name
	puts(colored.blue('Visualizing the file: %s\n Started: %s'%(name,datetime.now())))

	# Read in the gcode
	gcode = GCode(gfile, limit=None)
	gcode.parse()
	
	# parse the code into an array of tool moves
	tool = Tool(gcode)
	tool.uniq()
	box = tool.boundBox()
	
	# proces and save image
	ext = args.ext if args is not None else '.pdf'
	outfile = os.path.splitext(gfile.name)[0] + FILEENDING + ext
	print box
	print box[0:2]
	image = Image(outfile, gridsize=box[0:2])
	image.process(tool)
	image.save()

	# how long did this take?
  	puts(colored.green('Time to completion: %s'%(deltaTime(start))))
  	print
Beispiel #2
0
def main(gfile, args=None):
    start = datetime.now()
    name = gfile if isinstance(gfile, str) else gfile.name
    puts(
        colored.blue('Visualizing the file: %s\n Started: %s' %
                     (name, datetime.now())))

    # Read in the gcode
    gcode = GCode(gfile, limit=None)
    gcode.parse()

    # parse the code into an array of tool moves
    tool = Tool(gcode)
    tool.uniq()
    box = tool.boundBox()

    # proces and save image
    ext = args.ext if args is not None else '.pdf'
    outfile = os.path.splitext(gfile.name)[0] + FILEENDING + ext
    print box
    print box[0:2]
    image = Image(outfile, gridsize=box[0:2])
    image.process(tool)
    image.save()

    # how long did this take?
    puts(colored.green('Time to completion: %s' % (deltaTime(start))))
    print
    def render_frame(self, frame_index):

        angle = 2 * math.pi * frame_index / self._frames

        self._camera.set_position(self._dist * math.cos(angle), self._dist * math.sin(angle), 0.0)
        self._camera.set_direction(_rad(180.0) + angle, 0.0)
        get_points = self._camera.compiled_get_points()

        image = Image(self._W, self._H, background_color = (0.1, 0.1, 0.1))

        for line in self._osm_cart:
            image.draw_polygon(
                *[self._camera.get_point(*point) for point in line],
                line_color = (0.7, 0.7, 0.7),
                line_width = 0.3,
            )

        get_points(self._usgs_cart, self._usgs_cart_2d)
        for index in range(self._usgs_cart_2d.shape[1]):
            image.draw_filledcircle(
                *self._usgs_cart_2d[:, index], r = 1.0,
                fill_color = (1.0, 0.0, 0.0),
            )

        image.save(os.path.join('frames', f'frame_{frame_index:05d}.png'))