How to paint using canvas

What I’m trying to do:
I’m trying to draw a mask for image inpainting
I want to draw a path when I drag my mouse to make the mask
What I’ve tried and what’s not working:
I’ve consult Image Zoom on mouseover
I try line_to and it doesn’t work
Code Sample:

# this is a formatted code snippet.
# paste your code between ``` 
  def canvas_1_mouse_down(self, x, y, button, **event_args):
    """This method is called when a mouse button is pressed on this component"""
    self.canvas_1.line_width = 10
    self.canvas_1.move_to(x,y)
    self.canvas_1.line_to(x, y)
    self.canvas_1.global_composite_operation = "destination-over"
    self.canvas_1.draw_image(self.img, 
                             self.canvas_1.get_width() / 2 - self.w / 2,
                             self.canvas_1.get_height() / 2 - self.h / 2)
    pass

Clone link:
share a copy of your app

Have you looked at the sample app for collecting electronic signatures? It does essentially the same thing, so should be a good example to work from: Collecting signatures with an Anvil app

1 Like

It works!
Thank you!!