def draw(self):
<EOL>self.update()<EOL>x, y = mouse()<EOL>if self.show_grid:<EOL><INDENT>self.grid.draw()<EOL>x, y = self.grid.snap(x, y)<EOL><DEDENT>_ctx.strokewidth(self.strokewidth)<EOL>if self.freehand:<EOL><INDENT>self.draw_freehand()<EOL><DEDENT>r = <NUM_LIT:4><EOL>_ctx.nofill()<EOL>if len(self._points) > <NUM_LIT:0>:<EOL><INDENT>first = True            <EOL>for i in range(len(self._points)):<EOL><INDENT>pt = self._points[i]<EOL>if first:<EOL><INDENT>_ctx.beginpath(pt.x, pt.y)<EOL>first = False<EOL><DEDENT>else:<EOL><INDENT>if pt.cmd == CLOSE:<EOL><INDENT>_ctx.closepath()<EOL><DEDENT>elif pt.cmd == MOVETO:<EOL><INDENT>_ctx.moveto(pt.x, pt.y)<EOL><DEDENT>elif pt.cmd == LINETO:<EOL><INDENT>_ctx.lineto(pt.x, pt.y)<EOL><DEDENT>elif pt.cmd == CURVETO:<EOL><INDENT>_ctx.curveto(pt.ctrl1.x, pt.ctrl1.y, <EOL>pt.ctrl2.x, pt.ctrl2.y, <EOL>pt.x, pt.y)<EOL><DEDENT><DEDENT>if ((i == self.edit and self.new == None)or pt == self.new)and pt.cmd == CURVETOand not pt.freehand:<EOL><INDENT>_ctx.stroke(self.handle_color)<EOL>_ctx.nofill()<EOL>_ctx.oval(pt.x-r, pt.y-r, r*<NUM_LIT:2>, r*<NUM_LIT:2>)<EOL>_ctx.stroke(self.handle_color)<EOL>_ctx.line(pt.ctrl2.x, pt.ctrl2.y, pt.x, pt.y)<EOL>_ctx.fill(self.handle_color)<EOL><DEDENT>if pt == self.newand not pt.freehand:<EOL><INDENT>rx, ry = self.reflect(pt.x, pt.y, pt.ctrl2.x, pt.ctrl2.y)<EOL>_ctx.stroke(self.handle_color)<EOL>_ctx.line(rx, ry, pt.x, pt.y)<EOL>_ctx.nostroke()<EOL>_ctx.fill(self.handle_color)<EOL>_ctx.oval(rx-r/<NUM_LIT:2>, ry-r/<NUM_LIT:2>, r, r)<EOL><DEDENT>if i == self.editand self.new == Noneand pt.cmd == CURVETOand not pt.freehand:<EOL><INDENT>_ctx.oval(pt.ctrl2.x-r/<NUM_LIT:2>, pt.ctrl2.y-r/<NUM_LIT:2>, r, r)<EOL>if i > <NUM_LIT:0>:<EOL><INDENT>prev = self._points[i-<NUM_LIT:1>]<EOL>_ctx.line(pt.ctrl1.x, pt.ctrl1.y, prev.x, prev.y)<EOL>_ctx.oval(pt.ctrl1.x-r/<NUM_LIT:2>, pt.ctrl1.y-r/<NUM_LIT:2>, r, r)<EOL><DEDENT>if i > <NUM_LIT:0> and self._points[i-<NUM_LIT:1>].cmd != MOVETO:<EOL><INDENT>_ctx.line(prev.ctrl2.x, prev.ctrl2.y, prev.x, prev.y)<EOL><DEDENT>if i < len(self._points)-<NUM_LIT:1>:<EOL><INDENT>next = self._points[i+<NUM_LIT:1>]<EOL>if next.cmd == CURVETO:<EOL><INDENT>_ctx.line(next.ctrl1.x, next.ctrl1.y, pt.x, pt.y)<EOL><DEDENT><DEDENT><DEDENT>elif self.overlap(x, y, pt.x, pt.y)and not pt.freehand:<EOL><INDENT>self.insert = False <EOL>_ctx.nofill()<EOL>_ctx.stroke(self.handle_color)<EOL>_ctx.oval(pt.x-r, pt.y-r, r*<NUM_LIT:2>, r*<NUM_LIT:2>)<EOL><DEDENT>_ctx.fontsize(<NUM_LIT:9>)<EOL>_ctx.fill(self.handle_color)<EOL>txt = "<STR_LIT>"+str(int(pt.x))+"<STR_LIT:U+002CU+0020>"+str(int(pt.y))+"<STR_LIT:)>"<EOL>if (i == self.edit and self.new == None)or pt == self.newand not pt.freehand:<EOL><INDENT>_ctx.text(txt, pt.x+r, pt.y+<NUM_LIT:2>)                                       <EOL><DEDENT>elif self.overlap(x, y, pt.x, pt.y)and not pt.freehand:<EOL><INDENT>_ctx.text(txt, pt.x+r, pt.y+<NUM_LIT:2>)<EOL><DEDENT>if not pt.freehand:<EOL><INDENT>if pt.cmd != MOVETO:<EOL><INDENT>_ctx.fill(self.path_color)<EOL>_ctx.nostroke()<EOL><DEDENT>else:<EOL><INDENT>_ctx.stroke(self.path_color)<EOL>_ctx.nofill()<EOL><DEDENT>_ctx.oval(pt.x-r/<NUM_LIT:2>, pt.y-r/<NUM_LIT:2>, r, r)<EOL><DEDENT><DEDENT>_ctx.stroke(self.path_color)<EOL>_ctx.fill(self.path_fill)<EOL>_ctx.autoclosepath(False)    <EOL>p = _ctx.endpath()<EOL>self.path = p<EOL>if self.insert:<EOL><INDENT>_ctx.stroke(self.handle_color)<EOL>_ctx.nofill()<EOL>_ctx.oval(x-r*<NUM_LIT>, y-r*<NUM_LIT>, r*<NUM_LIT>, r*<NUM_LIT>)<EOL><DEDENT>if self.edit == Noneand self.new == Noneand self.moveto != Trueand not self.freehand:<EOL><INDENT>_ctx.nofill()<EOL>_ctx.stroke(self.new_color)<EOL>rx, ry = self.reflect(pt.x, pt.y, pt.ctrl2.x, pt.ctrl2.y)<EOL>_ctx.beginpath(pt.x, pt.y)<EOL>_ctx.curveto(rx, ry, x, y, x, y)<EOL>_ctx.endpath()<EOL>if self.last_moveto != None:<EOL><INDENT>start = self.last_moveto<EOL><DEDENT>else:<EOL><INDENT>start = self._points[<NUM_LIT:0>]<EOL><DEDENT>p = _ctx.line(x, y, start.x, start.y, draw=False)<EOL>try: p._nsBezierPath.setLineDash_count_phase_([<NUM_LIT:2>,<NUM_LIT:4>], <NUM_LIT:2>, <NUM_LIT:50>)<EOL>except:<EOL><INDENT>pass<EOL><DEDENT>_ctx.drawpath(p)<EOL><DEDENT>elif self.edit == Noneand self.new == Noneand self.moveto != None:<EOL><INDENT>_ctx.stroke(self.new_color)<EOL>_ctx.nofill()<EOL>_ctx.oval(x-r*<NUM_LIT>, y-r*<NUM_LIT>, r*<NUM_LIT>, r*<NUM_LIT>)<EOL><DEDENT>if self.edit != None:<EOL><INDENT>pt = self._points[self.edit]<EOL>x = pt.x + self.btn_x<EOL>y = pt.y + self.btn_y<EOL>r = self.btn_r<EOL>_ctx.nostroke()<EOL>_ctx.fill(<NUM_LIT:0>,<NUM_LIT:0>,<NUM_LIT:0>,<NUM_LIT>)<EOL>_ctx.fill(self.handle_color)<EOL>_ctx.oval(x-r, y-r, r*<NUM_LIT:2>, r*<NUM_LIT:2>)<EOL>_ctx.fill(<NUM_LIT:1>)<EOL>_ctx.rotate(<NUM_LIT>)<EOL>_ctx.rect(x-r+<NUM_LIT:2>, y-<NUM_LIT>, r+<NUM_LIT:1>, <NUM_LIT>)<EOL>_ctx.rotate(-<NUM_LIT>)<EOL>_ctx.rect(x-r+<NUM_LIT:2>, y-<NUM_LIT>, r+<NUM_LIT:1>, <NUM_LIT>)<EOL>_ctx.reset()<EOL>if self.edit == len(self._points)-<NUM_LIT:1>:<EOL><INDENT>_ctx.fill(self.handle_color)<EOL>_ctx.oval(x+r*<NUM_LIT:2>+<NUM_LIT:2>-r, y-r, r*<NUM_LIT:2>, r*<NUM_LIT:2>)<EOL>_ctx.fill(<NUM_LIT:1>)<EOL>_ctx.rect(x+r*<NUM_LIT:2>+<NUM_LIT:2>-<NUM_LIT>, y-r+<NUM_LIT:3>, <NUM_LIT>, r-<NUM_LIT:1>)<EOL>_ctx.rect(x+r*<NUM_LIT:2>+<NUM_LIT:2>+<NUM_LIT>, y-r+<NUM_LIT:3>, <NUM_LIT>, r-<NUM_LIT:1>)<EOL><DEDENT><DEDENT><DEDENT>if self.msg != "<STR_LIT>":<EOL><INDENT>self.msg_alpha -= <NUM_LIT:0.1><EOL>_ctx.nostroke()<EOL>_ctx.fill(<NUM_LIT:0>,<NUM_LIT:0>,<NUM_LIT:0>, self.msg_alpha)<EOL>_ctx.fontsize(<NUM_LIT>)<EOL>_ctx.lineheight(<NUM_LIT:1>)<EOL>w = _ctx.textwidth(self.msg)<EOL>_ctx.rect(_ctx.WIDTH/<NUM_LIT:2>-w/<NUM_LIT:2>-<NUM_LIT:9>, _ctx.HEIGHT/<NUM_LIT:2>-<NUM_LIT>, w+<NUM_LIT>, <NUM_LIT>, roundness=<NUM_LIT>)<EOL>_ctx.fill(<NUM_LIT:1>,<NUM_LIT:1>,<NUM_LIT:1>, <NUM_LIT>)<EOL>_ctx.align(CENTER) <EOL>_ctx.text(self.msg, <NUM_LIT:0>, _ctx.HEIGHT/<NUM_LIT:2>, width=_ctx.WIDTH)<EOL><DEDENT>if self.msg_alpha <= <NUM_LIT:0.0>:<EOL><INDENT>self.msg = "<STR_LIT>"<EOL>self.msg_alpha = <NUM_LIT:1.0><EOL><DEDENT>
Draws the editable path and interface elements.