How to clear a line from view?

Dear friends,
By following codes we show a line on screen.

def draw view
  view.line_width = 3
  view.draw_polyline pt1, pt2
end

How can we clear this line from view? Thank you for your help in advance.

Use view.invalidate, to force a redraw, then use an if statement to prevent the line from being redrawn.

3 Likes

By using an “if” statement I do nothing in “def draw view” and it clear everything I draw before. Thank you for your help.

correctly:

def draw(view)
4 Likes