How do I make the draw line feature draw only in a specified area?

ABC

You can use a drag to draw, if you calculate the linear equation y = ax + b for each of the three black lines.

If the current drag y location is within a small distance from the y equation value derived from the current x location and one of those three equations, you can draw a circle there.

An alternative approach would be to express each of the 3 black lines as a list of (x,y) points, counting in pixels. If the current drag (x,y) is within a small distance (4 pixels?) of one of the points on those lists, allow the draw at that point.

Look for the PaintPot tutorial for basic drawing code.

2 Likes