def __init__(self, lab: UndirectedGraph, canvas_width: int = 400, canvas_height: int = 400, margin: int = 10): EasyCanvas.__init__(self) # check 'lab' type if not isinstance(lab, UndirectedGraph) or \ any([type(p) != type((1, 1)) or len(p) != 2 or type(p[0]) != type(1) or type(p[1]) != type(1) for p in lab.V]): raise TypeError( "The labyrinth must be an UnirectedGraph of two integer tuples" ) self.lab = lab self.paths = [] self.marked_cells = [] self.margin = margin self.max_col = max(p[1] for p in self.lab.V) self.max_row = max(p[0] for p in self.lab.V) self.canvas_width = canvas_width self.canvas_height = canvas_height self.cell_size = min( float((canvas_width - margin) / (self.max_col + 1)), float((canvas_height - margin) / (self.max_row + 1))) self.mw = self.canvas_width - self.cell_size * (self.max_col + 1) self.mh = self.canvas_height - self.cell_size * (self.max_row + 1) self.ip = self.op = None
def __init__(self, g, window_size=(400, 400), vertexmode=X_Y): EasyCanvas.__init__(self) if not isinstance(g, UndirectedGraph) or \ any([type(p) != type((1, 1)) or len(p) != 2 or type(p[0]) != type(p[1]) for p in g.V]) or \ any([type(p[0]) != type(1) and type(p[0]) != type(1.0) for p in g.V]): raise TypeError( "The graph must be an UndirectedGraph. Vertices must be tuples of two integers or floats" ) if vertexmode == Graph2dViewer.ROW_COL: if any([type(p[0]) != type(1) for p in g.V]): raise TypeError( "In this mode, vertices must be tuples of two integers") g = UndirectedGraph(V=[(v[1], -v[0]) for v in g.V], E=[((u[1], -u[0]), (v[1], -v[0])) for (u, v) in g.E]) self.g = g self.max_y = max(p[1] for p in self.g.V) self.max_x = max(p[0] for p in self.g.V) self.min_y = min(p[1] for p in self.g.V) self.min_x = min(p[0] for p in self.g.V) self.window_size = window_size
def __init__(self, g, colors=None, window_size=(400, 400)): EasyCanvas.__init__(self) self.colors = colors # check 'g' type if not isinstance(g, UndirectedGraph) or \ any([type(p) != type((1, 1)) and type(p) != type((1.0, 1.0)) or len(p) != 2 for p in g.V]): raise TypeError( "The graph must be an UnirectedGraph of two integer tuples") self.g = g self.right = max(p[0] for p in self.g.V) self.bottom = min(p[1] for p in self.g.V) self.left = min(p[0] for p in self.g.V) self.top = max(p[1] for p in self.g.V) self.window_size = window_size self.height = self.top - self.bottom self.width = self.right - self.left self.ar = self.width / self.height ar = self.window_size[0] / self.window_size[1] if ar < self.ar: self.window_size = (self.window_size[0], self.window_size[0] / self.ar) else: self.window_size = (self.window_size[1] * self.ar, self.window_size[1])
def __init__(self, heights, scores, path, window_size=(600,400)): EasyCanvas.__init__(self) self.heights = heights self.scores = scores self.path = path self.window_size = window_size
def __init__(self, nom_fich_trabajos: str, nom_fich_solucion: str): EasyCanvas.__init__(self) try: self.pageSize, self.foil_dict = ImprentaViewer.dict_imprenta(nom_fich_trabajos) except Exception: print("ERROR leyendo fichero '{0}".format(nom_fich_trabajos)) sys.exit() try: self.sol = ImprentaViewer.lee_fichero_solucion(nom_fich_solucion) except Exception: print("ERROR leyendo fichero '{0}".format(nom_fich_solucion)) sys.exit() self.num_pages = max(s[1] for s in self.sol)
def __init__(self, g, window_size=(400, 400)): EasyCanvas.__init__(self) # check 'g' type if not isinstance(g, UndirectedGraph) or \ any([type(p)!=type((1,1)) or len(p)!=2 or type(p[0])!=type(1) or type(p[1])!=type(1) for p in g.V]): raise TypeError( "The labyrinth must be an UnirectedGraph of two integer tuples" ) self.g = g self.max_col = max(p[1] for p in self.g.V) self.max_row = max(p[0] for p in self.g.V) self.min_col = min(p[1] for p in self.g.V) self.min_row = min(p[0] for p in self.g.V) self.window_size = window_size
def __init__(self, lab, cell_size=10, margin=10, show_io = False): EasyCanvas.__init__(self) # check 'lab' type if not isinstance(lab, UndirectedGraph) or \ any([type(p)!=type((1,1)) or len(p)!=2 or type(p[0])!=type(1) or type(p[1])!=type(1) for p in lab.V]): raise TypeError("The labyrinth must be an UnirectedGraph of two integer tuples") self.lab = lab self.cell_size = cell_size self.margin = margin self.max_col = max(p[1] for p in self.lab.V) self.max_row = max(p[0] for p in self.lab.V) self.paths=[] self.treasure = None self.show_io = show_io
def __init__(self, kdtree: KDTree): EasyCanvas.__init__(self) self.kdtree = kdtree
def __init__(self, skyline, unit=30): EasyCanvas.__init__(self) self.unit = unit self.buildings = [] self.skyline = skyline
def __init__(self, coords, route): EasyCanvas.__init__(self) self.canvas_width = self.root.winfo_screenwidth() * 0.8 self.canvas_height = self.root.winfo_screenheight() * 0.8 self.coords = coords self.route = list(route)