def __init__(self, dataSource: TableModel, XColumn: ColumnModel, width: double, height: double, animation: bool, nameFile: str): self.animation = animation self.metaData = list() self.Index =0 self.listOfPercentageValue =dict() self.widthView = 1000 self.heightView = 1000 self.dataSourceTableWithoutXcolumn = dataSource self.xColumn = XColumn self.idOfKeyColumn = 0 self.zeroX = 655.3 self.zeroY = 417.1 self.color = self.dataSourceTableWithoutXcolumn.columnsColors[0] self.latColumn = self.findLatColumn() self.lngColumn = self.findLngColumn() if self.latColumn != self.xColumn and self.lngColumn != self.xColumn : self.listOfLength = list() self.d = draw.Drawing(self.widthView , self.heightView) self.drawlayOut() self.drawMap() self.drawPoint() else: self.d.append(draw.Text(text="Error: you have to select keyCountries in columns", fontSize=60, x=50, y=self.heightView / 2)) self.d.setPixelScale(min(width,height)/1000) # Set number of pixels per geometry unit #self.d.saveSvg(nameFile+'.svg') self.SVG = self.d.asSvg()
def render(circles, data, size, highlight=[], output='circles.svg'): d = draw.Drawing(size, size, origin='center') d.append(draw.Rectangle( -size / 2, -size / 2, size, size, fill='white', )) for i, item in enumerate(zip(circles, data)): circle = item[0] if item[1][1] > 0: color = '#3b3b3b' else: if item[1][0] and item[1][0] in highlight: color = '#ffff00' else: color = '#84ab3f' d.append( draw.Circle( *circle, fill=color, amount=item[1][1], person=html.escape(item[1][0]), target=html.escape(item[1][2]) if len(item[1]) >= 4 else '', description=html.escape(item[1][3]) if len(item[1]) >= 4 else '', )) d.saveSvg(output)
def draw_points(pts, name, bg_margin_ratio, bg_col='#1248ff', path_kwargs=def_path_kwargs): """ Draws a path connecting the points and saves it as a svg image. """ n = pts.shape[1] p = draw.Path(**path_kwargs) p.M(*pts[:, -1]) for k in range(n): p.L(*pts[:, k]) p.Z() # Background sz_half = int(bg_margin_ratio * np.max(np.abs(pts))) sz = 2 * sz_half bg_rect = draw.Rectangle(-sz_half, -sz_half, sz, sz, fill=bg_col) # Draw d = draw.Drawing(sz, sz, origin='center') d.append(bg_rect) d.append(p) # Save save_path = get_img_path(name) d.saveSvg(save_path)
def __init__(self, dataSource: TableModel, XColumn: ColumnModel, width: double, height: double, animation: bool, nameFile: str): super().__init__(dataSource, width, height, XColumn, animation) self.widthView = 1000 self.heightView = 1000 self.LabelColumn = XColumn self.colorList = self.dataSourceTableWithoutXcolumn.rowsColors self.listOfLength = list() self.d = draw.Drawing(self.widthView, self.heightView) self.Check = False self.femaleColumn = self.maleColumn = XColumn self.getMaleAndFemaleColumns() self.maleTotal = self.sumColumn(self.maleColumn) self.femaleTotal = self.sumColumn(self.femaleColumn) self.drawlayOut() self.drawText() if self.Check: self.drawMaleAndFemaleStack() self.drawHuman() else: self.drawlayOut() self.d.append( draw.Text( text= "Error: we can't found male or Female column \n. . . Try to check column name", fontSize=40, x=0, y=self.heightView / 2)) self.d.setPixelScale(min(width, height) / 1000) # Set number of pixels per geometry unit #self.d.saveSvg(nameFile + '.svg') self.SVG = self.d.asSvg()
def reset(self): self.canvas = draw.Drawing(PaintEnvParameters.CANVAS_WIDTH, PaintEnvParameters.CANVAS_HEIGHT) self.path = draw.Path(stroke_width=PaintEnvParameters.STROKE_WIDTH, stroke=PaintEnvParameters.STROKE_COLOR, fill='none') self.path.M(0, 0)
def __init__(self, dataSource: TableModel, XColumn: ColumnModel, width: double, height: double, animation: bool, nameFile: str): super().__init__(dataSource, width, height, XColumn, animation) self.widthView = 1000 self.heightView = 1000 self.LabelColumn = dataSource.columns[0] self.xColumn = XColumn self.colorList = self.dataSourceTableWithoutXcolumn.rowsColors self.listOfLength = list() self.d = draw.Drawing(self.widthView, self.heightView) self.total = self.sumColumn(self.xColumn) self.drawlayOut() if self.xColumn.columnType == enums.ColumnDataType.Measures.value: self.drawStack() self.drawHuman() self.drawText() else: self.d.append( draw.Text(text="Error: Xcolumn is not Measured", fontSize=60, x=50, y=self.heightView / 2)) self.d.setPixelScale(min(width, height) / 1000) # Set number of pixels per geometry unit #self.d.saveSvg(nameFile+'.svg') self.SVG = self.d.asSvg()
def draw_line(self, dims, vals, grid_size=10, color='#ffffff'): anim = draw.Drawing(330, 120, origin=(0, 0)) for x in range(dims[0]): group = draw.Group() group.draw( draw.Rectangle( 100 * x + grid_size, # origin x coords grid_size, # origin y coords 100, # grid width 100, # grid height stroke_width=grid_size, # outline size stroke='black', # outline color fill=color)) # fill color string_output = str(vals[x]) font_size = 50 / len(string_output) + 25 group.draw( draw.Text( string_output, font_size, 100 * x + grid_size + font_size / 3 + 2 * len(string_output), # origin x coords grid_size + 2250 / (font_size + 20), # origin y coords center=0)) anim.append(group) return anim
def create_svg(input_image_file, output_image_name, element_list, board_x, board_y, board_width, board_height): image_width, image_height = get_image_size(input_image_file) factor = (image_width / board_width + image_height / board_height) / 2 # Fixed size for PCB image d = draw.Drawing(image_width, image_height, origin=(board_x * factor, board_y * factor)) # Draw background d.append( draw.Image(board_x * factor, board_y * factor, image_width, image_height, input_image_file)) # draw_legend(d) for item in element_list.values(): draw_via_pads(d, item.via_pads.items(), factor) draw_smd_pads(d, item.smd_pads.items(), factor) d.setRenderSize(image_width, image_height) d.savePng(output_image_name + ".png") d.saveSvg(output_image_name + ".svg")
def main(path): df = pd.read_csv('{}/wire_locations.csv'.format(path), header=0) df *= 1000 # converting to mm wire_locations = np.array(df['z']) wire_radius = df.iloc[0, -1] # wire radius converted to mm former_radius = df.iloc[0, 0] + wire_radius # radius of coil former inner_radius = df.iloc[0, -3] # center of inner wire position drawing = draw.Drawing(2.1*former_radius, 2.1*wire_locations[-1], origin='center') # draws wire grooves wire_groups = np.split(wire_locations, np.where(np.diff(wire_locations) > 2.5*wire_radius)[0]+1) # finds bundled wire groups for group in wire_groups: groove(drawing, group, former_radius, inner_radius, wire_radius) drawing.setRenderSize(w=5000) drawing.saveSvg('{}/grooves.svg'.format(path)) # draws wires on previous drawing for wire in wire_locations: for turn in df.iloc[0, :-1]: drawing.append(draw.Circle(turn, wire, wire_radius, fill='none', stroke_width=0.01, stroke='black')) drawing.setRenderSize(w=5000) drawing.saveSvg('{}/grooves_and_wires.svg'.format(path))
def main(drawingArray): d = draw.Drawing(200, 200, origin='center') #print (datetime.datetime.now()) print(strokeArray) strokeCount = len(drawingArray) print("no of strokes", strokeCount) #receive strokes for i in range(strokeCount): draw_stroke(drawingArray[i], d) draw_stroke_min(drawingArray[i], d) #draw_minimize(drawingArray[i], d) #draw_stroke([[-39, -27], [0, 0], [-3, 32]], d) #draw_minimize([[-37, -27], [0, 0], [-5, 32]], d) #draw_stroke([[-39, -27], [-39, -27], [-39, -27], [-39, -27], [-39, -27], [-39, -27], [-39, -27], [-39, -27], [-39, -27], [-39, -27], [-38, -26], [-38, -26], [-37, -25], [-37, -25], [-37, -25], [-36, -24], [-36, -24], [-36, -23], [-35, -23], [-35, -22], [-35, -21], [-34, -21], [-34, -20], [-34, -19], [-33, -18], [-33, -17], [-33, -16], [-32, -15], [-32, -14], [-31, -12], [-31, -11], [-30, -9], [-29, -7], [-28, -6], [-27, -4], [-26, -2], [-25, 0], [-24, 2], [-23, 4], [-21, 6], [-20, 8], [-18, 10], [-16, 12], [-15, 14], [-13, 16], [-12, 18], [-10, 20], [-9, 21], [-8, 23], [-7, 25], [-6, 26], [-5, 28], [-4, 29], [-4, 30], [-4, 31], [-3, 32], [-3, 32]], d) #draw_stroke_black([[-39, -27], [-36, -24], [-36, -23], [-35, -23], [-35, -21], [-34, -21], [-34, -19], [-33, -18], [-33, -16], [-32, -15], [-32, -14], [-31, -12], [-31, -11], [-29, -7], [-28, -6], [-23, 4], [-21, 6], [-20, 8], [-16, 12], [-15, 14], [-13, 16], [-12, 18], [-9, 21], [-7, 25], [-6, 26], [-5, 28], [-4, 29], [-4, 31], [-3, 32]], d) d.setPixelScale(2) # Set number of pixels per geometry unit #d.setRenderSize(400,200) # Alternative to setPixelScale timeString = str(datetime.datetime.now()) filename = timeString[:19] d.saveSvg('character/test' + filename + '.svg') d.savePng('character/test' + filename + '.png') d.rasterize() # Display as PNG d # Display as SVG
def __init__(self, dataSourceTableWithoutXcolumn: TableModel, widthView: double, heightView: double, xcolumon: ColumnModel, quality: double, animation: bool, nameFile): tempWidth = widthView if(len(xcolumon.cells)>40): tempWidth = 100*len(xcolumon.cells) super().__init__(dataSourceTableWithoutXcolumn, tempWidth, heightView, xcolumon, animation) self.widthOfYLabels = widthView / 8 self.heightOfXLabels = heightView / 8 self.widthOfCoordinatePlane = self.widthView - self.widthOfYLabels self.heightOfCoordinatePlane = self.heightView - self.heightOfXLabels self.widthView -= self.widthOfYLabels/2 self.heightView -= self.heightOfXLabels/2 self.quality = quality self.d = draw.Drawing(self.widthView, self.heightView) self.listOfLevelXValue = list() self.drawlayOut() self.maximumValue = self.findMaximumValue() self.minimumValue = self.findMinimumValue() self.yDistance = self.getDistant() self.yUnit = self.getyUnit() self.xUnit = self.getxUnit() self.yStep = self.getYstep() self.yUnit = self.correctingUnit() self.getYLevelsValue() self.startValue = self.listOfLevelXValue[0] self.drawYLineLevels() self.drawXPointsWithXValueSteps() self.drawPointsOfValuesInDataSourceTableWithoutXColumn(dataSourceTableWithoutXcolumn.columnsColors) self.drawColmunsColorList(dataSourceTableWithoutXcolumn.columnsColors) self.drawSideLable() #self.d.setPixelScale(100000) # Set number of pixels per geometry unit #self.d.saveSvg(nameFile + '.svg') # self.d.savePng(nameFile+'.png') self.SVG = self.d.asSvg()
def generate_svg(root_image_path, svg_save_path): with open(os.path.join(root_image_path, "draw_objects.pickle"), 'rb') as f: draw_objects = pickle.load(f) canvas_shape = (0, 0 ) # automatically find the shape through maximizing for draw_object in draw_objects: points = draw_object["points"] canvas_shape = np.maximum(canvas_shape, points.max(axis=0)) canvas_shape = canvas_shape.astype(np.int) image = draw.Drawing(*canvas_shape, displayInline=False) image.append(draw.Rectangle(0, 0, *canvas_shape, fill='black')) # shuffle(draw_objects) # don't shuffle the polygons :), they are overlaid over each other for idx, draw_object in enumerate(draw_objects): polygon = draw_object["points"] color = draw_object["color"] polygon = polygon.astype(np.int) color = color.astype(np.int) color = color.tolist() BGR, alpha = color[:-1], color[-1] / MAX_COLOR draw_svg_polygon(image, polygon, BGR, alpha) temp_svg = "/tmp/temp.svg" image.saveSvg(temp_svg) drawing = svg2rlg(temp_svg) os.remove(temp_svg) drawing.transform = (1, 0, 0, -1, 0, canvas_shape[1] ) # reflect and translate renderPDF.drawToFile(drawing, svg_save_path)
def draw(self): w = (len(self.state_sequence)-1) * self.w_time + self.w_label - self.font*0.5 h = (self.num_states-1) * self.h_state + self.font*2 + self.gate_font*3 x = -self.w_label/2 + self.font y = -(self.num_states-1)/2 * self.h_state - self.font*1.5 d = draw.Drawing(w, h, origin=(x, y), displayInline=False) d.append(self.d) return d
def create_tria_svg(): """ Creates the fancy triangular shape and saves it as a .svg image. """ # Parameters d_0 = 0.3 d_1 = 0.4 f = 0.43 alpha = 54 s = 300 bg_col = '#1248ff' fg_col = '#000000' name = 'fancy_tria' # Compute triangles main_tria = get_iso_tria(s) inner_tria = get_iso_tria(f * s, -alpha) # Draw sz = 800 d = draw.Drawing(sz, sz, origin='center') # Background bg_rect = draw.Rectangle(-sz / 2, -sz / 2, sz, sz, fill=bg_col) d.append(bg_rect) p = draw.Path(stroke_width=0, stroke=fg_col, fill=fg_col, fill_opacity=1.0) prev_corner = main_tria[:, -1] p.M(*prev_corner) for k in range(3): # Compute points curr_corner = main_tria[:, k] side_vec = curr_corner - prev_corner side_pt1 = prev_corner + d_0 * side_vec side_pt2 = prev_corner + (1 - d_1) * side_vec inner_pt = inner_tria[:, (k + 1) % 3] # Draw points p.L(*side_pt1) p.L(*inner_pt) p.L(*side_pt2) p.L(*curr_corner) prev_corner = curr_corner p.Z() d.append(p) # Save save_path = get_img_path(name) d.saveSvg(save_path)
def draw_frame(t): d = draw.Drawing(2, 5.00, origin=(-1, -1.05)) d.setRenderSize(h=150) d.append(draw.Rectangle(-4, -4, 8, 10, fill='white')) d.append(draw.Rectangle(-1, -1.00, 8, 1.05, fill='brown')) t = (t + 1) % 2 - 1 y = 4 - t**2 * 4 d.append(draw.Circle(0, y, 1, fill='lime')) return d
def __init__(self): """반지름이 1인 원을 생성하고, group하나를 만든다.""" self.image_size = 500 self.d = draw.Drawing(2, 2, origin='center') # viewbox(-1, -1, 2, 2) self.d.setRenderSize(self.image_size) self.d.append(draw.Circle(0, 0, 1, fill='orange')) group = draw.Group() self.d.append(group)
def draw_frame(*args, background='white', **kwargs): d = draw.Drawing(5, 3, origin='center') d.setRenderSize(624) if background: d.append(draw.Rectangle(-100, -100, 200, 200, fill=background)) g = draw.Group() draw_bloch_sphere(g, background=None, *args, **kwargs) d.append(g) return d
def to_svg(elements): keyboard_index = 0 keyboard = keyboards[keyboard_index] width, height = keyboard.left + keyboard.width, keyboard.top + keyboard.height root = draw.Group(transform=f'scale(1,-1)') root.append(draw_keyboard(keyboard_index)) root.extend(elements) svg = draw.Drawing(width, height, origin=(0, -height)) svg.append(root) return svg
def __init__(self, dataSourceTableWithoutXcolumn: TableModel, widthView: double, heightView: double, xcolumon: ColumnModel, animation: bool): self.animation = animation self.d = draw.Drawing(0, 0) self.Index = 0 self.metaData = list() self.dataSourceTableWithoutXcolumn = dataSourceTableWithoutXcolumn self.xColumn = xcolumon self.widthView = widthView self.heightView = heightView
def draw_whole_frame(f1, f2, background='white', extra_elements=()): d = draw.Drawing(10, 4, origin=(-5, -1.5)) d.setRenderSize(624 * 2) if background: d.append(draw.Rectangle(-100, -100, 200, 200, fill=background)) d.append(draw.Group([f1.elements[-1]], transform='translate(-2.5)')) d.append(draw.Group([f2.elements[-1]], transform='translate(2.5)')) d.extend(extra_elements) return d
def setup(): if not os.path.exists(OUTPUT_DIR): os.makedirs(OUTPUT_DIR) if not os.path.exists(TEMP_DIR): os.makedirs(TEMP_DIR) background_top = INPUT_DIR + "axiom_beta_mixed_panel.top_rotated.png" background_bottom = INPUT_DIR + "axiom_beta_mixed_panel.bottom_rotated.png" board_x = 0 board_y = 0 board_outline = gerberex.read('output_stage1/axiom_beta_mixed_panel.boardoutline.ger') board_width = board_outline.size[1] board_height = board_outline.size[0] image_width, image_height = get_image_size(background_top) global drawing_top, drawing_bottom, factor, output_image_height output_image_width = image_width / 2 output_image_height = image_height / 2 factor = (output_image_width / board_width + output_image_height / board_height) / 2 # Fixed size for PCB image drawing_top = draw.Drawing(output_image_width, output_image_height) drawing_bottom = draw.Drawing(output_image_width, output_image_height) # Draw background drawing_top.append(draw.Image(board_x * factor, board_y * factor, output_image_width, output_image_height, background_top)) drawing_top.append(draw.Rectangle(0, 0, output_image_width, output_image_height, fill="black", opacity=0.5)) drawing_bottom.append(draw.Image(board_x * factor, board_y * factor, output_image_width, output_image_height, background_bottom)) drawing_bottom.append(draw.Rectangle(0, 0, output_image_width, output_image_height, fill="black", opacity=0.5))
def render(T, output, image_size, vertices_labels=True, draw_inner_lines=True, face_colors=["lightcoral", "mistyrose", "steelblue"]): d = drawSvg.Drawing(2.1, 2.1, origin="center") d.draw(euclid.shapes.Circle(0, 0, 1), fill="silver") for (i, j), flist in T.face_indices.items(): for face in flist: coords = [T.project(v) for v in face.points] center = T.project(face.center) for k, D in enumerate(face.domain1): if len(D) == 2: P, V = [T.project(p) for p in D] poly = Polygon.fromVertices([P, V, center]) else: P1, V, P2 = [T.project(p) for p in D] poly = Polygon.fromVertices([P1, V, P2, center]) d.draw(poly, fill=face_colors[2 * (i + j) % 3]) if draw_inner_lines: d.draw(poly, fill="papayawhip", hwidth=0.02) for k, D in enumerate(face.domain2): if len(D) == 2: P, V = [T.project(p) for p in D] poly = Polygon.fromVertices([P, V, center]) else: P1, V, P2 = [T.project(p) for p in D] poly = Polygon.fromVertices([P1, V, P2, center]) d.draw(poly, fill=face_colors[2 * (i + j) % 3], opacity=0.3) if draw_inner_lines: d.draw(poly, fill="papayawhip", hwidth=0.02) poly2 = Polygon.fromVertices(coords) d.draw(poly2, fill="#666", hwidth=0.05) if vertices_labels: for i in range(min(100, T.num_vertices)): d.draw( drawSvg.Text(str(i), 0.05, *T.project(T.vertices_coords[i]), center=0.7, fill="yellow")) d.setRenderSize(w=image_size) d.saveSvg(output)
def main(): # Setup Path(OUTPUT_DIR).mkdir(parents=True, exist_ok=True) # Parse command line arguments parser = argparse.ArgumentParser( description='Generate preview of probed PCB data.') setup_args(parser) args = parser.parse_args() # Find board dimensions for visualization tree = ElementTree.parse(args.eagle_brd_file) xml_root = tree.getroot() board_x, board_y, board_width, board_height = get_board_dimensions( xml_root) # Load background image image = Image.open(args.background_image) factor = (image.width / board_width + image.height / board_height) / 2 d = drawSvg.Drawing(image.width, image.height, origin=(board_x * factor, board_y * factor)) d.append( drawSvg.Image(board_x * factor, board_y * factor, image.width, image.height, args.background_image, embed=True)) # Load measurement data df = pandas.read_csv(args.data_file, sep=';', header=3) data = prepare_data(df) # Load board data board_data = {} load_board_data(args, board_data) # Modify color values and apply factors data['MEAS_3_CLAMPED'] = data['MEAS_3'].apply( lambda x: (x - args.red_value) * args.red_factor) data['MEAS_5_CLAMPED'] = data['MEAS_5'].apply( lambda x: (x - args.green_value) * args.green_factor) data['MEAS_6_CLAMPED'] = data['MEAS_6'].apply( lambda x: (x - args.blue_value) * args.blue_factor) draw_pads(board_data, d, data, factor) d.savePng(OUTPUT_DIR + "measurement_result.png") d.saveSvg(OUTPUT_DIR + "measurement_result.svg")
def _disp(svg, msg): '''Show rendering progress when VERBOSE is True.''' if not VERBOSE: return svg try: from IPython.display import display except ImportError: display = print class DispWrap: def _repr_svg_(self): return d._repr_svg_() def __repr__(self): return msg d = draw.Drawing(50, 20, origin='center', displayInline=False) d.draw(svg, center=True) display(DispWrap()) return svg
def drawDiagram(self, baseNote: str) -> dsvg.Drawing: width = 600 height = 600 d = dsvg.Drawing(width, height, origin=(0, 0)) x = 30 y = 550 y -= self.drawHeading(d, baseNote, x, y) + 6 lowerFret, upperFret = self.getMarkedRange() y -= self.drawFretNumbers(d, lowerFret, upperFret, x, y) self.drawFretBoard(d, lowerFret, upperFret, x, y) y -= self.drawCurrentMarked(d, lowerFret, upperFret, x, y) y -= self.drawFretNumbers(d, lowerFret, upperFret, x, y) return d
def createSigil(message, planet, fileName): planets = ["moon", "mercury", "venus", "sun", "mars", "jupiter", "saturn"] planet = planets.index(planet.lower()) # set up SVG canvas d = svg.Drawing(400, 400, origin='center') # define canvas # draw sigils message = prepareMessage(message) print("sigilizing:", message) coordList = kameaSigil(planet, message) drawSigil( coordList, d, "black") # save sigil to SVG file d.saveSvg(fileName)
def __init__(self, number_matrix, tile_layout): self.file_name = "catan_board.svg" self.numbers = np.array(self._fill_sea(number_matrix)) self.tiles = np.array(self._fill_sea(tile_layout, filler="ocean"), dtype='U8') if self.numbers.shape != self.tiles.shape: raise ValueError("Tile layout an number layout do not match") self.shape = self.numbers.shape self.drawing = draw.Drawing( (self.shape[1] - 2.5) * self.TILE_SIZE, (self.shape[0] - 1.5) * self.TILE_SIZE * self.HEX_COEFF, overflow="hidden") self.drawing.viewBox = (-self.TILE_SIZE, -self.HALF_TILE, self.drawing.width + self.TILE_SIZE, self.drawing.height + self.TILE_SIZE) self._init_tile_images()
def trend(samples: List[int], stroke_color: str, stroke_width: int) -> str: canvas = draw.Drawing(WIDTH, HEIGHT, origin=(0, -Y_OFFSET)) path = draw.Path( fill="transparent", stroke=pybadges._NAME_TO_COLOR.get(stroke_color, stroke_color), stroke_width=stroke_width, stroke_linejoin="round", ) xp, yp = fit_data(samples) path.M(X_OFFSET + xp[0], yp[0]) for x, y in zip(xp[1:], yp[1:]): path.L(X_OFFSET + x, y) canvas.append(path) return canvas.asDataUri()
def __init__(self, dataSource: TableModel, XColumn: ColumnModel, width: double, height: double, animation: bool, nameFile: str): super().__init__(dataSource, width, height, XColumn, animation) width -= width / 4 self.r = (min(width, height) / 2) / 1.1 self.stroke = self.r / 50 self.d = draw.Drawing(self.widthView, self.heightView) self.total = self.sumColumn(XColumn) self.xCenter = width / 2 self.yCenter = -height / 2 self.drawlayOut() self.drawCircle() #self.d.saveSvg(nameFile + '.svg') self.SVG = self.d.asSvg()
def drawMatrix(mat, color = None): # values expected b/w 0 and 1 if color == None: r,g,b = 255,0,0 else: r,g,b = color m = len(mat) n = len(mat[0]) d = draw.Drawing(n*10, m*10, displayInline=False) for row in range(0,m): for col in range(0,n): x,y= col*10, (m-1-row)*10 active = mat[row][col] color = rgb2hex(round(r*active), round(g*active), round(b*active)) drawRect(d, x, y, color) return d