You may find that `pmouse_x` and [](sketch_pmouse_y) have different values when referenced inside of `draw()` and inside of mouse events like `mouse_pressed()` and `mouse_moved()`. Inside `draw()`, `pmouse_x` and [](sketch_pmouse_y) update only once per frame (once per trip through the `draw()` loop). But inside mouse events, they update each time the event is called. If these values weren't updated immediately during mouse events, then the mouse position would be read only once per frame, resulting in slight delays and choppy interaction. If the mouse variables were always updated multiple times per frame, then something like `line(pmouse_x, pmouse_y, mouse_x, mouse_y)` inside `draw()` would have lots of gaps, because `pmouse_x` may have changed several times in between the calls to [](sketch_line).
0 commit comments