def test_lib_floatcanvas_fc_line(self): fccanvas = fc.FloatCanvas(self.frame) obj = fc.Line((2, 2)) fccanvas.AddObject(obj) fccanvas.Destroy()
def __init__(self, parent, xform, color, isactive, isselected, style): self.xform = xform self.coefs = xform.coefs self.parent = parent points = xform.points self.triangle = AlphaPolygon(points, LineColor=color, FillColor=color, LineStyle=style, Opacity=isselected * 96 or isactive * 64) diameter = parent.circle_radius * 2 circles = map(partial(FC.Circle, Diameter=diameter, LineColor=color), points) text = map(partial(FC.Text, Size=10, Color=color), "XYO", points) self._circles = circles if isactive: parent._cornerpoints = self.GetCornerPoints() corners = [ FC.Line(i, LineColor=color) for i in parent._cornerpoints ] text.extend(corners) FC.Group.__init__(self, [self.triangle] + circles + text)
def __init__(self,parent, id,title,position,size): wx.Frame.__init__(self,parent, id,title,position, size) self.CreateStatusBar() # Add the Canvas NC = NavCanvas.NavCanvas(self, size= (500,500), ProjectionFun = None, Debug = 0, ) self.Canvas = NC.Canvas self.Show(True) # --- draw link between centroids --- # build link link_pts = get_line_pts([-100,-170],[500,301],order=4, num=100) # construct arrow in center of line arrow_coords = build_arrow(link_pts, arrow_length=3) # plot the link and arrowhead self.Canvas.AddObject(FloatCanvas.Polygon(arrow_coords,FillColor='Blue',InForeground=True)) #self.Canvas.AddObject(FloatCanvas.Line(link_pts,LineWidth=2,InForeground=False)) cmap = plt.cm.Blues num_colors = len(link_pts) colors = [cmap(1.*i/num_colors) for i in range(num_colors)] # import random # r = lambda: random.randint(0,255) for i in range(0,len(link_pts)-1): #color = '#%02X%02X%02X' % (r(),r(),r()) color = mcolors.rgb2hex(colors[i]) #color = colors[i][:-1] self.Canvas.AddObject(FloatCanvas.Line((link_pts[i],link_pts[i+1]),LineColor=color,LineWidth=2,InForeground=False)) # --- draw rounded rectangle objects --- # draw some boxes draw_rounded_rectangle(self.Canvas,(-100,-170),width=200, height=100) draw_rounded_rectangle(self.Canvas,(500,301), width=250, height=150) # zoom to bounding box self.Canvas.ZoomToBB() return None
def draw_blocked_bed(self, room, bed): settings = ROOM_SETTINGS['room_mapping'][BedRoom] roomWidth = settings[WIDTH] * (2 - 1 / float(room.capacity)) bedWidth = roomWidth / float(room.capacity) bedCoord = (room.guiCoords[0] - roomWidth / 2.0 + bedWidth * bed, room.guiCoords[1] - settings[HEIGHT] / 2.0) self.patientGroup.AddObject( FloatCanvas.Line( ((bedCoord[0], bedCoord[1]), (bedCoord[0] + bedWidth, bedCoord[1] + settings[HEIGHT])), LineColor='Grey', LineWidth=ROOM_SETTINGS['double_room_line_width'])) self.patientGroup.AddObject( FloatCanvas.Line( ((bedCoord[0], bedCoord[1] + settings[HEIGHT]), (bedCoord[0] + bedWidth, bedCoord[1])), LineColor='Grey', LineWidth=ROOM_SETTINGS['double_room_line_width']))
def draw_data(self): if len(self.datac) > 0: w = self.__flag_selected and 3 or 1 self.add_shape( fc.Line(self.datac, LineColor=self.__color, LineWidth=w, LineStyle=self.__line_style))
def draw_excl_flat(rad, flat_y, line_width=1, line_color='black'): """Draw a wafer flat for a given radius and flat length.""" flat_x = math.sqrt(rad**2 - flat_y**2) flat = FloatCanvas.Line( [(-flat_x, flat_y), (flat_x, flat_y)], LineColor=wm_const.wm_WAFER_EDGE_COLOR, LineWidth=3, ) return flat
def draw_wafer_flat(rad, flat_length): """Draw a wafer flat for a given radius and flat length.""" x = flat_length / 2 y = -math.sqrt(rad**2 - x**2) flat = FloatCanvas.Line( [(-x, y), (x, y)], LineColor=wm_const.wm_WAFER_EDGE_COLOR, LineWidth=3, ) return flat
def draw_edges(self, flag, limit): if flag == 1: for i in range(len(N)): for j in range(len(N)): dist = self.distance_calc(X[i], -Y[i], X[j], -Y[j]) if dist < limit: self.Canvas.AddObject( FloatCanvas.Line([(X[i], -Y[i]), (X[j], -Y[j])], LineColor='Black', LineStyle='Solid', LineWidth=1)) self.Canvas.Draw()
def draw_crosshairs(dia=150, dot=False): """Draw the crosshairs or wafer center dot.""" if dot: circ = FloatCanvas.Circle( (0, 0), 2.5, FillColor=wm_const.wm_WAFER_CENTER_DOT_COLOR, ) return FloatCanvas.Group([circ]) else: # Default: use crosshairs rad = dia / 2 xline = FloatCanvas.Line( [(rad * 1.05, 0), (-rad * 1.05, 0)], LineColor=wx.CYAN, ) yline = FloatCanvas.Line( [(0, rad * 1.05), (0, -rad * 1.05)], LineColor=wx.CYAN, ) return FloatCanvas.Group([xline, yline])
def draw_wafer_notch(rad): """Draw a wafer notch for a given wafer radius.""" ang = 2.5 ang_rad = ang * math.pi / 180 # Define the Notch as a series of 3 (x, y) points xy_points = [(-rad * math.sin(ang_rad), -rad * math.cos(ang_rad)), (0, -rad * 0.95), (rad * math.sin(ang_rad), -rad * math.cos(ang_rad))] notch = FloatCanvas.Line( xy_points, LineColor=wm_const.wm_WAFER_EDGE_COLOR, LineWidth=2, ) return notch
def draw_lines(self, flag, limit): if flag == 1: G = nx.Graph() for i in range(1, len(N)): for j in range(1, len(N)): if i != j: dist = self.distance_calc(X[i], -Y[i], X[j], -Y[j]) if dist < limit: self.Canvas.AddObject( FloatCanvas.Line([(X[i], -Y[i]), (X[j], -Y[j])], LineColor='Black', LineStyle='Solid', LineWidth=1)) E.append((i, j)) self.nx_edge(G, E) self.Canvas.Draw()
def draw(self, x=None, y=None): """Draws marker and stores shapes just created.""" self.shapes = [] if x <> None: self.x = x if y <> None: self.y = y if self.type == MARKER_STAR: self.make_points((90, 234, 378, 522, 666, 810)) elif self.type == MARKER_TRIANGLE: self.make_points((90, 210, 360, 480)) sh = fc.Line(self.points, LineColor=self.color, LineWidth=self.line_width) self.shapes.append(sh) self.fc.AddObject(sh)
def draw_lines(self, L): if len(L) >= 2: self.Canvas.RemoveObjects(edges) del E[:] del edges[:] for i in range(1, len(N)): for j in range(1, len(N)): if i != j: dist = self.distance_calc(X[i], -Y[i], X[j], -Y[j]) if dist < L[len(L) - 1]: edges.append( FloatCanvas.Line([(X[i], -Y[i]), (X[j], -Y[j])], LineColor='Black', LineStyle='Solid', LineWidth=1)) self.Canvas.AddObject(edges[-1]) self.Canvas.Draw() E.append((i, j)) self.draw_nx_graph(E)
def draw_die_gridlines(wf): """ Draw the die gridlines. Parameters ---------- wf : :class:`wm_info.WaferInfo` The wafer info to calculate gridlines for. Returns ------- group : :class:`wx.lib.floatcanvas.FloatCanvas.Group` The collection of all die gridlines. """ x_size = wf.die_size[0] y_size = wf.die_size[1] grey = wx.Colour(64, 64, 64) edge = (wf.dia / 2) * 1.05 # calculate the values for the gridlines x_ref = math.modf(wf.center_xy[0])[0] * x_size + (x_size / 2) pos_vert = np.arange(x_ref, edge, x_size) neg_vert = np.arange(x_ref, -edge, -x_size) y_ref = math.modf(wf.center_xy[1])[0] * y_size + (y_size / 2) pos_horiz = np.arange(y_ref, edge, y_size) neg_horiz = np.arange(y_ref, -edge, -y_size) # reverse `[::-1]`, remove duplicate `[1:]`, and join x_values = np.concatenate((neg_vert[::-1], pos_vert[1:])) y_values = np.concatenate((neg_horiz[::-1], pos_horiz[1:])) line_coords = list([(x, -edge), (x, edge)] for x in x_values) line_coords.extend([(-edge, y), (edge, y)] for y in y_values) lines = [FloatCanvas.Line(l, LineColor=grey) for l in line_coords] return FloatCanvas.Group(list(lines))
def OnClickLeft(self, event): with open('testjson.json', 'r') as file1: T = json.load(file1) for room, dim in T.items(): for par, dim1 in dim.items(): if par == "topright_pos_y": xx = int(T[room]["topright_pos_x"]) y1 = int(T[room]["topright_pos_y"]) yy = 0 - y1 ll = int(T[room]["length"]) bb = int(T[room]["breadth"]) drline1 = FloatCanvas.Line([(xx, yy), (xx + ll, yy)], LineWidth=4, LineColor='black') self.Canvas.AddObject(drline1) self.Canvas.Draw() drline2 = FloatCanvas.Line([(xx, yy), (xx, yy - bb)], LineWidth=4, LineColor='black') self.Canvas.AddObject(drline2) self.Canvas.Draw() drline3 = FloatCanvas.Line([(xx + ll, yy), (xx + ll, yy - bb)], LineWidth=4, LineColor='black') self.Canvas.AddObject(drline3) self.Canvas.Draw() drline4 = FloatCanvas.Line([(xx, yy - bb), (xx + ll, yy - bb)], LineWidth=4, LineColor='black') self.Canvas.AddObject(drline4) self.Canvas.Draw() self.Canvas.Draw() if par == "nodes": for i in range(len(T[room]["nodes"])): for node_par, node_val in T[room][par][i].items(): if T[room][par][i]["type"] == "s": cir = FloatCanvas.Circle([ int(T[room][par][i]["node_pos_x"]), 0 - int(T[room][par][i]["node_pos_y"]) ], 7, FillColor='red') self.Canvas.AddObject(cir) if T[room][par][i]["type"] == "p": rect = FloatCanvas.Rectangle([ int(T[room][par][i]["node_pos_x"]), 0 - int(T[room][par][i]["node_pos_y"]) ], (8, 8), FillColor='blue') self.Canvas.AddObject(rect) if T[room][par][i]["type"] == "k": poly = FloatCanvas.Polygon( [(int(T[room][par][i]["node_pos_x"]) - 4, 0 - int(T[room][par][i]["node_pos_y"]) - 4), (int(T[room][par][i]["node_pos_x"]) + 4, 0 - int(T[room][par][i]["node_pos_y"]) - 4), (int(T[room][par][i]["node_pos_x"]) + 4, 0 - int(T[room][par][i]["node_pos_y"]) + 4), (int(T[room][par][i]["node_pos_x"]) - 4, 0 - int(T[room][par][i]["node_pos_y"]) + 4)], FillColor='yellow') self.Canvas.AddObject(poly) if T[room][par][i]["type"] == "r": poly1 = FloatCanvas.Polygon( [(int(T[room][par][i]["node_pos_x"]), 0 - int(T[room][par][i]["node_pos_y"]) - 7), (int(T[room][par][i]["node_pos_x"]) - 7, 0 - int(T[room][par][i]["node_pos_y"]) + 7), (int(T[room][par][i]["node_pos_x"]) + 7, 0 - int(T[room][par][i]["node_pos_y"]) + 7)], FillColor='cyan') self.Canvas.AddObject(poly1) self.Canvas.Draw() if room == "Blank_Area": points = [(int(T[room]['x1']), 0 - int(T[room]['y1'])), (int(T[room]['x2']), 0 - int(T[room]['y2'])), (int(T[room]['x3']), 0 - int(T[room]['y3'])), (int(T[room]['x4']), 0 - int(T[room]['y4'])), (int(T[room]['x5']), 0 - int(T[room]['y5'])), (int(T[room]['x6']), 0 - int(T[room]['y6'])), (int(T[room]['x7']), 0 - int(T[room]['y7'])), (int(T[room]['x8']), 0 - int(T[room]['y8'])), (int(T[room]['x9']), 0 - int(T[room]['y9'])), (int(T[room]['x10']), 0 - int(T[room]['y10'])), (int(T[room]['x11']), 0 - int(T[room]['y11']))] blankarea = FloatCanvas.Polygon(points, LineWidth=4, LineColor='black', FillColor="SKY BLUE", FillStyle='Solid') self.Canvas.AddObject(blankarea) self.Canvas.Draw()
def OnClickLeft(self,event): with open('testjson.json','r') as file1: T = json.load(file1) for room,dim in T.items(): for par,dim1 in dim.items(): if par == "topright_pos_y": xx=int(T[room]["topright_pos_x"]) y1=int(T[room]["topright_pos_y"]) yy=0-y1 # changing the +Y-axis to -Y-axis ll=int(T[room]["length"]) bb=int(T[room]["breadth"]) drline1 = FloatCanvas.Line([(xx,yy),(xx+ll,yy)],LineWidth=4,LineColor='black') self.Canvas.AddObject(drline1) drline2 = FloatCanvas.Line([(xx,yy),(xx,yy-bb)],LineWidth=4,LineColor='black') self.Canvas.AddObject(drline2) drline3 = FloatCanvas.Line([(xx+ll,yy),(xx+ll,yy-bb)],LineWidth=4,LineColor='black') self.Canvas.AddObject(drline3) drline4 = FloatCanvas.Line([(xx,yy-bb),(xx+ll,yy-bb)],LineWidth=4,LineColor='black') self.Canvas.AddObject(drline4) self.Canvas.Draw() if par == "nodes": for i in range(len(T[room]["nodes"])): N.append(int(T[room][par][i]["node_id"])) X.append(int(T[room][par][i]["node_pos_x"])) Y.append(int(T[room][par][i]["node_pos_y"])) # Drawing Nodes for node_par,node_val in T[room][par][i].items(): if T[room][par][i]["type"] == "s": cir = FloatCanvas.Circle([int(T[room][par][i]["node_pos_x"]),-int(T[room][par][i]["node_pos_y"])],7,FillColor = 'red') self.Canvas.AddObject(cir) if T[room][par][i]["type"] == "p": rect = FloatCanvas.Rectangle([int(T[room][par][i]["node_pos_x"]),-int(T[room][par][i]["node_pos_y"])],(8,8),FillColor='blue') self.Canvas.AddObject(rect) if T[room][par][i]["type"] == "k": poly = FloatCanvas.Polygon([(int(T[room][par][i]["node_pos_x"])-4,-int(T[room][par][i]["node_pos_y"])-4), (int(T[room][par][i]["node_pos_x"])+4,-int(T[room][par][i]["node_pos_y"])-4), (int(T[room][par][i]["node_pos_x"])+4,-int(T[room][par][i]["node_pos_y"])+4), (int(T[room][par][i]["node_pos_x"])-4,-int(T[room][par][i]["node_pos_y"])+4)], FillColor='yellow') self.Canvas.AddObject(poly) if T[room][par][i]["type"] == "r": poly1 = FloatCanvas.Polygon([(int(T[room][par][i]["node_pos_x"]),-int(T[room][par][i]["node_pos_y"])-7), (int(T[room][par][i]["node_pos_x"])-7,-int(T[room][par][i]["node_pos_y"])+7), (int(T[room][par][i]["node_pos_x"])+7,-int(T[room][par][i]["node_pos_y"])+7)], FillColor='cyan') self.Canvas.AddObject(poly1) # Drawing and highlighting the unused area if room == "Blank_Area": points = [(int(T[room]['x1']),-int(T[room]['y1'])), (int(T[room]['x2']),-int(T[room]['y2'])), (int(T[room]['x3']),-int(T[room]['y3'])), (int(T[room]['x4']),-int(T[room]['y4'])), (int(T[room]['x5']),-int(T[room]['y5'])), (int(T[room]['x6']),-int(T[room]['y6'])), (int(T[room]['x7']),-int(T[room]['y7'])), (int(T[room]['x8']),-int(T[room]['y8'])), (int(T[room]['x9']),-int(T[room]['y9'])), (int(T[room]['x10']),-int(T[room]['y10'])), (int(T[room]['x11']),-int(T[room]['y11']))] blankarea = FloatCanvas.Polygon(points,LineWidth=4,LineColor='black',FillColor = "SKY BLUE" , FillStyle='Solid') self.Canvas.AddObject(blankarea) # Making edges for distances < 100 between two nodes for i in range (len(N)): for j in range (len(N)): dist = self.distance_calc(X[i],-Y[i],X[j],-Y[j]) if dist < 100: self.Canvas.AddObject(FloatCanvas.Line([(X[i],-Y[i]),(X[j],-Y[j])], LineColor = 'Black', LineStyle='Solid',LineWidth=1)) self.Canvas.Draw()
def OnClickLeft(self, event): with open('testjson.json', 'r') as file1: T = json.load(file1) for room, dim in T.items(): for par, dim1 in dim.items(): if par == "topright_pos_y": xx = int(T[room]["topright_pos_x"]) y1 = int(T[room]["topright_pos_y"]) yy = 0 - y1 # changing the +Y-axis to -Y-axis ll = int(T[room]["length"]) bb = int(T[room]["breadth"]) drline1 = FloatCanvas.Line([(xx, yy), (xx + ll, yy)], LineWidth=4, LineColor='black') self.Canvas.AddObject(drline1) drline2 = FloatCanvas.Line([(xx, yy), (xx, yy - bb)], LineWidth=4, LineColor='black') self.Canvas.AddObject(drline2) drline3 = FloatCanvas.Line([(xx + ll, yy), (xx + ll, yy - bb)], LineWidth=4, LineColor='black') self.Canvas.AddObject(drline3) drline4 = FloatCanvas.Line([(xx, yy - bb), (xx + ll, yy - bb)], LineWidth=4, LineColor='black') self.Canvas.AddObject(drline4) self.Canvas.Draw() if par == "nodes": for i in range(len(T[room]["nodes"])): N.append(int(T[room][par][i]["node_id"])) X.append(int(T[room][par][i]["node_pos_x"])) Y.append(int(T[room][par][i]["node_pos_y"])) for node_par, node_val in T[room][par][i].items(): if T[room][par][i]["type"] == "s": cir = FloatCanvas.Circle([ int(T[room][par][i]["node_pos_x"]), -int(T[room][par][i]["node_pos_y"]) ], 7, FillColor='red') self.Canvas.AddObject(cir) if T[room][par][i]["type"] == "p": rect = FloatCanvas.Rectangle([ int(T[room][par][i]["node_pos_x"]), -int(T[room][par][i]["node_pos_y"]) ], (8, 8), FillColor='blue') self.Canvas.AddObject(rect) if T[room][par][i]["type"] == "k": poly = FloatCanvas.Polygon([ (int(T[room][par][i]["node_pos_x"]) - 4, -int(T[room][par][i]["node_pos_y"]) - 4), (int(T[room][par][i]["node_pos_x"]) + 4, -int(T[room][par][i]["node_pos_y"]) - 4), (int(T[room][par][i]["node_pos_x"]) + 4, -int(T[room][par][i]["node_pos_y"]) + 4), (int(T[room][par][i]["node_pos_x"]) - 4, -int(T[room][par][i]["node_pos_y"]) + 4) ], FillColor='yellow') self.Canvas.AddObject(poly) if T[room][par][i]["type"] == "r": poly1 = FloatCanvas.Polygon([ (int(T[room][par][i]["node_pos_x"]), -int(T[room][par][i]["node_pos_y"]) - 7), (int(T[room][par][i]["node_pos_x"]) - 7, -int(T[room][par][i]["node_pos_y"]) + 7), (int(T[room][par][i]["node_pos_x"]) + 7, -int(T[room][par][i]["node_pos_y"]) + 7) ], FillColor='cyan') self.Canvas.AddObject(poly1) if room == "Blank_Area": points = [(int(T[room]['x1']), -int(T[room]['y1'])), (int(T[room]['x2']), -int(T[room]['y2'])), (int(T[room]['x3']), -int(T[room]['y3'])), (int(T[room]['x4']), -int(T[room]['y4'])), (int(T[room]['x5']), -int(T[room]['y5'])), (int(T[room]['x6']), -int(T[room]['y6'])), (int(T[room]['x7']), -int(T[room]['y7'])), (int(T[room]['x8']), -int(T[room]['y8'])), (int(T[room]['x9']), -int(T[room]['y9'])), (int(T[room]['x10']), -int(T[room]['y10'])), (int(T[room]['x11']), -int(T[room]['y11']))] blankarea = FloatCanvas.Polygon(points, LineWidth=4, LineColor='black', FillColor="#95bce7", FillStyle='Solid') self.Canvas.AddObject(blankarea) # Dialog Box to input the limiting distance dlg_limit = wx.TextEntryDialog(self, 'Enter the Limiting Distance:') if dlg_limit.ShowModal() == wx.ID_OK: limit = int(dlg_limit.GetValue()) dlg_limit.Destroy() # Drawing lines for shortest distances between two nodes for i in range(len(N)): for j in range(len(N)): dist = self.distance_calc(X[i], -Y[i], X[j], -Y[j]) if dist < limit: self.Canvas.AddObject( FloatCanvas.Line([(X[i], -Y[i]), (X[j], -Y[j])], LineColor='Black', LineStyle='Solid', LineWidth=1)) self.Canvas.Draw()
def process_jsonfile(self, T): for room, dim in T.items(): for par, dim1 in dim.items(): if par == "topright_pos_y": xx = int(T[room]["topright_pos_x"]) y1 = int(T[room]["topright_pos_y"]) yy = 0 - y1 # changing the +Y-axis to -Y-axis ll = int(T[room]["length"]) bb = int(T[room]["breadth"]) drline1 = FloatCanvas.Line([(xx, yy), (xx + ll, yy)], LineWidth=4, LineColor='black') self.Canvas.AddObject(drline1) drline2 = FloatCanvas.Line([(xx, yy), (xx, yy - bb)], LineWidth=4, LineColor='black') self.Canvas.AddObject(drline2) drline3 = FloatCanvas.Line([(xx + ll, yy), (xx + ll, yy - bb)], LineWidth=4, LineColor='black') self.Canvas.AddObject(drline3) drline4 = FloatCanvas.Line([(xx, yy - bb), (xx + ll, yy - bb)], LineWidth=4, LineColor='black') self.Canvas.AddObject(drline4) self.Canvas.Draw() if par == "Nodes": for i in range(len(T[room]["Nodes"])): N.append(int(T[room][par][i]["node_id"])) X.append(int(T[room][par][i]["node_pos_x"])) Y.append(int(T[room][par][i]["node_pos_y"])) for node_par, node_val in T[room][par][i].items(): print("----", T[room][par][i]["node_id"], "------") if T[room][par][i]["type"] == "s": cir = FloatCanvas.Circle([ int(T[room][par][i]["node_pos_x"]), -int(T[room][par][i]["node_pos_y"]) ], 7, FillColor='red') self.Canvas.AddObject(cir) print(T[room][par][i]["type"]) if T[room][par][i]["type"] == "k": poly = FloatCanvas.Polygon([ (int(T[room][par][i]["node_pos_x"]) - 4, -int(T[room][par][i]["node_pos_y"]) - 4), (int(T[room][par][i]["node_pos_x"]) + 4, -int(T[room][par][i]["node_pos_y"]) - 4), (int(T[room][par][i]["node_pos_x"]) + 4, -int(T[room][par][i]["node_pos_y"]) + 4), (int(T[room][par][i]["node_pos_x"]) - 4, -int(T[room][par][i]["node_pos_y"]) + 4) ], FillColor='yellow') self.Canvas.AddObject(poly) print(T[room][par][i]["type"]) if T[room][par][i]["type"] == "r": rect = FloatCanvas.Rectangle([ int(T[room][par][i]["node_pos_x"]), -int(T[room][par][i]["node_pos_y"]) ], (8, 8), FillColor='blue') self.Canvas.AddObject(rect) print(T[room][par][i]["type"]) if room == "Blank_Area": points = [(int(T[room]['x1']), -int(T[room]['y1'])), (int(T[room]['x2']), -int(T[room]['y2'])), (int(T[room]['x3']), -int(T[room]['y3'])), (int(T[room]['x4']), -int(T[room]['y4'])), (int(T[room]['x5']), -int(T[room]['y5'])), (int(T[room]['x6']), -int(T[room]['y6'])), (int(T[room]['x7']), -int(T[room]['y7'])), (int(T[room]['x8']), -int(T[room]['y8'])), (int(T[room]['x9']), -int(T[room]['y9'])), (int(T[room]['x10']), -int(T[room]['y10'])), (int(T[room]['x11']), -int(T[room]['y11']))] blankarea = FloatCanvas.Polygon(points, LineWidth=4, LineColor='black', FillColor="#95bce7", FillStyle='Solid') self.Canvas.AddObject(blankarea)
def draw_rounded_rectangle(canvas, center, width=50, height=50): bez = bezier() s = N.array(center) w = width h = height wh = N.array([width,height]) # build rounded rectangle points start = s - wh/2 end = s + wh/2 tb = range(start[1],end[1],1) lr = range(start[0],end[0],1) # build the edges l = [(start[0],tb[i]) for i in range(0,len(tb))] r = [(end[0],tb[i]) for i in range(0,len(tb))] t = [(lr[i],end[1]) for i in range(0,len(lr))] b = [(lr[i],start[1]) for i in range(0,len(lr))] # order lists clockwise r.reverse() b.reverse() # remove radius coords l = N.array(l[10:-10]) t = N.array(t[10:-10]) r = N.array(r[10:-10]) b = N.array(b[10:-10]) # plot the edges for coords in [l,r,t,b]: canvas.AddObject(FloatCanvas.Line(coords,LineColor = 'red')) # build corners corners = [] ltc = bez.GetBezier([l[-1],l[-1]+[0,5],t[0]-[5,0],t[0]]) rtc = bez.GetBezier([t[-1],t[-1]+[5,0],r[0]+[0,5],r[0]]) rbc = bez.GetBezier([r[-1],r[-1]-[0,5],b[0]+[5,0],b[0]]) lbc = bez.GetBezier([b[-1],b[-1]-[5,0],l[0]-[0,5],l[0]]) corners =[ [ltc, [l[-1],l[-1]+[0,5]],[t[0]-[5,0],t[0]]], [rtc, [t[-1],t[-1]+[5,0]],[r[0]+[0,5],r[0]]], [rbc, [r[-1],r[-1]-[0,5]],[b[0]+[5,0],b[0]]], [lbc, [b[-1],b[-1]-[5,0]],[l[0]-[0,5],l[0]]] ] # plot corners for corner in corners: pts = corner[0] canvas.AddObject(FloatCanvas.Line(N.array([pts[0],pts[1]]))) canvas.AddObject(FloatCanvas.Line(N.array([pts[2],pts[3]]))) canvas.AddObject(FloatCanvas.Line(corner[1],LineColor='green')) # build polygon object coords = N.vstack((l,ltc,t,rtc,r,rbc,b,lbc))