def draw_handlers(self, ctx, canvas, offset=(0, 0)): points = self.to_device(canvas, offset, skip_holes=True) if self.is_curve(): debug_points(ctx, points) else: color = (0,0,1) # blue for point in points: draw_point(ctx, point.x, point.y, 0.5, color=color)
def is_control(self, control, point): dcontrol = self._canvas.user_to_device(control) dpoint = self._canvas.user_to_device(point) draw_point(self.ctx, dcontrol.x, dcontrol.y, 1, stroke=False) rvalue = self.ctx.in_stroke(dpoint.x, dpoint.y) or self.ctx.in_fill(dpoint.x, dpoint.y) #print "iscontrol?", control, point, rvalue self.ctx.new_path() return rvalue
def draw(self, ctx, screen): if not len(self._line): return canvas = screen.get_canvas() line = [canvas.user_to_device(point) for point in self._line] ctx.save() ctx.set_line_width(1.0) #ctx.set_dash([2, 2], 0) ctx.set_source_rgb(0, 0, 0) ctx.move_to(line[0].x+0.5, line[0].y+0.5) for i in xrange(1, len(line)): x, y = line[i].x+0.5, line[i].y+0.5 ctx.line_to(x, y) #draw_point(ctx, x, y, 0.5) ctx.stroke() draw_point(ctx, line[-1].x, line[-1].y, 0.5) ctx.restore()