def draw_freehand(self):
if _ctx._ns["<STR_LIT>"]:<EOL><INDENT>x, y = mouse()<EOL>if self.show_grid:<EOL><INDENT>x, y = self.grid.snap(x, y)<EOL><DEDENT>if self.freehand_move == True:<EOL><INDENT>cmd = MOVETO<EOL>self.freehand_move = False<EOL><DEDENT>else:<EOL><INDENT>cmd = LINETO<EOL><DEDENT>pt = PathElement()<EOL>if cmd != MOVETO:<EOL><INDENT>pt.freehand = True <EOL><DEDENT>else:<EOL><INDENT>pt.freehand = False<EOL><DEDENT>pt.cmd = cmd<EOL>pt.x = x<EOL>pt.y = y<EOL>pt.ctrl1 = Point(x,y)<EOL>pt.ctrl2 = Point(x,y)<EOL>self._points.append(pt)<EOL>r = <NUM_LIT:4><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>_ctx.fontsize(<NUM_LIT:9>)<EOL>_ctx.fill(self.handle_color)<EOL>_ctx.text("<STR_LIT>"+str(int(pt.x))+"<STR_LIT:U+002CU+0020>"+str(int(pt.y))+"<STR_LIT:)>", pt.x+r, pt.y)<EOL>self._dirty = True<EOL><DEDENT>else:<EOL><INDENT>self.freehand_move = True<EOL>if self._dirty:<EOL><INDENT>self._points[-<NUM_LIT:1>].freehand = False<EOL>self.export_svg()<EOL>self._dirty = False<EOL><DEDENT><DEDENT>
Freehand sketching.