def draw_lines(self, gc, x, y): """ x and y are equal length arrays, draw lines connecting each point in x, y """ assert(len(x)==len(y)) # faster as a list comp path = [(paint.MOVETO, x[0], self.height-y[0])] path.extend( [ (paint.LINETO, x[i], self.height-y[i]) for i in range(1, len(x))]) path = self.dash_path(gc, paint.make_path(path)) self.image.stroke(path, self.get_paint_color(gc.get_rgb()), self.points_to_pixels(gc.get_linewidth()))
def draw_lines(self, gc, x, y): """ x and y are equal length arrays, draw lines connecting each point in x, y """ assert (len(x) == len(y)) # faster as a list comp path = [(paint.MOVETO, x[0], self.height - y[0])] path.extend([(paint.LINETO, x[i], self.height - y[i]) for i in range(1, len(x))]) path = self.dash_path(gc, paint.make_path(path)) self.image.stroke(path, self.get_paint_color(gc.get_rgb()), self.points_to_pixels(gc.get_linewidth()))
def draw_polygon(self, gcEdge, rgbFace, points): """ Draw a polygon. points is a len vertices tuple, each element giving the x,y coords a vertex. If rgbFace is not None, fill the rectangle with it. gcEdge is a GraphicsContext instance """ x = [p[0] for p in points] y = [p[1] for p in points] path = [(paint.MOVETO, x[0], self.height - y[0])] for i in range(len(x) - 1): path.append((paint.LINETO, x[i + 1], self.height - y[i + 1])) path.append((paint.LINETO, x[0], self.height - y[0])) path = paint.make_path(path) if rgbFace: self.image.fill(path, self.get_paint_color(rgbFace)) self.image.stroke(path, self.get_paint_color(gcEdge.get_rgb()), self.points_to_pixels(gcEdge.get_linewidth()))
def draw_polygon(self, gcEdge, rgbFace, points): """ Draw a polygon. points is a len vertices tuple, each element giving the x,y coords a vertex. If rgbFace is not None, fill the rectangle with it. gcEdge is a GraphicsContext instance """ x = [p[0] for p in points] y = [p[1] for p in points] path = [(paint.MOVETO, x[0], self.height - y[0])] for i in range(len(x)-1): path.append((paint.LINETO, x[i+1], self.height - y[i+1])) path.append((paint.LINETO, x[0], self.height - y[0])) path = paint.make_path(path) if rgbFace: self.image.fill(path, self.get_paint_color(rgbFace)) self.image.stroke(path, self.get_paint_color(gcEdge.get_rgb()), self.points_to_pixels(gcEdge.get_linewidth()))