Skip to main content
Inspiring
October 11, 2020
Question

Size and coordinates of a drawing window

  • October 11, 2020
  • 1 reply
  • 262 views

Hello,
In Animate HTML5 canvas, I draw a graphic with the mouse (var ctx = canvas.getContext("2d") ;...) and I wish that the drawing can not be done outside a frame whose dimensions and coordinates are defined. Is it possible to specify the coordinates and size of this frame? I can't find an answer.

Thank you for any help.

    This topic has been closed for replies.

    1 reply

    Legend
    October 11, 2020

    I don't understand what the problem is. Your code is already retrieving the mouse coordinates and using them to plot pixels on a canvas element, so... just check the coordinate values?

    Inspiring
    October 11, 2020

    It's perfect, thank you very much. I hadn't thought about it. I have one last question please: is it possible to scroll indefinitely the created design to the left or to the right?
    Thank you for your answer.